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

Unicode C++ 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 v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Unicode C++) Xero Build Hashtable of Account Codes

To create a new account, a unique and unused account Code would need to be selected. How do we know what account Codes already exist? One way of finding out is to download the complete set of Accounts every time. Another way is to download once, and keep a local hash table of the account Codes. This makes it possible to find a new and unused Code without having to continually fetch data from the Xero server.

Note: Requires Chilkat v9.5.0.64 or greater.

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <CkRestW.h>
#include <CkStringBuilderW.h>
#include <CkHashtableW.h>
#include <CkXmlW.h>

void ChilkatSample(void)
    {
    // Note: Requires Chilkat v9.5.0.64 or greater.

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

    CkRestW rest;
    bool success;

    // Before sending REST API calls, the REST object needs to be
    // initialized for OAuth1.
    // See Xero 2-Legged OAuth1 Setup for sample code.

    // Assuming the REST object's OAuth1 authenticator is setup, and the initial
    // connection was made, we may now send REST HTTP requests..

    // -----------------------------------------------------
    // Get the full list of accounts.
    CkStringBuilderW sbXml;
    success = rest.FullRequestNoBodySb(L"GET",L"/api.xro/2.0/Accounts",sbXml);
    if (success != true) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    // A 200 response is expected for actual success.
    if (rest.get_ResponseStatusCode() != 200) {
        wprintf(L"%s\n",sbXml.getAsString());
        return;
    }

    // Iterate over the accounts, and build a Hashtable where the
    // key is the account Code, and the value is the XML record for the account.
    CkHashtableW htAccounts;

    bool bAutoTrim = false;
    CkXmlW xml;
    xml.LoadSb(sbXml,bAutoTrim);
    xml.put_EmitXmlDecl(false);
    xml.put_EmitCompact(true);

    // How many accounts exist?
    int numAccounts = xml.NumChildrenAt(L"Accounts");
    wprintf(L"numAccounts = %d\n",numAccounts);

    int i = 0;
    while (i < numAccounts) {
        xml.put_I(i);
        const wchar_t *hashKey = xml.getChildContent(L"Accounts|Account[i]|Code");
        // Update the xml object's internal reference to the i'th account record.
        const wchar_t *notUsed = xml.chilkatPath(L"Accounts|Account[i]|$");

        wprintf(L"hash key = %s\n",hashKey);
        if (i < 5) {
            // Show a few of the values..
            wprintf(L"%s\n",xml.getXml());
        }

        htAccounts.AddStr(hashKey,xml.getXml());

        // Update the xml object's internal reference to the XML root node.
        xml.GetRoot2();
        i = i + 1;
    }

    // At this point the Hashtable is built.
    // Save the Hashtable to a file.  This will be used in subsequent requests
    // when we need to find a unique/unused Code, or if we want to get
    // the account information from the local hash table.
    CkStringBuilderW htXmlSb;
    htAccounts.ToXmlSb(htXmlSb);
    success = htXmlSb.WriteFile(L"qa_cache/xero_accounts_by_code.xml",L"utf-8",false);

    wprintf(L"success = %d\n",success);
    }

 

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