Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

DataFlex Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(DataFlex) Shippo Validate Existing Address

Demonstrates how to validate an existing address.

For more information, see https://goshippo.com/docs/address-validation/

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sSource
    String sCode
    String sV_type
    String sText
    String sObject_created
    String sObject_updated
    String sObject_id
    Boolean iIs_complete
    Boolean iValidation_resultsIs_valid
    String sObject_owner
    String sName
    String sCompany
    String sStreet_no
    String sStreet1
    String sStreet2
    String sCity
    String sState
    String sZip
    String sCountry
    String sPhone
    Integer i
    Integer iCount_i
    String sTemp1

    // 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/addresses/e9dabe9669334b84baad3a08646b2202/validate/ \
    //     -H "Authorization: ShippoToken <API_TOKEN>"

    Send ComSetRequestHeader To hoHttp "Authorization" "ShippoToken <API_TOKEN>"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://api.goshippo.com/addresses/e9dabe9669334b84baad3a08646b2202/validate/" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    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 ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

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

    // {
    //   "object_created": "2015-03-30T23:47:11.574Z",
    //   "object_updated": "2015-03-30T23:47:11.596Z",
    //   "object_id": "67183b2e81e9421f894bfbcdc4236b16",
    //   "is_complete": false,
    //   "validation_results": {
    //     "is_valid": false,
    //     "messages": [
    //       {
    //         "source": "USPS",
    //         "code": "Address Not Found",
    //         "type": "address_error",
    //         "text": "The address as submitted could not be found. Please check for excessive abbreviations in the street address line or in the City name."
    //       }
    //     ]
    //   },
    //   "object_owner": "shippotle@goshippo.com",
    //   "name": "Shawn Ippotle",
    //   "company": "Shippo",
    //   "street_no": "",
    //   "street1": "215 HIPPO ST.",
    //   "street2": "",
    //   "city": "SAN FRANCISCO",
    //   "state": "CA",
    //   "zip": "94107",
    //   "country": "US",
    //   "phone": ""
    // }

    // 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_created" To sObject_created
    Get ComStringOf Of hoJResp "object_updated" To sObject_updated
    Get ComStringOf Of hoJResp "object_id" To sObject_id
    Get ComBoolOf Of hoJResp "is_complete" To iIs_complete
    Get ComBoolOf Of hoJResp "validation_results.is_valid" To iValidation_resultsIs_valid
    Get ComStringOf Of hoJResp "object_owner" To sObject_owner
    Get ComStringOf Of hoJResp "name" To sName
    Get ComStringOf Of hoJResp "company" To sCompany
    Get ComStringOf Of hoJResp "street_no" To sStreet_no
    Get ComStringOf Of hoJResp "street1" To sStreet1
    Get ComStringOf Of hoJResp "street2" To sStreet2
    Get ComStringOf Of hoJResp "city" To sCity
    Get ComStringOf Of hoJResp "state" To sState
    Get ComStringOf Of hoJResp "zip" To sZip
    Get ComStringOf Of hoJResp "country" To sCountry
    Get ComStringOf Of hoJResp "phone" To sPhone
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "validation_results.messages" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "validation_results.messages[i].source" To sSource
        Get ComStringOf Of hoJResp "validation_results.messages[i].code" To sCode
        Get ComStringOf Of hoJResp "validation_results.messages[i].type" To sV_type
        Get ComStringOf Of hoJResp "validation_results.messages[i].text" To sText
        Move i + 1 To i
    Loop



End_Procedure

 

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