Ejemplo n.º 1
0
    def getUserProducts(self, Id='current', queryPars=None):
        '''
        Returns the Products for the current user

        :param Id: The id of the user, optional
        :param queryPars: An (optional) object of type QueryParametersPurchasedProduct for custom sorting and filtering by 'Tags' and/or 'ProductIds'
        '''
        if queryPars is None:
            queryPars = qpp()
        elif not isinstance(queryPars, qpp):
            raise QueryParameterException("Query parameter argument must be a QueryParameterPurchasedProduct object")
        method = 'GET'
        resourcePath = '/users/{Id}/products'
        resourcePath = resourcePath.replace('{Id}', str(Id))
        queryPars.validate()
        queryParams = queryPars.getParameterDict()    
        headerParams = {}
        return self.__listRequest__(PurchasedProduct.PurchasedProduct, resourcePath, method, queryParams, headerParams)
Ejemplo n.º 2
0
    def getUserProducts(self, Id='current', queryPars=None):
        '''
        Returns the Products for the current user

        :param Id: The id of the user, optional
        :param queryPars: An (optional) object of type QueryParametersPurchasedProduct for custom sorting and filtering by 'Tags' and/or 'ProductIds'
        '''
        if queryPars is None:
            queryPars = qpp()
        elif not isinstance(queryPars, qpp):
            raise QueryParameterException("Query parameter argument must be a QueryParameterPurchasedProduct object")
        method = 'GET'
        resourcePath = '/users/{Id}/products'
        resourcePath = resourcePath.replace('{Id}', str(Id))
        queryPars.validate()
        queryParams = queryPars.getParameterDict()    
        headerParams = {}
        return self.__listRequest__(PurchasedProduct.PurchasedProduct, resourcePath, method, queryParams, headerParams)
Ejemplo n.º 3
0
## PAUSE HERE
print "Opening: " + purch.HrefPurchaseDialog
webbrowser.open_new(purch.HrefPurchaseDialog)
print "Waiting 30 seconds..."
time.sleep(30)
## PAUSE HERE

print "\nConfirm the purchase"
post_purch = billAPI.getPurchaseById(purchaseId)
print "The status of the purchase is now: " + post_purch.Status

print "\nRefunding the Purchase"
# note we must use the same access token that was provided used for the purchase
refunded_purchase = billAPI.refundPurchase(purchaseId, refundSecret, comment='the product did not function well as a frisbee')

print "\nGetting all purchases for the current user with the tags we used for the purchase above"
purch_prods = billAPI.getUserProducts(Id='current', queryPars=qpp( {'Tags':'test,test_tag'} ))
if not len(purch_prods):
    print "\nHmmm, didn't find any purchases with these tags. Did everything go OK above?\n"
else:
    print "\nFor the first of these purchases:\n"
    print "Purchase Name: " + purch_prods[0].Name
    print "Purchase Price: " + purch_prods[0].Price
    print "Purchase Quantity: " + purch_prods[0].Quantity
    print "Tags: " + str(purch_prods[0].Tags)

    # Get the refund status of the purchase
    print "\nGetting the (refunded) Purchase we just made"
    get_purch = billAPI.getPurchaseById(purch_prods[0].PurchaseId)
    print "Refund Status: " + get_purch.RefundStatus + "\n"
Ejemplo n.º 4
0
print("\nConfirm the purchase")
post_purch = billAPI.getPurchaseById(purchaseId)
print("The status of the purchase is now: " + post_purch.Status)

print("\nRefunding the Purchase")
# note we must use the same access token that was provided used for the purchase
refunded_purchase = billAPI.refundPurchase(
    purchaseId,
    refundSecret,
    comment='the product did not function well as a frisbee')

print(
    "\nGetting all purchases for the current user with the tags we used for the purchase above"
)
purch_prods = billAPI.getUserProducts(Id='current',
                                      queryPars=qpp({'Tags': 'test,test_tag'}))
if not len(purch_prods):
    print(
        "\nHmmm, didn't find any purchases with these tags. Did everything go OK above?\n"
    )
else:
    print("\nFor the first of these purchases:\n")
    print("Purchase Name: " + purch_prods[0].Name)
    print("Purchase Price: " + purch_prods[0].Price)
    print("Purchase Quantity: " + purch_prods[0].Quantity)
    print("Tags: " + str(purch_prods[0].Tags))

    # Get the refund status of the purchase
    print("\nGetting the (refunded) Purchase we just made")
    get_purch = billAPI.getPurchaseById(purch_prods[0].PurchaseId)
    print("Refund Status: " + get_purch.RefundStatus + "\n")