PowerBuilder
PowerBuilder
MercadoLibre - Search Orders from a Buyer
See more MercadoLibre Examples
Search for orders from a buyer.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_JsonToken
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
oleobject loo_Date_closed
oleobject loo_Date_last_updated
oleobject loo_Date_created
oleobject loo_Date_approved
oleobject loo_Date_last_modified
string ls_SellerPhoneNumber
string ls_SellerPhoneExtension
string ls_SellerPhoneArea_code
integer li_SellerPhoneVerified
string ls_SellerAlternative_phoneNumber
string ls_SellerAlternative_phoneExtension
string ls_SellerAlternative_phoneArea_code
string ls_SellerNickname
string ls_SellerLast_name
integer li_SellerId
string ls_SellerFirst_name
string ls_SellerEmail
integer li_Fulfilled
string ls_Buying_mode
string ls_TaxesAmount
string ls_TaxesCurrency_id
string ls_Order_requestChange
string ls_Order_requestReturn
string ls_Expiration_date
string ls_FeedbackSale
string ls_FeedbackPurchase
integer li_ShippingId
integer li_Id
string ls_Manufacturing_ending_date
integer li_Hidden_for_seller
string ls_Last_updated
string ls_Comments
string ls_Pack_id
integer li_CouponAmount
string ls_CouponId
integer li_Shipping_cost
string ls_Application_id
string ls_Pickup_id
string ls_Status_detail
string ls_BuyerBilling_infoDoc_number
string ls_BuyerBilling_infoDoc_type
string ls_BuyerPhoneNumber
string ls_BuyerPhoneExtension
string ls_BuyerPhoneArea_code
integer li_BuyerPhoneVerified
string ls_BuyerAlternative_phoneNumber
string ls_BuyerAlternative_phoneExtension
string ls_BuyerAlternative_phoneArea_code
string ls_BuyerNickname
string ls_BuyerLast_name
integer li_BuyerId
string ls_BuyerFirst_name
string ls_BuyerEmail
string ls_Total_amount
string ls_Paid_amount
string ls_Currency_id
string ls_Status
integer j
integer li_Count_j
string ls_Reason
string ls_Status_code
string ls_Total_paid_amount
string ls_Operation_type
string ls_Transaction_amount
integer li_CollectorId
string ls_Coupon_id
integer li_Installments
string ls_Authorization_code
integer li_Taxes_amount
integer li_Coupon_amount
string ls_Installment_amount
string ls_Activation_uri
integer li_Overpaid_amount
integer li_Card_id
string ls_Issuer_id
string ls_Payment_method_id
string ls_Payment_type
string ls_Deferred_period
string ls_Atm_transfer_referenceTransaction_id
string ls_Atm_transfer_referenceCompany_id
string ls_Site_id
integer li_Payer_id
string ls_Marketplace_fee
integer li_Order_id
string ls_Transaction_order_id
integer k
integer li_Count_k
string ls_StrVal
string ls_ItemSeller_custom_field
string ls_ItemCondition
string ls_ItemCategory_id
string ls_ItemVariation_id
string ls_ItemSeller_sku
string ls_ItemWarranty
string ls_ItemId
string ls_ItemTitle
integer li_Quantity
string ls_Differential_pricing_id
string ls_Sale_fee
string ls_Listing_type_id
string ls_Base_currency_id
string ls_Unit_price
string ls_Full_unit_price
string ls_Base_exchange_rate
string ls_Manufacturing_days
string ls_Id_str
string ls_Name
string ls_Query
string ls_SortId
string ls_SortName
integer li_PagingTotal
integer li_PagingOffset
integer li_PagingLimit
string ls_Display
integer i
integer li_Count_i
li_Success = 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// First get our previously obtained OAuth2 access token.
loo_JsonToken = create oleobject
li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_JsonToken.LoadFile("qa_data/tokens/mercadolibre.json")
// Implements the following CURL command:
// curl -X GET https://api.mercadolibre.com/orders/search?buyer=$BUYER_ID&access_token=$ACCESS_TOKEN
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
loo_Http.SetUrlVar("access_token",loo_JsonToken.StringOf("access_token"))
// Use an actual buyer ID here..
loo_Http.SetUrlVar("buyer_id","577815702")
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Http.QuickGetSb("https://api.mercadolibre.com/orders/search?buyer={$buyer_id}&access_token={$access_token}",loo_SbResponseBody)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
Write-Debug "Response Header:"
Write-Debug loo_Http.LastHeader
Write-Debug "----"
Write-Debug "Response Body:"
Write-Debug loo_SbResponseBody.GetAsString()
Write-Debug "Failed."
destroy loo_Http
destroy loo_JsonToken
destroy loo_SbResponseBody
return
end if
loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Http.LastHeader
Write-Debug "----"
Write-Debug "Response Body:"
Write-Debug loo_SbResponseBody.GetAsString()
Write-Debug "Failed."
destroy loo_Http
destroy loo_JsonToken
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "query": "2032217210",
// "results": [
// {
// "seller": {
// "phone": {
// "number": "11971427863",
// "extension": "",
// "area_code": null,
// "verified": false
// },
// "alternative_phone": {
// "number": "",
// "extension": "",
// "area_code": ""
// },
// "nickname": "VENDASDKMB",
// "last_name": "Cheracomo",
// "id": 239432672,
// "first_name": "Demétrio",
// "email": "dcherac.8m6k0q+2-ogiydgmrsge3tenby@mail.mercadolivre.com"
// },
// "payments": [
// {
// "reason": "Kit Com 03 Adesivo Spray 3m 75 Cola Silk Sublimação 300g",
// "status_code": null,
// "total_paid_amount": 129.95,
// "operation_type": "regular_payment",
// "transaction_amount": 129.95,
// "date_approved": "2019-05-22T03:51:07.000-04:00",
// "collector": {
// "id": 239432672
// },
// "coupon_id": null,
// "installments": 1,
// "authorization_code": "008877",
// "taxes_amount": 0,
// "id": 4792155710,
// "date_last_modified": "2019-05-22T03:51:07.000-04:00",
// "coupon_amount": 0,
// "available_actions": [
// "refund"
// ],
// "shipping_cost": 0,
// "installment_amount": 129.95,
// "date_created": "2019-05-22T03:51:05.000-04:00",
// "activation_uri": null,
// "overpaid_amount": 0,
// "card_id": 203453778,
// "status_detail": "accredited",
// "issuer_id": "24",
// "payment_method_id": "master",
// "payment_type": "credit_card",
// "deferred_period": null,
// "atm_transfer_reference": {
// "transaction_id": "135292",
// "company_id": null
// },
// "site_id": "MLB",
// "payer_id": 89660613,
// "marketplace_fee": 14.290000000000001,
// "order_id": 2032217210,
// "currency_id": "BRL",
// "status": "approved",
// "transaction_order_id": null
// }
// ],
// "fulfilled": true,
// "buying_mode": "buy_equals_pay",
// "taxes": {
// "amount": null,
// "currency_id": null
// },
// "order_request": {
// "change": null,
// "return": null
// },
// "expiration_date": "2019-06-19T03:51:07.000-04:00",
// "feedback": {
// "sale": null,
// "purchase": null
// },
// "shipping": {
// "id": 27968238880
// },
// "date_closed": "2019-05-22T03:51:07.000-04:00",
// "id": 2032217210,
// "manufacturing_ending_date": null,
// "hidden_for_seller": false,
// "order_items": [
// {
// "item": {
// "seller_custom_field": null,
// "condition": "new",
// "category_id": "MLB33383",
// "variation_id": null,
// "variation_attributes": [
// ],
// "seller_sku": null,
// "warranty": "Garantia de 1 ano fabricante",
// "id": "MLB1054990648",
// "title": "Kit Com 03 Adesivo Spray 3m 75 Cola Silk Sublimação 300g"
// },
// "quantity": 1,
// "differential_pricing_id": null,
// "sale_fee": 14.29,
// "listing_type_id": "gold_special",
// "base_currency_id": null,
// "unit_price": 129.95,
// "full_unit_price": 129.95,
// "base_exchange_rate": null,
// "currency_id": "BRL",
// "manufacturing_days": null
// }
// ],
// "date_last_updated": "2020-02-14T02:55:49.811Z",
// "last_updated": "2019-05-28T15:16:04.000-04:00",
// "comments": null,
// "pack_id": null,
// "coupon": {
// "amount": 0,
// "id": null
// },
// "shipping_cost": 0,
// "date_created": "2019-05-22T03:51:05.000-04:00",
// "application_id": "7092",
// "pickup_id": null,
// "status_detail": null,
// "tags": [
// "delivered",
// "paid"
// ],
// "buyer": {
// "billing_info": {
// "doc_number": "02183212950",
// "doc_type": "CPF"
// },
// "phone": {
// "number": "99962663",
// "extension": "",
// "area_code": "41",
// "verified": false
// },
// "alternative_phone": {
// "number": "30576339",
// "extension": "",
// "area_code": "41"
// },
// "nickname": "S.VICTORHUGO",
// "last_name": "Schemberger",
// "id": 89660613,
// "first_name": "Victor Hugo",
// "email": "vschemb.y14cdz+2-ogiydgmrsge3tenbz@mail.mercadolivre.com"
// },
// "total_amount": 129.95,
// "paid_amount": 129.95,
// "mediations": [
// ],
// "currency_id": "BRL",
// "status": "paid"
// }
// ],
// "sort": {
// "id": "date_asc",
// "name": "Date ascending"
// },
// "available_sorts": [
// {
// "id": "date_desc",
// "name": "Date descending"
// }
// ],
// "filters": [
// ],
// "paging": {
// "total": 1,
// "offset": 0,
// "limit": 50
// },
// "display": "complete"
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
loo_Date_closed = create oleobject
li_rc = loo_Date_closed.ConnectToNewObject("Chilkat.DtObj")
loo_Date_last_updated = create oleobject
li_rc = loo_Date_last_updated.ConnectToNewObject("Chilkat.DtObj")
loo_Date_created = create oleobject
li_rc = loo_Date_created.ConnectToNewObject("Chilkat.DtObj")
loo_Date_approved = create oleobject
li_rc = loo_Date_approved.ConnectToNewObject("Chilkat.DtObj")
loo_Date_last_modified = create oleobject
li_rc = loo_Date_last_modified.ConnectToNewObject("Chilkat.DtObj")
ls_Query = loo_JResp.StringOf("query")
ls_SortId = loo_JResp.StringOf("sort.id")
ls_SortName = loo_JResp.StringOf("sort.name")
li_PagingTotal = loo_JResp.IntOf("paging.total")
li_PagingOffset = loo_JResp.IntOf("paging.offset")
li_PagingLimit = loo_JResp.IntOf("paging.limit")
ls_Display = loo_JResp.StringOf("display")
i = 0
li_Count_i = loo_JResp.SizeOfArray("results")
do while i < li_Count_i
loo_JResp.I = i
ls_SellerPhoneNumber = loo_JResp.StringOf("results[i].seller.phone.number")
ls_SellerPhoneExtension = loo_JResp.StringOf("results[i].seller.phone.extension")
ls_SellerPhoneArea_code = loo_JResp.StringOf("results[i].seller.phone.area_code")
li_SellerPhoneVerified = loo_JResp.BoolOf("results[i].seller.phone.verified")
ls_SellerAlternative_phoneNumber = loo_JResp.StringOf("results[i].seller.alternative_phone.number")
ls_SellerAlternative_phoneExtension = loo_JResp.StringOf("results[i].seller.alternative_phone.extension")
ls_SellerAlternative_phoneArea_code = loo_JResp.StringOf("results[i].seller.alternative_phone.area_code")
ls_SellerNickname = loo_JResp.StringOf("results[i].seller.nickname")
ls_SellerLast_name = loo_JResp.StringOf("results[i].seller.last_name")
li_SellerId = loo_JResp.IntOf("results[i].seller.id")
ls_SellerFirst_name = loo_JResp.StringOf("results[i].seller.first_name")
ls_SellerEmail = loo_JResp.StringOf("results[i].seller.email")
li_Fulfilled = loo_JResp.BoolOf("results[i].fulfilled")
ls_Buying_mode = loo_JResp.StringOf("results[i].buying_mode")
ls_TaxesAmount = loo_JResp.StringOf("results[i].taxes.amount")
ls_TaxesCurrency_id = loo_JResp.StringOf("results[i].taxes.currency_id")
ls_Order_requestChange = loo_JResp.StringOf("results[i].order_request.change")
ls_Order_requestReturn = loo_JResp.StringOf("results[i].order_request.return")
ls_Expiration_date = loo_JResp.StringOf("results[i].expiration_date")
ls_FeedbackSale = loo_JResp.StringOf("results[i].feedback.sale")
ls_FeedbackPurchase = loo_JResp.StringOf("results[i].feedback.purchase")
li_ShippingId = loo_JResp.IntOf("results[i].shipping.id")
loo_JResp.DtOf("results[i].date_closed",0,loo_Date_closed)
li_Id = loo_JResp.IntOf("results[i].id")
ls_Manufacturing_ending_date = loo_JResp.StringOf("results[i].manufacturing_ending_date")
li_Hidden_for_seller = loo_JResp.BoolOf("results[i].hidden_for_seller")
loo_JResp.DtOf("results[i].date_last_updated",0,loo_Date_last_updated)
ls_Last_updated = loo_JResp.StringOf("results[i].last_updated")
ls_Comments = loo_JResp.StringOf("results[i].comments")
ls_Pack_id = loo_JResp.StringOf("results[i].pack_id")
li_CouponAmount = loo_JResp.IntOf("results[i].coupon.amount")
ls_CouponId = loo_JResp.StringOf("results[i].coupon.id")
li_Shipping_cost = loo_JResp.IntOf("results[i].shipping_cost")
loo_JResp.DtOf("results[i].date_created",0,loo_Date_created)
ls_Application_id = loo_JResp.StringOf("results[i].application_id")
ls_Pickup_id = loo_JResp.StringOf("results[i].pickup_id")
ls_Status_detail = loo_JResp.StringOf("results[i].status_detail")
ls_BuyerBilling_infoDoc_number = loo_JResp.StringOf("results[i].buyer.billing_info.doc_number")
ls_BuyerBilling_infoDoc_type = loo_JResp.StringOf("results[i].buyer.billing_info.doc_type")
ls_BuyerPhoneNumber = loo_JResp.StringOf("results[i].buyer.phone.number")
ls_BuyerPhoneExtension = loo_JResp.StringOf("results[i].buyer.phone.extension")
ls_BuyerPhoneArea_code = loo_JResp.StringOf("results[i].buyer.phone.area_code")
li_BuyerPhoneVerified = loo_JResp.BoolOf("results[i].buyer.phone.verified")
ls_BuyerAlternative_phoneNumber = loo_JResp.StringOf("results[i].buyer.alternative_phone.number")
ls_BuyerAlternative_phoneExtension = loo_JResp.StringOf("results[i].buyer.alternative_phone.extension")
ls_BuyerAlternative_phoneArea_code = loo_JResp.StringOf("results[i].buyer.alternative_phone.area_code")
ls_BuyerNickname = loo_JResp.StringOf("results[i].buyer.nickname")
ls_BuyerLast_name = loo_JResp.StringOf("results[i].buyer.last_name")
li_BuyerId = loo_JResp.IntOf("results[i].buyer.id")
ls_BuyerFirst_name = loo_JResp.StringOf("results[i].buyer.first_name")
ls_BuyerEmail = loo_JResp.StringOf("results[i].buyer.email")
ls_Total_amount = loo_JResp.StringOf("results[i].total_amount")
ls_Paid_amount = loo_JResp.StringOf("results[i].paid_amount")
ls_Currency_id = loo_JResp.StringOf("results[i].currency_id")
ls_Status = loo_JResp.StringOf("results[i].status")
j = 0
li_Count_j = loo_JResp.SizeOfArray("results[i].payments")
do while j < li_Count_j
loo_JResp.J = j
ls_Reason = loo_JResp.StringOf("results[i].payments[j].reason")
ls_Status_code = loo_JResp.StringOf("results[i].payments[j].status_code")
ls_Total_paid_amount = loo_JResp.StringOf("results[i].payments[j].total_paid_amount")
ls_Operation_type = loo_JResp.StringOf("results[i].payments[j].operation_type")
ls_Transaction_amount = loo_JResp.StringOf("results[i].payments[j].transaction_amount")
loo_JResp.DtOf("results[i].payments[j].date_approved",0,loo_Date_approved)
li_CollectorId = loo_JResp.IntOf("results[i].payments[j].collector.id")
ls_Coupon_id = loo_JResp.StringOf("results[i].payments[j].coupon_id")
li_Installments = loo_JResp.IntOf("results[i].payments[j].installments")
ls_Authorization_code = loo_JResp.StringOf("results[i].payments[j].authorization_code")
li_Taxes_amount = loo_JResp.IntOf("results[i].payments[j].taxes_amount")
li_Id = loo_JResp.IntOf("results[i].payments[j].id")
loo_JResp.DtOf("results[i].payments[j].date_last_modified",0,loo_Date_last_modified)
li_Coupon_amount = loo_JResp.IntOf("results[i].payments[j].coupon_amount")
li_Shipping_cost = loo_JResp.IntOf("results[i].payments[j].shipping_cost")
ls_Installment_amount = loo_JResp.StringOf("results[i].payments[j].installment_amount")
loo_JResp.DtOf("results[i].payments[j].date_created",0,loo_Date_created)
ls_Activation_uri = loo_JResp.StringOf("results[i].payments[j].activation_uri")
li_Overpaid_amount = loo_JResp.IntOf("results[i].payments[j].overpaid_amount")
li_Card_id = loo_JResp.IntOf("results[i].payments[j].card_id")
ls_Status_detail = loo_JResp.StringOf("results[i].payments[j].status_detail")
ls_Issuer_id = loo_JResp.StringOf("results[i].payments[j].issuer_id")
ls_Payment_method_id = loo_JResp.StringOf("results[i].payments[j].payment_method_id")
ls_Payment_type = loo_JResp.StringOf("results[i].payments[j].payment_type")
ls_Deferred_period = loo_JResp.StringOf("results[i].payments[j].deferred_period")
ls_Atm_transfer_referenceTransaction_id = loo_JResp.StringOf("results[i].payments[j].atm_transfer_reference.transaction_id")
ls_Atm_transfer_referenceCompany_id = loo_JResp.StringOf("results[i].payments[j].atm_transfer_reference.company_id")
ls_Site_id = loo_JResp.StringOf("results[i].payments[j].site_id")
li_Payer_id = loo_JResp.IntOf("results[i].payments[j].payer_id")
ls_Marketplace_fee = loo_JResp.StringOf("results[i].payments[j].marketplace_fee")
li_Order_id = loo_JResp.IntOf("results[i].payments[j].order_id")
ls_Currency_id = loo_JResp.StringOf("results[i].payments[j].currency_id")
ls_Status = loo_JResp.StringOf("results[i].payments[j].status")
ls_Transaction_order_id = loo_JResp.StringOf("results[i].payments[j].transaction_order_id")
k = 0
li_Count_k = loo_JResp.SizeOfArray("results[i].payments[j].available_actions")
do while k < li_Count_k
loo_JResp.K = k
ls_StrVal = loo_JResp.StringOf("results[i].payments[j].available_actions[k]")
k = k + 1
loop
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("results[i].order_items")
do while j < li_Count_j
loo_JResp.J = j
ls_ItemSeller_custom_field = loo_JResp.StringOf("results[i].order_items[j].item.seller_custom_field")
ls_ItemCondition = loo_JResp.StringOf("results[i].order_items[j].item.condition")
ls_ItemCategory_id = loo_JResp.StringOf("results[i].order_items[j].item.category_id")
ls_ItemVariation_id = loo_JResp.StringOf("results[i].order_items[j].item.variation_id")
ls_ItemSeller_sku = loo_JResp.StringOf("results[i].order_items[j].item.seller_sku")
ls_ItemWarranty = loo_JResp.StringOf("results[i].order_items[j].item.warranty")
ls_ItemId = loo_JResp.StringOf("results[i].order_items[j].item.id")
ls_ItemTitle = loo_JResp.StringOf("results[i].order_items[j].item.title")
li_Quantity = loo_JResp.IntOf("results[i].order_items[j].quantity")
ls_Differential_pricing_id = loo_JResp.StringOf("results[i].order_items[j].differential_pricing_id")
ls_Sale_fee = loo_JResp.StringOf("results[i].order_items[j].sale_fee")
ls_Listing_type_id = loo_JResp.StringOf("results[i].order_items[j].listing_type_id")
ls_Base_currency_id = loo_JResp.StringOf("results[i].order_items[j].base_currency_id")
ls_Unit_price = loo_JResp.StringOf("results[i].order_items[j].unit_price")
ls_Full_unit_price = loo_JResp.StringOf("results[i].order_items[j].full_unit_price")
ls_Base_exchange_rate = loo_JResp.StringOf("results[i].order_items[j].base_exchange_rate")
ls_Currency_id = loo_JResp.StringOf("results[i].order_items[j].currency_id")
ls_Manufacturing_days = loo_JResp.StringOf("results[i].order_items[j].manufacturing_days")
k = 0
li_Count_k = loo_JResp.SizeOfArray("results[i].order_items[j].item.variation_attributes")
do while k < li_Count_k
loo_JResp.K = k
k = k + 1
loop
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("results[i].tags")
do while j < li_Count_j
loo_JResp.J = j
ls_StrVal = loo_JResp.StringOf("results[i].tags[j]")
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("results[i].mediations")
do while j < li_Count_j
loo_JResp.J = j
j = j + 1
loop
i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("available_sorts")
do while i < li_Count_i
loo_JResp.I = i
ls_Id_str = loo_JResp.StringOf("available_sorts[i].id")
ls_Name = loo_JResp.StringOf("available_sorts[i].name")
i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("filters")
do while i < li_Count_i
loo_JResp.I = i
i = i + 1
loop
destroy loo_Http
destroy loo_JsonToken
destroy loo_SbResponseBody
destroy loo_JResp
destroy loo_Date_closed
destroy loo_Date_last_updated
destroy loo_Date_created
destroy loo_Date_approved
destroy loo_Date_last_modified