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

SQL Server Examples

ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
FileAccess
Firebase
GMail REST API
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Sheets
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)

Java KeyStore (JKS)
Jira
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
Upload
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(SQL Server) Xero Get Employees (Payroll API Australia)

Demonstrates how to get the summarised list of active employees.

Note: This example requires Chilkat v9.5.0.64 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(4000)
    --  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.

    DECLARE @rest int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Rest', @rest OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    --  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 employees.
    DECLARE @sbXml int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbXml OUT

    EXEC sp_OAMethod @rest, 'FullRequestNoBodySb', @success OUT, 'GET', '/payroll.xro/1.0/Employees', @sbXml
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @rest
        EXEC @hr = sp_OADestroy @sbXml
        RETURN
      END

    --  A 200 response is expected for actual success.
    EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
    IF @iTmp0 <> 200
      BEGIN
        EXEC sp_OAMethod @sbXml, 'GetAsString', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @rest
        EXEC @hr = sp_OADestroy @sbXml
        RETURN
      END

    --  Iterate over the employees and get some information..

    DECLARE @bAutoTrim int
    SELECT @bAutoTrim = 0
    DECLARE @xml int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @xml OUT

    EXEC sp_OAMethod @xml, 'LoadSb', @success OUT, @sbXml, @bAutoTrim
    EXEC sp_OAMethod @xml, 'SaveXml', @success OUT, 'qa_cache/xero_employees.xml'

    --  How many records exist?
    DECLARE @recordCount int
    EXEC sp_OAMethod @xml, 'NumChildrenAt', @recordCount OUT, 'Employees'

    PRINT 'numRecords = ' + @recordCount

    DECLARE @i int
    SELECT @i = 0
    WHILE @i < @recordCount
      BEGIN
        EXEC sp_OASetProperty @xml, 'I', @i

        EXEC sp_OAMethod @xml, 'GetChildContent', @sTmp0 OUT, 'Employees|Employee[i]|EmployeeID'
        PRINT 'EmployeeID: ' + @sTmp0

        EXEC sp_OAMethod @xml, 'GetChildContent', @sTmp0 OUT, 'Employees|Employee[i]|FirstName'
        PRINT 'FirstName: ' + @sTmp0

        EXEC sp_OAMethod @xml, 'GetChildContent', @sTmp0 OUT, 'Employees|Employee[i]|LastName'
        PRINT 'LastName: ' + @sTmp0

        PRINT '----'
        SELECT @i = @i + 1
      END

    --  The output looks like this:

    --  	numRecords = 6
    --  	EmployeeID: 056a9821-55b8-4c91-b5ce-a6ce2ab508ab
    --  	FirstName: James
    --  	LastName: Lebron
    --  	----
    --  	EmployeeID: 1f606d28-0537-42af-80ce-312d449458af
    --  	FirstName: Odette
    --  	LastName: Garrison
    --  	----
    --  	EmployeeID: c086c9ce-821b-4636-8e9a-7864bd50d882
    --  	FirstName: Oliver
    --  	LastName: Gray
    --  	----
    --  	EmployeeID: 1612dfee-37d2-4c5d-a7b9-187aee5f264a
    --  	FirstName: Sally
    --  	LastName: Martin
    --  	----
    --  	EmployeeID: 2df65756-538b-4bc1-b0c3-f3971d86b650
    --  	FirstName: Sonia
    --  	LastName: Michaels
    --  	----
    --  	EmployeeID: 08dcd870-3d8f-495f-af54-69029a89eb7d
    --  	FirstName: Tracy
    --  	LastName: Green
    --  	----

    --  The xero_employees.xml file contains data that looks like this:

    --  <?xml version="1.0" encoding="utf-8" ?>
    --  <Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    --      <Id>c1dfd096-5552-4459-bf94-f283357998c5</Id>
    --      <Status>OK</Status>
    --      <ProviderName>ChilkatAU</ProviderName>
    --      <DateTimeUTC>2016-11-11T20:47:18.4411917Z</DateTimeUTC>
    --      <Employees>
    --          <Employee>
    --              <EmployeeID>056a9821-55b8-4c91-b5ce-a6ce2ab508ab</EmployeeID>
    --              <FirstName>James</FirstName>
    --              <LastName>Lebron</LastName>
    --              <Status>ACTIVE</Status>
    --              <Email>JL@madeup.email.com</Email>
    --              <DateOfBirth>1982-03-15T00:00:00</DateOfBirth>
    --              <Gender>M</Gender>
    --              <Phone>0400-000-123</Phone>
    --              <Mobile> 408-230-9732</Mobile>
    --              <StartDate>2015-09-01T00:00:00</StartDate>
    --              <OrdinaryEarningsRateID>2c4fbb29-aa68-4a8d-bc05-3f6366f75227</OrdinaryEarningsRateID>
    --              <PayrollCalendarID>4c08f63d-53af-4521-a8be-1d77fc0faf45</PayrollCalendarID>
    --              <UpdatedDateUTC>2016-11-11T20:29:03</UpdatedDateUTC>
    --          </Employee>
    --          <Employee>
    --              <EmployeeID>1f606d28-0537-42af-80ce-312d449458af</EmployeeID>
    --              <FirstName>Odette</FirstName>
    --              <LastName>Garrison</LastName>
    --              <Status>ACTIVE</Status>
    --              <Email>ogg@madeup.email.com</Email>
    --              <DateOfBirth>1978-12-18T00:00:00</DateOfBirth>
    --              <Gender>F</Gender>
    --              <Phone>9000 1234</Phone>
    --              <StartDate>2015-11-05T00:00:00</StartDate>
    --              <OrdinaryEarningsRateID>2c4fbb29-aa68-4a8d-bc05-3f6366f75227</OrdinaryEarningsRateID>
    --              <PayrollCalendarID>e53023e6-70f1-45c7-b699-6558b5e42b4e</PayrollCalendarID>
    --              <UpdatedDateUTC>2016-11-11T20:29:03</UpdatedDateUTC>
    --          </Employee>
    --          <Employee>
    --              <EmployeeID>c086c9ce-821b-4636-8e9a-7864bd50d882</EmployeeID>
    --              <FirstName>Oliver</FirstName>
    --              <LastName>Gray</LastName>
    --              <Status>ACTIVE</Status>
    --              <Email>og@madeup.email.com</Email>
    --              <DateOfBirth>1969-07-28T00:00:00</DateOfBirth>
    --              <Gender>M</Gender>
    --              <Phone>0401 123 456</Phone>
    --              <StartDate>2016-02-02T00:00:00</StartDate>
    --              <OrdinaryEarningsRateID>2c4fbb29-aa68-4a8d-bc05-3f6366f75227</OrdinaryEarningsRateID>
    --              <PayrollCalendarID>4c08f63d-53af-4521-a8be-1d77fc0faf45</PayrollCalendarID>
    --              <UpdatedDateUTC>2016-11-11T20:29:03</UpdatedDateUTC>
    --          </Employee>
    --          <Employee>
    --              <EmployeeID>1612dfee-37d2-4c5d-a7b9-187aee5f264a</EmployeeID>
    --              <FirstName>Sally </FirstName>
    --              <LastName>Martin</LastName>
    --              <Status>ACTIVE</Status>
    --              <Email>sm@madeup3993.com</Email>
    --              <DateOfBirth>1987-06-28T00:00:00</DateOfBirth>
    --              <Gender>F</Gender>
    --              <Phone>0400 123 456</Phone>
    --              <StartDate>2016-08-01T00:00:00</StartDate>
    --              <OrdinaryEarningsRateID>2c4fbb29-aa68-4a8d-bc05-3f6366f75227</OrdinaryEarningsRateID>
    --              <PayrollCalendarID>4c08f63d-53af-4521-a8be-1d77fc0faf45</PayrollCalendarID>
    --              <UpdatedDateUTC>2016-11-11T20:29:03</UpdatedDateUTC>
    --          </Employee>
    --          <Employee>
    --              <EmployeeID>2df65756-538b-4bc1-b0c3-f3971d86b650</EmployeeID>
    --              <FirstName>Sonia</FirstName>
    --              <LastName>Michaels</LastName>
    --              <Status>ACTIVE</Status>
    --              <Email>som@madeup3993.com</Email>
    --              <DateOfBirth>1989-08-24T00:00:00</DateOfBirth>
    --              <Gender>F</Gender>
    --              <Phone>02 2345 6789</Phone>
    --              <Mobile> </Mobile>
    --              <UpdatedDateUTC>2016-11-11T20:29:03</UpdatedDateUTC>
    --          </Employee>
    --          <Employee>
    --              <EmployeeID>08dcd870-3d8f-495f-af54-69029a89eb7d</EmployeeID>
    --              <FirstName>Tracy</FirstName>
    --              <LastName>Green</LastName>
    --              <Status>ACTIVE</Status>
    --              <Email>tg@madeup.email.com</Email>
    --              <DateOfBirth>1989-03-06T00:00:00</DateOfBirth>
    --              <Gender>F</Gender>
    --              <Phone>0402 123 456</Phone>
    --              <StartDate>2015-12-02T00:00:00</StartDate>
    --              <OrdinaryEarningsRateID>2c4fbb29-aa68-4a8d-bc05-3f6366f75227</OrdinaryEarningsRateID>
    --              <PayrollCalendarID>e53023e6-70f1-45c7-b699-6558b5e42b4e</PayrollCalendarID>
    --              <UpdatedDateUTC>2016-11-11T20:29:03</UpdatedDateUTC>
    --          </Employee>
    --      </Employees>
    --  </Response>

    EXEC @hr = sp_OADestroy @rest
    EXEC @hr = sp_OADestroy @sbXml
    EXEC @hr = sp_OADestroy @xml


END
GO

 

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