Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Fix typo and refactor the code #24

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ Most of SDK functions only accept keyword arguments.
Examples
========

Goto `examples <examples>`_ to see more examples.
Go to `examples <examples>`_ to see more examples.
12 changes: 12 additions & 0 deletions aftership/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Meta data of aftership SDK."""

from __future__ import unicode_literals

__version__ = '1.1.0'
__author__ = 'AfterShip '
__copyright__ = 'Copyright 2014 - present,Aike Technology (Shenzhen) Co., Ltd '
__license__ = 'MIT'

__all__ = (
'__version__'
)
44 changes: 38 additions & 6 deletions aftership/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
from . import courier, exception, tracking, notification # noqa


__version__ = '1.1.0'

api_key = None
from .courier import (
list_couriers,
list_all_couriers,
detect_courier,
)
from .tracking import (
delete_tracking,
create_tracking,
update_tracking,
get_tracking,
get_last_checkpoint,
list_trackings,
retrack,
)
from .exception import (
AfterShipError,
BadRequest,
Forbidden,
NotFound,
InternalError,
Unauthorized,
TooManyRequests,
)
from .notification import (
list_notifications,
remove_notification,
add_notification,
)
from .request import (
build_request_url,
make_request,
)
from .__about__ import (
__version__,
)
from .constants import (
API_KEY,
)
1 change: 1 addition & 0 deletions aftership/const.py → aftership/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

API_VERSION = "v4"
API_ENDPOINT = "https://api.aftership.com/v4/"
API_KEY = None
5 changes: 4 additions & 1 deletion aftership/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import requests

from .const import API_KEY_FILED_NAME, API_ENDPOINT
from .constants import (
API_KEY_FILED_NAME,
API_ENDPOINT,
)
from .util import get_api_key


Expand Down
11 changes: 9 additions & 2 deletions aftership/response.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from .exception import BadRequest, Forbidden, NotFound, Unauthorized, TooManyRequests, InternalError, UnexpectedError

from .exception import (
BadRequest,
Unauthorized,
Forbidden,
NotFound,
TooManyRequests,
InternalError,
UnexpectedError,
)
error_mapping = {
'BadRequest': BadRequest,
'Unauthorized': Unauthorized,
Expand Down
4 changes: 2 additions & 2 deletions aftership/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def _build_tracking_url(tracking_id, slug, tracking_number):

def get_api_key():
"""Get AfterShip API key"""
if aftership.api_key is not None:
return aftership.api_key
if aftership.API_KEY is not None:
return aftership.constants.API_KEY
return os.getenv('AFTERSHIP_API_KEY')