def ListOrdersByNextToken(execute_command):
     if common_unit.test_access_param(execute_command) != -1:
         result = common_unit.read_xmlfile('test_file/order_list_next.xml')
     else:
         params = ['Action=ListOrdersByNextToken'] + api_version + [
             'Timestamp=' + common_unit.get_time_stamp()
         ]
         # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
         params += common_unit.make_access_param(execute_command)
         if 'next_token' in execute_command:
             if execute_command['next_token'] != '':
                 next_token = execute_command['next_token']
                 params += ['NextToken=' + quote(next_token)]
         params += default_params
         params = sorted(params)
         params = '&'.join(params)
         params = params.replace('+', '%2B')
         params = params.replace('/', '%2F')
         sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params
         signature = quote(
             str(
                 common_unit.cal_signature(sig_string,
                                           execute_command['secret_key'])))
         signature = signature.replace('=', '%3D')
         signature = signature.replace('/', '%2F')
         url = connect_url(params, signature)
         r = requests.post(url, headers=headers)
         result = common_unit.xmltojson(r.text)
         error_result = common_unit.catch_exception(result)  # 异常处理
         if error_result != '':
             result = error_result
     return result
Exemple #2
0
 def ListMarketplaceParticipations(execute_command):
     if common_unit.test_access_param(execute_command) == 0:
         # result = common_unit.read_xmlfile('test_file/listmarketplace.xml')
         seller_id = execute_command['seller_id']
         result = common_unit.xmltojson(listMarketplace)
         result = test_interface.test_ListMarketplaceParticipations(
             seller_id, result)
     else:
         params = ['Action=ListMarketplaceParticipations'] + api_version + [
             'Timestamp=' + common_unit.get_time_stamp()
         ]
         # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
         params += common_unit.make_access_param(execute_command)
         params = params + default_params
         params = sorted(params)
         params = '&'.join(params)
         sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params
         signature = quote(
             str(
                 common_unit.cal_signature(sig_string,
                                           execute_command['secret_key'])))
         url = connect_url(params, signature)
         r = requests.post(url, headers=headers)
         print(r.text)
         result = common_unit.xmltojson(r.text)
         error_result = common_unit.catch_exception(result)  # 异常处理
         if error_result != '':
             result = error_result
     return result
Exemple #3
0
    def ListInventorySupplyByNextToken(execute_command):
        if common_unit.test_access_param(execute_command) == 0:
            result = common_unit.read_xmlfile(
                'test_file/inventory_list_next.xml')

        else:
            params = [
                'Action=ListInventorySupplyByNextToken'
            ] + api_version + ['Timestamp=' + common_unit.get_time_stamp()]
            # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
            params += common_unit.make_access_param(
                execute_command)  # 获取包含认证参数的字典
            if 'next_token' in execute_command:
                if execute_command['next_token'] != '':
                    params += ['NextToken=' + execute_command['next_token']]

            params = params + default_params
            params = sorted(params)
            params = '&'.join(params)
            params = params.replace('+', '%2B')
            params = params.replace('/', '%2F')
            sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params  # 连接签名字符串
            signature = quote(
                str(
                    common_unit.cal_signature(
                        sig_string,
                        execute_command['secret_key'])))  # 计算字符串的加密签名
            url = connect_url(params, signature)  # 拼接请求字符串
            r = requests.post(url, headers=headers)  # 发起请求
            result = common_unit.xmltojson(r.text)
            error_result = common_unit.catch_exception(result)  # 异常处理
            if error_result != '':
                result = error_result
        return result
Exemple #4
0
 def GetReport(execute_command):
     if common_unit.test_access_param(execute_command) == 0:
         result = common_unit.report_content
     else:
         params = ['Action=GetReport'] + api_version + [
             'Timestamp=' + common_unit.get_time_stamp()
         ]
         # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
         params += common_unit.make_access_param(
             execute_command)  # 获取包含认证参数的字典
         if 'report_id' in execute_command:
             if execute_command['report_id'] != '':
                 params.append('ReportId=' +
                               quote(execute_command['report_id']))
         params = params + default_params
         params = sorted(
             params)  # 拼接公有请求参数,认证请求参数,和特征请求参数,并进行排序,拼接请求身,需要按首字母排序
         params = '&'.join(params)  # 对请求身进行分割
         sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params  # 连接签名字符串
         signature = quote(
             str(
                 common_unit.cal_signature(
                     sig_string,
                     execute_command['secret_key'])))  # 计算字符串的加密签名
         url = connect_url(params, signature)  # 拼接请求字符串
         r = requests.post(url, headers=headers)  # 发起请求
         # print(r)
         # print(r.text)
         # print(r.content)
         result = common_unit.read_file(r.text)
         # result = common_unit.xmltojson(r.content)
         error_result = common_unit.catch_exception(result)  # 异常处理
         if error_result != '':
             result = error_result
     return result
Exemple #5
0
    def ListInventorySupply(execute_command):
        if common_unit.test_access_param(execute_command) == 0:
            # result = common_unit.read_xmlfile('test_file/inventory_list.xml')
            result = common_unit.xmltojson(str(inventory))
            result = test_interface.select_inventory_list(result)
        else:
            params = ['Action=ListInventorySupply'] + api_version + [
                'Timestamp=' + common_unit.get_time_stamp()
            ]
            # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
            params += common_unit.make_access_param(
                execute_command)  # 获取包含认证参数的字典

            if 'sku' in execute_command:
                if execute_command['sku'] != '':
                    sku_list = execute_command['sku'].split(',')
                    sku_params_list = []
                    for i in sku_list:
                        sku_params_list.append('SellerSkus.member.' +
                                               str(sku_list.index(i) + 1) +
                                               '=' + i)
                    params += sku_params_list

            if 'start_time' in execute_command:
                if execute_command['start_time'] != '':
                    st = execute_command['start_time']
                    s_time = common_unit.conver_time(st)
                    params.append('QueryStartDateTime=' + quote(s_time))

            if 'response_group' in execute_command:
                if execute_command['response_group'] != '':
                    params.append('ResponseGroup=' +
                                  quote(execute_command['response_group']))

            params = params + default_params
            params = sorted(
                params)  # 拼接公有请求参数,认证请求参数,和特征请求参数,并进行排序,拼接请求身,需要按首字母排序
            params = '&'.join(params)  # 对请求身进行分割
            params = params.replace('+', "%2B")
            params = params.replace(' ', "%20")
            sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params  # 连接签名字符串
            signature = quote(
                str(
                    common_unit.cal_signature(sig_string,
                                              execute_command['secret_key'])))
            signature = signature.replace('/', '%2F')
            # print(signature)
            # signature = signature.replace('=','%3D') # 计算字符串的加密签名
            url = connect_url(params, signature)  # 拼接请求字符串
            r = requests.post(url, headers=headers)  # 发起请求
            result = common_unit.xmltojson(r.text)
            error_result = common_unit.catch_exception(result)  # 异常处理
            if error_result != '':
                result = error_result
        return result
Exemple #6
0
    def RequestReport(execute_command):
        if common_unit.test_access_param(execute_command) == 0:
            result = common_unit.read_xmlfile('test_file/requestReport.xml')
        else:
            params = ['Action=RequestReport'
                      ] + ['Timestamp=' + common_unit.get_time_stamp()]
            # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
            access_params = common_unit.make_access_param(execute_command)
            market_place_id = access_params[-1].split('=')[1]
            access_params += ['MarketplaceIdList.Id.1=' + market_place_id]
            params = params + access_params  # 获取包含认证参数的字典
            if 'report_type' in execute_command:
                if execute_command['report_type'] != '':
                    params.append('ReportType=' +
                                  quote(execute_command['report_type']))

            if 'start_time' in execute_command:
                s = execute_command['start_time']
                if s != '':
                    st = common_unit.conver_time(s)
                    st = quote(st)
                    params.append('StartDate=' + st)

            if 'end_time' in execute_command:
                e = execute_command['end_time']
                if e != '':
                    et = common_unit.conver_time(e)
                    et = quote(et)
                    params.append('EndDate=' + et)

            params = params + default_params
            params = sorted(
                params)  # 拼接公有请求参数,认证请求参数,和特征请求参数,并进行排序,拼接请求身,需要按首字母排序
            params = '&'.join(params)  # 对请求身进行分割
            sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params  # 连接签名字符串
            signature = quote(
                str(
                    common_unit.cal_signature(
                        sig_string,
                        execute_command['secret_key'])))  # 计算字符串的加密签名
            signature = signature.replace('/', '%2F')
            url = connect_url(params, signature)  # 拼接请求字符串
            # print(url)
            r = requests.post(url, headers=headers)  # 发起请求
            result = common_unit.xmltojson(r.text)
            # print(r.text)
            error_result = common_unit.catch_exception(result)  #异常处理
            if error_result != '':
                result = error_result
        return result
 def ListOrders(execute_command):
     if common_unit.test_access_param(execute_command) != -1:
         result = common_unit.read_xmlfile('test_file/order_list.xml')
         result = eval(result)
         test_common.get_test_order_list(execute_command, result)
     else:
         params = ['Action=ListOrders'] + api_version + [
             'Timestamp=' + common_unit.get_time_stamp()
         ]
         # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
         params += common_unit.make_access_param(execute_command)
         params[-1] = 'MarketplaceId.Id.1=' + params[-1].split('=')[1]
         if 'create_time' in execute_command:
             if execute_command['create_time'] != '':
                 ct = common_unit.conver_time(
                     execute_command['create_time'])
                 c_time = quote(ct)
                 params += ['CreatedAfter=' + c_time]
             else:
                 params += ['CreatedAfter=' + quote('1970-01-01T00:00:00')]
         if 'end_time' in execute_command:
             if execute_command['end_time'] != '':
                 # params += ['CreatedBefore=' + quote(execute_command['end_time'] + 'T00:00:00')]
                 et = common_unit.conver_time(execute_command['end_time'])
                 e_time = quote(et)
                 params += ['CreatedBefore=' + e_time]
             else:
                 delay = datetime.datetime.now() - datetime.timedelta(
                     days=1)
                 e_time = delay.strftime('%Y-%m-%dT%H:%M:%S')
                 params += ['CreatedBefore=' + quote(e_time)]
         params = params + default_params
         params = sorted(params)
         params = '&'.join(params)
         sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params  # 连接签名字符串
         signature = quote(
             str(
                 common_unit.cal_signature(
                     sig_string,
                     execute_command['secret_key'])))  # 计算字符串的加密签名
         url = connect_url(params, signature)
         r = requests.post(url, headers=headers)  # 发起请求
         result = common_unit.xmltojson(r.text)
         error_result = common_unit.catch_exception(result)  # 异常处理
         if error_result != '':
             result = error_result
     return result
Exemple #8
0
 def ListAllFulfillmentOrdersByNextToken(execute_command):
     if common_unit.test_access_param(execute_command) == 0:
         result = common_unit.read_xmlfile(
             'test_file/listAllfulfillmentorderbynextToken.xml')
         # result = common_unit.xmljson(listAllfulfillmentOrders)
         # result = test_interface.select_inboundlist_between_time(result)
     else:
         r = ''
         if 'next_token' in execute_command:
             if execute_command['next_token'] != '':
                 ntoken = execute_command['next_token']
                 params = 'Action=ListAllFulfillmentOrdersByNextToken&NextToken=' + ntoken
                 url = 'https://' + host_name + port_point + '?' + params
                 r = requests.post(url, headers=headers)  # 发起请求
         result = common_unit.xmltojson(r.text)
         error_result = common_unit.catch_exception(result)  # 异常处理
         if error_result != '':
             result = error_result
     return result
Exemple #9
0
    def ListAllFulfillmentOrders(execute_command):
        if common_unit.test_access_param(execute_command) == 0:
            # result = common_unit.xmltojson(listAllfulfillmentOrder)
            # result = common_unit.read_xmlfile('test_file/listAllfulfillmentorder.xml')

            if 'start_time' in execute_command:
                if execute_command['start_time'] != '':
                    start_time = execute_command['start_time']
                    start_date, time_stamp = common_unit.conver_date_time(
                        start_time)
                    # print(start_time,time_stamp)
                    result = common_unit.xmltojson(listAllfulfillmentOrder)
                    result = test_interface.listAllfulfillmentOrders_between_time(
                        start_date, result)

        else:
            params = ['Action=ListAllFulfillmentOrders'] + api_version + [
                'Timestamp=' + common_unit.get_time_stamp()
            ]
            # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
            params += common_unit.make_access_param(execute_command)
            if 'start_time' in execute_command:
                if execute_command['start_time'] != '':
                    st = execute_command['start_time']
                    st = common_unit.conver_time(st)
                    params.append('QueryStartDateTime=' + quote(st))
            params = params + default_params
            params = sorted(params)
            params = '&'.join(params)
            sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params
            signature = quote(
                str(
                    common_unit.cal_signature(sig_string,
                                              execute_command['secret_key'])))
            url = connect_url(params, signature)
            r = requests.post(url, headers=headers)
            print(r.text)
            result = common_unit.xmltojson(r.text)
            error_result = common_unit.catch_exception(result)  # 异常处理
            if error_result != '':
                result = error_result
        return result
 def GetOrder(execute_command):
     if common_unit.test_access_param(execute_command) != -1:
         result = common_unit.read_xmlfile('test_file/get_order.xml')
         result = eval(result)
         test_common.get_test_order(execute_command, result)
     else:
         params = ['Action=GetOrder'] + api_version + [
             'Timestamp=' + common_unit.get_time_stamp()
         ]
         # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
         params += common_unit.make_access_param(
             execute_command)  # 获取包含认证参数的字典
         if 'order_id' in execute_command:
             if execute_command['order_id'] != '':
                 order_id_list = execute_command['order_id'].split(',')
                 order_param_list = []
                 for i in order_id_list:
                     order_param_list.append(
                         'AmazonOrderId.Id.' +
                         str(order_id_list.index(i) + 1) + '=' + i)
                 params += order_param_list
         params = params + default_params
         params = sorted(
             params)  # 拼接公有请求参数,认证请求参数,和特征请求参数,并进行排序,拼接请求身,需要按首字母排序
         params = '&'.join(params)  # 对请求身进行分割
         sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params  # 连接签名字符串
         signature = quote(
             str(
                 common_unit.cal_signature(
                     sig_string,
                     execute_command['secret_key'])))  # 计算字符串的加密签名
         url = connect_url(params, signature)  # 拼接请求字符串
         r = requests.post(url, headers=headers)  # 发起请求
         result = common_unit.xmltojson(r.text)
         error_result = common_unit.catch_exception(result)  # 异常处理
         if error_result != '':
             result = error_result
     return result
Exemple #11
0
 def GetFulfillmentOrder(execute_command):
     if common_unit.test_access_param(execute_command) == 0:
         # result = common_unit.read_xmlfile('test_file/getfulfillmentorder.xml')
         if 'fulfillment_order_id' in execute_command:
             if execute_command['fulfillment_order_id'] != '':
                 fulfillment_order_id = execute_command[
                     'fulfillment_order_id']
                 result = common_unit.xmltojson(getfulfillmentOrder)
                 result = test_interface.getFulfillmentOrder(
                     fulfillment_order_id, result)
     else:
         params = ['Action=GetFulfillmentOrder'] + api_version + [
             'Timestamp=' + common_unit.get_time_stamp()
         ]
         # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
         params += common_unit.make_access_param(execute_command)
         if 'fulfillment_order_id' in execute_command:
             if execute_command['fulfillment_order_id'] != '':
                 params.append(
                     'SellerFulfillmentOrderId=' +
                     quote(execute_command['fulfillment_order_id']))
         params = params + default_params
         params = sorted(params)
         params = '&'.join(params)
         sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params
         signature = quote(
             str(
                 common_unit.cal_signature(sig_string,
                                           execute_command['secret_key'])))
         url = connect_url(params, signature)
         r = requests.post(url, headers=headers)
         print(r.text)
         result = common_unit.xmltojson(r.text)
         error_result = common_unit.catch_exception(result)
         if error_result != '':
             result = error_result
     return result
    def ListOrderItems(execute_command):
        if common_unit.test_access_param(execute_command) != -1:
            result = common_unit.read_xmlfile('test_file/order_item_list.xml')
            result = eval(result)
            test_common.get_test_orderitem_list(execute_command, result)
        else:
            params = ['Action=ListOrderItems'] + api_version + [
                'Timestamp=' + common_unit.get_time_stamp()
            ]
            # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])

            params += common_unit.make_access_param(execute_command)
            if 'order_id' in execute_command:
                if execute_command['order_id'] != '':
                    params += [
                        str('AmazonOrderId=' +
                            quote(execute_command['order_id']))
                    ]
            params += default_params
            params = sorted(params)
            params = '&'.join(params)
            sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params
            signature = quote(
                str(
                    common_unit.cal_signature(
                        sig_string,
                        execute_command['secret_key'])))  # 计算字符串的加密签名
            url = connect_url(params, signature)
            r = requests.post(url, headers=headers)
            result = common_unit.xmltojson(r.text)
            # print(attribute_content)
            # print(type(attribute_content))
            # result = write_order_item_into_database(execute_command,attribute_content)
            error_result = common_unit.catch_exception(result)  # 异常处理
            if error_result != '':
                result = error_result
        return result
Exemple #13
0
    def GetReportRequestList(execute_command):
        if common_unit.test_access_param(execute_command) == 0:
            result = common_unit.read_xmlfile(
                'test_file/getReportRequestList.xml')
        else:
            params = ['Action=GetReportRequestList'] + api_version + [
                'Timestamp=' + common_unit.get_time_stamp()
            ]
            # user_access_dict = common_unit.get_amazon_keys(execute_command['store_id'])
            params += common_unit.make_access_param(
                execute_command)  # 获取包含认证参数的字典
            if 'report_request_id' in execute_command:
                if execute_command['report_request_id'] != '':
                    request_id_list = execute_command[
                        'report_request_id'].split(',')
                    request_list = []
                    for i in request_id_list:
                        request_list.append('ReportRequestIdList.Id.' +
                                            str(request_id_list.index(i) + 1) +
                                            '=' + i)
                    params += request_list

            if 'report_type' in execute_command:
                if execute_command['report_type'] != '':
                    report_list = execute_command['report_type'].split(',')
                    report_type_list = []
                    for i in report_list:
                        report_type_list.append('ReportTypeList.Type.' +
                                                str(report_list.index(i) + 1) +
                                                '=' + i)
                    params += report_type_list

            if 'process_status' in execute_command:
                if execute_command['process_status'] != '':
                    process_status_list = execute_command[
                        'process_status'].split(',')
                    process_list = []
                    for i in process_status_list:
                        process_list.append(
                            'ReportProcessingStatusList.Status.' +
                            str(process_status_list.index(i) + 1) + '=' + i)
                    params += process_list

            if 'max_count' in execute_command:
                if execute_command['max_count'] != '':
                    params.append('MaxCount=' +
                                  quote(execute_command['max_count']))

            if 'start_time' in execute_command:
                if execute_command['start_time'] != '':
                    st = common_unit.conver_time(execute_command['start_time'])
                    st = quote(st)
                    params.append('RequestedFromDate=' + st)  #开始时间

            if 'end_time' in execute_command:
                if execute_command['end_time'] != '':
                    et = common_unit.conver_time(execute_command['end_time'])
                    et = quote(et)
                    params.append('RequestedToDate=' + et)  #结束时间

            params = params + default_params
            params = sorted(
                params)  # 拼接公有请求参数,认证请求参数,和特征请求参数,并进行排序,拼接请求身,需要按首字母排序
            params = '&'.join(params)  # 对请求身进行分割
            sig_string = 'POST\n' + host_name + '\n' + port_point + '\n' + params  # 连接签名字符串
            signature = quote(
                str(
                    common_unit.cal_signature(
                        sig_string,
                        execute_command['secret_key'])))  # 计算字符串的加密签名
            url = connect_url(params, signature)  # 拼接请求字符串
            r = requests.post(url, headers=headers)  # 发起请求
            result = common_unit.xmltojson(r.text)
            # print(r.text)
            error_result = common_unit.catch_exception(result)  # 异常处理
            if error_result != '':
                result = error_result

        return result