Skip to content
Merged
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 shipday/carrier/carrier_request.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import defaultdict

from shipday.exeptions.shipday_exeption import ShipdayException
from shipday.exceptions.shipday_exception import ShipdayException
from shipday.utils.verifiers import verify_instance_of


Expand Down
2 changes: 2 additions & 0 deletions shipday/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from shipday.exceptions.shipday_exception import ShipdayException
from shipday.exceptions.ratelimit_exception import ShipdayRateLimitException
5 changes: 5 additions & 0 deletions shipday/exceptions/ratelimit_exception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from shipday.exceptions.shipday_exception import ShipdayException

class ShipdayRateLimitException(ShipdayException):
def __init__(self, message):
super().__init__(message)
1 change: 0 additions & 1 deletion shipday/exeptions/__init__.py

This file was deleted.

11 changes: 11 additions & 0 deletions shipday/httpclient/shipdayclient.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import json
from typing import Any

import requests

from shipday.exceptions import ShipdayRateLimitException


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

def __check_status_(self, response: Any):
if response.status_code == 429:
raise ShipdayRateLimitException(response.text)

def set_api_key(self, api_key: str):
self._api_key = api_key

def get(self, suffix: str):
url = self.__create_url_(suffix)
response = requests.get(url, headers=self.__get_headers_())
self.__check_status_(response)
return response.json()

def post(self, suffix: str, data: dict):
url = self.__create_url_(suffix)
response = requests.post(url, json.dumps(data), headers=self.__get_headers_())
self.__check_status_(response)
return response.json()

def put(self, suffix: str, data: dict):
url = self.__create_url_(suffix)
response = requests.put(url, json.dumps(data), headers=self.__get_headers_())
self.__check_status_(response)
return response.json()

def delete(self, suffix: str):
url = self.__create_url_(suffix)
response = requests.delete(url, headers=self.__get_headers_())
self.__check_status_(response)
return response
2 changes: 1 addition & 1 deletion shipday/order/order_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime
from typing import List

from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.order.customer import Customer
from shipday.order.pickup import Pickup
from shipday.order.order_item import OrderItem
Expand Down
2 changes: 1 addition & 1 deletion shipday/order/order_item.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from collections import defaultdict

from shipday.exeptions.shipday_exeption import ShipdayException
from shipday.exceptions.shipday_exception import ShipdayException
from shipday.utils.verifiers import verify_instance_of, verify_none_or_instance_of


Expand Down
2 changes: 1 addition & 1 deletion shipday/order/order_query.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from datetime import datetime

from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.order.order_status import OrderStatus
from shipday.utils.verifiers import verify_none_or_instance_of
from shipday.order.customer import Customer
Expand Down
2 changes: 1 addition & 1 deletion shipday/services/carrier_service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from shipday.carrier import CarrierRequest
from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.httpclient.shipdayclient import ShipdayClient


Expand Down
2 changes: 1 addition & 1 deletion shipday/services/on_demand_delivery_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from shipday.bo import PodType
from shipday.utils.verifiers import verify_instance_of, verify_none_or_instance_of
from shipday.exeptions.shipday_exeption import ShipdayException
from shipday.exceptions.shipday_exception import ShipdayException
from shipday.httpclient.shipdayclient import ShipdayClient
from shipday.order.address import Address
from datetime import datetime
Expand Down
2 changes: 1 addition & 1 deletion shipday/services/order_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.httpclient.shipdayclient import ShipdayClient
from shipday.order import Order, OrderQuery
from shipday.utils.verifiers import verify_instance_of
Expand Down
2 changes: 1 addition & 1 deletion shipday/shipday_object.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.services import OrderService, CarrierService, OnDemandDeliveryService


Expand Down
2 changes: 1 addition & 1 deletion shipday/utils/verifiers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException


def verify_none_or_instance_of(obj_type, variable, error_message):
Expand Down
2 changes: 1 addition & 1 deletion shipday/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '1.4.4'
VERSION = '2.0.0'
2 changes: 1 addition & 1 deletion tests/test_carrier/test_carrier_request.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from shipday.exeptions.shipday_exeption import ShipdayException
from shipday.exceptions.shipday_exception import ShipdayException
from shipday.carrier.carrier_request import CarrierRequest


Expand Down
2 changes: 1 addition & 1 deletion tests/test_order/test_address.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.order import Address


Expand Down
2 changes: 1 addition & 1 deletion tests/test_order/test_customer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.order import Customer, Address


Expand Down
2 changes: 1 addition & 1 deletion tests/test_order/test_order_cost.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from itertools import combinations

from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.order import OrderCost


Expand Down
2 changes: 1 addition & 1 deletion tests/test_order/test_order_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from datetime import datetime

from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.order import Order, Customer, Pickup, OrderItem, OrderCost, Address


Expand Down
2 changes: 1 addition & 1 deletion tests/test_order/test_order_item.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.order import OrderItem


Expand Down
2 changes: 1 addition & 1 deletion tests/test_order/test_order_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from itertools import combinations

from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.order import OrderQuery, Customer, Pickup, OrderItem, OrderCost, Address, OrderStatus


Expand Down
2 changes: 1 addition & 1 deletion tests/test_order/test_pickup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from shipday.exeptions import ShipdayException
from shipday.exceptions import ShipdayException
from shipday.order import Pickup, Address


Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils/test_verifiers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from shipday.exeptions.shipday_exeption import ShipdayException
from shipday.exceptions.shipday_exception import ShipdayException
from shipday.utils.verifiers import verify_instance_of, verify_none_or_instance_of, \
verify_not_negative, verify_none_or_not_negative, verify_none_or_within_range, verify_all_none_or_not

Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[tox]
envlist =
python3.6
python3.7
python3.8
python3.9
python3.10
python3.11
python3.12
python3.13
python3.14


skip_missing_interpreters = true
Expand Down