Esempio n. 1
0
 def test_sandboxify(self):
     # Create one-off connection class that has self._sandboxed = True
     conn = MWSConnection(https_connection_factory=self.https_connection_factory,
         aws_access_key_id='aws_access_key_id',
         aws_secret_access_key='aws_secret_access_key',
         sandbox=True)
     self.assertEqual(conn._sandboxify('a/bogus/path'), 'a/bogus_Sandbox/path')
def amazonbarcodesearch(list, mkt, idtype):
    '''
    
    :param list: list of barcodes to search inside Amazon
    :param mkt: Marketplace ID
    :param idtype: Barcode Type, EG UPC, EAN
    :return: List of results

    Amazon Marketplace	MarketplaceId
    DE	                A1PA6795UKMFR9
    ES	                A1RKKUPIHCS9HS
    FR	                A13V1IB3VIYZZH
    IT	                APJ6JRA9NG5V4
    UK	                A1F83G8C2ARO7P
    
    '''

    counter = 1
    results = []
    # Provide credentials
    conn = MWSConnection(
        aws_access_key_id="",  #add your access_key_id
        aws_secret_access_key="",  #add your secret_access_key
        Merchant="",  #add your merchant id
        host=""  #add your host
    )

    while len(list) > 0:
        # Get a list of orders.
        response = conn.get_matching_product_for_id(
            IdType=idtype,
            # Can only search 5 barcodes at a time
            IdList=list[0:5],
            MarketplaceId=mkt)

        product = response.GetMatchingProductForIdResult
        print(product)

        for value in product:
            status = value['status']
            barcode = value['Id']

            if status != 'Success':
                results.append(
                    "There is no matching Amazon product for item with {}: {}".
                    format(idtype, barcode))
            else:
                itemtitle = unidecode(value.Products.Product[0].AttributeSets.
                                      ItemAttributes[0].Title)
                asin = value.Products.Product[
                    0].Identifiers.MarketplaceASIN.ASIN
                results.append(
                    "Found match for Linnworks Item: {}.  {}: {} with matching ASIN: {}"
                    .format(itemtitle, idtype, barcode, asin))

        list = list[5:]
        counter += 1

    return results
Esempio n. 3
0
 def _get_connection(self):
     self.ensure_one()
     account = self._get_existing_keychain()
     try:
         return MWSConnection(self.accesskey,
                              account.get_password(),
                              Merchant=self.merchant,
                              host=self.host)
     except Exception as e:
         raise UserError(u"Amazon response:\n\n%s" % e)
Esempio n. 4
0
 def connection(self):
     """
     Share the connection between the streams,
     but only establish it when we need it - lazy loading
     This may be overkill
     """
     if not self._connection:
         self._connection = MWSConnection(
             aws_access_key_id=self.config.get('aws_access_key'),
             aws_secret_access_key=self.config.get('client_secret'),
             Merchant=self.config.get('seller_id'),
             # mws_auth_token=self.config.get('mws_auth_token'),
         )
     return self._connection
Esempio n. 5
0
 def __init__(self, ReportType):
     self.simple = SIMPLE
     self.shack = SHACK
     self.mws = MWSConnection(Merchant=self.simple,
                              aws_access_key_id=ID,
                              aws_secret_access_key=SECRET)
     self.ProcessingStatus = None
     # self.ReportType = '_GET_FBA_MYI_ALL_INVENTORY_DATA_'
     self.ReportType = ReportType
     self.Report = None
     self.GeneratedReportId = None
     self.hasNext = False
     self.nextToken = None
     self.ReportRequestList = None
     self.ReportList = None
     self.ReportRequestId = None
Esempio n. 6
0
 def setUp(self):
     self.mws = MWSConnection(Merchant=simple, debug=0)
# ********************** Fill in your credentials. **************************
SELLER_ID	= 'add yours here'
ACCESS_KEY	= 'add yours here'
SECRET_KEY	= 'add yours here'

MARKETPLACE_IDS	= {
    'CA':	'add yours here'
    'MX':	'add yours here'
    'US':	'add yours here'
    }

# Provide your credentials.
conn = MWSConnection(
    Merchant			= SELLER_ID,
    aws_access_key_id		= ACCESS_KEY,
    aws_secret_access_key	= SECRET_KEY,
)

# ********************** Adjust dates.  **************************
# Request report.
# Adjust dates so you get some data but not too much.
# Report types documented here.
# https://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html
rptReq = conn.request_report(
    ReportType		= '_GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_',
    # Adjust as necessary  StartDate		= '2017-08-01T10:00:00Z',
    # Adjust as necessary  EndDate		= '2017-08-01T11:00:00Z',
    MarketplaceIdList	= [MARKETPLACE_IDS['US']],
)
reqId	= rptReq.RequestReportResult.ReportRequestInfo.ReportRequestId
Esempio n. 8
0
#Return a result set
###################################

#results = sql.executeScriptsFromFile('N:\Planning\John\SQL Queries\Python Queries\\sql_test_files.sql')
#print "hello world"

today = datetime.datetime.now()
#print today.strftime("%Y-%m-%d")
#exit()
AccessKeyID = 'ACCESS KEY'
SecretKey = 'SECRET KEY'

merchant_id = 'SELLER ID'
marketplaceId = 'MARKETPLACE'

conn = MWSConnection(AccessKeyID, SecretKey)
conn.SellerId = 'SELLER ID'
conn.Merchant = 'MERCHANT NAME'
conn.MarketplaceId = 'MARKETPLACE'  #https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html

variants = tera.runQuery(
    "select * from list_of_top_sellers  where sales >= '1000' "
)  #where upc = '190528763607'

#print variants

#variants = [190528763294, 190528763379]

print type(variants)
x = 0
records = len(variants)
Esempio n. 9
0
count = 0

#payload = {'amazonorderid':'123123123123'}

url = 'https://api.fieldbook.com/v1/56733a810c342f030073c9d9/orders'
itemUrl = 'https://api.fieldbook.com/v1/56733a810c342f030073c9d9/orderitems'

headers = {'content-type': 'application/json', 'accept': 'application/json'}

accessKey = "accessKey"
merchantID = "merchantID"
marketplaceID = "marketplaceID"
secretKey = "secretKey"

mws = MWSConnection(accessKey, secretKey)
mws.Merchant = merchantID
mws.SellerId = merchantID
mws.MarketplaceId = marketplaceID

while month < 13:
    response = mws.list_orders(CreatedAfter='2015-12-01T00:00:00Z',
                               MarketplaceId=[marketplaceID])
    #if month>9:
    #response = mws.list_orders(CreatedAfter = '2015-10-01T00:00:00Z', MarketplaceId = [marketplaceID])

    orders = response.ListOrdersResult.Orders.Order

    for order in orders:
        payload = {
            'amazonorderid':
Esempio n. 10
0
 def __init__(self, *args, **kw):
     TestCase.__init__(self, *args, **kw)
     self.mws = MWSConnection(Merchant=simple, debug=0)
Esempio n. 11
0
from itertools import zip_longest
import time
from attributes import Attributes
from boto.exception import BotoServerError
from multiprocessing import Pool
import os
import csv

# AWS Credentials
aws_access_key_id = os.environ.get('aws_access_key_id')
aws_secret_access_key = os.environ.get('aws_secret_access_key')
sellerid = os.environ.get('sellerid')
marketplaceid = os.environ.get('marketplaceid')

mws = MWSConnection(aws_access_key_id=aws_access_key_id,
                    aws_secret_access_key=aws_secret_access_key,
                    Merchant=sellerid)


def get_attributes(asin_list):
    '''
    Retrieve certain attributes for all active ASINS from goodstuff database

    Args:
       asin_list(list of lists):
       Each internal list contains 10 ASIN.  This because the mws function
       allows to submit an api request for 10 ASIN at a time.

    Returns:
        master(list): A list of attributes for each ASIN.
        The attributes are: