def test_get_orders_400_error(): from sp_api.base import SellingApiBadRequestException try: Orders().get_orders(CreatedAfter='TEST_CASE_400') except SellingApiBadRequestException as sep: assert sep.code == 400 assert sep.amzn_code == 'InvalidInput'
def test_get_orders(): try: res = Orders().get_orders(CreatedAfter=(datetime.utcnow() - timedelta(days=1)).isoformat()) print(res.payload) # json data except SellingApiException as ex: print(ex)
def fetch_orders(self, updated_after: str, page_size: int, next_token: Optional[str]) -> any: page_count = page_size or self.PAGECOUNT response = Orders(credentials=self.credentials, marketplace=self.marketplace).get_orders( LastUpdatedAfter=updated_after, MaxResultsPerPage=page_count, NextToken=next_token) return response.payload
def test_get_order_items_buyer_info(): res = Orders().get_order_items_buyer_info('TEST_CASE_200') assert res.errors is None assert res.payload.get('AmazonOrderId') is not None
def test_get_order_address(): res = Orders().get_order_address('TEST_CASE_200') assert res.errors is None assert res.payload.get('AmazonOrderId') is not None
def test_get_order_api_response_call2(): res = Orders().get_order('TEST_CASE_200') assert res() is not None assert isinstance(res(), dict) assert res.errors is None assert res.payload.get('AmazonOrderId') is not None
def test_get_order_api_response_call(): res = Orders().get_order('TEST_CASE_200') print(res('DefaultShipFromLocationAddress')) assert res('DefaultShipFromLocationAddress') is not None assert res.errors is None assert res.payload.get('AmazonOrderId') is not None
def load_all_orders(**kwargs): return Orders().get_orders(**kwargs)
def test_get_order_items(): print(Orders().get_order_items(''))
def test_get_order(): print(Orders().get_order('1asdf1-3654623').payload)
def test_get_order_items(): print(Orders().get_order_items('asdf-4229851').payload)
def test_get_orders(): res = Orders().get_orders(CreatedAfter='TEST_CASE_200') assert res.errors is None assert res.payload.get('Orders') is not None
def test_get_order(): print(Orders().get_order('').payload)
def test_get_order_buyer_info(): print(Orders().get_order_buyer_info(''))
def test_get_order_address(): print(Orders().get_order_address(''))
def test_get_orders(): res = Orders().get_orders(CreatedAfter='TEST_CASE_200', MarketplaceIds=["ATVPDKIKX0DER"]) assert res.errors is None assert res.payload.get('Orders') is not None
# Import datetime and timedelta from python's datetime module # https://docs.python.org/3/library/datetime.html from datetime import datetime, timedelta # Import the Orders class from python-amazon-sp-api from sp_api.api import Orders from sp_api.base import SellingApiException, Marketplaces # Fill in credential info here credentials = dict( refresh_token='', lwa_app_id='', lwa_client_secret='', aws_secret_key='', aws_access_key='', role_arn='', ) try: # Get orders created after 1 day ago res = Orders(credentials=credentials, marketplace=Marketplaces.GB).get_orders(CreatedAfter=(datetime.utcnow() - timedelta(days=1)).isoformat()) print(res) # If something goes wrong, print out the exception except SellingApiException as ex: print(ex)