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


Python Connection.execute方法代码示例

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


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

示例1: revise_ebay_price

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
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,代码行数:34,代码来源:revise_items.py

示例2: memberMessages

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
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,代码行数:37,代码来源:trading.py

示例3: get_myebay_selling_request

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
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,代码行数:28,代码来源:ebay_active_listings.py

示例4: get_item

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
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,代码行数:33,代码来源:ebay_requests.py

示例5: verifyAddItemErrorCodes

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
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,代码行数:60,代码来源:trading.py

示例6: get_orders

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
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,代码行数:60,代码来源:ebay_requests.py

示例7: getOrders

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
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,代码行数:13,代码来源:trading.py

示例8: getTokenStatus

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
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,代码行数:13,代码来源:trading.py

示例9: getUser

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
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,代码行数:13,代码来源:trading.py

示例10: run

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
def run(opts):

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

        api.execute('GetCharities', {'CharityID': 3897})
        dump(api)
        print(api.response_dict().Charity.Name)

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

示例11: getUser

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
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': 'sallyma789'})
        dump(api, full=False)

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

示例12: check_ebay_item_exists

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
def check_ebay_item_exists(itemID):
    ''' 
    True if Item exists   
    '''
    try:
        api = Trading(debug=False, config_file=config_file, appid=appid,
                      certid=certid, devid=devid,warnings=False)
        api.execute('GetItem', {'ItemID': itemID})
        return True
       
    except ConnectionError as e:
        return False
开发者ID:rjweyant1,项目名称:ebamazon,代码行数:14,代码来源:preliminary.py

示例13: feedback

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
def feedback(opts):
    try:
        api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
                      certid=opts.certid, devid=opts.devid, warnings=False)

        api.execute('GetFeedback', {'UserID': 'tim0th3us'})
        dump(api)

        if int(api.response_dict().FeedbackScore) > 50:
            print("Doing good!")
        else:
            print("Sell more, buy more..")
    
    except ConnectionError as e:
        print e
开发者ID:HypnoTherapist,项目名称:ebaysdk-python,代码行数:17,代码来源:trading.py

示例14: get_ebay_item_price

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
def get_ebay_item_price(itemID):
    ''' 
    searches for itemID and returns the start price.    
    '''
    try:
        api = Trading(debug=False, config_file=config_file, appid=appid,
                      certid=certid, devid=devid,warnings=False)
    
        api.execute('GetItem', {'ItemID': itemID})
        return float(api.response.reply.Item.StartPrice.value)
       
    except ConnectionError as e:
        print(e)
        print(e.response.dict())
        return False
开发者ID:rjweyant1,项目名称:ebamazon,代码行数:17,代码来源:preliminary.py

示例15: get_seller_list

# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import execute [as 别名]
def get_seller_list(item_codes=None, site_id=default_site_id):
    """Runs GetSellerList to obtain a list of items."""

    # Create eBay acceptable datetime stamps for EndTimeTo and EndTimeFrom
    end_from = datetime.utcnow().isoformat()[:-3] + 'Z'
    end_to = (datetime.utcnow() + timedelta(days=119)).isoformat()[:-3] + 'Z'

    listings = []

    try:
        # Initialize TradingAPI; default timeout is 20.

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

        page = 1
        while True:
            # TradingAPI results are paginated, so loop until
            # all pages have been obtained
            api.execute('GetSellerList', {
                'SKUArray': {'SKU': item_codes},
                'EndTimeTo': end_to,
                'EndTimeFrom': end_from,
                'Pagination': {
                    'EntriesPerPage': 50,
                    'PageNumber': page}
                })

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

            n_listings = int(listings_api['ReturnedItemCountActual'])
            if n_listings == 1:
                listings.append(listings_api['ItemArray']['Item'])
            elif int(listings_api['ReturnedItemCountActual']) > 0:
                listings.extend(listings_api['ItemArray']['Item'])
            if listings_api['HasMoreItems'] == 'false':
                break
            page += 1

    except ConnectionError as e:
        handle_ebay_error(e)

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

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


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