PowerBuilder
PowerBuilder
ETrade List Transactions
See more ETrade Examples
Gets transactions for the selected brokerage account.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_JsonToken
string ls_SandboxUrl
string ls_LiveUrl
oleobject loo_Resp
oleobject loo_Xml
string ls_TransactionId
integer li_AccountId
string ls_TransactionDate
string ls_PostDate
integer li_Amount
string ls_Description
integer li_Description2
string ls_TransactionType
string ls_ImageFlag
string ls_InstType
integer li_Quantity
integer li_Price
string ls_SettlementCurrency
string ls_PaymentCurrency
integer li_Fee
string ls_SettlementDate
string ls_DetailsURI
string ls_PageMarkers
string ls_MoreTransactions
integer li_TransactionCount
integer li_TotalCount
integer i
integer li_Count_i
li_Success = 0
// This requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
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
loo_Http.OAuth1 = 1
loo_Http.OAuthVerifier = ""
loo_Http.OAuthConsumerKey = "ETRADE_CONSUMER_KEY"
loo_Http.OAuthConsumerSecret = "ETRADE_CONSUMER_SECRET"
// Load the access token previously obtained via the OAuth1 Authorization
loo_JsonToken = create oleobject
li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_JsonToken.LoadFile("qa_data/tokens/etrade.json")
if li_Success <> 1 then
Write-Debug "Failed to load OAuth1 token"
destroy loo_Http
destroy loo_JsonToken
return
end if
loo_Http.OAuthToken = loo_JsonToken.StringOf("oauth_token")
loo_Http.OAuthTokenSecret = loo_JsonToken.StringOf("oauth_token_secret")
ls_SandboxUrl = "https://apisb.etrade.com/v1/accounts/{$accountIdKey}/transactions"
ls_LiveUrl = "https://api.etrade.com/v1/accounts/{$accountIdKey}/transactions"
loo_Http.SetUrlVar("accountIdKey","6_Dpy0rmuQ9cu9IbTfvF2A")
loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")
li_Success = loo_Http.HttpNoBody("GET",ls_SandboxUrl,loo_Resp)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_JsonToken
destroy loo_Resp
return
end if
// Make sure a successful response was received.
if loo_Resp.StatusCode > 200 then
Write-Debug loo_Resp.StatusLine
Write-Debug loo_Resp.Header
Write-Debug loo_Resp.BodyStr
destroy loo_Http
destroy loo_JsonToken
destroy loo_Resp
return
end if
// Sample XML response:
// Use this online tool to generate parsing code from sample XML:
// Generate Parsing Code from XML
// <?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>
loo_Xml = create oleobject
li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml")
loo_Xml.LoadXml(loo_Resp.BodyStr)
Write-Debug loo_Xml.GetXml()
i = 0
li_Count_i = loo_Xml.NumChildrenHavingTag("Transaction")
do while i < li_Count_i
loo_Xml.I = i
ls_TransactionId = loo_Xml.GetChildContent("Transaction[i]|transactionId")
li_AccountId = loo_Xml.GetChildIntValue("Transaction[i]|accountId")
ls_TransactionDate = loo_Xml.GetChildContent("Transaction[i]|transactionDate")
ls_PostDate = loo_Xml.GetChildContent("Transaction[i]|postDate")
li_Amount = loo_Xml.GetChildIntValue("Transaction[i]|amount")
ls_Description = loo_Xml.GetChildContent("Transaction[i]|description")
li_Description2 = loo_Xml.GetChildIntValue("Transaction[i]|description2")
ls_TransactionType = loo_Xml.GetChildContent("Transaction[i]|transactionType")
ls_ImageFlag = loo_Xml.GetChildContent("Transaction[i]|imageFlag")
ls_InstType = loo_Xml.GetChildContent("Transaction[i]|instType")
li_Quantity = loo_Xml.GetChildIntValue("Transaction[i]|brokerage|quantity")
li_Price = loo_Xml.GetChildIntValue("Transaction[i]|brokerage|price")
ls_SettlementCurrency = loo_Xml.GetChildContent("Transaction[i]|brokerage|settlementCurrency")
ls_PaymentCurrency = loo_Xml.GetChildContent("Transaction[i]|brokerage|paymentCurrency")
li_Fee = loo_Xml.GetChildIntValue("Transaction[i]|brokerage|fee")
ls_SettlementDate = loo_Xml.GetChildContent("Transaction[i]|brokerage|settlementDate")
ls_DetailsURI = loo_Xml.GetChildContent("Transaction[i]|detailsURI")
i = i + 1
loop
ls_PageMarkers = loo_Xml.GetChildContent("pageMarkers")
ls_MoreTransactions = loo_Xml.GetChildContent("moreTransactions")
li_TransactionCount = loo_Xml.GetChildIntValue("transactionCount")
li_TotalCount = loo_Xml.GetChildIntValue("totalCount")
Write-Debug "Success."
destroy loo_Http
destroy loo_JsonToken
destroy loo_Resp
destroy loo_Xml