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

DataFlex 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
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

 

 

 

(DataFlex) Xero Add a Payroll Timesheet with Lines

Demonstrates how to POST a timesheet with lines (for Xero Payroll).

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

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Handle hoXml
    String sTagPath
    String sResponseXml
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // 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.

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    // 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..

    // --------------------------------------------------------------
    // Build the following XML:

    // 	<Timesheets> 
    // 	  <Timesheet>  
    // 	    <EmployeeID>1f606d28-0537-42af-80ce-312d449458af</EmployeeID> 
    // 	    <StartDate>2016-11-22</StartDate> 
    // 	    <EndDate>2016-11-28</EndDate> 
    // 	    <Status>Draft</Status> 
    // 	    <TimesheetLines> 
    // 	        <TimesheetLine> 
    // 	            <EarningsRateID>2c4fbb29-aa68-4a8d-bc05-3f6366f75227</EarningsRateID> 
    // 	            <NumberOfUnits> 
    // 	                <NumberOfUnit>8.00</NumberOfUnit> 
    // 	                <NumberOfUnit>8.00</NumberOfUnit> 
    // 	                <NumberOfUnit>8.00</NumberOfUnit> 
    // 	                <NumberOfUnit>8.00</NumberOfUnit> 
    // 	                <NumberOfUnit>8.00</NumberOfUnit> 
    // 	                <NumberOfUnit>0.00</NumberOfUnit> 
    // 	                <NumberOfUnit>0.00</NumberOfUnit> 
    // 	            </NumberOfUnits> 
    // 	        </TimesheetLine> 
    // 	    </TimesheetLines> 
    // 	  </Timesheet> 
    // 	</Timesheets>  

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Set ComTag Of hoXml To "Timesheets"
    Send ComNewChild2 To hoXml "Timesheet|EmployeeID" "1f606d28-0537-42af-80ce-312d449458af"
    Send ComNewChild2 To hoXml "Timesheet|StartDate" "2016-11-22"
    Send ComNewChild2 To hoXml "Timesheet|EndDate" "2016-11-28"
    Send ComNewChild2 To hoXml "Timesheet|Status" "Draft"
    Send ComNewChild2 To hoXml "Timesheet|TimesheetLines|TimesheetLine|EarningsRateID" "2c4fbb29-aa68-4a8d-bc05-3f6366f75227"
    Move "Timesheet|TimesheetLines|TimesheetLine|NumberOfUnits|NumberOfUnit" To sTagPath
    Send ComNewChild2 To hoXml sTagPath "8.00"
    Send ComNewChild2 To hoXml sTagPath "8.00"
    Send ComNewChild2 To hoXml sTagPath "8.00"
    Send ComNewChild2 To hoXml sTagPath "8.00"
    Send ComNewChild2 To hoXml sTagPath "8.00"
    Send ComNewChild2 To hoXml sTagPath "0.00"
    Send ComNewChild2 To hoXml sTagPath "0.00"

    // Do not emit the XML declarator. Xero does not accept the XML if it
    // has the initial line: <?xml version="1.0" encoding="utf-8"?>
    Set ComEmitXmlDecl Of hoXml To False
    Get ComGetXml Of hoXml To sTemp1
    Showln sTemp1
    Showln "--"

    Set ComEmitCompact Of hoXml To True

    Get ComGetXml Of hoXml To sTemp1
    Get ComAddQueryParam Of hoRest "xml" sTemp1 To iSuccess

    Get ComFullRequestFormUrlEncoded Of hoRest "POST" "/payroll.xro/1.0/Timesheets" To sResponseXml
    Get ComLastMethodSuccess Of hoRest To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // A 200 response is expected for actual success.
    Get ComResponseStatusCode Of hoRest To iTemp1
    If (iTemp1 <> 200) Begin
        Showln sResponseXml
        Procedure_Return
    End

    // Examine the XML response
    Get ComLoadXml Of hoXml sResponseXml To iSuccess
    Get ComGetXml Of hoXml To sTemp1
    Showln sTemp1

    // A successful XML response is as follows:

    // 	<Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    // 	    <Id>f213ed01-5a70-4adf-b11f-1aa0c74b96ac</Id>
    // 	    <Status>OK</Status>
    // 	    <ProviderName>ChilkatAU</ProviderName>
    // 	    <DateTimeUTC>2016-11-11T22:39:10.2293174Z</DateTimeUTC>
    // 	    <Timesheets>
    // 	        <Timesheet>
    // 	            <TimesheetID>f62b4437-62b8-4d21-b0c6-791999652712</TimesheetID>
    // 	            <EmployeeID>1f606d28-0537-42af-80ce-312d449458af</EmployeeID>
    // 	            <StartDate>2016-11-22T00:00:00</StartDate>
    // 	            <EndDate>2016-11-28T00:00:00</EndDate>
    // 	            <Status>DRAFT</Status>
    // 	            <Hours>40.00</Hours>
    // 	            <TimesheetLines>
    // 	                <TimesheetLine>
    // 	                    <EarningsRateID>2c4fbb29-aa68-4a8d-bc05-3f6366f75227</EarningsRateID>
    // 	                    <NumberOfUnits>
    // 	                        <NumberOfUnit>8.00</NumberOfUnit>
    // 	                        <NumberOfUnit>8.00</NumberOfUnit>
    // 	                        <NumberOfUnit>8.00</NumberOfUnit>
    // 	                        <NumberOfUnit>8.00</NumberOfUnit>
    // 	                        <NumberOfUnit>8.00</NumberOfUnit>
    // 	                        <NumberOfUnit>0.00</NumberOfUnit>
    // 	                        <NumberOfUnit>0.00</NumberOfUnit>
    // 	                    </NumberOfUnits>
    // 	                    <UpdatedDateUTC>2016-11-11T22:39:10.1824429</UpdatedDateUTC>
    // 	                </TimesheetLine>
    // 	            </TimesheetLines>
    // 	            <UpdatedDateUTC>2016-11-11T22:39:10.1824429</UpdatedDateUTC>
    // 	        </Timesheet>
    // 	    </Timesheets>
    // 	</Response


End_Procedure

 

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