snaptrade 3.0.59 → 3.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +63 -2
- data/lib/snaptrade/api/account_information_api.rb +154 -0
- data/lib/snaptrade/models/account_transactions_response.rb +239 -0
- data/lib/snaptrade/models/account_transactions_response_pagination.rb +244 -0
- data/lib/snaptrade/models/activity.rb +351 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +3 -0
- data/spec/api/account_information_api_spec.rb +19 -0
- data/spec/models/account_transactions_response_pagination_spec.rb +41 -0
- data/spec/models/account_transactions_response_spec.rb +35 -0
- data/spec/models/activity_spec.rb +89 -0
- metadata +302 -293
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff9bff09706d84fbbb1a951f55e874c000a4a56cf09f8d82c13898bd80a41562
|
|
4
|
+
data.tar.gz: 03bd2ebc53576ae493cddd7acb865b9468bb0178252fa46a68b424e81fed1248
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 56013af1c2ebaffbe8cbeea301d4c8f9b0a141387d4c9ca1e04aa156808ed2bbd4cc7f1b95308cf28b14d20120657f5b991d5320023be396a6787d276f0eafd6
|
|
7
|
+
data.tar.gz: 365b0ae84e13dc96f75033b50601f4c1fc6a0f4e96664f46f37dabaf2ff116158282ac5d27fce9d091ab0c119041dcd6cd0403a8dc092b1de4ad628e700624b0
|
data/README.md
CHANGED
|
@@ -63,7 +63,7 @@ backoff with jitter rather than from the headers.
|
|
|
63
63
|
See https://docs.snaptrade.com/docs/ratelimiting.
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
[](https://rubygems.org/gems/snaptrade/versions/3.0.61)
|
|
67
67
|
[](https://snaptrade.com/)
|
|
68
68
|
|
|
69
69
|
</div>
|
|
@@ -81,6 +81,7 @@ See https://docs.snaptrade.com/docs/ratelimiting.
|
|
|
81
81
|
* [`snaptrade.account_information.get_account_balances_v2`](#snaptradeaccount_informationget_account_balances_v2)
|
|
82
82
|
* [`snaptrade.account_information.get_account_details`](#snaptradeaccount_informationget_account_details)
|
|
83
83
|
* [`snaptrade.account_information.get_account_order`](#snaptradeaccount_informationget_account_order)
|
|
84
|
+
* [`snaptrade.account_information.get_account_transactions`](#snaptradeaccount_informationget_account_transactions)
|
|
84
85
|
* [`snaptrade.account_information.get_all_account_orders`](#snaptradeaccount_informationget_all_account_orders)
|
|
85
86
|
* [`snaptrade.account_information.get_all_account_positions`](#snaptradeaccount_informationget_all_account_positions)
|
|
86
87
|
* [`snaptrade.account_information.get_all_account_recent_orders`](#snaptradeaccount_informationget_all_account_recent_orders)
|
|
@@ -149,7 +150,7 @@ See https://docs.snaptrade.com/docs/ratelimiting.
|
|
|
149
150
|
Add to Gemfile:
|
|
150
151
|
|
|
151
152
|
```ruby
|
|
152
|
-
gem 'snaptrade', '~> 3.0.
|
|
153
|
+
gem 'snaptrade', '~> 3.0.61'
|
|
153
154
|
```
|
|
154
155
|
|
|
155
156
|
## Getting Started<a id="getting-started"></a>
|
|
@@ -445,6 +446,66 @@ p result
|
|
|
445
446
|
---
|
|
446
447
|
|
|
447
448
|
|
|
449
|
+
### `snaptrade.account_information.get_account_transactions`<a id="snaptradeaccount_informationget_account_transactions"></a>
|
|
450
|
+
|
|
451
|
+
Returns the account's cached transaction history, most recent trade date first. Transactions with the same timestamp are ordered by descending internal activity ID.
|
|
452
|
+
|
|
453
|
+
History refreshes daily. Timing and available history depend on the brokerage. A disabled connection continues to return its last cached history.
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
|
457
|
+
|
|
458
|
+
```ruby
|
|
459
|
+
result = snaptrade.account_information.get_account_transactions(
|
|
460
|
+
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
461
|
+
user_id: "snaptrade-user-123",
|
|
462
|
+
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
463
|
+
start_date: "2022-01-24",
|
|
464
|
+
end_date: "2022-01-24",
|
|
465
|
+
type: "BUY,DIVIDEND",
|
|
466
|
+
offset: 0,
|
|
467
|
+
limit: 1000,
|
|
468
|
+
)
|
|
469
|
+
p result
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
473
|
+
|
|
474
|
+
##### account_id: `String`<a id="account_id-string"></a>
|
|
475
|
+
##### user_id: `String`<a id="user_id-string"></a>
|
|
476
|
+
##### user_secret: `String`<a id="user_secret-string"></a>
|
|
477
|
+
##### start_date: `Date`<a id="start_date-date"></a>
|
|
478
|
+
First trade date to include (UTC). Defaults to the earliest available
|
|
479
|
+
transaction.
|
|
480
|
+
|
|
481
|
+
##### end_date: `Date`<a id="end_date-date"></a>
|
|
482
|
+
Last trade date to include (UTC). Defaults to the latest available transaction.
|
|
483
|
+
|
|
484
|
+
##### type: `String`<a id="type-string"></a>
|
|
485
|
+
Comma-separated activity types. A transaction matches its base type or its
|
|
486
|
+
option action, case-insensitively. For example, BUY includes opening and closing
|
|
487
|
+
option purchases, while BUY_TO_OPEN selects only opening purchases. A
|
|
488
|
+
transaction matching multiple values appears once.
|
|
489
|
+
|
|
490
|
+
##### offset: `Integer`<a id="offset-integer"></a>
|
|
491
|
+
Number of matching transactions to skip.
|
|
492
|
+
|
|
493
|
+
##### limit: `Integer`<a id="limit-integer"></a>
|
|
494
|
+
Maximum number of transactions to return in this page.
|
|
495
|
+
|
|
496
|
+
#### 🔄 Return<a id="🔄-return"></a>
|
|
497
|
+
|
|
498
|
+
[AccountTransactionsResponse](./lib/snaptrade/models/account_transactions_response.rb)
|
|
499
|
+
|
|
500
|
+
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
|
501
|
+
|
|
502
|
+
`/accounts/{accountId}/transactions` `GET`
|
|
503
|
+
|
|
504
|
+
[🔙 **Back to Table of Contents**](#table-of-contents)
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
|
|
448
509
|
### `snaptrade.account_information.get_all_account_orders`<a id="snaptradeaccount_informationget_all_account_orders"></a>
|
|
449
510
|
|
|
450
511
|
Returns a list of recent orders in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/positions/all`.
|
|
@@ -659,6 +659,160 @@ module SnapTrade
|
|
|
659
659
|
end
|
|
660
660
|
|
|
661
661
|
|
|
662
|
+
# List account transactions
|
|
663
|
+
#
|
|
664
|
+
# Returns the account's cached transaction history, most recent trade date first. Transactions with the same timestamp are ordered by descending internal activity ID.
|
|
665
|
+
#
|
|
666
|
+
# History refreshes daily. Timing and available history depend on the brokerage. A disabled connection continues to return its last cached history.
|
|
667
|
+
#
|
|
668
|
+
# @param account_id [String]
|
|
669
|
+
# @param user_id [String]
|
|
670
|
+
# @param user_secret [String]
|
|
671
|
+
# @param start_date [Date] First trade date to include (UTC). Defaults to the earliest available transaction.
|
|
672
|
+
# @param end_date [Date] Last trade date to include (UTC). Defaults to the latest available transaction.
|
|
673
|
+
# @param type [String] Comma-separated activity types. A transaction matches its base type or its option action, case-insensitively. For example, BUY includes opening and closing option purchases, while BUY_TO_OPEN selects only opening purchases. A transaction matching multiple values appears once.
|
|
674
|
+
# @param offset [Integer] Number of matching transactions to skip.
|
|
675
|
+
# @param limit [Integer] Maximum number of transactions to return in this page.
|
|
676
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
677
|
+
def get_account_transactions(account_id:, user_id:, user_secret:, start_date: SENTINEL, end_date: SENTINEL, type: SENTINEL, offset: 0, limit: 1000, extra: {})
|
|
678
|
+
extra[:start_date] = start_date if start_date != SENTINEL
|
|
679
|
+
extra[:end_date] = end_date if end_date != SENTINEL
|
|
680
|
+
extra[:type] = type if type != SENTINEL
|
|
681
|
+
extra[:offset] = offset if offset != SENTINEL
|
|
682
|
+
extra[:limit] = limit if limit != SENTINEL
|
|
683
|
+
data, _status_code, _headers = get_account_transactions_with_http_info_impl(account_id, user_id, user_secret, extra)
|
|
684
|
+
data
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
# List account transactions
|
|
688
|
+
#
|
|
689
|
+
# Returns the account's cached transaction history, most recent trade date first. Transactions with the same timestamp are ordered by descending internal activity ID.
|
|
690
|
+
#
|
|
691
|
+
# History refreshes daily. Timing and available history depend on the brokerage. A disabled connection continues to return its last cached history.
|
|
692
|
+
#
|
|
693
|
+
# @param account_id [String]
|
|
694
|
+
# @param user_id [String]
|
|
695
|
+
# @param user_secret [String]
|
|
696
|
+
# @param start_date [Date] First trade date to include (UTC). Defaults to the earliest available transaction.
|
|
697
|
+
# @param end_date [Date] Last trade date to include (UTC). Defaults to the latest available transaction.
|
|
698
|
+
# @param type [String] Comma-separated activity types. A transaction matches its base type or its option action, case-insensitively. For example, BUY includes opening and closing option purchases, while BUY_TO_OPEN selects only opening purchases. A transaction matching multiple values appears once.
|
|
699
|
+
# @param offset [Integer] Number of matching transactions to skip.
|
|
700
|
+
# @param limit [Integer] Maximum number of transactions to return in this page.
|
|
701
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
702
|
+
def get_account_transactions_with_http_info(account_id:, user_id:, user_secret:, start_date: SENTINEL, end_date: SENTINEL, type: SENTINEL, offset: 0, limit: 1000, extra: {})
|
|
703
|
+
extra[:start_date] = start_date if start_date != SENTINEL
|
|
704
|
+
extra[:end_date] = end_date if end_date != SENTINEL
|
|
705
|
+
extra[:type] = type if type != SENTINEL
|
|
706
|
+
extra[:offset] = offset if offset != SENTINEL
|
|
707
|
+
extra[:limit] = limit if limit != SENTINEL
|
|
708
|
+
get_account_transactions_with_http_info_impl(account_id, user_id, user_secret, extra)
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
# List account transactions
|
|
712
|
+
# Returns the account's cached transaction history, most recent trade date first. Transactions with the same timestamp are ordered by descending internal activity ID. History refreshes daily. Timing and available history depend on the brokerage. A disabled connection continues to return its last cached history.
|
|
713
|
+
# @param account_id [String]
|
|
714
|
+
# @param user_id [String]
|
|
715
|
+
# @param user_secret [String]
|
|
716
|
+
# @param [Hash] opts the optional parameters
|
|
717
|
+
# @option opts [Date] :start_date First trade date to include (UTC). Defaults to the earliest available transaction.
|
|
718
|
+
# @option opts [Date] :end_date Last trade date to include (UTC). Defaults to the latest available transaction.
|
|
719
|
+
# @option opts [String] :type Comma-separated activity types. A transaction matches its base type or its option action, case-insensitively. For example, BUY includes opening and closing option purchases, while BUY_TO_OPEN selects only opening purchases. A transaction matching multiple values appears once.
|
|
720
|
+
# @option opts [Integer] :offset Number of matching transactions to skip. (default to 0)
|
|
721
|
+
# @option opts [Integer] :limit Maximum number of transactions to return in this page. (default to 1000)
|
|
722
|
+
# @return [AccountTransactionsResponse]
|
|
723
|
+
private def get_account_transactions_impl(account_id, user_id, user_secret, opts = {})
|
|
724
|
+
data, _status_code, _headers = get_account_transactions_with_http_info(account_id, user_id, user_secret, opts)
|
|
725
|
+
data
|
|
726
|
+
end
|
|
727
|
+
|
|
728
|
+
# List account transactions
|
|
729
|
+
# Returns the account's cached transaction history, most recent trade date first. Transactions with the same timestamp are ordered by descending internal activity ID. History refreshes daily. Timing and available history depend on the brokerage. A disabled connection continues to return its last cached history.
|
|
730
|
+
# @param account_id [String]
|
|
731
|
+
# @param user_id [String]
|
|
732
|
+
# @param user_secret [String]
|
|
733
|
+
# @param [Hash] opts the optional parameters
|
|
734
|
+
# @option opts [Date] :start_date First trade date to include (UTC). Defaults to the earliest available transaction.
|
|
735
|
+
# @option opts [Date] :end_date Last trade date to include (UTC). Defaults to the latest available transaction.
|
|
736
|
+
# @option opts [String] :type Comma-separated activity types. A transaction matches its base type or its option action, case-insensitively. For example, BUY includes opening and closing option purchases, while BUY_TO_OPEN selects only opening purchases. A transaction matching multiple values appears once.
|
|
737
|
+
# @option opts [Integer] :offset Number of matching transactions to skip. (default to 0)
|
|
738
|
+
# @option opts [Integer] :limit Maximum number of transactions to return in this page. (default to 1000)
|
|
739
|
+
# @return [Array<(AccountTransactionsResponse, Integer, Hash)>] AccountTransactionsResponse data, response status code and response headers
|
|
740
|
+
private def get_account_transactions_with_http_info_impl(account_id, user_id, user_secret, opts = {})
|
|
741
|
+
if @api_client.config.debugging
|
|
742
|
+
@api_client.config.logger.debug 'Calling API: AccountInformationApi.get_account_transactions ...'
|
|
743
|
+
end
|
|
744
|
+
# verify the required parameter 'account_id' is set
|
|
745
|
+
if @api_client.config.client_side_validation && account_id.nil?
|
|
746
|
+
fail ArgumentError, "Missing the required parameter 'account_id' when calling AccountInformationApi.get_account_transactions"
|
|
747
|
+
end
|
|
748
|
+
# verify the required parameter 'user_id' is set
|
|
749
|
+
if @api_client.config.client_side_validation && user_id.nil?
|
|
750
|
+
fail ArgumentError, "Missing the required parameter 'user_id' when calling AccountInformationApi.get_account_transactions"
|
|
751
|
+
end
|
|
752
|
+
# verify the required parameter 'user_secret' is set
|
|
753
|
+
if @api_client.config.client_side_validation && user_secret.nil?
|
|
754
|
+
fail ArgumentError, "Missing the required parameter 'user_secret' when calling AccountInformationApi.get_account_transactions"
|
|
755
|
+
end
|
|
756
|
+
if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
|
|
757
|
+
fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling AccountInformationApi.get_account_transactions, must be greater than or equal to 0.'
|
|
758
|
+
end
|
|
759
|
+
|
|
760
|
+
if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
|
|
761
|
+
fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling AccountInformationApi.get_account_transactions, must be smaller than or equal to 1000.'
|
|
762
|
+
end
|
|
763
|
+
|
|
764
|
+
if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
|
|
765
|
+
fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling AccountInformationApi.get_account_transactions, must be greater than or equal to 1.'
|
|
766
|
+
end
|
|
767
|
+
|
|
768
|
+
# resource path
|
|
769
|
+
local_var_path = '/accounts/{accountId}/transactions'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
|
|
770
|
+
|
|
771
|
+
# query parameters
|
|
772
|
+
query_params = opts[:query_params] || {}
|
|
773
|
+
query_params[:'userId'] = user_id
|
|
774
|
+
query_params[:'userSecret'] = user_secret
|
|
775
|
+
query_params[:'startDate'] = opts[:'start_date'] if !opts[:'start_date'].nil?
|
|
776
|
+
query_params[:'endDate'] = opts[:'end_date'] if !opts[:'end_date'].nil?
|
|
777
|
+
query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
|
|
778
|
+
query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
|
|
779
|
+
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
|
|
780
|
+
|
|
781
|
+
# header parameters
|
|
782
|
+
header_params = opts[:header_params] || {}
|
|
783
|
+
# HTTP header 'Accept' (if needed)
|
|
784
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
|
785
|
+
|
|
786
|
+
# form parameters
|
|
787
|
+
form_params = opts[:form_params] || {}
|
|
788
|
+
|
|
789
|
+
# http body (model)
|
|
790
|
+
post_body = opts[:debug_body]
|
|
791
|
+
|
|
792
|
+
# return_type
|
|
793
|
+
return_type = opts[:debug_return_type] || 'AccountTransactionsResponse'
|
|
794
|
+
|
|
795
|
+
# auth_names
|
|
796
|
+
auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
|
|
797
|
+
|
|
798
|
+
new_options = opts.merge(
|
|
799
|
+
:operation => :"AccountInformationApi.get_account_transactions",
|
|
800
|
+
:header_params => header_params,
|
|
801
|
+
:query_params => query_params,
|
|
802
|
+
:form_params => form_params,
|
|
803
|
+
:body => post_body,
|
|
804
|
+
:auth_names => auth_names,
|
|
805
|
+
:return_type => return_type
|
|
806
|
+
)
|
|
807
|
+
|
|
808
|
+
data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options)
|
|
809
|
+
if @api_client.config.debugging
|
|
810
|
+
@api_client.config.logger.debug "API called: AccountInformationApi#get_account_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
811
|
+
end
|
|
812
|
+
return data, status_code, headers, response
|
|
813
|
+
end
|
|
814
|
+
|
|
815
|
+
|
|
662
816
|
# List all account orders
|
|
663
817
|
#
|
|
664
818
|
# Returns a list of recent orders in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/positions/all`.
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#SnapTrade
|
|
3
|
+
|
|
4
|
+
#Connect brokerage accounts to your app for live positions and trading. ## Rate limiting Two limits apply to requests signed with your `clientId`. The stricter one wins, and exceeding either returns `429 Too Many Requests`. - **Customer-level** — 250 requests/minute by default, scoped to your `clientId` and applied across all endpoints. Reported in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. - **Account-level** — 10 requests/minute per account, scoped to (`clientId`, `accountId`). All covered operations for one account draw on the same bucket — reading balances and reading positions share it — and enforcement does not depend on the HTTP method, so updating an account consumes the same bucket as reading it. Only enforced for Personal users, and only for integrations it has been rolled out to — it is not yet in force for every Personal integration. It also does not apply on every operation that documents a 429 below. Where it applies it is reported in `X-RateLimit-Account-Limit`, `X-RateLimit-Account-Remaining` and `X-RateLimit-Account-Reset`. Do not read the absence of those headers as proof the limit is off — some configurations omit the rate limit headers while still enforcing the limit, so header absence tells you nothing about your allowance. On a 429, `X-RateLimit-Remaining: 0` means you hit the customer-level limit and `X-RateLimit-Account-Remaining: 0` means the account-level one. Wait for the corresponding `*-Reset` value (seconds) before retrying, or fall back to exponential backoff with jitter. Not every 429 is explained by those headers. A separate per-authenticated-user limit, reported in no `X-RateLimit-*` header, covers OAuth-authenticated requests and signed requests in configurations where the customer-level limit is not in effect — on the operations that use the default throttles. A few operations override those and are governed by the customer-level limit alone. The two do not stack: a signed request governed by the customer-level limit above is not additionally subject to the per-user one. If a 429 arrives with no header at zero — or with no `X-RateLimit-*` headers at all — honour `Retry-After` and back off. Treat the remaining counts as a hint, not a guarantee that the next request will succeed. Because the customer-level limit applies everywhere, any signed request can return 429. **OAuth-authenticated requests are an exception.** They are not subject to the customer-level limit and do not receive `X-RateLimit-Limit`, `X-RateLimit-Remaining` or `X-RateLimit-Reset` — do not wait on those headers or design around a customer-level allowance on this path. The account-level limit still applies to them on the account-data endpoints above, reported in the `X-RateLimit-Account-*` headers. On operations using the default throttles the per-user limit above applies to them as well, so an OAuth request can be rejected while the account headers still show capacity; on the few operations that override those throttles, OAuth callers have no per-user ceiling at all. Drive retries from `Retry-After` and exponential backoff with jitter rather than from the headers. See https://docs.snaptrade.com/docs/ratelimiting.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: api@snaptrade.com
|
|
8
|
+
=end
|
|
9
|
+
|
|
10
|
+
require 'date'
|
|
11
|
+
require 'time'
|
|
12
|
+
|
|
13
|
+
module SnapTrade
|
|
14
|
+
# A page of account transactions.
|
|
15
|
+
class AccountTransactionsResponse
|
|
16
|
+
# Matching transactions in descending date order.
|
|
17
|
+
attr_accessor :data
|
|
18
|
+
|
|
19
|
+
attr_accessor :pagination
|
|
20
|
+
|
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
22
|
+
def self.attribute_map
|
|
23
|
+
{
|
|
24
|
+
:'data' => :'data',
|
|
25
|
+
:'pagination' => :'pagination'
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Returns all the JSON keys this model knows about
|
|
30
|
+
def self.acceptable_attributes
|
|
31
|
+
attribute_map.values
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Attribute type mapping.
|
|
35
|
+
def self.openapi_types
|
|
36
|
+
{
|
|
37
|
+
:'data' => :'Array<Activity>',
|
|
38
|
+
:'pagination' => :'AccountTransactionsResponsePagination'
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# List of attributes with nullable: true
|
|
43
|
+
def self.openapi_nullable
|
|
44
|
+
Set.new([
|
|
45
|
+
])
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Initializes the object
|
|
49
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
50
|
+
def initialize(attributes = {})
|
|
51
|
+
if (!attributes.is_a?(Hash))
|
|
52
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::AccountTransactionsResponse` initialize method"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
56
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
57
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
58
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::AccountTransactionsResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
59
|
+
end
|
|
60
|
+
h[k.to_sym] = v
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if attributes.key?(:'data')
|
|
64
|
+
if (value = attributes[:'data']).is_a?(Array)
|
|
65
|
+
self.data = value
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
if attributes.key?(:'pagination')
|
|
70
|
+
self.pagination = attributes[:'pagination']
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
75
|
+
# @return Array for valid properties with the reasons
|
|
76
|
+
def list_invalid_properties
|
|
77
|
+
invalid_properties = Array.new
|
|
78
|
+
if @data.nil?
|
|
79
|
+
invalid_properties.push('invalid value for "data", data cannot be nil.')
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if @pagination.nil?
|
|
83
|
+
invalid_properties.push('invalid value for "pagination", pagination cannot be nil.')
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
invalid_properties
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Check to see if the all the properties in the model are valid
|
|
90
|
+
# @return true if the model is valid
|
|
91
|
+
def valid?
|
|
92
|
+
return false if @data.nil?
|
|
93
|
+
return false if @pagination.nil?
|
|
94
|
+
true
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Checks equality by comparing each attribute.
|
|
98
|
+
# @param [Object] Object to be compared
|
|
99
|
+
def ==(o)
|
|
100
|
+
return true if self.equal?(o)
|
|
101
|
+
self.class == o.class &&
|
|
102
|
+
data == o.data &&
|
|
103
|
+
pagination == o.pagination
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# @see the `==` method
|
|
107
|
+
# @param [Object] Object to be compared
|
|
108
|
+
def eql?(o)
|
|
109
|
+
self == o
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Calculates hash code according to all attributes.
|
|
113
|
+
# @return [Integer] Hash code
|
|
114
|
+
def hash
|
|
115
|
+
[data, pagination].hash
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Builds the object from hash
|
|
119
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
120
|
+
# @return [Object] Returns the model itself
|
|
121
|
+
def self.build_from_hash(attributes)
|
|
122
|
+
new.build_from_hash(attributes)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Builds the object from hash
|
|
126
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
127
|
+
# @return [Object] Returns the model itself
|
|
128
|
+
def build_from_hash(attributes)
|
|
129
|
+
return nil unless attributes.is_a?(Hash)
|
|
130
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
131
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
132
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
133
|
+
self.send("#{key}=", nil)
|
|
134
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
135
|
+
# check to ensure the input is an array given that the attribute
|
|
136
|
+
# is documented as an array but the input is not
|
|
137
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
138
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
139
|
+
end
|
|
140
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
141
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
self
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Deserializes the data based on type
|
|
149
|
+
# @param string type Data type
|
|
150
|
+
# @param string value Value to be deserialized
|
|
151
|
+
# @return [Object] Deserialized data
|
|
152
|
+
def _deserialize(type, value)
|
|
153
|
+
case type.to_sym
|
|
154
|
+
when :Time
|
|
155
|
+
Time.parse(value)
|
|
156
|
+
when :Date
|
|
157
|
+
Date.parse(value)
|
|
158
|
+
when :String
|
|
159
|
+
value.to_s
|
|
160
|
+
when :Integer
|
|
161
|
+
value.to_i
|
|
162
|
+
when :Float
|
|
163
|
+
value.to_f
|
|
164
|
+
when :Boolean
|
|
165
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
166
|
+
true
|
|
167
|
+
else
|
|
168
|
+
false
|
|
169
|
+
end
|
|
170
|
+
when :Object
|
|
171
|
+
# generic object (usually a Hash), return directly
|
|
172
|
+
value
|
|
173
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
174
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
175
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
176
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
177
|
+
k_type = Regexp.last_match[:k_type]
|
|
178
|
+
v_type = Regexp.last_match[:v_type]
|
|
179
|
+
{}.tap do |hash|
|
|
180
|
+
value.each do |k, v|
|
|
181
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
else # model
|
|
185
|
+
# models (e.g. Pet) or oneOf
|
|
186
|
+
klass = SnapTrade.const_get(type)
|
|
187
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Returns the string representation of the object
|
|
192
|
+
# @return [String] String presentation of the object
|
|
193
|
+
def to_s
|
|
194
|
+
to_hash.to_s
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
|
199
|
+
def to_body
|
|
200
|
+
to_hash
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Returns the object in the form of hash
|
|
204
|
+
# @return [Hash] Returns the object in the form of hash
|
|
205
|
+
def to_hash
|
|
206
|
+
hash = {}
|
|
207
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
208
|
+
value = self.send(attr)
|
|
209
|
+
if value.nil?
|
|
210
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
211
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
hash[param] = _to_hash(value)
|
|
215
|
+
end
|
|
216
|
+
hash
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Outputs non-array value in the form of hash
|
|
220
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
221
|
+
# @param [Object] value Any valid value
|
|
222
|
+
# @return [Hash] Returns the value in the form of hash
|
|
223
|
+
def _to_hash(value)
|
|
224
|
+
if value.is_a?(Array)
|
|
225
|
+
value.compact.map { |v| _to_hash(v) }
|
|
226
|
+
elsif value.is_a?(Hash)
|
|
227
|
+
{}.tap do |hash|
|
|
228
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
229
|
+
end
|
|
230
|
+
elsif value.respond_to? :to_hash
|
|
231
|
+
value.to_hash
|
|
232
|
+
else
|
|
233
|
+
value
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
end
|