Xbase++
Xbase++
MercadoLibre - Search Orders from a Buyer
See more MercadoLibre Examples
Search for orders from a buyer.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oJsonToken
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL oDate_closed
LOCAL oDate_last_updated
LOCAL oDate_created
LOCAL oDate_approved
LOCAL oDate_last_modified
LOCAL cSellerPhoneNumber
LOCAL cSellerPhoneExtension
LOCAL cSellerPhoneArea_code
LOCAL nSellerPhoneVerified
LOCAL cSellerAlternative_phoneNumber
LOCAL cSellerAlternative_phoneExtension
LOCAL cSellerAlternative_phoneArea_code
LOCAL cSellerNickname
LOCAL cSellerLast_name
LOCAL nSellerId
LOCAL cSellerFirst_name
LOCAL cSellerEmail
LOCAL nFulfilled
LOCAL cBuying_mode
LOCAL cTaxesAmount
LOCAL cTaxesCurrency_id
LOCAL cOrder_requestChange
LOCAL cOrder_requestReturn
LOCAL cExpiration_date
LOCAL cFeedbackSale
LOCAL cFeedbackPurchase
LOCAL nShippingId
LOCAL nId
LOCAL cManufacturing_ending_date
LOCAL nHidden_for_seller
LOCAL cLast_updated
LOCAL cComments
LOCAL cPack_id
LOCAL nCouponAmount
LOCAL cCouponId
LOCAL nShipping_cost
LOCAL cApplication_id
LOCAL cPickup_id
LOCAL cStatus_detail
LOCAL cBuyerBilling_infoDoc_number
LOCAL cBuyerBilling_infoDoc_type
LOCAL cBuyerPhoneNumber
LOCAL cBuyerPhoneExtension
LOCAL cBuyerPhoneArea_code
LOCAL nBuyerPhoneVerified
LOCAL cBuyerAlternative_phoneNumber
LOCAL cBuyerAlternative_phoneExtension
LOCAL cBuyerAlternative_phoneArea_code
LOCAL cBuyerNickname
LOCAL cBuyerLast_name
LOCAL nBuyerId
LOCAL cBuyerFirst_name
LOCAL cBuyerEmail
LOCAL cTotal_amount
LOCAL cPaid_amount
LOCAL cCurrency_id
LOCAL cStatus
LOCAL j
LOCAL nCount_j
LOCAL cReason
LOCAL cStatus_code
LOCAL cTotal_paid_amount
LOCAL cOperation_type
LOCAL cTransaction_amount
LOCAL nCollectorId
LOCAL cCoupon_id
LOCAL nInstallments
LOCAL cAuthorization_code
LOCAL nTaxes_amount
LOCAL nCoupon_amount
LOCAL cInstallment_amount
LOCAL cActivation_uri
LOCAL nOverpaid_amount
LOCAL nCard_id
LOCAL cIssuer_id
LOCAL cPayment_method_id
LOCAL cPayment_type
LOCAL cDeferred_period
LOCAL cAtm_transfer_referenceTransaction_id
LOCAL cAtm_transfer_referenceCompany_id
LOCAL cSite_id
LOCAL nPayer_id
LOCAL cMarketplace_fee
LOCAL nOrder_id
LOCAL cTransaction_order_id
LOCAL k
LOCAL nCount_k
LOCAL cStrVal
LOCAL cItemSeller_custom_field
LOCAL cItemCondition
LOCAL cItemCategory_id
LOCAL cItemVariation_id
LOCAL cItemSeller_sku
LOCAL cItemWarranty
LOCAL cItemId
LOCAL cItemTitle
LOCAL nQuantity
LOCAL cDifferential_pricing_id
LOCAL cSale_fee
LOCAL cListing_type_id
LOCAL cBase_currency_id
LOCAL cUnit_price
LOCAL cFull_unit_price
LOCAL cBase_exchange_rate
LOCAL cManufacturing_days
LOCAL cId_str
LOCAL cName
LOCAL cQuery
LOCAL cSortId
LOCAL cSortName
LOCAL nPagingTotal
LOCAL nPagingOffset
LOCAL nPagingLimit
LOCAL cDisplay
LOCAL i
LOCAL nCount_i
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("Chilkat.Http")
// First get our previously obtained OAuth2 access token.
oJsonToken := CreateObject("Chilkat.JsonObject")
nSuccess := oJsonToken: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
oHttp:SetUrlVar("access_token", oJsonToken:StringOf("access_token"))
// Use an actual buyer ID here..
oHttp:SetUrlVar("buyer_id", "577815702")
oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://api.mercadolibre.com/orders/search?buyer={$buyer_id}&access_token={$access_token}", oSbResponseBody)
IF (nSuccess == 0)
? oHttp:LastErrorText
? "Response Header:"
? oHttp:LastHeader
? "----"
? "Response Body:"
? oSbResponseBody:GetAsString()
? "Failed."
oHttp:destroy()
oJsonToken:destroy()
oSbResponseBody:destroy()
RETURN
ENDIF
oJResp := CreateObject("Chilkat.JsonObject")
oJResp:LoadSb(oSbResponseBody)
oJResp:EmitCompact := 0
? "Response Body:"
? oJResp:Emit()
nRespStatusCode := oHttp:LastStatus
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
? "Response Header:"
? oHttp:LastHeader
? "----"
? "Response Body:"
? oSbResponseBody:GetAsString()
? "Failed."
oHttp:destroy()
oJsonToken:destroy()
oSbResponseBody:destroy()
oJResp:destroy()
RETURN
ENDIF
// 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
oDate_closed := CreateObject("Chilkat.DtObj")
oDate_last_updated := CreateObject("Chilkat.DtObj")
oDate_created := CreateObject("Chilkat.DtObj")
oDate_approved := CreateObject("Chilkat.DtObj")
oDate_last_modified := CreateObject("Chilkat.DtObj")
cQuery := oJResp:StringOf("query")
cSortId := oJResp:StringOf("sort.id")
cSortName := oJResp:StringOf("sort.name")
nPagingTotal := oJResp:IntOf("paging.total")
nPagingOffset := oJResp:IntOf("paging.offset")
nPagingLimit := oJResp:IntOf("paging.limit")
cDisplay := oJResp:StringOf("display")
i := 0
nCount_i := oJResp:SizeOfArray("results")
DO WHILE i < nCount_i
oJResp:I := i
cSellerPhoneNumber := oJResp:StringOf("results[i].seller.phone.number")
cSellerPhoneExtension := oJResp:StringOf("results[i].seller.phone.extension")
cSellerPhoneArea_code := oJResp:StringOf("results[i].seller.phone.area_code")
nSellerPhoneVerified := oJResp:BoolOf("results[i].seller.phone.verified")
cSellerAlternative_phoneNumber := oJResp:StringOf("results[i].seller.alternative_phone.number")
cSellerAlternative_phoneExtension := oJResp:StringOf("results[i].seller.alternative_phone.extension")
cSellerAlternative_phoneArea_code := oJResp:StringOf("results[i].seller.alternative_phone.area_code")
cSellerNickname := oJResp:StringOf("results[i].seller.nickname")
cSellerLast_name := oJResp:StringOf("results[i].seller.last_name")
nSellerId := oJResp:IntOf("results[i].seller.id")
cSellerFirst_name := oJResp:StringOf("results[i].seller.first_name")
cSellerEmail := oJResp:StringOf("results[i].seller.email")
nFulfilled := oJResp:BoolOf("results[i].fulfilled")
cBuying_mode := oJResp:StringOf("results[i].buying_mode")
cTaxesAmount := oJResp:StringOf("results[i].taxes.amount")
cTaxesCurrency_id := oJResp:StringOf("results[i].taxes.currency_id")
cOrder_requestChange := oJResp:StringOf("results[i].order_request.change")
cOrder_requestReturn := oJResp:StringOf("results[i].order_request.return")
cExpiration_date := oJResp:StringOf("results[i].expiration_date")
cFeedbackSale := oJResp:StringOf("results[i].feedback.sale")
cFeedbackPurchase := oJResp:StringOf("results[i].feedback.purchase")
nShippingId := oJResp:IntOf("results[i].shipping.id")
oJResp:DtOf("results[i].date_closed", 0, oDate_closed)
nId := oJResp:IntOf("results[i].id")
cManufacturing_ending_date := oJResp:StringOf("results[i].manufacturing_ending_date")
nHidden_for_seller := oJResp:BoolOf("results[i].hidden_for_seller")
oJResp:DtOf("results[i].date_last_updated", 0, oDate_last_updated)
cLast_updated := oJResp:StringOf("results[i].last_updated")
cComments := oJResp:StringOf("results[i].comments")
cPack_id := oJResp:StringOf("results[i].pack_id")
nCouponAmount := oJResp:IntOf("results[i].coupon.amount")
cCouponId := oJResp:StringOf("results[i].coupon.id")
nShipping_cost := oJResp:IntOf("results[i].shipping_cost")
oJResp:DtOf("results[i].date_created", 0, oDate_created)
cApplication_id := oJResp:StringOf("results[i].application_id")
cPickup_id := oJResp:StringOf("results[i].pickup_id")
cStatus_detail := oJResp:StringOf("results[i].status_detail")
cBuyerBilling_infoDoc_number := oJResp:StringOf("results[i].buyer.billing_info.doc_number")
cBuyerBilling_infoDoc_type := oJResp:StringOf("results[i].buyer.billing_info.doc_type")
cBuyerPhoneNumber := oJResp:StringOf("results[i].buyer.phone.number")
cBuyerPhoneExtension := oJResp:StringOf("results[i].buyer.phone.extension")
cBuyerPhoneArea_code := oJResp:StringOf("results[i].buyer.phone.area_code")
nBuyerPhoneVerified := oJResp:BoolOf("results[i].buyer.phone.verified")
cBuyerAlternative_phoneNumber := oJResp:StringOf("results[i].buyer.alternative_phone.number")
cBuyerAlternative_phoneExtension := oJResp:StringOf("results[i].buyer.alternative_phone.extension")
cBuyerAlternative_phoneArea_code := oJResp:StringOf("results[i].buyer.alternative_phone.area_code")
cBuyerNickname := oJResp:StringOf("results[i].buyer.nickname")
cBuyerLast_name := oJResp:StringOf("results[i].buyer.last_name")
nBuyerId := oJResp:IntOf("results[i].buyer.id")
cBuyerFirst_name := oJResp:StringOf("results[i].buyer.first_name")
cBuyerEmail := oJResp:StringOf("results[i].buyer.email")
cTotal_amount := oJResp:StringOf("results[i].total_amount")
cPaid_amount := oJResp:StringOf("results[i].paid_amount")
cCurrency_id := oJResp:StringOf("results[i].currency_id")
cStatus := oJResp:StringOf("results[i].status")
j := 0
nCount_j := oJResp:SizeOfArray("results[i].payments")
DO WHILE j < nCount_j
oJResp:J := j
cReason := oJResp:StringOf("results[i].payments[j].reason")
cStatus_code := oJResp:StringOf("results[i].payments[j].status_code")
cTotal_paid_amount := oJResp:StringOf("results[i].payments[j].total_paid_amount")
cOperation_type := oJResp:StringOf("results[i].payments[j].operation_type")
cTransaction_amount := oJResp:StringOf("results[i].payments[j].transaction_amount")
oJResp:DtOf("results[i].payments[j].date_approved", 0, oDate_approved)
nCollectorId := oJResp:IntOf("results[i].payments[j].collector.id")
cCoupon_id := oJResp:StringOf("results[i].payments[j].coupon_id")
nInstallments := oJResp:IntOf("results[i].payments[j].installments")
cAuthorization_code := oJResp:StringOf("results[i].payments[j].authorization_code")
nTaxes_amount := oJResp:IntOf("results[i].payments[j].taxes_amount")
nId := oJResp:IntOf("results[i].payments[j].id")
oJResp:DtOf("results[i].payments[j].date_last_modified", 0, oDate_last_modified)
nCoupon_amount := oJResp:IntOf("results[i].payments[j].coupon_amount")
nShipping_cost := oJResp:IntOf("results[i].payments[j].shipping_cost")
cInstallment_amount := oJResp:StringOf("results[i].payments[j].installment_amount")
oJResp:DtOf("results[i].payments[j].date_created", 0, oDate_created)
cActivation_uri := oJResp:StringOf("results[i].payments[j].activation_uri")
nOverpaid_amount := oJResp:IntOf("results[i].payments[j].overpaid_amount")
nCard_id := oJResp:IntOf("results[i].payments[j].card_id")
cStatus_detail := oJResp:StringOf("results[i].payments[j].status_detail")
cIssuer_id := oJResp:StringOf("results[i].payments[j].issuer_id")
cPayment_method_id := oJResp:StringOf("results[i].payments[j].payment_method_id")
cPayment_type := oJResp:StringOf("results[i].payments[j].payment_type")
cDeferred_period := oJResp:StringOf("results[i].payments[j].deferred_period")
cAtm_transfer_referenceTransaction_id := oJResp:StringOf("results[i].payments[j].atm_transfer_reference.transaction_id")
cAtm_transfer_referenceCompany_id := oJResp:StringOf("results[i].payments[j].atm_transfer_reference.company_id")
cSite_id := oJResp:StringOf("results[i].payments[j].site_id")
nPayer_id := oJResp:IntOf("results[i].payments[j].payer_id")
cMarketplace_fee := oJResp:StringOf("results[i].payments[j].marketplace_fee")
nOrder_id := oJResp:IntOf("results[i].payments[j].order_id")
cCurrency_id := oJResp:StringOf("results[i].payments[j].currency_id")
cStatus := oJResp:StringOf("results[i].payments[j].status")
cTransaction_order_id := oJResp:StringOf("results[i].payments[j].transaction_order_id")
k := 0
nCount_k := oJResp:SizeOfArray("results[i].payments[j].available_actions")
DO WHILE k < nCount_k
oJResp:K := k
cStrVal := oJResp:StringOf("results[i].payments[j].available_actions[k]")
k := k + 1
ENDDO
j := j + 1
ENDDO
j := 0
nCount_j := oJResp:SizeOfArray("results[i].order_items")
DO WHILE j < nCount_j
oJResp:J := j
cItemSeller_custom_field := oJResp:StringOf("results[i].order_items[j].item.seller_custom_field")
cItemCondition := oJResp:StringOf("results[i].order_items[j].item.condition")
cItemCategory_id := oJResp:StringOf("results[i].order_items[j].item.category_id")
cItemVariation_id := oJResp:StringOf("results[i].order_items[j].item.variation_id")
cItemSeller_sku := oJResp:StringOf("results[i].order_items[j].item.seller_sku")
cItemWarranty := oJResp:StringOf("results[i].order_items[j].item.warranty")
cItemId := oJResp:StringOf("results[i].order_items[j].item.id")
cItemTitle := oJResp:StringOf("results[i].order_items[j].item.title")
nQuantity := oJResp:IntOf("results[i].order_items[j].quantity")
cDifferential_pricing_id := oJResp:StringOf("results[i].order_items[j].differential_pricing_id")
cSale_fee := oJResp:StringOf("results[i].order_items[j].sale_fee")
cListing_type_id := oJResp:StringOf("results[i].order_items[j].listing_type_id")
cBase_currency_id := oJResp:StringOf("results[i].order_items[j].base_currency_id")
cUnit_price := oJResp:StringOf("results[i].order_items[j].unit_price")
cFull_unit_price := oJResp:StringOf("results[i].order_items[j].full_unit_price")
cBase_exchange_rate := oJResp:StringOf("results[i].order_items[j].base_exchange_rate")
cCurrency_id := oJResp:StringOf("results[i].order_items[j].currency_id")
cManufacturing_days := oJResp:StringOf("results[i].order_items[j].manufacturing_days")
k := 0
nCount_k := oJResp:SizeOfArray("results[i].order_items[j].item.variation_attributes")
DO WHILE k < nCount_k
oJResp:K := k
k := k + 1
ENDDO
j := j + 1
ENDDO
j := 0
nCount_j := oJResp:SizeOfArray("results[i].tags")
DO WHILE j < nCount_j
oJResp:J := j
cStrVal := oJResp:StringOf("results[i].tags[j]")
j := j + 1
ENDDO
j := 0
nCount_j := oJResp:SizeOfArray("results[i].mediations")
DO WHILE j < nCount_j
oJResp:J := j
j := j + 1
ENDDO
i := i + 1
ENDDO
i := 0
nCount_i := oJResp:SizeOfArray("available_sorts")
DO WHILE i < nCount_i
oJResp:I := i
cId_str := oJResp:StringOf("available_sorts[i].id")
cName := oJResp:StringOf("available_sorts[i].name")
i := i + 1
ENDDO
i := 0
nCount_i := oJResp:SizeOfArray("filters")
DO WHILE i < nCount_i
oJResp:I := i
i := i + 1
ENDDO
oHttp:destroy()
oJsonToken:destroy()
oSbResponseBody:destroy()
oJResp:destroy()
oDate_closed:destroy()
oDate_last_updated:destroy()
oDate_created:destroy()
oDate_approved:destroy()
oDate_last_modified:destroy()