Skip to content

Commit

Permalink
Update badges 20190521 (#3)
Browse files Browse the repository at this point in the history
* Updating badges for Travis CI, licensing, and PyPI downloads

* Updating badges for Travis CI, licensing, and PyPI downloads

* Update badges to include PyPI status

* Update badges with links

* Update badges with PyPI versioning

* Update badges: remove PyPI download count badge (not working)
  • Loading branch information
jamesliupenn authored May 22, 2019
1 parent 209b178 commit 0f58ad7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 23 deletions.
38 changes: 30 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Onfleet Python Wrapper

![Travis (.org)](https://img.shields.io/travis/onfleet/pyonfleet.svg?style=popout-square)
[![GitHub](https://img.shields.io/github/license/onfleet/pyonfleet.svg?style=popout-square)](https://github.com/onfleet/pyonfleet/blob/master/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/pyonfleet.svg?style=popout-square)](https://pypi.org/project/pyonfleet/)
![GitHub top language](https://img.shields.io/github/languages/top/onfleet/pyonfleet.svg?style=popout-square)

*Read this document in another language: [English](https://github.com/onfleet/pyonfleet/blob/master/README.md), [正體中文](https://github.com/onfleet/pyonfleet/blob/master/README.zh-tw.md)*

If you have any questions, please reach out to Onfleet by submitting an issue [here](https://github.com/onfleet/pyonfleet/issues) or contact [email protected]

## Table of Contents
- [Onfleet Python Wrapper](#onfleet-python-wrapper)
* [Table of Contents](#table-of-contents)
* [Synopsis](#synopsis)
* [Installation](#installation)
* [Usage](#usage)
Expand All @@ -13,14 +20,16 @@ If you have any questions, please reach out to Onfleet by submitting an issue [h
+ [Supported CRUD Operations](#supported-crud-operations)
- [GET Requests](#get-requests)
* [Examples of get()](#examples-of-get--)
* [Examples of get()](#examples-of-get--)
* [Examples of get(param)](#examples-of-get-param-)
* [Examples of getByLocation:](#examples-of-getbylocation-)
- [POST Requests](#post-requests)
* [Examples of create()](#examples-of-create--)
- [PUT Requests](#put-requests)
* [Examples of update()](#examples-of-update--)
* [Examples of updateSchedule()](#examples-of-updateschedule--)
* [Examples of insertTask()](#examples-of-inserttask--)
- [DELETE Requests](#delete-requests)
* [Examples of deleteOne()](#examples-of-deleteone--)
+ [Examples of utilizing your CRUD operations](#examples-of-utilizing-your-crud-operations)

## Synopsis

Expand All @@ -29,7 +38,7 @@ The Onfleet Python library provides convenient access to the Onfleet API.
## Installation

```
pip install python_onfleet
pip install pyonfleet
```
## Usage
Before using the API wrapper, you will need to obtain an API key from your organization admin. Creation and integration of API keys are performed through the [Onfleet dashboard](https://onfleet.com/dashboard#/manage).
Expand All @@ -40,7 +49,6 @@ The format of `.auth.json` is shown below:
```json
{
"API_KEY": "<your_api_key>",
"API_SECRET": "<your_api_secret>" // Not supported now, empty string "" will suffice
}
```
You can also opt in to not store your API key here and use it on the fly instead.
Expand All @@ -57,12 +65,12 @@ api = Onfleet(api_key="<your_api_key>") # if no .auth.json was provided
Rate limiting is enforced by the API with a threshold of 20 requests per second across all your organization's API keys, learn more about it [here](http://docs.onfleet.com/docs/throttling).

### Responses
The `pyonfleet` API wrapper returns a [Response object](https://2.python-requests.org//en/master/api/#requests.Response), where headers and other information are stored. To access the results of the response, simply parse it as JSON using the [json() method](https://developer.mozilla.org/en-US/docs/Web/API/Body/json).
The `pyonfleet` API wrapper returns the body of a [Response object](https://2.python-requests.org//en/master/api/#requests.Response).

### Supported CRUD Operations
The base URL for the Onfleet API is `https://onfleet.com/api/v2`, here are the supported CRUD operations for each endpoint:

| | GET | POST | PUT | DELETE |
| `<endpoint>` | GET | POST | PUT | DELETE |
|:------------:|:---------------------------------------------------------------:|:----------------------------------------------------------------------:|:------------------------------------:|:-------------:|
| [Admins](http://docs.onfleet.com/docs/administrators) | get() | create(body) | update(id, body) | deleteOne(id) |
| [Containers](http://docs.onfleet.com/docs/containers) | get(workers=id), get(teams=id), get(organizations=id) | x | update(id, body) | x |
Expand Down Expand Up @@ -99,7 +107,7 @@ To get one of the document within an endpoint, specify the param that you wish t
get(param=<some_param>)
```

##### Examples of get()
##### Examples of get(param)
```python
api.workers.get(id="<24_digit_id>")
api.workers.get(id="<24_digit_id>", queryParams={"analytics": "true"})
Expand All @@ -111,8 +119,12 @@ api.containers.get(workers="<worker_id>")
api.containers.get(teams="<team_id>")
api.containers.get(organizations="<org_id>")
```
To get a driver by location, use the `getByLocation` function:
```python
getByLocation(queryParams=<some_param>)
```

##### Special endpoints - getByLocation using JSON query parameters:
##### Examples of getByLocation:
```python
params = {"longitude":"-122.4","latitude":"37.7601983","radius":"6000"}
api.workers.getByLocation(queryParams=params)
Expand Down Expand Up @@ -163,6 +175,16 @@ updateBody = {
}
api.workers.update(id="<24_digit_id>", body=updateBody)
```
##### Examples of updateSchedule()
```python
api.workers.updateSchedule(id="<24_digit_id>", body=newSchedule)
```
For more details, check our documentation on [updateSchedule](http://docs.onfleet.com/docs/workers#update-workers-schedule)

##### Examples of insertTask()
```python
api.workers.insertTask(id="kAQ*G5hnqlOq4jVvwtGNuacl", body="<body_object>")
```

#### DELETE Requests
To delete a document within an endpoint:
Expand Down
39 changes: 25 additions & 14 deletions README.zh-tw.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Onfleet Python Wrapper

![Travis (.org)](https://img.shields.io/travis/onfleet/pyonfleet.svg?style=popout-square)
[![GitHub](https://img.shields.io/github/license/onfleet/pyonfleet.svg?style=popout-square)](https://github.com/onfleet/pyonfleet/blob/master/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/pyonfleet.svg?style=popout-square)](https://pypi.org/project/pyonfleet/)
![GitHub top language](https://img.shields.io/github/languages/top/onfleet/pyonfleet.svg?style=popout-square)

*其他語言版本: [English](https://github.com/onfleet/pyonfleet/blob/master/README.md),[正體中文](https://github.com/onfleet/pyonfleet/blob/master/README.zh-tw.md)*

如果對於Onfleet應用程式介面或是我們產品有任何的問題,歡迎在此留言或直接聯繫 [email protected]
Expand All @@ -12,14 +18,15 @@
+ [請求回應](#請求回應)
+ [支援的CRUD操作](#支援的CRUD操作)
- [GET 請求](#get-請求)
* [展示所有資源的範例](#展示所有資源的範例)
* [展示指定資源的範例](#展示指定資源的範例)
* [使用get展示所有資源的範例](#使用get展示所有資源的範例)
* [使用get展示指定資源的範例](#使用get展示指定資源的範例)
- [POST 請求](#post-請求)
* [提交指定資源的範例](#提交指定資源的範例)
* [使用create提交指定資源的範例](#使用create提交指定資源的範例)
- [PUT 請求](#put-請求)
* [取代指定資源的範例](#取代指定資源的範例)
* [使用update取代指定資源的範例](#使用update取代指定資源的範例)
* [使用insertTask取代指定資源的範例](#使用insertTask取代指定資源的範例)
- [DELETE 請求](#delete-請求)
* [刪除指定資源的範例](#刪除指定資源的範例)
* [使用deleteOne刪除指定資源的範例](#使用deleteone刪除指定資源的範例)


## 概要
Expand All @@ -29,7 +36,7 @@
## 安裝

```
pip install python_onfleet
pip install pyonfleet
```

## 使用守則
Expand All @@ -42,7 +49,6 @@ pip install python_onfleet
```json
{
"API_KEY": "<你的API金鑰>",
"API_SECRET": "<你的API密碼>" //這部分目前沒有支援,設定為空白字串""
}
```
當Onfleet物件成功被創建,而金鑰又是合法的,您會獲得訪問以下各endpoint資源的函式。欲獲得各endpoint資源的定義,請洽[Onfleet官方應用程式介面文件](http://docs.onfleet.com/)
Expand All @@ -59,12 +65,12 @@ api = Onfleet(api_key="<your_api_key>") #直接引入參數
原則上API的速限為每秒鐘20次請求,詳情請參考[官方文件](http://docs.onfleet.com/docs/throttling)

### 請求回應
`pyonfleet`所回應的物件為一[Response物件](https://2.python-requests.org//en/master/api/#requests.Response),在此物件中,許多的附帶訊息用於提供給client端更多資訊。若欲取得回應的數據,請在回應的物件中執行[json()](https://developer.mozilla.org/en-US/docs/Web/API/Body/json)即可獲得JSON化的請求結果
`pyonfleet`所回應的物件為一[Response物件](https://2.python-requests.org//en/master/api/#requests.Response)的本體

### 支援的CRUD操作
Onfleet應用程式介面的基本URL為 `https://onfleet.com/api/v2`,下面為各endpoint所支援的函式列表:

| | GET | POST | PUT | DELETE |
| `<endpoint>` | GET | POST | PUT | DELETE |
|:------------:|:---------------------------------------------------------------:|:----------------------------------------------------------------------:|:------------------------------------:|:-------------:|
| [Admins](http://docs.onfleet.com/docs/administrators) | get() | create(body) | update(id, body) | deleteOne(id) |
| [Containers](http://docs.onfleet.com/docs/containers) | get(workers=id), get(teams=id), get(organizations=id) | x | update(id, body) | x |
Expand All @@ -82,7 +88,7 @@ Onfleet應用程式介面的基本URL為 `https://onfleet.com/api/v2`,下面
```python
get()
```
##### 展示所有資源的範例
##### 使用get展示所有資源的範例
```python
api.workers.get()
api.workers.get(queryParams="")
Expand All @@ -97,7 +103,7 @@ api.workers.get(queryParams="phones=<phone_number>")
get(param=<some_param>)
```

##### 展示指定資源的範例
##### 使用get展示指定資源的範例
```python
api.workers.get(id="<24_digit_id>")
api.workers.get(id="<24_digit_id>", queryParams={"analytics": "true"})
Expand All @@ -115,7 +121,7 @@ api.containers.get(organizations="<org_id>")
```python
create(body="<body_object>")
```
##### 提交指定資源的範例
##### 使用create提交指定資源的範例
```python
driver = {
"name": "A Swartz Test",
Expand Down Expand Up @@ -148,7 +154,7 @@ api.workers.setSchedule(id="<24_digit_id>", body="<schedule_object>")
```python
update(id="<24_digit_id>", body="<body_object>")
```
##### 取代指定資源的範例
##### 使用update取代指定資源的範例
```python
updateBody = {
"name": "New Driver Name",
Expand All @@ -161,12 +167,17 @@ api.workers.updateSchedule(id="<24_digit_id>", body=newSchedule)
```
參考資料:[updateSchedule](http://docs.onfleet.com/docs/workers#update-workers-schedule)

##### 使用insertTask取代指定資源的範例
```python
api.workers.insertTask(id="kAQ*G5hnqlOq4jVvwtGNuacl", body="<body_object>")
```

#### DELETE 請求
刪除某單一指定資源的指令如下:
```python
deleteOne(id="<24_digit_id>")
```
##### 刪除指定資源的範例
##### 使用deleteOne刪除指定資源的範例
```python
api.workers.deleteOne(id="<24_digit_id>")
```
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="pyonfleet",
version= "1.0.0.1",
version= "1.0.1",
author="James Li",
author_email="[email protected]",
description="Onfleet's Python API Wrapper Package",
Expand Down

0 comments on commit 0f58ad7

Please sign in to comment.