Skip to content

Commit

Permalink
Merge pull request #4 from panxl6/2024-04
Browse files Browse the repository at this point in the history
init project
  • Loading branch information
panxl6 authored Jun 25, 2024
2 parents 9f272ab + b505964 commit ec0073c
Show file tree
Hide file tree
Showing 80 changed files with 5,249 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This code was auto generated by AfterShip SDK Generator.
# Do not edit the class manually.

name: Release to PyPI

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python # Set Python version
uses: actions/setup-python@v3
with:
python-version: 3.11

- name: Install dependencies
run: |
python -m pip install --upgrade pip poetry
poetry config virtualenvs.in-project --unset
make install
- name: Build
run: |
make build
- name: Format
run: |
make format
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_version.outputs.VERSION }}
path: dist

- name: Release to PyPI
run: |
pip install twine
twine upload -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} --verbose dist/*
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) 2024 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
308 changes: 307 additions & 1 deletion README.md

Large diffs are not rendered by default.

516 changes: 516 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[tool.poetry]
name = "aftership-tracking-sdk"
version = "2.0.2"
description = "The official AfterShip Tracking Python API library"
authors = ["AfterShip <[email protected]>"]
license = "MIT"
readme = "README.md"
keywords = ["aftership", "tracking", "track", "fedex", "ups", "usps", "dhl", "shipping", "fulfillment", "couriers", "carriers", "logistics"]

classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Topic :: Software Development",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]

packages = [
{ include = "tracking" },
{ include = "*.md" },
{ include = "LICENSE" },
]

[tool.poetry.dependencies]
python = "^3.8"
pycryptodome = ">= 3.9.0"
pydantic = ">=2"
httpx = ">=0.27.0"
retrying = "^1.3.4"
typing_extensions = ">=4.7.1"
urllib3 = "^2.2.2"
socksio = "^1.0.0"

[tool.poetry.group.dev.dependencies]
ruff = "^0.4.8"
pytest = "^8.2.2"
flake8 = ">=4.0.0"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

[tool.ruff]
target-version = "py311"
line-length = 100

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
docstring-code-format = true
docstring-code-line-length = 60
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
max-line-length=99

[bdist_wheel]
universal = 0

[metadata]
license_file = LICENSE
14 changes: 14 additions & 0 deletions tracking/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# coding: utf-8
#
# This code was auto generated by AfterShip SDK Generator.
# Do not edit the class manually.

# flake8: noqa

from .auth import ApiKey, Aes, Rsa
from .client import Client
from .configuration import Configuration
from . import exceptions
from .models import *

__version__ = "2.0.0"
18 changes: 18 additions & 0 deletions tracking/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# coding: utf-8
#
# This code was auto generated by AfterShip SDK Generator.
# Do not edit the class manually.

__all__ = [
"CourierApi",
"EstimatedDeliveryDateApi",
"LastCheckpointApi",
"NotificationApi",
"TrackingApi",
]

from .courier import CourierApi
from .estimated_delivery_date import EstimatedDeliveryDateApi
from .last_checkpoint import LastCheckpointApi
from .notification import NotificationApi
from .tracking import TrackingApi
79 changes: 79 additions & 0 deletions tracking/api/courier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# coding: utf-8
#
# This code was auto generated by AfterShip SDK Generator.
# Do not edit the class manually.

import json
from typing import Union


from tracking.models import (
TrackingDetectCourierRequest,
DetectCourierResponse,
GetAllCouriersResponse,
GetUserCouriersResponse,
)
from tracking.request import ApiClient, validate_params


class CourierApi(ApiClient):
"""CourierApi api implements"""

@validate_params
def detect_courier(
self, detect_courier_request: Union[TrackingDetectCourierRequest, dict], **kwargs
) -> DetectCourierResponse:
"""
Return a list of matched couriers based on tracking number format and or a list of couriers.
:param detect_courier_request:
:param kwargs:
request options:
**headers** (dict): support custom headers.
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
verify the identity of requested hosts. Either `True` (default CA bundle),
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
(which will disable verification).
"""
url = "/tracking/2024-04/couriers/detect"

body = detect_courier_request
if not isinstance(body, dict):
body = detect_courier_request.model_dump(exclude_none=True)
body = json.dumps({"tracking": body})

result = self._request("POST", url=url, body=body, **kwargs)
return DetectCourierResponse().from_dict(result)

@validate_params
def get_all_couriers(self, **kwargs) -> GetAllCouriersResponse:
"""
Return a list of all couriers.
:param kwargs:
request options:
**headers** (dict): support custom headers.
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
verify the identity of requested hosts. Either `True` (default CA bundle),
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
(which will disable verification).
"""
url = "/tracking/2024-04/couriers/all"

result = self._request("GET", url=url, **kwargs)
return GetAllCouriersResponse().from_dict(result)

@validate_params
def get_user_couriers(self, **kwargs) -> GetUserCouriersResponse:
"""
Return a list of .
:param kwargs:
request options:
**headers** (dict): support custom headers.
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
verify the identity of requested hosts. Either `True` (default CA bundle),
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
(which will disable verification).
"""
url = "/tracking/2024-04/couriers"

result = self._request("GET", url=url, **kwargs)
return GetUserCouriersResponse().from_dict(result)
43 changes: 43 additions & 0 deletions tracking/api/estimated_delivery_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# coding: utf-8
#
# This code was auto generated by AfterShip SDK Generator.
# Do not edit the class manually.

import json
from typing import Union


from tracking.models import (
PredictBatchRequest,
PredictBatchResponse,
)
from tracking.request import ApiClient, validate_params


class EstimatedDeliveryDateApi(ApiClient):
"""EstimatedDeliveryDateApi api implements"""

@validate_params
def predict_batch(
self, predict_batch_request: Union[PredictBatchRequest, dict], **kwargs
) -> PredictBatchResponse:
"""
> The estimated delivery date is provided by AfterShip, based on its AI-predictive model. You can display the EDD on the product page, cart, and order checkout page. It indicates when a customer will receive the order.You can use to activate this feature.Supported functionalities require:1. One `EstimatedDeliveryDate` object for one prediction result.2. Maximum 5 `EstimatedDeliveryDate` objects are allowed.3. API call will fail if any of the requests `EstimatedDeliveryDate` objects do not meet the specification requirement.
:param predict_batch_request:
:param kwargs:
request options:
**headers** (dict): support custom headers.
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
verify the identity of requested hosts. Either `True` (default CA bundle),
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
(which will disable verification).
"""
url = "/tracking/2024-04/estimated-delivery-date/predict-batch"

body = predict_batch_request
if not isinstance(body, dict):
body = predict_batch_request.model_dump(exclude_none=True)
body = json.dumps(body)

result = self._request("POST", url=url, body=body, **kwargs)
return PredictBatchResponse().from_dict(result)
Loading

0 comments on commit ec0073c

Please sign in to comment.