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

PowerBuilder 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

 

 

 

(PowerBuilder) Square API - Batch Upsert Catalog Objects

Creates or updates up to 10,000 target objects based on the provided list of objects. The target objects are grouped into batches and each batch is inserted/updated in an all-or-nothing manner.

For more information, see https://developer.squareup.com/reference/square/catalog-api/batch-upsert-catalog-objects

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
oleobject loo_Http
integer li_Success
integer i
integer j
integer k
oleobject loo_Json
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_V_type
string ls_Id
string ls_Updated_at
integer li_Version
integer li_Is_deleted
integer li_Present_at_all_locations
string ls_Item_dataName
string ls_Item_dataDescription
string ls_Item_dataCategory_id
string ls_Category_dataName
string ls_Tax_dataName
string ls_Tax_dataCalculation_phase
string ls_Tax_dataInclusion_type
string ls_Tax_dataPercentage
integer li_Tax_dataApplies_to_custom_amounts
integer li_Tax_dataEnabled
integer li_Count_j
string ls_StrVal
string ls_Item_variation_dataItem_id
string ls_Item_variation_dataName
integer li_Item_variation_dataOrdinal
string ls_Item_variation_dataPricing_type
integer li_Item_variation_dataPrice_moneyAmount
string ls_Item_variation_dataPrice_moneyCurrency
string ls_Client_object_id
string ls_Object_id
integer li_Count_i

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

// The following JSON is sent in the request body.

// {
//   "idempotency_key": "789ff020-f723-43a9-b4b5-43b5dc1fa3dc",
//   "batches": [
//     {
//       "objects": [
//         {
//           "type": "ITEM",
//           "id": "#Tea",
//           "present_at_all_locations": true,
//           "item_data": {
//             "name": "Tea",
//             "description": "Hot Leaf Juice",
//             "category_id": "#Beverages",
//             "tax_ids": [
//               "#SalesTax"
//             ],
//             "variations": [
//               {
//                 "type": "ITEM_VARIATION",
//                 "id": "#Tea_Mug",
//                 "present_at_all_locations": true,
//                 "item_variation_data": {
//                   "item_id": "#Tea",
//                   "name": "Mug",
//                   "pricing_type": "FIXED_PRICING",
//                   "price_money": {
//                     "amount": 150,
//                     "currency": "USD"
//                   }
//                 }
//               }
//             ]
//           }
//         },
//         {
//           "type": "ITEM",
//           "id": "#Coffee",
//           "present_at_all_locations": true,
//           "item_data": {
//             "name": "Coffee",
//             "description": "Hot Bean Juice",
//             "category_id": "#Beverages",
//             "tax_ids": [
//               "#SalesTax"
//             ],
//             "variations": [
//               {
//                 "type": "ITEM_VARIATION",
//                 "id": "#Coffee_Regular",
//                 "present_at_all_locations": true,
//                 "item_variation_data": {
//                   "item_id": "#Coffee",
//                   "name": "Regular",
//                   "pricing_type": "FIXED_PRICING",
//                   "price_money": {
//                     "amount": 250,
//                     "currency": "USD"
//                   }
//                 }
//               },
//               {
//                 "type": "ITEM_VARIATION",
//                 "id": "#Coffee_Large",
//                 "present_at_all_locations": true,
//                 "item_variation_data": {
//                   "item_id": "#Coffee",
//                   "name": "Large",
//                   "pricing_type": "FIXED_PRICING",
//                   "price_money": {
//                     "amount": 350,
//                     "currency": "USD"
//                   }
//                 }
//               }
//             ]
//           }
//         },
//         {
//           "type": "CATEGORY",
//           "id": "#Beverages",
//           "present_at_all_locations": true,
//           "category_data": {
//             "name": "Beverages"
//           }
//         },
//         {
//           "type": "TAX",
//           "id": "#SalesTax",
//           "present_at_all_locations": true,
//           "tax_data": {
//             "name": "Sales Tax",
//             "calculation_phase": "TAX_SUBTOTAL_PHASE",
//             "inclusion_type": "ADDITIVE",
//             "percentage": "5.0",
//             "applies_to_custom_amounts": true,
//             "enabled": true
//           }
//         }
//       ]
//     }
//   ]
// }

loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

loo_Json.UpdateString("idempotency_key","789ff020-f723-43a9-b4b5-43b5dc1fa3dc")
i = 0
loo_Json.I = i
j = 0
loo_Json.J = j
loo_Json.UpdateString("batches[i].objects[j].type","ITEM")
loo_Json.UpdateString("batches[i].objects[j].id","#Tea")
loo_Json.UpdateBool("batches[i].objects[j].present_at_all_locations",1)
loo_Json.UpdateString("batches[i].objects[j].item_data.name","Tea")
loo_Json.UpdateString("batches[i].objects[j].item_data.description","Hot Leaf Juice")
loo_Json.UpdateString("batches[i].objects[j].item_data.category_id","#Beverages")
loo_Json.UpdateString("batches[i].objects[j].item_data.tax_ids[0]","#SalesTax")
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[0].type","ITEM_VARIATION")
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[0].id","#Tea_Mug")
loo_Json.UpdateBool("batches[i].objects[j].item_data.variations[0].present_at_all_locations",1)
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[0].item_variation_data.item_id","#Tea")
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[0].item_variation_data.name","Mug")
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[0].item_variation_data.pricing_type","FIXED_PRICING")
loo_Json.UpdateInt("batches[i].objects[j].item_data.variations[0].item_variation_data.price_money.amount",150)
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[0].item_variation_data.price_money.currency","USD")
j = j + 1
loo_Json.J = j
loo_Json.UpdateString("batches[i].objects[j].type","ITEM")
loo_Json.UpdateString("batches[i].objects[j].id","#Coffee")
loo_Json.UpdateBool("batches[i].objects[j].present_at_all_locations",1)
loo_Json.UpdateString("batches[i].objects[j].item_data.name","Coffee")
loo_Json.UpdateString("batches[i].objects[j].item_data.description","Hot Bean Juice")
loo_Json.UpdateString("batches[i].objects[j].item_data.category_id","#Beverages")
loo_Json.UpdateString("batches[i].objects[j].item_data.tax_ids[0]","#SalesTax")
k = 0
loo_Json.K = k
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].type","ITEM_VARIATION")
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].id","#Coffee_Regular")
loo_Json.UpdateBool("batches[i].objects[j].item_data.variations[k].present_at_all_locations",1)
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].item_variation_data.item_id","#Coffee")
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].item_variation_data.name","Regular")
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].item_variation_data.pricing_type","FIXED_PRICING")
loo_Json.UpdateInt("batches[i].objects[j].item_data.variations[k].item_variation_data.price_money.amount",250)
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].item_variation_data.price_money.currency","USD")
k = k + 1
loo_Json.K = k
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].type","ITEM_VARIATION")
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].id","#Coffee_Large")
loo_Json.UpdateBool("batches[i].objects[j].item_data.variations[k].present_at_all_locations",1)
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].item_variation_data.item_id","#Coffee")
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].item_variation_data.name","Large")
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].item_variation_data.pricing_type","FIXED_PRICING")
loo_Json.UpdateInt("batches[i].objects[j].item_data.variations[k].item_variation_data.price_money.amount",350)
loo_Json.UpdateString("batches[i].objects[j].item_data.variations[k].item_variation_data.price_money.currency","USD")
j = j + 1
loo_Json.J = j
loo_Json.UpdateString("batches[i].objects[j].type","CATEGORY")
loo_Json.UpdateString("batches[i].objects[j].id","#Beverages")
loo_Json.UpdateBool("batches[i].objects[j].present_at_all_locations",1)
loo_Json.UpdateString("batches[i].objects[j].category_data.name","Beverages")
j = j + 1
loo_Json.J = j
loo_Json.UpdateString("batches[i].objects[j].type","TAX")
loo_Json.UpdateString("batches[i].objects[j].id","#SalesTax")
loo_Json.UpdateBool("batches[i].objects[j].present_at_all_locations",1)
loo_Json.UpdateString("batches[i].objects[j].tax_data.name","Sales Tax")
loo_Json.UpdateString("batches[i].objects[j].tax_data.calculation_phase","TAX_SUBTOTAL_PHASE")
loo_Json.UpdateString("batches[i].objects[j].tax_data.inclusion_type","ADDITIVE")
loo_Json.UpdateString("batches[i].objects[j].tax_data.percentage","5.0")
loo_Json.UpdateBool("batches[i].objects[j].tax_data.applies_to_custom_amounts",1)
loo_Json.UpdateBool("batches[i].objects[j].tax_data.enabled",1)

// Adds the "Authorization: Bearer ACCESS_TOKEN" header.
loo_Http.AuthToken = "ACCESS_TOKEN"
loo_Http.SetRequestHeader("Square-Version","2020-07-22")
loo_Http.SetRequestHeader("Content-Type","application/json")

// This example uses the sandbox: connect.squareupsandbox.com
// Production should use connect.squareup.com
loo_Resp = loo_Http.PostJson3("https://connect.squareupsandbox.com/v2/catalog/batch-upsert","application/json",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Json
    return
end if

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_Json
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

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

// {
//   "objects": [
//     {
//       "type": "ITEM",
//       "id": "ZSDZN34NAXDLC6D5ZQMNSOUM",
//       "updated_at": "2017-05-10T18:48:39.798Z",
//       "version": 1494442119798,
//       "is_deleted": false,
//       "present_at_all_locations": true,
//       "item_data": {
//         "name": "Tea",
//         "description": "Hot Leaf Juice",
//         "category_id": "LYT72K3WGJFFCIMB63XARP3I",
//         "tax_ids": [
//           "XHSHLHNWSI3HVI4BW5ZUZXI3"
//         ],
//         "variations": [
//           {
//             "type": "ITEM_VARIATION",
//             "id": "NAYHET5R52MIYCEF34ZMAHFM",
//             "updated_at": "2017-05-10T18:48:39.798Z",
//             "version": 1494442119798,
//             "is_deleted": false,
//             "present_at_all_locations": true,
//             "item_variation_data": {
//               "item_id": "ZSDZN34NAXDLC6D5ZQMNSOUM",
//               "name": "Mug",
//               "ordinal": 0,
//               "pricing_type": "FIXED_PRICING",
//               "price_money": {
//                 "amount": 150,
//                 "currency": "USD"
//               }
//             }
//           }
//         ]
//       }
//     },
//     {
//       "type": "ITEM",
//       "id": "PJMCEBHHUS3OKDB6PYUHLCPP",
//       "updated_at": "2017-05-10T18:48:39.798Z",
//       "version": 1494442119798,
//       "is_deleted": false,
//       "present_at_all_locations": true,
//       "item_data": {
//         "name": "Coffee",
//         "description": "Hot Bean Juice",
//         "category_id": "LYT72K3WGJFFCIMB63XARP3I",
//         "tax_ids": [
//           "XHSHLHNWSI3HVI4BW5ZUZXI3"
//         ],
//         "variations": [
//           {
//             "type": "ITEM_VARIATION",
//             "id": "OTYDX45SPG7LJQUVCBZI4INH",
//             "updated_at": "2017-05-10T18:48:39.798Z",
//             "version": 1494442119798,
//             "is_deleted": false,
//             "present_at_all_locations": true,
//             "item_variation_data": {
//               "item_id": "PJMCEBHHUS3OKDB6PYUHLCPP",
//               "name": "Regular",
//               "ordinal": 0,
//               "pricing_type": "FIXED_PRICING",
//               "price_money": {
//                 "amount": 250,
//                 "currency": "USD"
//               }
//             }
//           },
//           {
//             "type": "ITEM_VARIATION",
//             "id": "GZDA3JB37FYVOPI4AOEBOITI",
//             "updated_at": "2017-05-10T18:48:39.798Z",
//             "version": 1494442119798,
//             "is_deleted": false,
//             "present_at_all_locations": true,
//             "item_variation_data": {
//               "item_id": "PJMCEBHHUS3OKDB6PYUHLCPP",
//               "name": "Large",
//               "ordinal": 1,
//               "pricing_type": "FIXED_PRICING",
//               "price_money": {
//                 "amount": 350,
//                 "currency": "USD"
//               }
//             }
//           }
//         ]
//       }
//     },
//     {
//       "type": "CATEGORY",
//       "id": "LYT72K3WGJFFCIMB63XARP3I",
//       "updated_at": "2017-05-10T18:48:39.798Z",
//       "version": 1494442119798,
//       "is_deleted": false,
//       "present_at_all_locations": true,
//       "category_data": {
//         "name": "Beverages"
//       }
//     },
//     {
//       "type": "TAX",
//       "id": "XHSHLHNWSI3HVI4BW5ZUZXI3",
//       "updated_at": "2017-05-10T18:48:39.798Z",
//       "version": 1494442119798,
//       "is_deleted": false,
//       "present_at_all_locations": true,
//       "tax_data": {
//         "name": "Sales Tax",
//         "calculation_phase": "TAX_SUBTOTAL_PHASE",
//         "inclusion_type": "ADDITIVE",
//         "percentage": "5.0",
//         "applies_to_custom_amounts": true,
//         "enabled": true
//       }
//     }
//   ],
//   "id_mappings": [
//     {
//       "client_object_id": "#Tea",
//       "object_id": "ZSDZN34NAXDLC6D5ZQMNSOUM"
//     },
//     {
//       "client_object_id": "#Coffee",
//       "object_id": "PJMCEBHHUS3OKDB6PYUHLCPP"
//     },
//     {
//       "client_object_id": "#Beverages",
//       "object_id": "LYT72K3WGJFFCIMB63XARP3I"
//     },
//     {
//       "client_object_id": "#SalesTax",
//       "object_id": "XHSHLHNWSI3HVI4BW5ZUZXI3"
//     },
//     {
//       "client_object_id": "#Tea_Mug",
//       "object_id": "NAYHET5R52MIYCEF34ZMAHFM"
//     },
//     {
//       "client_object_id": "#Coffee_Regular",
//       "object_id": "OTYDX45SPG7LJQUVCBZI4INH"
//     },
//     {
//       "client_object_id": "#Coffee_Large",
//       "object_id": "GZDA3JB37FYVOPI4AOEBOITI"
//     }
//   ]
// }

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

i = 0
li_Count_i = loo_JResp.SizeOfArray("objects")
do while i < li_Count_i
    loo_JResp.I = i
    ls_V_type = loo_JResp.StringOf("objects[i].type")
    ls_Id = loo_JResp.StringOf("objects[i].id")
    ls_Updated_at = loo_JResp.StringOf("objects[i].updated_at")
    li_Version = loo_JResp.IntOf("objects[i].version")
    li_Is_deleted = loo_JResp.BoolOf("objects[i].is_deleted")
    li_Present_at_all_locations = loo_JResp.BoolOf("objects[i].present_at_all_locations")
    ls_Item_dataName = loo_JResp.StringOf("objects[i].item_data.name")
    ls_Item_dataDescription = loo_JResp.StringOf("objects[i].item_data.description")
    ls_Item_dataCategory_id = loo_JResp.StringOf("objects[i].item_data.category_id")
    ls_Category_dataName = loo_JResp.StringOf("objects[i].category_data.name")
    ls_Tax_dataName = loo_JResp.StringOf("objects[i].tax_data.name")
    ls_Tax_dataCalculation_phase = loo_JResp.StringOf("objects[i].tax_data.calculation_phase")
    ls_Tax_dataInclusion_type = loo_JResp.StringOf("objects[i].tax_data.inclusion_type")
    ls_Tax_dataPercentage = loo_JResp.StringOf("objects[i].tax_data.percentage")
    li_Tax_dataApplies_to_custom_amounts = loo_JResp.BoolOf("objects[i].tax_data.applies_to_custom_amounts")
    li_Tax_dataEnabled = loo_JResp.BoolOf("objects[i].tax_data.enabled")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("objects[i].item_data.tax_ids")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("objects[i].item_data.tax_ids[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("objects[i].item_data.variations")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_V_type = loo_JResp.StringOf("objects[i].item_data.variations[j].type")
        ls_Id = loo_JResp.StringOf("objects[i].item_data.variations[j].id")
        ls_Updated_at = loo_JResp.StringOf("objects[i].item_data.variations[j].updated_at")
        li_Version = loo_JResp.IntOf("objects[i].item_data.variations[j].version")
        li_Is_deleted = loo_JResp.BoolOf("objects[i].item_data.variations[j].is_deleted")
        li_Present_at_all_locations = loo_JResp.BoolOf("objects[i].item_data.variations[j].present_at_all_locations")
        ls_Item_variation_dataItem_id = loo_JResp.StringOf("objects[i].item_data.variations[j].item_variation_data.item_id")
        ls_Item_variation_dataName = loo_JResp.StringOf("objects[i].item_data.variations[j].item_variation_data.name")
        li_Item_variation_dataOrdinal = loo_JResp.IntOf("objects[i].item_data.variations[j].item_variation_data.ordinal")
        ls_Item_variation_dataPricing_type = loo_JResp.StringOf("objects[i].item_data.variations[j].item_variation_data.pricing_type")
        li_Item_variation_dataPrice_moneyAmount = loo_JResp.IntOf("objects[i].item_data.variations[j].item_variation_data.price_money.amount")
        ls_Item_variation_dataPrice_moneyCurrency = loo_JResp.StringOf("objects[i].item_data.variations[j].item_variation_data.price_money.currency")
        j = j + 1
    loop
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("id_mappings")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Client_object_id = loo_JResp.StringOf("id_mappings[i].client_object_id")
    ls_Object_id = loo_JResp.StringOf("id_mappings[i].object_id")
    i = i + 1
loop


destroy loo_Http
destroy loo_Json
destroy loo_SbResponseBody
destroy loo_JResp

 

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