Skip to content

Commit

Permalink
Merge pull request #52 from onfleet/INT-1311-python-onfleet-delivery-…
Browse files Browse the repository at this point in the history
…manifest-endpoint

[INT-1311][python-onfleet] Delivery Manifest Endpoint
  • Loading branch information
lisandrobigi-onfleet authored Jun 3, 2024
2 parents 9c4fc88 + cfb2344 commit 4ec42ef
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.4.1] - 2023-05-27
### Added
- Added support for Worker's Route Delivery Manifest

## [1.4.0] - 2023-05-15
### Added
- Added property for adding custom headers to all requests
Expand Down Expand Up @@ -88,7 +92,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial release on PyPI

[Unreleased]: https://github.com/onfleet/pyonfleet/compare/v1.4.0...HEAD
[Unreleased]: https://github.com/onfleet/pyonfleet/compare/v1.4.1...HEAD
[1.4.1]: https://github.com/onfleet/pyonfleet/compare/v1.4.0...v1.4.1
[1.4.0]: https://github.com/onfleet/pyonfleet/compare/v1.3.1...v1.4.0
[1.3.1]: https://github.com/onfleet/pyonfleet/compare/v1.3.0...v1.3.1
[1.3.0]: https://github.com/onfleet/pyonfleet/compare/v1.2.1...v1.3.0
Expand Down
5 changes: 3 additions & 2 deletions README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Estas son las operaciones disponibles para cada endpoint:
| [Tasks](https://docs.onfleet.com/reference/tasks) | get(queryParams={})<br />get(id)<br />get(shortId=id) | create(body={})<br />clone(id)<br />forceComplete(id)<br />batch(body={})<br />autoAssign(body={})<br />matchMetadata(body={}) | update(id, body={}) | deleteOne(id) |
| [Teams](https://docs.onfleet.com/reference/teams) | get()<br />get(id)<br />getWorkerEta(id, queryParams={})<br />getTasks(id, queryParams={}) | create(body={})<br />autoDispatch(id, body={}) | update(id, body={})<br />insertTask(id, body={}) | deleteOne(id) |
| [Webhooks](https://docs.onfleet.com/reference/webhooks) | get() | create(body={}) | x | deleteOne(id) |
| [Workers](https://docs.onfleet.com/reference/workers) | get()<br />get(id)<br />get(queryParams={})<br />getByLocation(queryParams={})<br />getSchedule(id)<br />getTasks(id, queryParams={}) | create(body={})<br />setSchedule(id, body={})<br />matchMetadata(body={}) | update(id, body={})<br />insertTask(id, body={}) | deleteOne(id) |
| [Workers](https://docs.onfleet.com/reference/workers) | get()<br />get(id)<br />get(queryParams={})<br />getByLocation(queryParams={})<br />getSchedule(id)<br />getTasks(id, queryParams={}) | create(body={})<br />setSchedule(id, body={})<br />matchMetadata(body={})<br />getDeliveryManifest(workerId, hubId, googleApiKey, queryParams={}) | update(id, body={})<br />insertTask(id, body={}) | deleteOne(id) |

#### Peticiones GET
Para obtener todos los elementos disponibles en un recurso:
Expand Down Expand Up @@ -186,13 +186,14 @@ onfleet_api.tasks.batchCreate(body="<data>")
onfleet_api.tasks.autoAssign(body="<data>")

onfleet_api.workers.setSchedule(id="<24_digit_ID>", body="<data>")
onfleet.api.workers.getDeliveryManifest(workerId="<workerId>", hubId="<hubId>", googleApiKey="<googleApiKey>", queryParams={"<startDate>", "<endDate>"})

onfleet_api.teams.autoDispatch(id="<24_digit_ID>", body="<data>")

onfleet_api.<entity_name_pluralized>.matchMetadata(body="<data>")
```

Para más información, podemos consultar la documentación sobre [`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule). [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata) y [`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch).
Para más información, podemos consultar la documentación sobre [`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule). [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), [`getDeliveryManifest`](https://docs.onfleet.com/reference/delivery-manifest) y [`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch).


#### Peticiones PUT
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Here are the operations available for each entity:
| [Tasks](https://docs.onfleet.com/reference/tasks) | get(queryParams={})<br />get(id)<br />get(shortId=id) | create(body={})<br />clone(id)<br />forceComplete(id)<br />batch(body={})<br />autoAssign(body={})<br />matchMetadata(body={}) | update(id, body={}) | deleteOne(id) |
| [Teams](https://docs.onfleet.com/reference/teams) | get()<br />get(id)<br />getWorkerEta(id, queryParams={})<br />getTasks(id, queryParams={}) | create(body={})<br />autoDispatch(id, body={}) | update(id, body={})<br />insertTask(id, body={}) | deleteOne(id) |
| [Webhooks](https://docs.onfleet.com/reference/webhooks) | get() | create(body={}) | x | deleteOne(id) |
| [Workers](https://docs.onfleet.com/reference/workers) | get()<br />get(id)<br />get(queryParams={})<br />getByLocation(queryParams={})<br />getSchedule(id)<br />getTasks(id, queryParams={}) | create(body={})<br />setSchedule(id, body={})<br />matchMetadata(body={}) | update(id, body={})<br />insertTask(id, body={}) | deleteOne(id) |
| [Workers](https://docs.onfleet.com/reference/workers) | get()<br />get(id)<br />get(queryParams={})<br />getByLocation(queryParams={})<br />getSchedule(id)<br />getTasks(id, queryParams={}) | create(body={})<br />setSchedule(id, body={})<br />matchMetadata(body={})<br />getDeliveryManifest(workerId, hubId, googleApiKey, queryParams={}) | update(id, body={})<br />insertTask(id, body={}) | deleteOne(id) |

#### GET Requests
To get all the documents within an endpoint:
Expand Down Expand Up @@ -193,13 +193,14 @@ onfleet_api.tasks.batchCreate(body="<data>")
onfleet_api.tasks.autoAssign(body="<data>")

onfleet_api.workers.setSchedule(id="<24_digit_ID>", body="<data>")
onfleet.api.workers.getDeliveryManifest(workerId="<workerId>", hubId="<hubId>", googleApiKey="<googleApiKey>", queryParams={"<startDate>", "<endDate>"})

onfleet_api.teams.autoDispatch(id="<24_digit_ID>", body="<data>")

onfleet_api.<entity_name_pluralized>.matchMetadata(body="<data>")
```

For more details, check our documentation on [`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule), [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), and [`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch).
For more details, check our documentation on [`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule), [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), [`getDeliveryManifest`](https://docs.onfleet.com/reference/delivery-manifest) and [`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch).


#### PUT Requests
Expand Down
5 changes: 3 additions & 2 deletions README.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ onfleet_api = Onfleet(api_key="<your_api_key>") # Without the .auth.json file
| [Tasks](https://docs.onfleet.com/reference/tasks) | get(queryParams={})<br />get(id)<br />get(shortId=id) | create(body={})<br />clone(id)<br />forceComplete(id)<br />batch(body={})<br />autoAssign(body={})<br />matchMetadata(body={}) | update(id, body={}) | deleteOne(id) |
| [Teams](https://docs.onfleet.com/reference/teams) | get()<br />get(id)<br />getWorkerEta(id, queryParams={})<br />getTasks(id, queryParams={}) | create(body={})<br />autoDispatch(id, body={}) | update(id, body={})<br />insertTask(id, body={}) | deleteOne(id) |
| [Webhooks](https://docs.onfleet.com/reference/webhooks) | get() | create(body={}) | x | deleteOne(id) |
| [Workers](https://docs.onfleet.com/reference/workers) | get()<br />get(id)<br />get(queryParams={})<br />getByLocation(queryParams={})<br />getSchedule(id)<br />getTasks(id, queryParams={}) | create(body={})<br />setSchedule(id, body={})<br />matchMetadata(body={}) | update(id, body={})<br />insertTask(id, body={}) | deleteOne(id) |
| [Workers](https://docs.onfleet.com/reference/workers) | get()<br />get(id)<br />get(queryParams={})<br />getByLocation(queryParams={})<br />getSchedule(id)<br />getTasks(id, queryParams={}) | create(body={})<br />setSchedule(id, body={})<br />matchMetadata(body={})<br />getDeliveryManifest(workerId, hubId, googleApiKey, queryParams={}) | update(id, body={})<br />insertTask(id, body={}) | deleteOne(id) |

#### GET 請求
展示所有資源的指令如下:
Expand Down Expand Up @@ -164,13 +164,14 @@ onfleet_api.tasks.batchCreate(body="<data>")
onfleet_api.tasks.autoAssign(body="<data>")

onfleet_api.workers.setSchedule(id="<24_digit_ID>", body="<data>")
onfleet.api.workers.getDeliveryManifest(workerId="<workerId>", hubId="<hubId>", googleApiKey="<googleApiKey>", queryParams={"<startDate>", "<endDate>"})

onfleet_api.teams.autoDispatch(id="<24_digit_ID>", body="<data>")

onfleet_api.<entity_name_pluralized>.matchMetadata(body="<data>")
```

參考資料:[`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule), [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), 以及[`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch)
參考資料:[`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule), [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), [`getDeliveryManifest`](https://docs.onfleet.com/reference/delivery-manifest) 以及[`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch)

#### PUT 請求
取代(更新)某單一指定資源的指令如下:
Expand Down
2 changes: 1 addition & 1 deletion onfleet/_meta.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.0'
__version__ = '1.4.1'
1 change: 1 addition & 0 deletions onfleet/onfleet.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Onfleet(object):
workers.setSchedule = Request('POST', '/workers/:workerId/schedule', _session)
workers.matchMetadata = Request('POST', '/workers/metadata', _session)
workers.insertTask = Request('PUT', '/containers/workers/:taskId', _session)
workers.getDeliveryManifest = Request('POST', '/integrations/marketplace', _session)

webhooks = Endpoint('webhooks', ('GET', 'POST', 'DELETE'), _session)

Expand Down
9 changes: 8 additions & 1 deletion onfleet/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, http_method, path, session):

@on_exception(expo, RateLimitError, max_tries=8)
@limits(calls=RATE_LIMIT, period=1)
def __call__(self, id=None, body=None, queryParams=None, **extra_data):
def __call__(self, id=None, body=None, workerId=None, hubId=None, googleApiKey=None, queryParams=None, **extra_data):
obj_id = id # TODO(julian): `id` is a reserved name, let's rename it to 'obj_id'
query_params = queryParams # TODO(julian): Let's rename `queryParams` to `query_params`

Expand All @@ -38,6 +38,13 @@ def __call__(self, id=None, body=None, queryParams=None, **extra_data):
url = self._url_id_setter(url, obj_id)
if extra_data:
url = self._url_extra_data_setter(url, extra_data)
if workerId and hubId:
body = {
'path': f'providers/manifest/generate?hubId={hubId}&workerId={workerId}',
'method': 'GET'
}
if googleApiKey:
self.default_headers['X-Api-Key'] = f'Google {googleApiKey}'

response = self.session.request(
method=self.http_method,
Expand Down

0 comments on commit 4ec42ef

Please sign in to comment.