Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Swift 3,4,5... Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Swift 3,4,5...) MercadoLibre - Search Orders from a Buyer

Search for orders from a buyer.

For more information, see https://developers.mercadolibre.com.ar/es_ar/gestiona-ventas#Como-filtrar

Chilkat Downloads for the Swift Programming Language

MAC OS X (Cocoa) Objective-C/Swift Libs

iOS Objective-C/Swift Libs

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!

    // First get our previously obtained OAuth2 access token.
    let jsonToken = CkoJsonObject()!
    var success: Bool = 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

    http.setUrlVar("access_token", value: jsonToken.string(of: "access_token"))
    // Use an actual buyer ID here..
    http.setUrlVar("buyer_id", value: "577815702")

    let sbResponseBody = CkoStringBuilder()!
    success = http.quickGetSb("https://api.mercadolibre.com/orders/search?buyer={$buyer_id}&access_token={$access_token}", sbContent: sbResponseBody)
    if success == false {
        print("\(http.lastErrorText!)")
        print("Response Header:")
        print("\(http.lastHeader!)")
        print("----")
        print("Response Body:")
        print("\(sbResponseBody.getAsString()!)")
        print("Failed.")
        return
    }

    let jResp = CkoJsonObject()!
    jResp.loadSb(sbResponseBody)
    jResp.emitCompact = false

    print("Response Body:")
    print("\(jResp.emit()!)")

    var respStatusCode: Int = http.lastStatus.intValue
    print("Response Status Code = \(respStatusCode)")
    if respStatusCode >= 400 {
        print("Response Header:")
        print("\(http.lastHeader!)")
        print("----")
        print("Response Body:")
        print("\(sbResponseBody.getAsString()!)")
        print("Failed.")
        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

    let date_closed = CkoDtObj()!
    let date_last_updated = CkoDtObj()!
    let date_created = CkoDtObj()!
    let date_approved = CkoDtObj()!
    let date_last_modified = CkoDtObj()!
    var sellerPhoneNumber: String?
    var sellerPhoneExtension: String?
    var sellerPhoneArea_code: String?
    var sellerPhoneVerified: Bool
    var sellerAlternative_phoneNumber: String?
    var sellerAlternative_phoneExtension: String?
    var sellerAlternative_phoneArea_code: String?
    var sellerNickname: String?
    var sellerLast_name: String?
    var sellerId: Int
    var sellerFirst_name: String?
    var sellerEmail: String?
    var fulfilled: Bool
    var buying_mode: String?
    var taxesAmount: String?
    var taxesCurrency_id: String?
    var order_requestChange: String?
    var order_requestReturn: String?
    var expiration_date: String?
    var feedbackSale: String?
    var feedbackPurchase: String?
    var shippingId: Int
    var id: Int
    var manufacturing_ending_date: String?
    var hidden_for_seller: Bool
    var last_updated: String?
    var comments: String?
    var pack_id: String?
    var couponAmount: Int
    var couponId: String?
    var shipping_cost: Int
    var application_id: String?
    var pickup_id: String?
    var status_detail: String?
    var buyerBilling_infoDoc_number: String?
    var buyerBilling_infoDoc_type: String?
    var buyerPhoneNumber: String?
    var buyerPhoneExtension: String?
    var buyerPhoneArea_code: String?
    var buyerPhoneVerified: Bool
    var buyerAlternative_phoneNumber: String?
    var buyerAlternative_phoneExtension: String?
    var buyerAlternative_phoneArea_code: String?
    var buyerNickname: String?
    var buyerLast_name: String?
    var buyerId: Int
    var buyerFirst_name: String?
    var buyerEmail: String?
    var total_amount: String?
    var paid_amount: String?
    var currency_id: String?
    var status: String?
    var j: Int
    var count_j: Int
    var reason: String?
    var status_code: String?
    var total_paid_amount: String?
    var operation_type: String?
    var transaction_amount: String?
    var collectorId: Int
    var coupon_id: String?
    var installments: Int
    var authorization_code: String?
    var taxes_amount: Int
    var coupon_amount: Int
    var installment_amount: String?
    var activation_uri: String?
    var overpaid_amount: Int
    var card_id: Int
    var issuer_id: String?
    var payment_method_id: String?
    var payment_type: String?
    var deferred_period: String?
    var atm_transfer_referenceTransaction_id: String?
    var atm_transfer_referenceCompany_id: String?
    var site_id: String?
    var payer_id: Int
    var marketplace_fee: String?
    var order_id: Int
    var transaction_order_id: String?
    var k: Int
    var count_k: Int
    var strVal: String?
    var itemSeller_custom_field: String?
    var itemCondition: String?
    var itemCategory_id: String?
    var itemVariation_id: String?
    var itemSeller_sku: String?
    var itemWarranty: String?
    var itemId: String?
    var itemTitle: String?
    var quantity: Int
    var differential_pricing_id: String?
    var sale_fee: String?
    var listing_type_id: String?
    var base_currency_id: String?
    var unit_price: String?
    var full_unit_price: String?
    var base_exchange_rate: String?
    var manufacturing_days: String?
    var id_str: String?
    var name: String?

    var query: String? = jResp.string(of: "query")
    var sortId: String? = jResp.string(of: "sort.id")
    var sortName: String? = jResp.string(of: "sort.name")
    var pagingTotal: Int = jResp.int(of: "paging.total").intValue
    var pagingOffset: Int = jResp.int(of: "paging.offset").intValue
    var pagingLimit: Int = jResp.int(of: "paging.limit").intValue
    var display: String? = jResp.string(of: "display")
    var i: Int = 0
    var count_i: Int = jResp.size(ofArray: "results").intValue
    while i < count_i {
        jResp.i = i
        sellerPhoneNumber = jResp.string(of: "results[i].seller.phone.number")
        sellerPhoneExtension = jResp.string(of: "results[i].seller.phone.extension")
        sellerPhoneArea_code = jResp.string(of: "results[i].seller.phone.area_code")
        sellerPhoneVerified = jResp.bool(of: "results[i].seller.phone.verified")
        sellerAlternative_phoneNumber = jResp.string(of: "results[i].seller.alternative_phone.number")
        sellerAlternative_phoneExtension = jResp.string(of: "results[i].seller.alternative_phone.extension")
        sellerAlternative_phoneArea_code = jResp.string(of: "results[i].seller.alternative_phone.area_code")
        sellerNickname = jResp.string(of: "results[i].seller.nickname")
        sellerLast_name = jResp.string(of: "results[i].seller.last_name")
        sellerId = jResp.int(of: "results[i].seller.id").intValue
        sellerFirst_name = jResp.string(of: "results[i].seller.first_name")
        sellerEmail = jResp.string(of: "results[i].seller.email")
        fulfilled = jResp.bool(of: "results[i].fulfilled")
        buying_mode = jResp.string(of: "results[i].buying_mode")
        taxesAmount = jResp.string(of: "results[i].taxes.amount")
        taxesCurrency_id = jResp.string(of: "results[i].taxes.currency_id")
        order_requestChange = jResp.string(of: "results[i].order_request.change")
        order_requestReturn = jResp.string(of: "results[i].order_request.return")
        expiration_date = jResp.string(of: "results[i].expiration_date")
        feedbackSale = jResp.string(of: "results[i].feedback.sale")
        feedbackPurchase = jResp.string(of: "results[i].feedback.purchase")
        shippingId = jResp.int(of: "results[i].shipping.id").intValue
        jResp.dt(of: "results[i].date_closed", bLocal: false, dt: date_closed)
        id = jResp.int(of: "results[i].id").intValue
        manufacturing_ending_date = jResp.string(of: "results[i].manufacturing_ending_date")
        hidden_for_seller = jResp.bool(of: "results[i].hidden_for_seller")
        jResp.dt(of: "results[i].date_last_updated", bLocal: false, dt: date_last_updated)
        last_updated = jResp.string(of: "results[i].last_updated")
        comments = jResp.string(of: "results[i].comments")
        pack_id = jResp.string(of: "results[i].pack_id")
        couponAmount = jResp.int(of: "results[i].coupon.amount").intValue
        couponId = jResp.string(of: "results[i].coupon.id")
        shipping_cost = jResp.int(of: "results[i].shipping_cost").intValue
        jResp.dt(of: "results[i].date_created", bLocal: false, dt: date_created)
        application_id = jResp.string(of: "results[i].application_id")
        pickup_id = jResp.string(of: "results[i].pickup_id")
        status_detail = jResp.string(of: "results[i].status_detail")
        buyerBilling_infoDoc_number = jResp.string(of: "results[i].buyer.billing_info.doc_number")
        buyerBilling_infoDoc_type = jResp.string(of: "results[i].buyer.billing_info.doc_type")
        buyerPhoneNumber = jResp.string(of: "results[i].buyer.phone.number")
        buyerPhoneExtension = jResp.string(of: "results[i].buyer.phone.extension")
        buyerPhoneArea_code = jResp.string(of: "results[i].buyer.phone.area_code")
        buyerPhoneVerified = jResp.bool(of: "results[i].buyer.phone.verified")
        buyerAlternative_phoneNumber = jResp.string(of: "results[i].buyer.alternative_phone.number")
        buyerAlternative_phoneExtension = jResp.string(of: "results[i].buyer.alternative_phone.extension")
        buyerAlternative_phoneArea_code = jResp.string(of: "results[i].buyer.alternative_phone.area_code")
        buyerNickname = jResp.string(of: "results[i].buyer.nickname")
        buyerLast_name = jResp.string(of: "results[i].buyer.last_name")
        buyerId = jResp.int(of: "results[i].buyer.id").intValue
        buyerFirst_name = jResp.string(of: "results[i].buyer.first_name")
        buyerEmail = jResp.string(of: "results[i].buyer.email")
        total_amount = jResp.string(of: "results[i].total_amount")
        paid_amount = jResp.string(of: "results[i].paid_amount")
        currency_id = jResp.string(of: "results[i].currency_id")
        status = jResp.string(of: "results[i].status")
        j = 0
        count_j = jResp.size(ofArray: "results[i].payments").intValue
        while j < count_j {
            jResp.j = j
            reason = jResp.string(of: "results[i].payments[j].reason")
            status_code = jResp.string(of: "results[i].payments[j].status_code")
            total_paid_amount = jResp.string(of: "results[i].payments[j].total_paid_amount")
            operation_type = jResp.string(of: "results[i].payments[j].operation_type")
            transaction_amount = jResp.string(of: "results[i].payments[j].transaction_amount")
            jResp.dt(of: "results[i].payments[j].date_approved", bLocal: false, dt: date_approved)
            collectorId = jResp.int(of: "results[i].payments[j].collector.id").intValue
            coupon_id = jResp.string(of: "results[i].payments[j].coupon_id")
            installments = jResp.int(of: "results[i].payments[j].installments").intValue
            authorization_code = jResp.string(of: "results[i].payments[j].authorization_code")
            taxes_amount = jResp.int(of: "results[i].payments[j].taxes_amount").intValue
            id = jResp.int(of: "results[i].payments[j].id").intValue
            jResp.dt(of: "results[i].payments[j].date_last_modified", bLocal: false, dt: date_last_modified)
            coupon_amount = jResp.int(of: "results[i].payments[j].coupon_amount").intValue
            shipping_cost = jResp.int(of: "results[i].payments[j].shipping_cost").intValue
            installment_amount = jResp.string(of: "results[i].payments[j].installment_amount")
            jResp.dt(of: "results[i].payments[j].date_created", bLocal: false, dt: date_created)
            activation_uri = jResp.string(of: "results[i].payments[j].activation_uri")
            overpaid_amount = jResp.int(of: "results[i].payments[j].overpaid_amount").intValue
            card_id = jResp.int(of: "results[i].payments[j].card_id").intValue
            status_detail = jResp.string(of: "results[i].payments[j].status_detail")
            issuer_id = jResp.string(of: "results[i].payments[j].issuer_id")
            payment_method_id = jResp.string(of: "results[i].payments[j].payment_method_id")
            payment_type = jResp.string(of: "results[i].payments[j].payment_type")
            deferred_period = jResp.string(of: "results[i].payments[j].deferred_period")
            atm_transfer_referenceTransaction_id = jResp.string(of: "results[i].payments[j].atm_transfer_reference.transaction_id")
            atm_transfer_referenceCompany_id = jResp.string(of: "results[i].payments[j].atm_transfer_reference.company_id")
            site_id = jResp.string(of: "results[i].payments[j].site_id")
            payer_id = jResp.int(of: "results[i].payments[j].payer_id").intValue
            marketplace_fee = jResp.string(of: "results[i].payments[j].marketplace_fee")
            order_id = jResp.int(of: "results[i].payments[j].order_id").intValue
            currency_id = jResp.string(of: "results[i].payments[j].currency_id")
            status = jResp.string(of: "results[i].payments[j].status")
            transaction_order_id = jResp.string(of: "results[i].payments[j].transaction_order_id")
            k = 0
            count_k = jResp.size(ofArray: "results[i].payments[j].available_actions").intValue
            while k < count_k {
                jResp.k = k
                strVal = jResp.string(of: "results[i].payments[j].available_actions[k]")
                k = k + 1
            }

            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "results[i].order_items").intValue
        while j < count_j {
            jResp.j = j
            itemSeller_custom_field = jResp.string(of: "results[i].order_items[j].item.seller_custom_field")
            itemCondition = jResp.string(of: "results[i].order_items[j].item.condition")
            itemCategory_id = jResp.string(of: "results[i].order_items[j].item.category_id")
            itemVariation_id = jResp.string(of: "results[i].order_items[j].item.variation_id")
            itemSeller_sku = jResp.string(of: "results[i].order_items[j].item.seller_sku")
            itemWarranty = jResp.string(of: "results[i].order_items[j].item.warranty")
            itemId = jResp.string(of: "results[i].order_items[j].item.id")
            itemTitle = jResp.string(of: "results[i].order_items[j].item.title")
            quantity = jResp.int(of: "results[i].order_items[j].quantity").intValue
            differential_pricing_id = jResp.string(of: "results[i].order_items[j].differential_pricing_id")
            sale_fee = jResp.string(of: "results[i].order_items[j].sale_fee")
            listing_type_id = jResp.string(of: "results[i].order_items[j].listing_type_id")
            base_currency_id = jResp.string(of: "results[i].order_items[j].base_currency_id")
            unit_price = jResp.string(of: "results[i].order_items[j].unit_price")
            full_unit_price = jResp.string(of: "results[i].order_items[j].full_unit_price")
            base_exchange_rate = jResp.string(of: "results[i].order_items[j].base_exchange_rate")
            currency_id = jResp.string(of: "results[i].order_items[j].currency_id")
            manufacturing_days = jResp.string(of: "results[i].order_items[j].manufacturing_days")
            k = 0
            count_k = jResp.size(ofArray: "results[i].order_items[j].item.variation_attributes").intValue
            while k < count_k {
                jResp.k = k
                k = k + 1
            }

            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "results[i].tags").intValue
        while j < count_j {
            jResp.j = j
            strVal = jResp.string(of: "results[i].tags[j]")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "results[i].mediations").intValue
        while j < count_j {
            jResp.j = j
            j = j + 1
        }

        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "available_sorts").intValue
    while i < count_i {
        jResp.i = i
        id_str = jResp.string(of: "available_sorts[i].id")
        name = jResp.string(of: "available_sorts[i].name")
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "filters").intValue
    while i < count_i {
        jResp.i = i
        i = i + 1
    }


}

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.