当前位置: 首页>>代码示例>>Python>>正文


Python trading.Connection类代码示例

本文整理汇总了Python中ebaysdk.trading.Connection的典型用法代码示例。如果您正苦于以下问题:Python Connection类的具体用法?Python Connection怎么用?Python Connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Connection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_myebay_selling_request

def get_myebay_selling_request(page):
    """get_myebay_selling_request"""
    try:
        api_trading = Trading(config_file=PATH_TO_YAML, warnings=True, timeout=20)

        api_request = {
            "ActiveList": {
                "Include": True,
                "Pagination": {
                    "EntriesPerPage": 100,
                    "PageNumber": page
                    },
                "IncludeWatchCount": True
                },
            'DetailLevel': 'ReturnAll'
            }

        api_trading.execute('GetMyeBaySelling', api_request)
        products = api_trading.response.dict()

    except ConnectionError as e:
        print(e)
        print(e.response.dict())
        raise e

    return products
开发者ID:bglazier,项目名称:erpnext_ebay,代码行数:26,代码来源:ebay_active_listings.py

示例2: get_item

def get_item(item_id=None, item_code=None, site_id=default_site_id):
    """Returns a single listing from the eBay TradingAPI."""

    if not (item_code or item_id):
        raise ValueError('No item_code or item_id passed to get_item!')

    api_dict = {'IncludeWatchCount': True}
    if item_code:
        api_dict['SKU'] = item_code
    if item_id:
        api_dict['ItemID'] = item_id

    try:
        # Initialize TradingAPI; default timeout is 20.

        api = Trading(config_file=PATH_TO_YAML,
                      siteid=site_id, warnings=True, timeout=20)

        api.execute('GetItem', api_dict)

        listing = api.response.dict()
        test_for_message(listing)

    except ConnectionError as e:
        handle_ebay_error(e)

    if six.PY2:
        # Convert all strings to unicode
        listing = convert_to_unicode(listing)

    return listing['Item']
开发者ID:bglazier,项目名称:erpnext_ebay,代码行数:31,代码来源:ebay_requests.py

示例3: get_eBay_details

def get_eBay_details(site_id=default_site_id, detail_name=None):
    """Perform a GeteBayDetails call."""

    try:
        # Initialize TradingAPI; default timeout is 20.
        api = Trading(config_file=PATH_TO_YAML,
                      siteid=site_id, warnings=True, timeout=20)

        api_options = {}
        if detail_name is not None:
            api_options['DetailName'] = detail_name

        response = api.execute('GeteBayDetails', api_options)

    except ConnectionError as e:
        handle_ebay_error(e)

    response_dict = response.dict()
    test_for_message(response_dict)

    if six.PY2:
        # Convert all strings to unicode
        response_dict = convert_to_unicode(response_dict)

    return response_dict
开发者ID:bglazier,项目名称:erpnext_ebay,代码行数:25,代码来源:ebay_requests.py

示例4: memberMessages

def memberMessages(opts):

    try:
        api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
                      certid=opts.certid, devid=opts.devid, warnings=True)

        now = datetime.datetime.now()

        memberData = {
            "WarningLevel": "High",
            "MailMessageType": "All",
            # "MessageStatus": "Unanswered",
            "StartCreationTime": now - datetime.timedelta(days=60),
            "EndCreationTime": now,
            "Pagination": {
                "EntriesPerPage": "5",
                "PageNumber": "1"
            }
        }

        api.execute('GetMemberMessages', memberData)

        dump(api)

        if api.response_dict().MemberMessage:
            messages = api.response_dict().MemberMessage.MemberMessageExchange

            if type(messages) != list:
                    messages = [ messages ]

            for m in messages:
                print("%s: %s" % (m.CreationDate, m.Question.Subject[:50]))

    except ConnectionError as e:
        print e
开发者ID:HypnoTherapist,项目名称:ebaysdk-python,代码行数:35,代码来源:trading.py

示例5: revise_ebay_price

def revise_ebay_price(item_code, new_price, is_auction):
    """Given item_code and (inc vat) price, revise the listing on eBay"""


    #get the ebay id given the item_code
    ebay_id = frappe.get_value('Item', item_code, 'ebay_id')
    if ebay_id and item_code and new_price:

        try:
            new_price_inc = float(new_price)
            api_trading = Trading(config_file=PATH_TO_YAML, warnings=True, timeout=20)

            if is_auction:
                api_trading.execute('ReviseItem', {'Item':{'ItemID':ebay_id, \
                                'StartPrice':new_price_inc}})
            else:
                # ReviseInventoryStatus enables change to price and/or quantity of an active, fixed-price listing. 
                # The fixed-price listing is identified with the ItemID of the listing or the SKUvalue of the item
                api_trading.execute('ReviseInventoryStatus', {'InventoryStatus':{'ItemID':ebay_id, \
                                    'StartPrice':new_price_inc}})

        except ConnectionError:
            return ("Connection Error - possibly ebay.yaml file not found")

        except Exception:
            return ("Price sync. There was a problem using the eBay Api")
            #raise

        else:
            return ("Price sync success - eBay listing updated!")
    else:
        return ("Price Sync Error: There was a problem getting with the item_code, price or ebayid")
开发者ID:bglazier,项目名称:erpnext_ebay,代码行数:32,代码来源:revise_items.py

示例6: verifyAddItemErrorCodes

def verifyAddItemErrorCodes(opts):
    """http://www.utilities-online.info/xmltojson/#.UXli2it4avc
    """

    try:
        api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
                      certid=opts.certid, devid=opts.devid, warnings=False)

        myitem = {
            "Item": {
                "Title": "Harry Potter and the Philosopher's Stone",
                "Description": "This is the first book in the Harry Potter series. In excellent condition!",
                "PrimaryCategory": {"CategoryID": "377aaaaaa"},
                "StartPrice": "1.0",
                "CategoryMappingAllowed": "true",
                "Country": "US",
                "ConditionID": "3000",
                "Currency": "USD",
                "DispatchTimeMax": "3",
                "ListingDuration": "Days_7",
                "ListingType": "Chinese",
                "PaymentMethods": "PayPal",
                "PayPalEmailAddress": "[email protected]",
                "PictureDetails": {"PictureURL": "http://i1.sandbox.ebayimg.com/03/i/00/30/07/20_1.JPG?set_id=8800005007"},
                "PostalCode": "95125",
                "Quantity": "1",
                "ReturnPolicy": {
                    "ReturnsAcceptedOption": "ReturnsAccepted",
                    "RefundOption": "MoneyBack",
                    "ReturnsWithinOption": "Days_30",
                    "Description": "If you are not satisfied, return the book for refund.",
                    "ShippingCostPaidByOption": "Buyer"
                },
                "ShippingDetails": {
                    "ShippingType": "Flat",
                    "ShippingServiceOptions": {
                        "ShippingServicePriority": "1",
                        "ShippingService": "USPSMedia",
                        "ShippingServiceCost": "2.50"
                    }
                },
                "Site": "US"
            }
        }

        api.execute('VerifyAddItem', myitem)
    
    except ConnectionError as e:
        # traverse the DOM to look for error codes
        for node in api.response.dom().findall('ErrorCode'):
            print("error code: %s" % node.text)

        # check for invalid data - error code 37
        if 37 in api.response_codes():
            print("Invalid data in request")

        print(e)
        print(e.response.dict())
开发者ID:rowbare,项目名称:ebaysdk-python,代码行数:58,代码来源:trading.py

示例7: get_orders

def get_orders():
    """Returns a list of recent orders from the eBay TradingAPI.

    This list is NOT filtered by a siteid as the API call does not filter
    by siteid.
    """

    num_days = frappe.db.get_value(
        'eBay Manager Settings', filters=None, fieldname='ebay_sync_days')

    try:
        if num_days < 1:
            frappe.msgprint('Invalid number of days: ' + str(num_days))
    except TypeError:
        raise ValueError('Invalid type in ebay_sync_days')

    orders = []
    page = 1

    try:
        # Initialize TradingAPI; default timeout is 20.

        # Always use the US site for GetOrders as it returns fields we need
        # (which the UK site, for example, doesn't) and it doesn't filter by
        # siteID anyway
        api = Trading(config_file=PATH_TO_YAML,
                      siteid=0, warnings=True, timeout=20)

        while True:
            # TradingAPI results are paginated, so loop until
            # all pages have been obtained
            api.execute('GetOrders', {
                'NumberOfDays': num_days,
                'Pagination': {
                    'EntriesPerPage': 50,
                    'PageNumber': page}
                })

            orders_api = api.response.dict()
            test_for_message(orders_api)

            n_orders = int(orders_api['ReturnedOrderCountActual'])
            if n_orders == 1:
                orders.append(orders_api['OrderArray']['Order'])
            elif n_orders > 0:
                orders.extend(orders_api['OrderArray']['Order'])
            if orders_api['HasMoreOrders'] == 'false':
                break
            page += 1

    except ConnectionError as e:
        handle_ebay_error(e)

    if six.PY2:
        # Convert all strings to unicode
        orders = convert_to_unicode(orders)

    return orders, num_days
开发者ID:bglazier,项目名称:erpnext_ebay,代码行数:58,代码来源:ebay_requests.py

示例8: test_get_user

def test_get_user(item):
	api = Connection(config_file='ebay.yaml')
	details_dict = dict()
	try: 
		response = api.execute('GetUser',{"UserID":item,"DetailLevel":"ReturnAll"})
		details = response.reply
		print details
	except Exception as e:
		print e
开发者ID:turpure,项目名称:categorySearTools,代码行数:9,代码来源:GetItemDetails.py

示例9: test_get_item

def test_get_item(item):
	api = Connection(config_file='ebay.yaml')
	details_dict = dict()
	try: 
		response = api.execute('GetItem',{"ItemID":item,"OutputSelector":"Seller","DetailLevel":"ReturnAll"})
		details = response.reply.Item
		print details
	except Exception as e:
		print e
开发者ID:turpure,项目名称:categorySearTools,代码行数:9,代码来源:GetItemDetails.py

示例10: get_categories

def get_categories(site_id=default_site_id):
    """Load the eBay categories for the categories cache."""

    try:
        # Initialize TradingAPI; default timeout is 20.
        api = Trading(config_file=PATH_TO_YAML,
                      siteid=site_id, warnings=True, timeout=60)

        response = api.execute('GetCategories', {'DetailLevel': 'ReturnAll',
                                                 'ViewAllNodes': 'true'})

    except ConnectionError as e:
        handle_ebay_error(e)

    categories_data = response.dict()

    if six.PY2:
        # Convert all strings to unicode
        categories_data = convert_to_unicode(categories_data)

    # Process the remaining categories data
    cl = categories_data['CategoryArray']['Category']
    # Use one dictionary element per level, to store each Category against its
    # CategoryID. For simplicity don't use the first [0] level as CategoryLevel
    # is one-indexed.
    levels = []
    for cat in cl:
        cat['Children'] = []
        cat_level = int(cat['CategoryLevel'])
        while cat_level > len(levels)-1:
            levels.append({})
        # Add the category to the relevant level dictionary
        levels[cat_level][cat['CategoryID']] = cat

    max_level = len(levels) - 1

    # Loop over all deeper levels; connect categories to their parents
    for parent_level, level_dict in enumerate(levels[2:], start=1):
        for cat in level_dict.values():
            parent = levels[parent_level][cat['CategoryParentID']]
            parent['Children'].append(cat)

    # Sort the Children list of each category according to its CategoryName
    for cat in cl:
        cat['Children'].sort(key=operator.itemgetter('CategoryName'))

    # Sort the top level list according to the CategoryName of the categories
    top_level = levels[1].values()
    top_level.sort(key=operator.itemgetter('CategoryName'))

    categories_data['TopLevel'] = top_level

    del categories_data['CategoryArray']

    # Return the new categories
    return categories_data, max_level
开发者ID:bglazier,项目名称:erpnext_ebay,代码行数:56,代码来源:ebay_requests.py

示例11: getOrders

def getOrders(opts):

    try:
        api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
                      certid=opts.certid, devid=opts.devid, warnings=True, timeout=20)

        api.execute('GetOrders', {'NumberOfDays': 30})
        dump(api, full=False)

    except ConnectionError as e:
        print e
开发者ID:HypnoTherapist,项目名称:ebaysdk-python,代码行数:11,代码来源:trading.py

示例12: getUser

def getUser(opts):
    try:

        api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
                      certid=opts.certid, devid=opts.devid, warnings=True, timeout=20, siteid=101)

        api.execute('GetUser', {'UserID': 'biddergoat'})
        dump(api, full=False)
    
    except ConnectionError as e:
        print e
开发者ID:HypnoTherapist,项目名称:ebaysdk-python,代码行数:11,代码来源:trading.py

示例13: getTokenStatus

def getTokenStatus(opts):

    try:
        api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
                      certid=opts.certid, devid=opts.devid, warnings=False)

        api.execute('GetTokenStatus')
        dump(api)

    except ConnectionError as e:
        print e
开发者ID:HypnoTherapist,项目名称:ebaysdk-python,代码行数:11,代码来源:trading.py

示例14: getxml

def getxml(myset):
    mycon = Connection(domain='api.ebay.com',
                appid='ZhouPeng-3242-4cc7-88fd-310f513fcd71',
                devid='df3f2898-65b1-4e15-afd5-172b989903aa',
                certid='a0e19cf9-9b2b-457f-b6f1-87f3f600ca63',
                token='AgAAAA**AQAAAA**aAAAAA**cJyLVQ**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wMkoqiC5mHoQmdj6x9nY+seQ**N+QCAA**AAMAAA**nLCwNt4AQt1TRtd2ydNIMuZ2JYnQZKVVYarn41QQfBSqccEDld22ltKr+C/HJTN8AKD4+jn/nIEqtjNMkmh9sxTIa6jVVLAH5sN/93X7gTCmTkOsE/Av612U90nRoyQJ5bX1+NO25tMDZs9U0aTJIwVVu1BAB8/nsjL0pTCWw7KZACJ+a/aQ6swXLvSvOCWIBjFyCaWibKZseT2LoJMvJQmC2QpIuDsQ8cTYozLUYZqC88uKAjo7DNWIvaPVCdwkp/Vux3arR1Asin4ewX1l+LWCamWsXeBiVyaYq/oEUXABgknieVAPEpaFAfSzlrcTNmTWLBDDRwRGI/8hJCwK6/eJWexGrLk7U7p0kRltktNseTckAKT7g1ED4C5gUeQ4/nTHsNQBejUPTzTlwBWTJpwRaBFD7dAlbagH+TKaEJK41Esf/ZpL2599LUMolsO8tBgo0BhtCF/bYtdUUfopksIKNUwPXikadUxx6TurknnTtR1WDD229uUJIIf9BCS68WB56OfDTdXcZ8rdPZ0zdHuw5+BRxrumpFUzTQb5fJeHRDLPtQbLdX5rFPrS+NPJl6Qzi7bWNxUCydNQcIzKv7xLquIPoPx8bD1PRCoQbzjTQsOqhe9PBvLtcJ0Ggve78YjQKb5nDt6YThZ6D+1EOKdcthU03VizDfBKBLJ/NPqktDTx74tsS3l4feAjblGDoQ2RZXefJ9Jk3t+Qc4khlvl4mKpjZ4sCakh4qPWr9H6t3CN80hz5MO1Y7uHPUY61',

                )
    for ele in myset:
        myrequest={'ItemID':ele,'IncludeWatchCount':True}
        myresponse=mycon.execute('GetItem',myrequest)
        yield myresponse.text
开发者ID:turpure,项目名称:search,代码行数:12,代码来源:test.py

示例15: run

def run(api_request, params):
    try:
        api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid, certid=opts.certid, devid=opts.devid)

        response = api.execute(api_request, params)

        dump(api)
        # print(api.response.reply.Charity.Name)
        return response.dict()
    except ConnectionError as e:
        print(e)
        print(e.response.dict())
开发者ID:Azarieled,项目名称:GiftRecommenderSystem,代码行数:12,代码来源:tradingApi.py


注:本文中的ebaysdk.trading.Connection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。