Skip to content

Commit a621791

Browse files
authored
Major version 2.0.0 with breaking changes (#19)
1 parent 29dfbc1 commit a621791

25 files changed

Lines changed: 41 additions & 22 deletions

shipday/carrier/carrier_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections import defaultdict
22

3-
from shipday.exeptions.shipday_exeption import ShipdayException
3+
from shipday.exceptions.shipday_exception import ShipdayException
44
from shipday.utils.verifiers import verify_instance_of
55

66

shipday/exceptions/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from shipday.exceptions.shipday_exception import ShipdayException
2+
from shipday.exceptions.ratelimit_exception import ShipdayRateLimitException
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from shipday.exceptions.shipday_exception import ShipdayException
2+
3+
class ShipdayRateLimitException(ShipdayException):
4+
def __init__(self, message):
5+
super().__init__(message)

shipday/exeptions/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

shipday/httpclient/shipdayclient.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import json
2+
from typing import Any
23

34
import requests
45

6+
from shipday.exceptions import ShipdayRateLimitException
7+
58

69
class ShipdayClient:
710
def __init__(self, *args, api_key, **kwargs, ):
@@ -21,25 +24,33 @@ def __get_api_key_(self):
2124
def __create_url_(self, suffix: str) -> str:
2225
return self._base_url + suffix
2326

27+
def __check_status_(self, response: Any):
28+
if response.status_code == 429:
29+
raise ShipdayRateLimitException(response.text)
30+
2431
def set_api_key(self, api_key: str):
2532
self._api_key = api_key
2633

2734
def get(self, suffix: str):
2835
url = self.__create_url_(suffix)
2936
response = requests.get(url, headers=self.__get_headers_())
37+
self.__check_status_(response)
3038
return response.json()
3139

3240
def post(self, suffix: str, data: dict):
3341
url = self.__create_url_(suffix)
3442
response = requests.post(url, json.dumps(data), headers=self.__get_headers_())
43+
self.__check_status_(response)
3544
return response.json()
3645

3746
def put(self, suffix: str, data: dict):
3847
url = self.__create_url_(suffix)
3948
response = requests.put(url, json.dumps(data), headers=self.__get_headers_())
49+
self.__check_status_(response)
4050
return response.json()
4151

4252
def delete(self, suffix: str):
4353
url = self.__create_url_(suffix)
4454
response = requests.delete(url, headers=self.__get_headers_())
55+
self.__check_status_(response)
4556
return response

shipday/order/order_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from datetime import datetime
33
from typing import List
44

5-
from shipday.exeptions import ShipdayException
5+
from shipday.exceptions import ShipdayException
66
from shipday.order.customer import Customer
77
from shipday.order.pickup import Pickup
88
from shipday.order.order_item import OrderItem

shipday/order/order_item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
from collections import defaultdict
33

4-
from shipday.exeptions.shipday_exeption import ShipdayException
4+
from shipday.exceptions.shipday_exception import ShipdayException
55
from shipday.utils.verifiers import verify_instance_of, verify_none_or_instance_of
66

77

shipday/order/order_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
from datetime import datetime
33

4-
from shipday.exeptions import ShipdayException
4+
from shipday.exceptions import ShipdayException
55
from shipday.order.order_status import OrderStatus
66
from shipday.utils.verifiers import verify_none_or_instance_of
77
from shipday.order.customer import Customer

shipday/services/carrier_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from shipday.carrier import CarrierRequest
2-
from shipday.exeptions import ShipdayException
2+
from shipday.exceptions import ShipdayException
33
from shipday.httpclient.shipdayclient import ShipdayClient
44

55

0 commit comments

Comments
 (0)