Exemple #1
0
def uploadSiteHostedPicture(filepath):
    isURL = 'http://' in filepath or 'https://' in filepath
    #get the user auth token
    token = get_config_store().get("auth", "token")
    oname = "UploadSiteHostedPictures"
    rname = "%sRequest" % oname
    root = etree.Element(rname, xmlns="urn:ebay:apis:eBLBaseComponents")
    credentials_elem = etree.SubElement(root, "RequesterCredentials")
    token_elem = etree.SubElement(credentials_elem, "eBayAuthToken")
    token_elem.text = token
    add_e(root, "PictureSet", "Supersize")
    if isURL:
        urlpath = filepath
    else:
        try:
            urlpath = imgur_post(filepath)
        except Exception as e:
            sys.stderr.write("Unable to upload img: %s. Abort -1.\n" % filepath)
            raise e

    epu = add_e(root, "ExternalPictureURL", urlpath)

    request = etree.tostring(root, pretty_print=True,
                              xml_declaration=True, encoding="UTF-8")

    response = get_response(oname, request, "UTF-8")

    return urlpath
Exemple #2
0
def uploadSiteHostedPicture(filepath):
    isURL = 'http://' in filepath or 'https://' in filepath
    #get the user auth token
    token = get_config_store().get("auth", "token")
    oname = "UploadSiteHostedPictures"
    rname = "%sRequest" % oname
    root = etree.Element(rname, xmlns="urn:ebay:apis:eBLBaseComponents")
    credentials_elem = etree.SubElement(root, "RequesterCredentials")
    token_elem = etree.SubElement(credentials_elem, "eBayAuthToken")
    token_elem.text = token
    add_e(root, "PictureSet", "Supersize")
    if isURL:
        urlpath = filepath
    else:
        try:
            urlpath = imgur_post(filepath)
        except Exception as e:
            sys.stderr.write("Unable to upload img: %s. Abort -1.\n" %
                             filepath)
            raise e

    epu = add_e(root, "ExternalPictureURL", urlpath)

    request = etree.tostring(root,
                             pretty_print=True,
                             xml_declaration=True,
                             encoding="UTF-8")

    response = get_response(oname, request, "UTF-8")

    return urlpath
Exemple #3
0
def addItem(title, description, primaryCategoryId,
            startPrice='0.99', buyItNowPrice=None, country='US',
            currency='USD', dispatchTimeMax='3', listingDuration='Days_7',
            listingType='Chinese', paymentMethods=['PayPal'],
            payPalEmailAddress='', pictureDetails=[], postalCode='',
            photoDisplay='PicturePack', condition='new',
            quantity=1, freeShipping=True, site='US', test=False):

    #get the user auth token
    token = get_config_store().get("auth", "token")
    oname = "AddItem" if not test else 'VerifyAddItem'
    rname = "%sRequest" % oname
    root = etree.Element(rname,
                         xmlns="urn:ebay:apis:eBLBaseComponents")
    #add it to the xml doc
    credentials_elem = etree.SubElement(root, "RequesterCredentials")
    token_elem = etree.SubElement(credentials_elem, "eBayAuthToken")
    token_elem.text = token


    item_e = etree.SubElement(root, "Item")
    t_e = add_e(item_e, "Title", str(title))
    d_e = add_e(item_e, "Description", str(description))
    pcat = add_e(item_e, "PrimaryCategory", None)
    cid = add_e(pcat, "CategoryID", primaryCategoryId)
    add_e(item_e, "ConditionID", CID.get(condition, 'new'))
    sp = add_e(item_e, "StartPrice", startPrice)
    if buyItNowPrice:
        sp = add_e(item_e, "BuyItNowPrice", buyItNowPrice)
    cma = add_e(item_e, "CategoryMappingAllowed", 'true')
    cnode = add_e(item_e, "Country", country)
    curre = add_e(item_e, "Currency", currency)
    dtme = add_e(item_e, "DispatchTimeMax", dispatchTimeMax)
    lde = add_e(item_e, "ListingDuration", listingDuration)
    for t in paymentMethods:
        pme = add_e(item_e, "PaymentMethods", t)
    ppea = add_e(item_e, "PayPalEmailAddress", payPalEmailAddress)
    picde = add_e(item_e, "PictureDetails", None)
    add_e(picde, "PhotoDisplay", photoDisplay)
    for url in pictureDetails:
        ure = add_e(picde, "PictureURL", url)
    pce = add_e(item_e, "PostalCode", postalCode)
    que = add_e(item_e, "Quantity", quantity)

    # default return
    returnPol_e = add_e(item_e, "ReturnPolicy", None)
    add_e(returnPol_e, "ReturnsAcceptedOption", "ReturnsAccepted")
    add_e(returnPol_e, "RefundOption", "MoneyBack")
    add_e(returnPol_e, "ReturnsWithinOption", "Days_30")
    add_e(returnPol_e, "Description", "If you are not satisfied, ship the item back for a full refund.")
    add_e(returnPol_e, "ShippingCostPaidByOption", "Buyer")
    # end default ret pol
    
    shipde_e = add_e(item_e, "ShippingDetails", None)
    if freeShipping:
        sst = add_e(shipde_e, "ShippingType", "Flat")
        sse = add_e(shipde_e, "ShippingServiceOptions", None)
        add_e(sse, "ShippingService", "USPSMedia")
        add_e(sse, "ShippingServiceCost", "0.0")
        add_e(sse, "ShippingServiceAdditionalCost", "0.0")
        add_e(sse, "ShippingServicePriority", "1")
        add_e(sse, "ExpeditedService", "false")
    site_e = add_e(item_e, "Site", site)

    #need to specify xml declaration and encoding or else will get error
    request = etree.tostring(root, pretty_print=True,
                              xml_declaration=True, encoding="utf-8")
    response = get_response(oname, request, "utf-8")

    return response
Exemple #4
0
def addItem(title,
            description,
            primaryCategoryId,
            startPrice='0.99',
            buyItNowPrice=None,
            country='US',
            currency='USD',
            dispatchTimeMax='3',
            listingDuration='Days_7',
            listingType='Chinese',
            paymentMethods=['PayPal'],
            payPalEmailAddress='',
            pictureDetails=[],
            postalCode='',
            photoDisplay='PicturePack',
            condition='new',
            quantity=1,
            freeShipping=True,
            site='US',
            test=False):
    #get the user auth token
    token = get_config_store().get("auth", "token")
    oname = "AddItem" if not test else 'VerifyAddItem'
    rname = "%sRequest" % oname
    root = etree.Element(rname, xmlns="urn:ebay:apis:eBLBaseComponents")
    #add it to the xml doc
    credentials_elem = etree.SubElement(root, "RequesterCredentials")
    token_elem = etree.SubElement(credentials_elem, "eBayAuthToken")
    token_elem.text = token

    item_e = etree.SubElement(root, "Item")
    t_e = add_e(item_e, "Title", str(title))
    d_e = add_e(item_e, "Description", str(description))
    pcat = add_e(item_e, "PrimaryCategory", None)
    cid = add_e(pcat, "CategoryID", primaryCategoryId)
    add_e(item_e, "ConditionID", CID.get(condition, 'new'))
    sp = add_e(item_e, "StartPrice", startPrice)
    if buyItNowPrice:
        sp = add_e(item_e, "BuyItNowPrice", buyItNowPrice)
    cma = add_e(item_e, "CategoryMappingAllowed", 'true')
    cnode = add_e(item_e, "Country", country)
    curre = add_e(item_e, "Currency", currency)
    dtme = add_e(item_e, "DispatchTimeMax", dispatchTimeMax)
    lde = add_e(item_e, "ListingDuration", listingDuration)
    for t in paymentMethods:
        pme = add_e(item_e, "PaymentMethods", t)
    ppea = add_e(item_e, "PayPalEmailAddress", payPalEmailAddress)
    picde = add_e(item_e, "PictureDetails", None)
    add_e(picde, "PhotoDisplay", photoDisplay)
    for url in pictureDetails:
        ure = add_e(picde, "PictureURL", url)
    pce = add_e(item_e, "PostalCode", postalCode)
    que = add_e(item_e, "Quantity", quantity)

    # default return
    returnPol_e = add_e(item_e, "ReturnPolicy", None)
    add_e(returnPol_e, "ReturnsAcceptedOption", "ReturnsAccepted")
    add_e(returnPol_e, "RefundOption", "MoneyBack")
    add_e(returnPol_e, "ReturnsWithinOption", "Days_30")
    add_e(returnPol_e, "Description",
          "If you are not satisfied, ship the item back for a full refund.")
    add_e(returnPol_e, "ShippingCostPaidByOption", "Buyer")
    # end default ret pol

    shipde_e = add_e(item_e, "ShippingDetails", None)
    if freeShipping:
        sst = add_e(shipde_e, "ShippingType", "Flat")
        sse = add_e(shipde_e, "ShippingServiceOptions", None)
        add_e(sse, "ShippingService", "USPSMedia")
        add_e(sse, "ShippingServiceCost", "0.0")
        add_e(sse, "ShippingServiceAdditionalCost", "0.0")
        add_e(sse, "ShippingServicePriority", "1")
        add_e(sse, "ExpeditedService", "false")
    site_e = add_e(item_e, "Site", site)

    #need to specify xml declaration and encoding or else will get error
    request = etree.tostring(root,
                             pretty_print=True,
                             xml_declaration=True,
                             encoding="utf-8")
    response = get_response(oname, request, "utf-8")

    return response