From 0f58ad795ff969f79a19fc4be22bb5fa30cfd96d Mon Sep 17 00:00:00 2001 From: ilsemaj Date: Wed, 22 May 2019 11:01:36 -0700 Subject: [PATCH] Update badges 20190521 (#3) * 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) --- README.md | 38 ++++++++++++++++++++++++++++++-------- README.zh-tw.md | 39 +++++++++++++++++++++++++-------------- setup.py | 2 +- 3 files changed, 56 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 98bc771..a978477 100644 --- a/README.md +++ b/README.md @@ -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 support@onfleet.com ## Table of Contents - [Onfleet Python Wrapper](#onfleet-python-wrapper) + * [Table of Contents](#table-of-contents) * [Synopsis](#synopsis) * [Installation](#installation) * [Usage](#usage) @@ -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 @@ -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). @@ -40,7 +49,6 @@ The format of `.auth.json` is shown below: ```json { "API_KEY": "", - "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. @@ -57,12 +65,12 @@ api = Onfleet(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 | +| `` | 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 | @@ -99,7 +107,7 @@ To get one of the document within an endpoint, specify the param that you wish t get(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"}) @@ -111,8 +119,12 @@ api.containers.get(workers="") api.containers.get(teams="") api.containers.get(organizations="") ``` +To get a driver by location, use the `getByLocation` function: +```python +getByLocation(queryParams=) +``` -##### 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) @@ -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="") +``` #### DELETE Requests To delete a document within an endpoint: diff --git a/README.zh-tw.md b/README.zh-tw.md index 181ad7d..4c4fd1a 100644 --- a/README.zh-tw.md +++ b/README.zh-tw.md @@ -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應用程式介面或是我們產品有任何的問題,歡迎在此留言或直接聯繫 support@onfleet.com。 @@ -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刪除指定資源的範例) ## 概要 @@ -29,7 +36,7 @@ ## 安裝 ``` -pip install python_onfleet +pip install pyonfleet ``` ## 使用守則 @@ -42,7 +49,6 @@ pip install python_onfleet ```json { "API_KEY": "<你的API金鑰>", - "API_SECRET": "<你的API密碼>" //這部分目前沒有支援,設定為空白字串"" } ``` 當Onfleet物件成功被創建,而金鑰又是合法的,您會獲得訪問以下各endpoint資源的函式。欲獲得各endpoint資源的定義,請洽[Onfleet官方應用程式介面文件](http://docs.onfleet.com/)。 @@ -59,12 +65,12 @@ api = Onfleet(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 | +| `` | 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 | @@ -82,7 +88,7 @@ Onfleet應用程式介面的基本URL為 `https://onfleet.com/api/v2`,下面 ```python get() ``` -##### 展示所有資源的範例 +##### 使用get展示所有資源的範例 ```python api.workers.get() api.workers.get(queryParams="") @@ -97,7 +103,7 @@ api.workers.get(queryParams="phones=") get(param=) ``` -##### 展示指定資源的範例 +##### 使用get展示指定資源的範例 ```python api.workers.get(id="<24_digit_id>") api.workers.get(id="<24_digit_id>", queryParams={"analytics": "true"}) @@ -115,7 +121,7 @@ api.containers.get(organizations="") ```python create(body="") ``` -##### 提交指定資源的範例 +##### 使用create提交指定資源的範例 ```python driver = { "name": "A Swartz Test", @@ -148,7 +154,7 @@ api.workers.setSchedule(id="<24_digit_id>", body="") ```python update(id="<24_digit_id>", body="") ``` -##### 取代指定資源的範例 +##### 使用update取代指定資源的範例 ```python updateBody = { "name": "New Driver Name", @@ -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="") +``` + #### DELETE 請求 刪除某單一指定資源的指令如下: ```python deleteOne(id="<24_digit_id>") ``` -##### 刪除指定資源的範例 +##### 使用deleteOne刪除指定資源的範例 ```python api.workers.deleteOne(id="<24_digit_id>") ``` \ No newline at end of file diff --git a/setup.py b/setup.py index 5210a97..28dbab3 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setuptools.setup( name="pyonfleet", - version= "1.0.0.1", + version= "1.0.1", author="James Li", author_email="support@onfleet.com", description="Onfleet's Python API Wrapper Package",