Skip to content

Commit

Permalink
Merge pull request #12 from AfterShip-Team-Mocha/2025-01
Browse files Browse the repository at this point in the history
feat: supporting 2025-01 version.
  • Loading branch information
panxl6 authored Jan 16, 2025
2 parents b5895de + 9309eaf commit 85340aa
Show file tree
Hide file tree
Showing 293 changed files with 8,404 additions and 1 deletion.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 AfterShip

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.PHONY: build

install:
poetry install

test:
poetry run pytest tests/ -v

record:
poetry run pytest tests/ --vcr-record=new_episodes

format:
poetry run ruff check --fix
poetry run ruff format

build:
poetry build
272 changes: 271 additions & 1 deletion README.md

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# coding=utf8

import tracking
from tracking import exceptions
from tracking import auth

try:
sdk = tracking.Client(
tracking.Configuration(
api_key="asat_870416d3ea2742dba0eb68e23ddfcbe9",
authentication_type=auth.ApiKey,
)
)
# result = sdk.tracking.get_tracking_by_id("b93c3984c3404910ad565385a5c40a1b")
# print(result)
# result = sdk.tracking.get_trackings()
# print(result)

# data = tracking.CreateTrackingRequest()
# data.tracking_number = "<tracking_number>"
# data.slug = "<slug>"
# result = sdk.tracking.create_tracking(data)
# print(result)

# res = sdk.tracking.delete_tracking_by_id("b93c3984c3404910ad565385a5c40a1b")
# print(res)
#
# result = sdk.tracking.get_trackings(keyword="test")
# print(result)

# result = sdk.tracking.get_tracking_by_id("b8ebdc47d885458690cf8347fe56731a")
# print(result)

# data = tracking.UpdateTrackingByIdRequest()
# data.note = "test"
# result = sdk.tracking.update_tracking_by_id("b8ebdc47d885458690cf8347fe56731a", data)
# print(result)

# result = sdk.tracking.retrack_tracking_by_id("b8ebdc47d885458690cf8347fe56731a")
# print(result)

# data = tracking.MarkTrackingCompletedByIdRequest()
# data.reason = "DELIVERED"
# result = sdk.tracking.mark_tracking_completed_by_id("b8ebdc47d885458690cf8347fe56731a", data)
# print(result)

# result = sdk.courier.get_user_couriers()
# print(result)

# result = sdk.courier.get_all_couriers()
# print(result)

# data = tracking.DetectCourierRequest()
# data.tracking_number = "1ZFW80170320376216"
# result = sdk.courier.detect_courier(data)
# print(result)

req = tracking.PredictBatchRequest()
date = tracking.EstimatedDeliveryDateRequest()
date.slug = "ups"
date.origin_address = "USA"
date.destination_address = "USA"

req.estimated_delivery_dates = [date]
result = sdk.estimated_delivery_date.predict_batch(req)

print(result)
except exceptions.InvalidOptionError:
pass
except exceptions.InvalidApiKeyError:
pass
except exceptions.RateLimitExceedError:
pass
Loading

0 comments on commit 85340aa

Please sign in to comment.