Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(C) MercadoLibre - Search Orders from a BuyerSearch for orders from a buyer. For more information, see https://developers.mercadolibre.com.ar/es_ar/gestiona-ventas#Como-filtrar
#include <C_CkHttp.h> #include <C_CkJsonObject.h> #include <C_CkStringBuilder.h> #include <C_CkDtObj.h> void ChilkatSample(void) { HCkHttp http; HCkJsonObject jsonToken; BOOL success; HCkStringBuilder sbResponseBody; HCkJsonObject jResp; int respStatusCode; HCkDtObj date_closed; HCkDtObj date_last_updated; HCkDtObj date_created; HCkDtObj date_approved; HCkDtObj date_last_modified; const char *sellerPhoneNumber; const char *sellerPhoneExtension; const char *sellerPhoneArea_code; BOOL sellerPhoneVerified; const char *sellerAlternative_phoneNumber; const char *sellerAlternative_phoneExtension; const char *sellerAlternative_phoneArea_code; const char *sellerNickname; const char *sellerLast_name; int sellerId; const char *sellerFirst_name; const char *sellerEmail; BOOL fulfilled; const char *buying_mode; const char *taxesAmount; const char *taxesCurrency_id; const char *order_requestChange; const char *order_requestReturn; const char *expiration_date; const char *feedbackSale; const char *feedbackPurchase; int shippingId; int id; const char *manufacturing_ending_date; BOOL hidden_for_seller; const char *last_updated; const char *comments; const char *pack_id; int couponAmount; const char *couponId; int shipping_cost; const char *application_id; const char *pickup_id; const char *status_detail; const char *buyerBilling_infoDoc_number; const char *buyerBilling_infoDoc_type; const char *buyerPhoneNumber; const char *buyerPhoneExtension; const char *buyerPhoneArea_code; BOOL buyerPhoneVerified; const char *buyerAlternative_phoneNumber; const char *buyerAlternative_phoneExtension; const char *buyerAlternative_phoneArea_code; const char *buyerNickname; const char *buyerLast_name; int buyerId; const char *buyerFirst_name; const char *buyerEmail; const char *total_amount; const char *paid_amount; const char *currency_id; const char *status; int j; int count_j; const char *reason; const char *status_code; const char *total_paid_amount; const char *operation_type; const char *transaction_amount; int collectorId; const char *coupon_id; int installments; const char *authorization_code; int taxes_amount; int coupon_amount; const char *installment_amount; const char *activation_uri; int overpaid_amount; int card_id; const char *issuer_id; const char *payment_method_id; const char *payment_type; const char *deferred_period; const char *atm_transfer_referenceTransaction_id; const char *atm_transfer_referenceCompany_id; const char *site_id; int payer_id; const char *marketplace_fee; int order_id; const char *transaction_order_id; int k; int count_k; const char *strVal; const char *itemSeller_custom_field; const char *itemCondition; const char *itemCategory_id; const char *itemVariation_id; const char *itemSeller_sku; const char *itemWarranty; const char *itemId; const char *itemTitle; int quantity; const char *differential_pricing_id; const char *sale_fee; const char *listing_type_id; const char *base_currency_id; const char *unit_price; const char *full_unit_price; const char *base_exchange_rate; const char *manufacturing_days; const char *id_str; const char *name; const char *query; const char *sortId; const char *sortName; int pagingTotal; int pagingOffset; int pagingLimit; const char *display; int i; int count_i; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttp_Create(); // First get our previously obtained OAuth2 access token. jsonToken = CkJsonObject_Create(); success = CkJsonObject_LoadFile(jsonToken,"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 CkHttp_SetUrlVar(http,"access_token",CkJsonObject_stringOf(jsonToken,"access_token")); // Use an actual buyer ID here.. CkHttp_SetUrlVar(http,"buyer_id","577815702"); sbResponseBody = CkStringBuilder_Create(); success = CkHttp_QuickGetSb(http,"https://api.mercadolibre.com/orders/search?buyer={$buyer_id}&access_token={$access_token}",sbResponseBody); if (success == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); printf("Response Header:\n"); printf("%s\n",CkHttp_lastHeader(http)); printf("----\n"); printf("Response Body:\n"); printf("%s\n",CkStringBuilder_getAsString(sbResponseBody)); printf("Failed.\n"); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbResponseBody); return; } jResp = CkJsonObject_Create(); CkJsonObject_LoadSb(jResp,sbResponseBody); CkJsonObject_putEmitCompact(jResp,FALSE); printf("Response Body:\n"); printf("%s\n",CkJsonObject_emit(jResp)); respStatusCode = CkHttp_getLastStatus(http); printf("Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { printf("Response Header:\n"); printf("%s\n",CkHttp_lastHeader(http)); printf("----\n"); printf("Response Body:\n"); printf("%s\n",CkStringBuilder_getAsString(sbResponseBody)); printf("Failed.\n"); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); return; } // 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 // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. date_closed = CkDtObj_Create(); date_last_updated = CkDtObj_Create(); date_created = CkDtObj_Create(); date_approved = CkDtObj_Create(); date_last_modified = CkDtObj_Create(); query = CkJsonObject_stringOf(jResp,"query"); sortId = CkJsonObject_stringOf(jResp,"sort.id"); sortName = CkJsonObject_stringOf(jResp,"sort.name"); pagingTotal = CkJsonObject_IntOf(jResp,"paging.total"); pagingOffset = CkJsonObject_IntOf(jResp,"paging.offset"); pagingLimit = CkJsonObject_IntOf(jResp,"paging.limit"); display = CkJsonObject_stringOf(jResp,"display"); i = 0; count_i = CkJsonObject_SizeOfArray(jResp,"results"); while (i < count_i) { CkJsonObject_putI(jResp,i); sellerPhoneNumber = CkJsonObject_stringOf(jResp,"results[i].seller.phone.number"); sellerPhoneExtension = CkJsonObject_stringOf(jResp,"results[i].seller.phone.extension"); sellerPhoneArea_code = CkJsonObject_stringOf(jResp,"results[i].seller.phone.area_code"); sellerPhoneVerified = CkJsonObject_BoolOf(jResp,"results[i].seller.phone.verified"); sellerAlternative_phoneNumber = CkJsonObject_stringOf(jResp,"results[i].seller.alternative_phone.number"); sellerAlternative_phoneExtension = CkJsonObject_stringOf(jResp,"results[i].seller.alternative_phone.extension"); sellerAlternative_phoneArea_code = CkJsonObject_stringOf(jResp,"results[i].seller.alternative_phone.area_code"); sellerNickname = CkJsonObject_stringOf(jResp,"results[i].seller.nickname"); sellerLast_name = CkJsonObject_stringOf(jResp,"results[i].seller.last_name"); sellerId = CkJsonObject_IntOf(jResp,"results[i].seller.id"); sellerFirst_name = CkJsonObject_stringOf(jResp,"results[i].seller.first_name"); sellerEmail = CkJsonObject_stringOf(jResp,"results[i].seller.email"); fulfilled = CkJsonObject_BoolOf(jResp,"results[i].fulfilled"); buying_mode = CkJsonObject_stringOf(jResp,"results[i].buying_mode"); taxesAmount = CkJsonObject_stringOf(jResp,"results[i].taxes.amount"); taxesCurrency_id = CkJsonObject_stringOf(jResp,"results[i].taxes.currency_id"); order_requestChange = CkJsonObject_stringOf(jResp,"results[i].order_request.change"); order_requestReturn = CkJsonObject_stringOf(jResp,"results[i].order_request.return"); expiration_date = CkJsonObject_stringOf(jResp,"results[i].expiration_date"); feedbackSale = CkJsonObject_stringOf(jResp,"results[i].feedback.sale"); feedbackPurchase = CkJsonObject_stringOf(jResp,"results[i].feedback.purchase"); shippingId = CkJsonObject_IntOf(jResp,"results[i].shipping.id"); CkJsonObject_DtOf(jResp,"results[i].date_closed",FALSE,date_closed); id = CkJsonObject_IntOf(jResp,"results[i].id"); manufacturing_ending_date = CkJsonObject_stringOf(jResp,"results[i].manufacturing_ending_date"); hidden_for_seller = CkJsonObject_BoolOf(jResp,"results[i].hidden_for_seller"); CkJsonObject_DtOf(jResp,"results[i].date_last_updated",FALSE,date_last_updated); last_updated = CkJsonObject_stringOf(jResp,"results[i].last_updated"); comments = CkJsonObject_stringOf(jResp,"results[i].comments"); pack_id = CkJsonObject_stringOf(jResp,"results[i].pack_id"); couponAmount = CkJsonObject_IntOf(jResp,"results[i].coupon.amount"); couponId = CkJsonObject_stringOf(jResp,"results[i].coupon.id"); shipping_cost = CkJsonObject_IntOf(jResp,"results[i].shipping_cost"); CkJsonObject_DtOf(jResp,"results[i].date_created",FALSE,date_created); application_id = CkJsonObject_stringOf(jResp,"results[i].application_id"); pickup_id = CkJsonObject_stringOf(jResp,"results[i].pickup_id"); status_detail = CkJsonObject_stringOf(jResp,"results[i].status_detail"); buyerBilling_infoDoc_number = CkJsonObject_stringOf(jResp,"results[i].buyer.billing_info.doc_number"); buyerBilling_infoDoc_type = CkJsonObject_stringOf(jResp,"results[i].buyer.billing_info.doc_type"); buyerPhoneNumber = CkJsonObject_stringOf(jResp,"results[i].buyer.phone.number"); buyerPhoneExtension = CkJsonObject_stringOf(jResp,"results[i].buyer.phone.extension"); buyerPhoneArea_code = CkJsonObject_stringOf(jResp,"results[i].buyer.phone.area_code"); buyerPhoneVerified = CkJsonObject_BoolOf(jResp,"results[i].buyer.phone.verified"); buyerAlternative_phoneNumber = CkJsonObject_stringOf(jResp,"results[i].buyer.alternative_phone.number"); buyerAlternative_phoneExtension = CkJsonObject_stringOf(jResp,"results[i].buyer.alternative_phone.extension"); buyerAlternative_phoneArea_code = CkJsonObject_stringOf(jResp,"results[i].buyer.alternative_phone.area_code"); buyerNickname = CkJsonObject_stringOf(jResp,"results[i].buyer.nickname"); buyerLast_name = CkJsonObject_stringOf(jResp,"results[i].buyer.last_name"); buyerId = CkJsonObject_IntOf(jResp,"results[i].buyer.id"); buyerFirst_name = CkJsonObject_stringOf(jResp,"results[i].buyer.first_name"); buyerEmail = CkJsonObject_stringOf(jResp,"results[i].buyer.email"); total_amount = CkJsonObject_stringOf(jResp,"results[i].total_amount"); paid_amount = CkJsonObject_stringOf(jResp,"results[i].paid_amount"); currency_id = CkJsonObject_stringOf(jResp,"results[i].currency_id"); status = CkJsonObject_stringOf(jResp,"results[i].status"); j = 0; count_j = CkJsonObject_SizeOfArray(jResp,"results[i].payments"); while (j < count_j) { CkJsonObject_putJ(jResp,j); reason = CkJsonObject_stringOf(jResp,"results[i].payments[j].reason"); status_code = CkJsonObject_stringOf(jResp,"results[i].payments[j].status_code"); total_paid_amount = CkJsonObject_stringOf(jResp,"results[i].payments[j].total_paid_amount"); operation_type = CkJsonObject_stringOf(jResp,"results[i].payments[j].operation_type"); transaction_amount = CkJsonObject_stringOf(jResp,"results[i].payments[j].transaction_amount"); CkJsonObject_DtOf(jResp,"results[i].payments[j].date_approved",FALSE,date_approved); collectorId = CkJsonObject_IntOf(jResp,"results[i].payments[j].collector.id"); coupon_id = CkJsonObject_stringOf(jResp,"results[i].payments[j].coupon_id"); installments = CkJsonObject_IntOf(jResp,"results[i].payments[j].installments"); authorization_code = CkJsonObject_stringOf(jResp,"results[i].payments[j].authorization_code"); taxes_amount = CkJsonObject_IntOf(jResp,"results[i].payments[j].taxes_amount"); id = CkJsonObject_IntOf(jResp,"results[i].payments[j].id"); CkJsonObject_DtOf(jResp,"results[i].payments[j].date_last_modified",FALSE,date_last_modified); coupon_amount = CkJsonObject_IntOf(jResp,"results[i].payments[j].coupon_amount"); shipping_cost = CkJsonObject_IntOf(jResp,"results[i].payments[j].shipping_cost"); installment_amount = CkJsonObject_stringOf(jResp,"results[i].payments[j].installment_amount"); CkJsonObject_DtOf(jResp,"results[i].payments[j].date_created",FALSE,date_created); activation_uri = CkJsonObject_stringOf(jResp,"results[i].payments[j].activation_uri"); overpaid_amount = CkJsonObject_IntOf(jResp,"results[i].payments[j].overpaid_amount"); card_id = CkJsonObject_IntOf(jResp,"results[i].payments[j].card_id"); status_detail = CkJsonObject_stringOf(jResp,"results[i].payments[j].status_detail"); issuer_id = CkJsonObject_stringOf(jResp,"results[i].payments[j].issuer_id"); payment_method_id = CkJsonObject_stringOf(jResp,"results[i].payments[j].payment_method_id"); payment_type = CkJsonObject_stringOf(jResp,"results[i].payments[j].payment_type"); deferred_period = CkJsonObject_stringOf(jResp,"results[i].payments[j].deferred_period"); atm_transfer_referenceTransaction_id = CkJsonObject_stringOf(jResp,"results[i].payments[j].atm_transfer_reference.transaction_id"); atm_transfer_referenceCompany_id = CkJsonObject_stringOf(jResp,"results[i].payments[j].atm_transfer_reference.company_id"); site_id = CkJsonObject_stringOf(jResp,"results[i].payments[j].site_id"); payer_id = CkJsonObject_IntOf(jResp,"results[i].payments[j].payer_id"); marketplace_fee = CkJsonObject_stringOf(jResp,"results[i].payments[j].marketplace_fee"); order_id = CkJsonObject_IntOf(jResp,"results[i].payments[j].order_id"); currency_id = CkJsonObject_stringOf(jResp,"results[i].payments[j].currency_id"); status = CkJsonObject_stringOf(jResp,"results[i].payments[j].status"); transaction_order_id = CkJsonObject_stringOf(jResp,"results[i].payments[j].transaction_order_id"); k = 0; count_k = CkJsonObject_SizeOfArray(jResp,"results[i].payments[j].available_actions"); while (k < count_k) { CkJsonObject_putK(jResp,k); strVal = CkJsonObject_stringOf(jResp,"results[i].payments[j].available_actions[k]"); k = k + 1; } j = j + 1; } j = 0; count_j = CkJsonObject_SizeOfArray(jResp,"results[i].order_items"); while (j < count_j) { CkJsonObject_putJ(jResp,j); itemSeller_custom_field = CkJsonObject_stringOf(jResp,"results[i].order_items[j].item.seller_custom_field"); itemCondition = CkJsonObject_stringOf(jResp,"results[i].order_items[j].item.condition"); itemCategory_id = CkJsonObject_stringOf(jResp,"results[i].order_items[j].item.category_id"); itemVariation_id = CkJsonObject_stringOf(jResp,"results[i].order_items[j].item.variation_id"); itemSeller_sku = CkJsonObject_stringOf(jResp,"results[i].order_items[j].item.seller_sku"); itemWarranty = CkJsonObject_stringOf(jResp,"results[i].order_items[j].item.warranty"); itemId = CkJsonObject_stringOf(jResp,"results[i].order_items[j].item.id"); itemTitle = CkJsonObject_stringOf(jResp,"results[i].order_items[j].item.title"); quantity = CkJsonObject_IntOf(jResp,"results[i].order_items[j].quantity"); differential_pricing_id = CkJsonObject_stringOf(jResp,"results[i].order_items[j].differential_pricing_id"); sale_fee = CkJsonObject_stringOf(jResp,"results[i].order_items[j].sale_fee"); listing_type_id = CkJsonObject_stringOf(jResp,"results[i].order_items[j].listing_type_id"); base_currency_id = CkJsonObject_stringOf(jResp,"results[i].order_items[j].base_currency_id"); unit_price = CkJsonObject_stringOf(jResp,"results[i].order_items[j].unit_price"); full_unit_price = CkJsonObject_stringOf(jResp,"results[i].order_items[j].full_unit_price"); base_exchange_rate = CkJsonObject_stringOf(jResp,"results[i].order_items[j].base_exchange_rate"); currency_id = CkJsonObject_stringOf(jResp,"results[i].order_items[j].currency_id"); manufacturing_days = CkJsonObject_stringOf(jResp,"results[i].order_items[j].manufacturing_days"); k = 0; count_k = CkJsonObject_SizeOfArray(jResp,"results[i].order_items[j].item.variation_attributes"); while (k < count_k) { CkJsonObject_putK(jResp,k); k = k + 1; } j = j + 1; } j = 0; count_j = CkJsonObject_SizeOfArray(jResp,"results[i].tags"); while (j < count_j) { CkJsonObject_putJ(jResp,j); strVal = CkJsonObject_stringOf(jResp,"results[i].tags[j]"); j = j + 1; } j = 0; count_j = CkJsonObject_SizeOfArray(jResp,"results[i].mediations"); while (j < count_j) { CkJsonObject_putJ(jResp,j); j = j + 1; } i = i + 1; } i = 0; count_i = CkJsonObject_SizeOfArray(jResp,"available_sorts"); while (i < count_i) { CkJsonObject_putI(jResp,i); id_str = CkJsonObject_stringOf(jResp,"available_sorts[i].id"); name = CkJsonObject_stringOf(jResp,"available_sorts[i].name"); i = i + 1; } i = 0; count_i = CkJsonObject_SizeOfArray(jResp,"filters"); while (i < count_i) { CkJsonObject_putI(jResp,i); i = i + 1; } CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); CkDtObj_Dispose(date_closed); CkDtObj_Dispose(date_last_updated); CkDtObj_Dispose(date_created); CkDtObj_Dispose(date_approved); CkDtObj_Dispose(date_last_modified); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.