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

DataFlex 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
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

 

 

 

(DataFlex) Shippo Create Transaction Object

Creates a Transaction object that represents a shipping label purchase and is based on the shipping rate.

For more information, see https://goshippo.com/docs/shipping-labels/

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vReq
    Handle hoReq
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sObject_state
    String sStatus
    String sObject_created
    String sObject_updated
    String sObject_id
    String sObject_owner
    Boolean iTest
    String sRate
    String sTracking_number
    String sTracking_status
    String sEta
    String sTracking_url_provider
    String sLabel_url
    String sCommercial_invoice_url
    String sOrder
    String sMetadata
    String sParcel
    Integer i
    Integer iCount_i
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // Implements the following CURL command:

    // curl https://api.goshippo.com/transactions \
    //     -H "Authorization: ShippoToken <API_TOKEN>" \
    //     -d rate="478fb066930e4e3195a3686f7ea5b612"
    //     -d label_file_type="PDF"
    //     -d async=false

    Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
    If (Not(IsComObjectCreated(hoReq))) Begin
        Send CreateComObject of hoReq
    End
    Set ComHttpVerb Of hoReq To "POST"
    Set ComPath Of hoReq To "/transactions"
    Set ComContentType Of hoReq To "application/x-www-form-urlencoded"
    Send ComAddParam To hoReq "rate" "478fb066930e4e3195a3686f7ea5b612"
    Send ComAddParam To hoReq "label_file_type" "PDF"
    Send ComAddParam To hoReq "async" "false"

    Send ComAddHeader To hoReq "Authorization" "ShippoToken <API_TOKEN>"

    Get pvComObject of hoReq to vReq
    Get ComPostUrlEncoded Of hoHttp "https://api.goshippo.com/transactions" vReq To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

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

    // {
    //   "object_state": "VALID",
    //   "status": "SUCCESS",
    //   "object_created": "2019-06-28T18:04:08.679Z",
    //   "object_updated": "2019-06-28T18:04:10.516Z",
    //   "object_id": "6178e155da304f10aa4b4271fdca84fb",
    //   "object_owner": "admin@chilkatsoft.com",
    //   "test": true,
    //   "rate": "dd7556c284e8444294d2ab7099e662d2",
    //   "tracking_number": "92701902416755000000000015",
    //   "tracking_status": "UNKNOWN",
    //   "eta": null,
    //   "tracking_url_provider": "https://tools.usps.com/go/TrackConfirmAction_input?origTrackNum=92701902416755000000000015",
    //   "label_url": "https://shippo-delivery-east.s3.amazonaws.com/6178e155da304f10aa4b4271fdca84fb.pdf?Signature=1LU0Qf11nQJGei%2FeLZr%2BQ5EwJS4%3D&Expires=1593281050&AWSAccessKeyId=AKIAJGLCC5MYLLWIG42A",
    //   "commercial_invoice_url": null,
    //   "messages": [
    //   ],
    //   "order": null,
    //   "metadata": "",
    //   "parcel": "5af766ff15684a4186b0e3c833348fac",
    //   "billing": {
    //     "payments": [
    //     ]
    //   }
    // }

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

    Get ComStringOf Of hoJResp "object_state" To sObject_state
    Get ComStringOf Of hoJResp "status" To sStatus
    Get ComStringOf Of hoJResp "object_created" To sObject_created
    Get ComStringOf Of hoJResp "object_updated" To sObject_updated
    Get ComStringOf Of hoJResp "object_id" To sObject_id
    Get ComStringOf Of hoJResp "object_owner" To sObject_owner
    Get ComBoolOf Of hoJResp "test" To iTest
    Get ComStringOf Of hoJResp "rate" To sRate
    Get ComStringOf Of hoJResp "tracking_number" To sTracking_number
    Get ComStringOf Of hoJResp "tracking_status" To sTracking_status
    Get ComStringOf Of hoJResp "eta" To sEta
    Get ComStringOf Of hoJResp "tracking_url_provider" To sTracking_url_provider
    Get ComStringOf Of hoJResp "label_url" To sLabel_url
    Get ComStringOf Of hoJResp "commercial_invoice_url" To sCommercial_invoice_url
    Get ComStringOf Of hoJResp "order" To sOrder
    Get ComStringOf Of hoJResp "metadata" To sMetadata
    Get ComStringOf Of hoJResp "parcel" To sParcel
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "messages" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "billing.payments" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop



End_Procedure

 

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