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

DataFlex Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
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)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(DataFlex) ETrade v1 List Transactions

Get information about the transactions in an ETrade brokerage account.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Handle hoJson
    Boolean iSuccess
    String sRespStr
    Integer iStatusCode
    Handle hoXml
    Integer i
    Integer iCount_i
    String sTagPath
    String sTransactionId
    Integer iAccountId
    String sTransactionDate
    String sPostDate
    Integer iAmount
    String sDescription
    Integer iDescription2
    String sTransactionType
    String sImageFlag
    String sInstType
    Integer iQuantity
    Integer iPrice
    String sSettlementCurrency
    String sPaymentCurrency
    Integer iFee
    String sSettlementDate
    String sDetailsURI
    String sPageMarkers
    String sMoreTransactions
    Integer iTransactionCount
    Integer iTotalCount
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Set ComOAuth1 Of hoHttp To True
    Set ComOAuthVerifier Of hoHttp To ""
    Set ComOAuthConsumerKey Of hoHttp To "ETRADE_CONSUMER_KEY"
    Set ComOAuthConsumerSecret Of hoHttp To "ETRADE_CONSUMER_SECRET"

    // Load the access token previously obtained via the OAuth1 3-Legged Authorization examples Step1 and Step2.
    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComLoadFile Of hoJson "qa_data/tokens/etrade.json" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Failed to load OAuth1 token"
        Procedure_Return
    End

    Get ComStringOf Of hoJson "oauth_token" To sTemp1
    Set ComOAuthToken Of hoHttp To sTemp1
    Get ComStringOf Of hoJson "oauth_token_secret" To sTemp1
    Set ComOAuthTokenSecret Of hoHttp To sTemp1

    // See the ETrade v1 API documentation HERE.

    Get ComSetUrlVar Of hoHttp "accountIdKey" "vsnhtF7d9jXxBy6HyaAC4vQ" To iSuccess
    Get ComQuickGetStr Of hoHttp "https://apisb.etrade.com/v1/accounts/{$accountIdKey}/transactions" To sRespStr
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // A 200 status code indicates success.
    Get ComLastStatus Of hoHttp To iStatusCode
    Showln "statusCode = " iStatusCode

    // Use the following online tool to generate parsing code from sample XML: 
    // Generate Parsing Code from XML

    // A sample XML response is shown below...

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Get ComLoadXml Of hoXml sRespStr To iSuccess

    Move 0 To i
    Get ComNumChildrenHavingTag Of hoXml "Transaction" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoXml To i
        Get ComGetChildContent Of hoXml "Transaction[i]|transactionId" To sTransactionId
        Get ComGetChildIntValue Of hoXml "Transaction[i]|accountId" To iAccountId
        Get ComGetChildContent Of hoXml "Transaction[i]|transactionDate" To sTransactionDate
        Get ComGetChildContent Of hoXml "Transaction[i]|postDate" To sPostDate
        Get ComGetChildIntValue Of hoXml "Transaction[i]|amount" To iAmount
        Get ComGetChildContent Of hoXml "Transaction[i]|description" To sDescription
        Get ComGetChildIntValue Of hoXml "Transaction[i]|description2" To iDescription2
        Get ComGetChildContent Of hoXml "Transaction[i]|transactionType" To sTransactionType
        Get ComGetChildContent Of hoXml "Transaction[i]|imageFlag" To sImageFlag
        Get ComGetChildContent Of hoXml "Transaction[i]|instType" To sInstType
        Get ComGetChildIntValue Of hoXml "Transaction[i]|brokerage|quantity" To iQuantity
        Get ComGetChildIntValue Of hoXml "Transaction[i]|brokerage|price" To iPrice
        Get ComGetChildContent Of hoXml "Transaction[i]|brokerage|settlementCurrency" To sSettlementCurrency
        Get ComGetChildContent Of hoXml "Transaction[i]|brokerage|paymentCurrency" To sPaymentCurrency
        Get ComGetChildIntValue Of hoXml "Transaction[i]|brokerage|fee" To iFee
        Get ComGetChildContent Of hoXml "Transaction[i]|brokerage|settlementDate" To sSettlementDate
        Get ComGetChildContent Of hoXml "Transaction[i]|detailsURI" To sDetailsURI
        Move i + 1 To i
    Loop

    Get ComGetChildContent Of hoXml "pageMarkers" To sPageMarkers
    Get ComGetChildContent Of hoXml "moreTransactions" To sMoreTransactions
    Get ComGetChildIntValue Of hoXml "transactionCount" To iTransactionCount
    Get ComGetChildIntValue Of hoXml "totalCount" To iTotalCount

    // <?xml version="1.0" encoding="UTF-8"?>
    // <TransactionListResponse>
    //    <Transaction>
    //       <transactionId>18165100001766</transactionId>
    //       <accountId>83564979</accountId>
    //       <transactionDate>1528948800000</transactionDate>
    //       <postDate>1528948800000</postDate>
    //       <amount>-2</amount>
    //       <description>ACH WITHDRAWL REFID:109187276;</description>
    //       <description2>109187276</description2>
    //       <transactionType>Transfer</transactionType>
    //       <memo />
    //       <imageFlag>false</imageFlag>
    //       <instType>BROKERAGE</instType>
    //       <brokerage>
    //          <product />
    //          <quantity>0</quantity>
    //          <price>0</price>
    //          <settlementCurrency>USD</settlementCurrency>
    //          <paymentCurrency>USD</paymentCurrency>
    //          <fee>0</fee>
    //          <settlementDate>1528948800000</settlementDate>
    //       </brokerage>
    //       <detailsURI>https://api.etrade.com/v1/accounts/yIFaUoJ81qyAhgxLWRQ42g/transactions/18165100001766</detailsURI>
    //    </Transaction>
    //    <Transaction>
    //       <transactionId>18158100000983</transactionId>
    //       <accountId>83564979</accountId>
    //       <transactionDate>1528344000000</transactionDate>
    //       <postDate>1528344000000</postDate>
    //       <amount>-2</amount>
    //       <description>ACH WITHDRAWL REFID:98655276;</description>
    //       <description2>98655276</description2>
    //       <transactionType>Transfer</transactionType>
    //       <memo />
    //       <imageFlag>false</imageFlag>
    //       <instType>BROKERAGE</instType>
    //       <brokerage>
    //          <product />
    //          <quantity>0</quantity>
    //          <price>0</price>
    //          <settlementCurrency>USD</settlementCurrency>
    //          <paymentCurrency>USD</paymentCurrency>
    //          <fee>0</fee>
    //          <settlementDate>1528344000000</settlementDate>
    //       </brokerage>
    //       <detailsURI>https://api.etrade.com/v1/accounts/yIFaUoJ81qyAhgxLWRQ42g/transactions/18158100000983</detailsURI>
    //    </Transaction>
    //    <pageMarkers>eNpTsAlITE91zi%2FNK%2FHMc04syi8tTs2xM7TRxybMpWATkl%2BSmBOUmpxflAKWtTO10ccQg6mDmwEyEE0EqAbE8SvNTUotCk4tLE3NS061M9Ax0DEEYgOIA9BkuRQgmjxTfDKLQUYoQAV8E4uyU4vsDC0MzUwNDYDA0NzMrKamBmIKVJYLphpiKsyTUB7IbH1kwwFa7F0D</pageMarkers>
    //    <moreTransactions>false</moreTransactions>
    //    <transactionCount>5</transactionCount>
    //    <totalCount>5</totalCount>
    // </TransactionListResponse


End_Procedure

 

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