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

Visual FoxPro 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

 

 

 

(Visual FoxPro) Shippo Create the Shipment, Get Rates, and Purchase Label

Demonstrates how retrieve rates and create labels for international shipments.

For more information, see https://goshippo.com/docs/international/

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcTemplate
LOCAL lcLength
LOCAL lcWidth
LOCAL lcHeight
LOCAL lcDistance_unit
LOCAL lcWeight
LOCAL lcMass_unit
LOCAL lcValue_amount
LOCAL lcValue_currency
LOCAL lnTest
LOCAL j
LOCAL lnCount_j
LOCAL lnIntVal
LOCAL lcObject_created
LOCAL lcObject_updated
LOCAL lcObject_id
LOCAL lcObject_owner
LOCAL lcStatus
LOCAL lcAddress_fromObject_id
LOCAL lnAddress_fromIs_complete
LOCAL lcAddress_fromCompany
LOCAL lcAddress_fromStreet_no
LOCAL lcAddress_fromName
LOCAL lcAddress_fromStreet1
LOCAL lcAddress_fromStreet2
LOCAL lcAddress_fromCity
LOCAL lcAddress_fromState
LOCAL lcAddress_fromZip
LOCAL lcAddress_fromCountry
LOCAL lcAddress_fromPhone
LOCAL lcAddress_fromEmail
LOCAL lcAddress_fromIs_residential
LOCAL lcAddress_toObject_id
LOCAL lnAddress_toIs_complete
LOCAL lcAddress_toName
LOCAL lcAddress_toStreet1
LOCAL lcAddress_toCity
LOCAL lcAddress_toState
LOCAL lcAddress_toZip
LOCAL lcAddress_toCountry
LOCAL lcAddress_toPhone
LOCAL lcAddress_toEmail
LOCAL lnAddress_toIs_residential
LOCAL lcAddress_return
LOCAL lcShipment_date
LOCAL lcExtraInsuranceCurrency
LOCAL lcExtraInsuranceAmount
LOCAL lcExtraReference_1
LOCAL lcExtraReference_2
LOCAL lcCustoms_declaration
LOCAL lcMetadata
LOCAL i
LOCAL lnCount_i

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')

* Implements the following CURL command:

* curl https://api.goshippo.com/customs/declarations/ \
*     -H "Authorization: ShippoToken <API_TOKEN>" \
*     -H "Content-Type: application/json"  \
*     -d '{          
*           "contents_type": "MERCHANDISE",
*           "non_delivery_option": "RETURN",
*           "certify": true,
*           "certify_signer": "Simon Kreuz",
*           "incoterm": "DDU",
*           "items": [{
*                     "description": "T-shirt",
*                     "quantity": 20,
*                     "net_weight": "5",
*                     "mass_unit": "lb",
*                     "value_amount": "200",
*                     "value_currency": "USD",
*                     "tariff_number": "",
*                     "origin_country": "US"
*             }]
*     }'

* Use this online tool to generate code from sample JSON:
* Generate Code to Create JSON

* The following JSON is sent in the request body.

* {
*   "contents_type": "MERCHANDISE",
*   "non_delivery_option": "RETURN",
*   "certify": true,
*   "certify_signer": "Simon Kreuz",
*   "incoterm": "DDU",
*   "items": [
*     {
*       "description": "T-shirt",
*       "quantity": 20,
*       "net_weight": "5",
*       "mass_unit": "lb",
*       "value_amount": "200",
*       "value_currency": "USD",
*       "tariff_number": "",
*       "origin_country": "US"
*     }
*   ]
* }

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("contents_type","MERCHANDISE")
loJson.UpdateString("non_delivery_option","RETURN")
loJson.UpdateBool("certify",1)
loJson.UpdateString("certify_signer","Simon Kreuz")
loJson.UpdateString("incoterm","DDU")
loJson.UpdateString("items[0].description","T-shirt")
loJson.UpdateInt("items[0].quantity",20)
loJson.UpdateString("items[0].net_weight","5")
loJson.UpdateString("items[0].mass_unit","lb")
loJson.UpdateString("items[0].value_amount","200")
loJson.UpdateString("items[0].value_currency","USD")
loJson.UpdateString("items[0].tariff_number","")
loJson.UpdateString("items[0].origin_country","US")

loHttp.SetRequestHeader("Authorization","ShippoToken <API_TOKEN>")
loHttp.SetRequestHeader("Content-Type","application/json")

loResp = loHttp.PostJson3("https://api.goshippo.com/customs/declarations/","application/json",loJson)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    CANCEL
ENDIF

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loJson
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)

* {
*   "object_created": "2014-07-17T00:04:06.163Z",
*   "object_updated": "2014-07-17T00:04:06.163Z",
*   "object_id": "89436997a794439ab47999701e60392e",
*   "object_owner": "shippotle@goshippo.com",
*   "status": "SUCCESS",
*   "address_from": {
*     "object_id": "0943ae4e373e4120a99c337e496dcce8",
*     "validation_results": {},
*     "is_complete": true,
*     "company": "",
*     "street_no": "",
*     "name": "Mr. Hippo",
*     "street1": "215 Clayton St.",
*     "street2": "",
*     "city": "San Francisco",
*     "state": "CA",
*     "zip": "94117",
*     "country": "US",
*     "phone": "+15553419393",
*     "email": "support@goshippo.com",
*     "is_residential": null
*   },
*   "address_to": {
*     "object_id": "4c7185d353764d0985a6a7825aed8ffb",
*     "validation_results": {},
*     "is_complete": true,
*     "name": "Mrs. Hippo",
*     "street1": "200 University Ave W",
*     "city": "Waterloo",
*     "state": "ON",
*     "zip": "N2L 3G1",
*     "country": "CA",
*     "phone": "+1 555 341 9393",
*     "email": "support@goshippo.com",
*     "is_residential": false
*   },
*   "address_return": null,
*   "parcels": [
*     {
*       "object_id": "ec952343dd4843c39b42aca620471fd5",
*       "object_created": "2013-12-01T06:24:21.121Z",
*       "object_updated": "2013-12-01T06:24:21.121Z",
*       "object_owner": "shippotle@goshippo.com",
*       "template": null,
*       "length": "5",
*       "width": "5",
*       "height": "5",
*       "distance_unit": "in",
*       "weight": "2",
*       "mass_unit": "lb",
*       "value_amount": null,
*       "value_currency": null,
*       "metadata": "",
*       "line_items": [
*       ],
*       "test": true
*     }
*   ],
*   "shipment_date": "2013-12-03T12:00:00Z",
*   "extra": {
*     "insurance": {
*       "currency": "",
*       "amount": ""
*     },
*     "reference_1": "",
*     "reference_2": ""
*   },
*   "customs_declaration": "b741b99f95e841639b54272834bc478c",
*   "rates": [
*     {
*       "object_created": "2014-07-17T00:04:06.263Z",
*       "object_id": "545ab0a1a6ea4c9f9adb2512a57d6d8b",
*       "object_owner": "shippotle@goshippo.com",
*       "shipment": "89436997a794439ab47999701e60392e",
*       "attributes": [
*       ],
*       "amount": "5.50",
*       "currency": "USD",
*       "amount_local": "5.50",
*       "currency_local": "USD",
*       "provider": "USPS",
*       "provider_image_75": "https://cdn2.goshippo.com/providers/75/USPS.png",
*       "provider_image_200": "https://cdn2.goshippo.com/providers/200/USPS.png",
*       "servicelevel": {
*         "name": "Priority Mail",
*         "token": "usps_priority",
*         "terms": ""
*       },
*       "days": 2,
*       "arrives_by": null,
*       "duration_terms": "Delivery in 1 to 3 business days.",
*       "messages": [
*       ],
*       "carrier_account": "078870331023437cb917f5187429b093",
*       "test": false,
*       "zone": 1
*     },
*     ...
*   ],
*   "carrier_accounts": [
*   ],
*   "messages": [
*   ],
*   "metadata": "Customer ID 123456"
* }

* Sample code for parsing the JSON response...
* Use the following online tool to generate parsing code from sample JSON:
* Generate Parsing Code from JSON

lcObject_created = loJResp.StringOf("object_created")
lcObject_updated = loJResp.StringOf("object_updated")
lcObject_id = loJResp.StringOf("object_id")
lcObject_owner = loJResp.StringOf("object_owner")
lcStatus = loJResp.StringOf("status")
lcAddress_fromObject_id = loJResp.StringOf("address_from.object_id")
lnAddress_fromIs_complete = loJResp.BoolOf("address_from.is_complete")
lcAddress_fromCompany = loJResp.StringOf("address_from.company")
lcAddress_fromStreet_no = loJResp.StringOf("address_from.street_no")
lcAddress_fromName = loJResp.StringOf("address_from.name")
lcAddress_fromStreet1 = loJResp.StringOf("address_from.street1")
lcAddress_fromStreet2 = loJResp.StringOf("address_from.street2")
lcAddress_fromCity = loJResp.StringOf("address_from.city")
lcAddress_fromState = loJResp.StringOf("address_from.state")
lcAddress_fromZip = loJResp.StringOf("address_from.zip")
lcAddress_fromCountry = loJResp.StringOf("address_from.country")
lcAddress_fromPhone = loJResp.StringOf("address_from.phone")
lcAddress_fromEmail = loJResp.StringOf("address_from.email")
lcAddress_fromIs_residential = loJResp.StringOf("address_from.is_residential")
lcAddress_toObject_id = loJResp.StringOf("address_to.object_id")
lnAddress_toIs_complete = loJResp.BoolOf("address_to.is_complete")
lcAddress_toName = loJResp.StringOf("address_to.name")
lcAddress_toStreet1 = loJResp.StringOf("address_to.street1")
lcAddress_toCity = loJResp.StringOf("address_to.city")
lcAddress_toState = loJResp.StringOf("address_to.state")
lcAddress_toZip = loJResp.StringOf("address_to.zip")
lcAddress_toCountry = loJResp.StringOf("address_to.country")
lcAddress_toPhone = loJResp.StringOf("address_to.phone")
lcAddress_toEmail = loJResp.StringOf("address_to.email")
lnAddress_toIs_residential = loJResp.BoolOf("address_to.is_residential")
lcAddress_return = loJResp.StringOf("address_return")
lcShipment_date = loJResp.StringOf("shipment_date")
lcExtraInsuranceCurrency = loJResp.StringOf("extra.insurance.currency")
lcExtraInsuranceAmount = loJResp.StringOf("extra.insurance.amount")
lcExtraReference_1 = loJResp.StringOf("extra.reference_1")
lcExtraReference_2 = loJResp.StringOf("extra.reference_2")
lcCustoms_declaration = loJResp.StringOf("customs_declaration")
lcMetadata = loJResp.StringOf("metadata")
i = 0
lnCount_i = loJResp.SizeOfArray("parcels")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcObject_id = loJResp.StringOf("parcels[i].object_id")
    lcObject_created = loJResp.StringOf("parcels[i].object_created")
    lcObject_updated = loJResp.StringOf("parcels[i].object_updated")
    lcObject_owner = loJResp.StringOf("parcels[i].object_owner")
    lcTemplate = loJResp.StringOf("parcels[i].template")
    lcLength = loJResp.StringOf("parcels[i].length")
    lcWidth = loJResp.StringOf("parcels[i].width")
    lcHeight = loJResp.StringOf("parcels[i].height")
    lcDistance_unit = loJResp.StringOf("parcels[i].distance_unit")
    lcWeight = loJResp.StringOf("parcels[i].weight")
    lcMass_unit = loJResp.StringOf("parcels[i].mass_unit")
    lcValue_amount = loJResp.StringOf("parcels[i].value_amount")
    lcValue_currency = loJResp.StringOf("parcels[i].value_currency")
    lcMetadata = loJResp.StringOf("parcels[i].metadata")
    lnTest = loJResp.BoolOf("parcels[i].test")
    j = 0
    lnCount_j = loJResp.SizeOfArray("parcels[i].line_items")
    DO WHILE j < lnCount_j
        loJResp.J = j
        j = j + 1
    ENDDO
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("rates")
DO WHILE i < lnCount_i
    loJResp.I = i
    lnIntVal = loJResp.IntOf("rates[i]")
    j = 0
    lnCount_j = loJResp.SizeOfArray("rates[i].attributes")
    DO WHILE j < lnCount_j
        loJResp.J = j
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("rates[i].messages")
    DO WHILE j < lnCount_j
        loJResp.J = j
        j = j + 1
    ENDDO
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("carrier_accounts")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("messages")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loJson
RELEASE loSbResponseBody
RELEASE loJResp


 

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