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

Android™ 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
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
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
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Android™) Shippo Create Customs Declaration

Demonstrates how to create a customs declaration and send a POST request with the necessary information to the Customs Declarations endpoint.

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

Chilkat Android™ Downloads

Android™ Java Libraries

Android C/C++ Libraries

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    CkHttp http = new CkHttp();
    boolean success;

    // 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"
    //     }
    //   ]
    // }

    CkJsonObject json = new CkJsonObject();
    json.UpdateString("contents_type","MERCHANDISE");
    json.UpdateString("non_delivery_option","RETURN");
    json.UpdateBool("certify",true);
    json.UpdateString("certify_signer","Simon Kreuz");
    json.UpdateString("incoterm","DDU");
    json.UpdateString("items[0].description","T-shirt");
    json.UpdateInt("items[0].quantity",20);
    json.UpdateString("items[0].net_weight","5");
    json.UpdateString("items[0].mass_unit","lb");
    json.UpdateString("items[0].value_amount","200");
    json.UpdateString("items[0].value_currency","USD");
    json.UpdateString("items[0].tariff_number","");
    json.UpdateString("items[0].origin_country","US");

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

    CkHttpResponse resp = http.PostJson3("https://api.goshippo.com/customs/declarations/","application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    resp.GetBodySb(sbResponseBody);
    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    Log.i(TAG, "Response Body:");
    Log.i(TAG, jResp.emit());

    int respStatusCode = resp.get_StatusCode();
    Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
    if (respStatusCode >= 400) {
        Log.i(TAG, "Response Header:");
        Log.i(TAG, resp.header());
        Log.i(TAG, "Failed.");

        return;
        }

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

    // {
    //   "object_created": "2019-07-04T16:00:29.043Z",
    //   "object_updated": "2019-07-04T16:00:29.043Z",
    //   "object_id": "4a1e6ab7b1ba49ed9bc6cb1a8798e0fd",
    //   "object_owner": "admin@chilkatsoft.com",
    //   "object_state": "VALID",
    //   "address_importer": null,
    //   "certify_signer": "Simon Kreuz",
    //   "certify": true,
    //   "items": [
    //     "4096c68693364b7ea0af72fb869ee861"
    //   ],
    //   "non_delivery_option": "RETURN",
    //   "contents_type": "MERCHANDISE",
    //   "contents_explanation": "",
    //   "exporter_reference": "",
    //   "importer_reference": "",
    //   "invoice": "",
    //   "commercial_invoice": false,
    //   "license": "",
    //   "certificate": "",
    //   "notes": "",
    //   "eel_pfc": "",
    //   "aes_itn": "",
    //   "disclaimer": "",
    //   "incoterm": "DDU",
    //   "metadata": "",
    //   "test": true,
    //   "duties_payor": null
    // }

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

    String strVal;

    String object_created = jResp.stringOf("object_created");
    String object_updated = jResp.stringOf("object_updated");
    String object_id = jResp.stringOf("object_id");
    String object_owner = jResp.stringOf("object_owner");
    String object_state = jResp.stringOf("object_state");
    String address_importer = jResp.stringOf("address_importer");
    String certify_signer = jResp.stringOf("certify_signer");
    boolean certify = jResp.BoolOf("certify");
    String non_delivery_option = jResp.stringOf("non_delivery_option");
    String contents_type = jResp.stringOf("contents_type");
    String contents_explanation = jResp.stringOf("contents_explanation");
    String exporter_reference = jResp.stringOf("exporter_reference");
    String importer_reference = jResp.stringOf("importer_reference");
    String invoice = jResp.stringOf("invoice");
    boolean commercial_invoice = jResp.BoolOf("commercial_invoice");
    String license = jResp.stringOf("license");
    String certificate = jResp.stringOf("certificate");
    String notes = jResp.stringOf("notes");
    String eel_pfc = jResp.stringOf("eel_pfc");
    String aes_itn = jResp.stringOf("aes_itn");
    String disclaimer = jResp.stringOf("disclaimer");
    String incoterm = jResp.stringOf("incoterm");
    String metadata = jResp.stringOf("metadata");
    boolean test = jResp.BoolOf("test");
    String duties_payor = jResp.stringOf("duties_payor");
    int i = 0;
    int count_i = jResp.SizeOfArray("items");
    while (i < count_i) {
        jResp.put_I(i);
        strVal = jResp.stringOf("items[i]");
        i = i + 1;
        }


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

 

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