""" This file is part of the MerchantAPI package. (c) Miva Inc <https://www.miva.com/> For the full copyright and license information, please view the LICENSE file that was distributed with this source code. """ from merchantapi.client import Client, ClientException from merchantapi.request import Module # Initialize a client client = Client('https://www.mystore.com/mm5/json.mvc', 'MyApiToken', 'MySigningKey', {}) # If you create a custom module or want to hook into an existing modules API functionality it exposes you can # use the Module request class to call into the module. request = Module(client) request.set_module_code('MyModuleCode').set_module_function('MyModuleFunction') # Add custom parameters to the request using the set_module_field method request.set_module_field('MyModuleField', 'Foo').set_module_field('MyModuleField_Array', ['foo', 'bar']) ''' It is best practice to create a custom class for your Module by extending the Module or the Request class. '''
# defaults to Client.SIGN_DIGEST_SHA256 'signing_key_digest': Client.SIGN_DIGEST_SHA256, # # The default store code that will be added to each request that # did not have one specified. Default is null. 'default_store_code': 'STORE_CODE', # Enable or disable ssl verification. Default is True 'ssl_verify': True # Multi call operation timeout, in seconds. Defaults to 60 'operation_timeout': 60 } client = Client('https://www.mystore.com/mm5/json.mvc', 'MyApiToken', 'MySigningKey', options) ''' Authentication via SSH Private Key Signing ''' from merchantapi.client import SSHClient from merchantapi.authenticator import SSHPrivateKeyAuthenticator client = SSHClient('https://www.mystore.com/mm5/json.mvc', 'Username', '/path/to/ssh/private/key/id_rsa', 'KeyPassword', SSHPrivateKeyAuthenticator.DIGEST_SSH_RSA_SHA256, options) # Alternately, you can use a string value of the private key = 'STRING_CONTENTS_OF_PRIVATE_KEY'
(c) Miva Inc <https://www.miva.com/> For the full copyright and license information, please view the LICENSE file that was distributed with this source code. """ from merchantapi.client import Client, ClientException from merchantapi.request import ProductUpdate from merchantapi.request import ProductListLoadQuery from merchantapi.request import CategoryListLoadQuery from merchantapi.request import PriceGroupListLoadQuery from merchantapi.multicall import MultiCallRequest # Initialize a client client = Client('https://www.mystore.com/mm5/json.mvc', 'MyApiToken', 'MySigningKey', {}) # Create a MultiCallRequest and add Request objects to it request = MultiCallRequest(client) request.add_request(ProductListLoadQuery()) request.add_requests([CategoryListLoadQuery(), PriceGroupListLoadQuery()]) # Send the request try: response = request.send() except ClientException as e: print(str(e)) exit()