Skip to content

Commit 85340aa

Browse files
authored
Merge pull request #12 from AfterShip-Team-Mocha/2025-01
feat: supporting 2025-01 version.
2 parents b5895de + 9309eaf commit 85340aa

File tree

293 files changed

+8404
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

293 files changed

+8404
-1
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 AfterShip
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.PHONY: build
2+
3+
install:
4+
poetry install
5+
6+
test:
7+
poetry run pytest tests/ -v
8+
9+
record:
10+
poetry run pytest tests/ --vcr-record=new_episodes
11+
12+
format:
13+
poetry run ruff check --fix
14+
poetry run ruff format
15+
16+
build:
17+
poetry build

README.md

Lines changed: 271 additions & 1 deletion
Large diffs are not rendered by default.

app.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# coding=utf8
2+
3+
import tracking
4+
from tracking import exceptions
5+
from tracking import auth
6+
7+
try:
8+
sdk = tracking.Client(
9+
tracking.Configuration(
10+
api_key="asat_870416d3ea2742dba0eb68e23ddfcbe9",
11+
authentication_type=auth.ApiKey,
12+
)
13+
)
14+
# result = sdk.tracking.get_tracking_by_id("b93c3984c3404910ad565385a5c40a1b")
15+
# print(result)
16+
# result = sdk.tracking.get_trackings()
17+
# print(result)
18+
19+
# data = tracking.CreateTrackingRequest()
20+
# data.tracking_number = "<tracking_number>"
21+
# data.slug = "<slug>"
22+
# result = sdk.tracking.create_tracking(data)
23+
# print(result)
24+
25+
# res = sdk.tracking.delete_tracking_by_id("b93c3984c3404910ad565385a5c40a1b")
26+
# print(res)
27+
#
28+
# result = sdk.tracking.get_trackings(keyword="test")
29+
# print(result)
30+
31+
# result = sdk.tracking.get_tracking_by_id("b8ebdc47d885458690cf8347fe56731a")
32+
# print(result)
33+
34+
# data = tracking.UpdateTrackingByIdRequest()
35+
# data.note = "test"
36+
# result = sdk.tracking.update_tracking_by_id("b8ebdc47d885458690cf8347fe56731a", data)
37+
# print(result)
38+
39+
# result = sdk.tracking.retrack_tracking_by_id("b8ebdc47d885458690cf8347fe56731a")
40+
# print(result)
41+
42+
# data = tracking.MarkTrackingCompletedByIdRequest()
43+
# data.reason = "DELIVERED"
44+
# result = sdk.tracking.mark_tracking_completed_by_id("b8ebdc47d885458690cf8347fe56731a", data)
45+
# print(result)
46+
47+
# result = sdk.courier.get_user_couriers()
48+
# print(result)
49+
50+
# result = sdk.courier.get_all_couriers()
51+
# print(result)
52+
53+
# data = tracking.DetectCourierRequest()
54+
# data.tracking_number = "1ZFW80170320376216"
55+
# result = sdk.courier.detect_courier(data)
56+
# print(result)
57+
58+
req = tracking.PredictBatchRequest()
59+
date = tracking.EstimatedDeliveryDateRequest()
60+
date.slug = "ups"
61+
date.origin_address = "USA"
62+
date.destination_address = "USA"
63+
64+
req.estimated_delivery_dates = [date]
65+
result = sdk.estimated_delivery_date.predict_batch(req)
66+
67+
print(result)
68+
except exceptions.InvalidOptionError:
69+
pass
70+
except exceptions.InvalidApiKeyError:
71+
pass
72+
except exceptions.RateLimitExceedError:
73+
pass

0 commit comments

Comments
 (0)