コード例 #1
0
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'
コード例 #2
0
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)
コード例 #3
0
ファイル: amazon.py プロジェクト: zestyping/airbyte
 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
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
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
コード例 #7
0
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
コード例 #8
0
 def load_all_orders(**kwargs):
     return Orders().get_orders(**kwargs)
コード例 #9
0
def test_get_order_items():
    print(Orders().get_order_items(''))
コード例 #10
0
def test_get_order():
    print(Orders().get_order('1asdf1-3654623').payload)
コード例 #11
0
def test_get_order_items():
    print(Orders().get_order_items('asdf-4229851').payload)
コード例 #12
0
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
コード例 #13
0
def test_get_order():
    print(Orders().get_order('').payload)
コード例 #14
0
def test_get_order_buyer_info():
    print(Orders().get_order_buyer_info(''))
コード例 #15
0
def test_get_order_address():
    print(Orders().get_order_address(''))
コード例 #16
0
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
コード例 #17
0
# 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)