From 083e906add9cb150a80b578d6f951616cced1d69 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 22:33:00 +0000 Subject: [PATCH 001/252] Regenerate SDKs (#12) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 156 ++-- lib/Api/AccountInformationApi.php | 74 +- lib/Api/ApiStatusApi.php | 8 + lib/Api/AuthenticationApi.php | 80 +- lib/Api/ConnectionsApi.php | 140 ++-- lib/Api/OptionsApi.php | 40 + lib/Api/ReferenceDataApi.php | 88 +++ lib/Api/TradingApi.php | 40 + lib/Api/TransactionsAndReportingApi.php | 76 +- lib/Configuration.php | 4 +- lib/Model/Account.php | 16 +- lib/Model/AccountOrderRecord.php | 2 +- .../AccountOrderRecordUniversalSymbol.php | 12 +- lib/Model/AccountSimple.php | 8 +- ...nticationLoginSnapTradeUser200Response.php | 19 +- lib/Model/Brokerage.php | 224 ++---- lib/Model/BrokerageAuthorization.php | 39 +- ...erageAuthorizationDisabledConfirmation.php | 1 + ...kerageAuthorizationRefreshConfirmation.php | 1 + lib/Model/BrokerageType.php | 2 +- lib/Model/DeleteUserResponse.php | 39 +- lib/Model/LoginRedirectURI.php | 19 +- lib/Model/SnapTradeLoginUserRequestBody.php | 16 +- lib/Model/Symbol.php | 61 +- ...lSymbolCurrency.php => SymbolCurrency.php} | 8 +- ...lSymbolExchange.php => SymbolExchange.php} | 8 +- lib/Model/UnderlyingSymbol.php | 6 +- lib/Model/UniversalActivity.php | 440 +++++------ lib/Model/UniversalActivityCurrency.php | 477 ++++++++++++ lib/Model/UniversalActivityOptionSymbol.php | 673 +++++++++++++++++ lib/Model/UniversalActivitySymbol.php | 714 ++++++++++++++++++ lib/Model/UniversalSymbol.php | 12 +- lib/Model/UserIDandSecret.php | 3 +- test/Api/AuthenticationApiTest.php | 8 +- test/Api/ConnectionsApiTest.php | 8 +- test/Model/AccountSimpleTest.php | 2 +- test/Model/AccountTest.php | 2 +- ...eAuthorizationDisabledConfirmationTest.php | 2 +- ...geAuthorizationRefreshConfirmationTest.php | 2 +- test/Model/BrokerageAuthorizationTest.php | 2 +- test/Model/BrokerageTest.php | 47 +- test/Model/BrokerageTypeTest.php | 2 +- test/Model/DeleteUserResponseTest.php | 11 +- ...urrencyTest.php => SymbolCurrencyTest.php} | 10 +- ...xchangeTest.php => SymbolExchangeTest.php} | 10 +- test/Model/SymbolTest.php | 6 +- test/Model/UniversalActivityCurrencyTest.php | 101 +++ .../UniversalActivityOptionSymbolTest.php | 137 ++++ test/Model/UniversalActivitySymbolTest.php | 155 ++++ test/Model/UniversalActivityTest.php | 60 +- test/Model/UserIDandSecretTest.php | 2 +- 52 files changed, 3307 insertions(+), 768 deletions(-) rename lib/Model/{UniversalSymbolCurrency.php => SymbolCurrency.php} (97%) rename lib/Model/{UniversalSymbolExchange.php => SymbolExchange.php} (98%) create mode 100644 lib/Model/UniversalActivityCurrency.php create mode 100644 lib/Model/UniversalActivityOptionSymbol.php create mode 100644 lib/Model/UniversalActivitySymbol.php rename test/Model/{UniversalSymbolCurrencyTest.php => SymbolCurrencyTest.php} (88%) rename test/Model/{UniversalSymbolExchangeTest.php => SymbolExchangeTest.php} (92%) create mode 100644 test/Model/UniversalActivityCurrencyTest.php create mode 100644 test/Model/UniversalActivityOptionSymbolTest.php create mode 100644 test/Model/UniversalActivitySymbolTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0dfe1f1..7aa31df 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -a0c1adb3-872f-4b04-9c66-72b150225d7f \ No newline at end of file +d3d97da5-f1b6-4f18-806f-d1175b962165 \ No newline at end of file diff --git a/README.md b/README.md index fb0a31d..59e43d7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.32-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.36-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.32" + "konfig/snaptrade-php-sdk": "2.0.36" } } ``` @@ -117,7 +117,7 @@ $snaptrade = new \SnapTrade\Client( $result = $snaptrade->accountInformation->getAllUserHoldings( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631" ); ``` @@ -139,7 +139,7 @@ account. ```php $result = $snaptrade->accountInformation->getAllUserHoldings( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631" ); ``` @@ -152,7 +152,7 @@ $result = $snaptrade->accountInformation->getAllUserHoldings( ##### brokerage_authorizations: `string` -Optional. Comma seperated list of authorization IDs (only use if filtering is needed on one or more authorizations). +Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations). #### πŸ”„ Return @@ -181,7 +181,7 @@ The data returned here is cached. How long the data is cached for varies by brok ```php $result = $snaptrade->accountInformation->getUserAccountBalance( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" ); ``` @@ -221,7 +221,7 @@ The data returned here is always cached and refreshed once a day. **If you need ```php $result = $snaptrade->accountInformation->getUserAccountDetails( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" ); ``` @@ -261,7 +261,7 @@ The data returned here is cached. How long the data is cached for varies by brok ```php $result = $snaptrade->accountInformation->getUserAccountOrders( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", state: "all", days: 30 @@ -311,7 +311,7 @@ The data returned here is cached. How long the data is cached for varies by brok ```php $result = $snaptrade->accountInformation->getUserAccountPositions( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" ); ``` @@ -352,7 +352,7 @@ The data returned here is cached. How long the data is cached for varies by brok $result = $snaptrade->accountInformation->getUserHoldings( account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", user_id: "snaptrade-user-123", - user_secret: "USERSECRET123" + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" ); ``` @@ -380,7 +380,7 @@ $result = $snaptrade->accountInformation->getUserHoldings( ### `snaptrade.accountInformation.listUserAccounts` -Returns all brokerage accounts known to SnapTrade for the authenticated user. +Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. @@ -391,7 +391,7 @@ The data returned here is always cached and refreshed once a day. **If you need ```php $result = $snaptrade->accountInformation->listUserAccounts( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123" + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" ); ``` @@ -425,7 +425,7 @@ Updates various properties of a specified account. ```php $result = $snaptrade->accountInformation->updateUserAccount( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "accountId_example" ); ``` @@ -481,7 +481,7 @@ $result = $snaptrade->apiStatus->check(); ### `snaptrade.authentication.deleteSnapTradeUser` -Deletes a user you've registered over the SnapTrade API, and any data associated with them or their investment accounts. +Deletes a registered user and all associated data. This action is irreversible. This API is asynchronous and will return a 200 status code if the request is accepted. The user and all associated data will be queued for deletion. Once deleted, a `USER_DELETED` webhook will be sent. #### πŸ› οΈ Usage @@ -512,7 +512,7 @@ $result = $snaptrade->authentication->deleteSnapTradeUser( ### `snaptrade.authentication.listSnapTradeUsers` -Returns a list of users you've registered over the SnapTrade API. +Returns a list of all registered user IDs. Please note that the response is not currently paginated. #### πŸ› οΈ Usage @@ -545,13 +545,13 @@ Logs in a SnapTrade user and returns an authenticated connection portal URL for ```php $result = $snaptrade->authentication->loginSnapTradeUser( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", broker: "ALPACA", immediate_redirect: True, custom_redirect: "https://snaptrade.com", reconnect: "8b5f262d-4bb9-365d-888a-202bd3b15fa1", connection_type: "read", - connection_portal_version: "v2" + connection_portal_version: "v3" ); ``` @@ -563,27 +563,27 @@ $result = $snaptrade->authentication->loginSnapTradeUser( ##### broker: `string` -Slug of the brokerage to connect the user to. See [this document](https://snaptrade.notion.site/SnapTrade-Brokerage-Integrations-f83946a714a84c3caf599f6a945f0ead) for a list of supported brokerages and their slugs. +Slug of the brokerage to connect the user to. See [the integrations page](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=3cfea70ef4254afc89704e47275a7a9a&pvs=4) for a list of supported brokerages and their slugs. ##### immediateRedirect: `bool` -When set to True, user will be redirected back to the partner's site instead of the connection portal +When set to `true`, user will be redirected back to the partner's site instead of the connection portal. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](https://docs.snaptrade.com/docs/implement-connection-portal) for more information. ##### customRedirect: `string` -URL to redirect the user to after the user connects their brokerage account +URL to redirect the user to after the user connects their brokerage account. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](https://docs.snaptrade.com/docs/implement-connection-portal) for more information. ##### reconnect: `string` -The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See β€˜Reconnecting Accounts’ for more information. +The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See the [guide on fixing broken connections](https://docs.snaptrade.com/docs/fix-broken-connections) for more information. ##### connectionType: `string` -Sets whether the connection should be read or trade +Sets whether the connection should be read-only or trade-enabled. ##### connectionPortalVersion: `string` -Sets the version of the connection portal to render, with a default to 'v3' +Sets the version of the connection portal to render. #### πŸ”„ Return @@ -601,8 +601,8 @@ Sets the version of the connection portal to render, with a default to 'v3' ### `snaptrade.authentication.registerSnapTradeUser` -Registers a new SnapTrade user under your ClientID. A user secret will be automatically generated for you and must be properly stored in your database. -Most SnapTrade operations require a user ID and user secret to be passed as a parameter. +Registers a new SnapTrade user under your Client ID. A user secret will be automatically generated for you and must be properly stored in your system. +Most SnapTrade operations require a user ID and user secret to be passed in as parameters. @@ -636,8 +636,7 @@ SnapTrade User ID. This is chosen by the API partner and can be any string that ### `snaptrade.authentication.resetSnapTradeUserSecret` -This API is used to rotate the secret for a SnapTrade user. You might use this if a userSecret -is compromised. Please note that if you call this endpoint and fail to save the new secret, you'll no longer be able to access any data for this user, and your only option will be to delete and recreate the user, then ask them to reconnect. +Rotates the secret for a SnapTrade user. You might use this if `userSecret` is compromised. Please note that if you call this endpoint and fail to save the new secret, you'll no longer be able to access any data for this user, and your only option will be to delete and recreate the user, then ask them to reconnect. @@ -646,7 +645,7 @@ is compromised. Please note that if you call this endpoint and fail to save the ```php $result = $snaptrade->authentication->resetSnapTradeUserSecret( user_id: "snaptrade-user-123", - user_secret: "h81@cx1lkalablakwjaltkejraj11=" + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" ); ``` @@ -658,7 +657,7 @@ SnapTrade User ID. This is chosen by the API partner and can be any string that ##### userSecret: `string` -SnapTrade User Secret randomly generated by SnapTrade. This is privileged information and if compromised, should be rotated via the SnapTrade API. +SnapTrade User Secret. This is a randomly generated string and should be stored securely. If compromised, please rotate it via the [rotate user secret endpoint](/reference/Authentication/Authentication_resetSnapTradeUserSecret). #### πŸ”„ Return @@ -676,16 +675,16 @@ SnapTrade User Secret randomly generated by SnapTrade. This is privileged inform ### `snaptrade.connections.detailBrokerageAuthorization` -Returns a single brokerage authorization object for the specified ID. +Returns a single connection for the specified ID. #### πŸ› οΈ Usage ```php $result = $snaptrade->connections->detailBrokerageAuthorization( - authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", + authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89", user_id: "snaptrade-user-123", - user_secret: "USERSECRET123" + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" ); ``` @@ -693,8 +692,6 @@ $result = $snaptrade->connections->detailBrokerageAuthorization( ##### authorization_id: `string` -The ID of a brokerage authorization object. - ##### user_id: `string` ##### user_secret: `string` @@ -715,16 +712,20 @@ The ID of a brokerage authorization object. ### `snaptrade.connections.disableBrokerageAuthorization` -Manually disable a connection. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a CONNECTION_BROKEN webhook for the connection. Please contact us in order to use this endpoint as it is disabled by default. +Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. +Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_broken) for the connection. + +*Please contact us in order to use this endpoint as it is disabled by default.* + #### πŸ› οΈ Usage ```php $result = $snaptrade->connections->disableBrokerageAuthorization( - authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", + authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89", user_id: "snaptrade-user-123", - user_secret: "USERSECRET123" + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" ); ``` @@ -732,8 +733,6 @@ $result = $snaptrade->connections->disableBrokerageAuthorization( ##### authorization_id: `string` -The ID of a brokerage authorization object. - ##### user_id: `string` ##### user_secret: `string` @@ -754,7 +753,12 @@ The ID of a brokerage authorization object. ### `snaptrade.connections.listBrokerageAuthorizations` -Returns a list of Brokerage Authorization objects for the user +Returns a list of all connections for the specified user. Note that `Connection` and `Brokerage Authorization` are interchangeable, but the term `Connection` is preferred and used in the doc for consistency. + +A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts. + +SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one. + #### πŸ› οΈ Usage @@ -762,7 +766,7 @@ Returns a list of Brokerage Authorization objects for the user ```php $result = $snaptrade->connections->listBrokerageAuthorizations( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123" + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" ); ``` @@ -788,16 +792,19 @@ $result = $snaptrade->connections->listBrokerageAuthorizations( ### `snaptrade.connections.refreshBrokerageAuthorization` -Trigger a holdings update for all accounts under this authorization. Updates will be queued asynchronously. ACCOUNT_HOLDINGS_UPDATED webhook will be sent once the sync completes. Please contact support for access as this endpoint is not enabled by default +Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. + +*Please contact support for access as this endpoint is not enabled by default.* + #### πŸ› οΈ Usage ```php $result = $snaptrade->connections->refreshBrokerageAuthorization( - authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", + authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89", user_id: "snaptrade-user-123", - user_secret: "USERSECRET123" + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" ); ``` @@ -805,8 +812,6 @@ $result = $snaptrade->connections->refreshBrokerageAuthorization( ##### authorization_id: `string` -The ID of a brokerage authorization object. - ##### user_id: `string` ##### user_secret: `string` @@ -827,16 +832,16 @@ The ID of a brokerage authorization object. ### `snaptrade.connections.removeBrokerageAuthorization` -Deletes a specified brokerage authorization given by the ID. +Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted. #### πŸ› οΈ Usage ```php $snaptrade->connections->removeBrokerageAuthorization( - authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", + authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89", user_id: "snaptrade-user-123", - user_secret: "USERSECRET123" + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" ); ``` @@ -844,8 +849,6 @@ $snaptrade->connections->removeBrokerageAuthorization( ##### authorization_id: `string` -The ID of the Authorization to delete. - ##### user_id: `string` ##### user_secret: `string` @@ -885,11 +888,11 @@ $result = $snaptrade->connections->sessionEvents( ##### user_id: `string` -Optional comma seperated list of user IDs used to filter the request on specific users +Optional comma separated list of user IDs used to filter the request on specific users ##### session_id: `string` -Optional comma seperated list of session IDs used to filter the request on specific users +Optional comma separated list of session IDs used to filter the request on specific users #### πŸ”„ Return @@ -925,7 +928,7 @@ $result = $snaptrade->options->getOptionStrategy( ], strategy_type: "CUSTOM", user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "accountId_example" ); ``` @@ -970,7 +973,7 @@ Returns the option chain for the specified symbol in the specified account. ```php $result = $snaptrade->options->getOptionsChain( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "accountId_example", symbol: "symbol_example" ); @@ -1015,7 +1018,7 @@ Returns a Strategy Quotes object which has latest market data of the specified o ```php $result = $snaptrade->options->getOptionsStrategyQuote( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "accountId_example", option_strategy_id: "2bcd7cc3-e922-4976-bce1-9858296801c3" ); @@ -1062,7 +1065,7 @@ The data returned here is cached. How long the data is cached for varies by brok ```php $result = $snaptrade->options->listOptionHoldings( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" ); ``` @@ -1101,7 +1104,7 @@ $result = $snaptrade->options->placeOptionStrategy( order_type: "Limit", time_in_force: "FOK", user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", option_strategy_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", price: 31.33 @@ -1440,7 +1443,7 @@ provided search string, matching on ticker and name. ```php $result = $snaptrade->referenceData->symbolSearchUserAccount( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", substring: "apple" ); @@ -1484,7 +1487,7 @@ This will only work if the order has not yet been executed. ```php $result = $snaptrade->trading->cancelUserAccountOrder( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", brokerage_order_id: "2bcd7cc3-e922-4976-bce1-9858296801c3" ); @@ -1526,7 +1529,7 @@ Return the trade object and it's impact on the account for the specified order. ```php $result = $snaptrade->trading->getOrderImpact( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", action: "BUY", order_type: "Limit", @@ -1591,7 +1594,7 @@ Returns quote(s) from the brokerage for the specified symbol(s). ```php $result = $snaptrade->trading->getUserAccountQuotes( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", symbols: "symbols_example", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", use_ticker: True @@ -1640,7 +1643,7 @@ Places a specified trade in the specified account. ```php $result = $snaptrade->trading->placeForceOrder( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", action: "BUY", order_type: "Limit", @@ -1708,7 +1711,7 @@ returns the status of the order from the brokerage. $result = $snaptrade->trading->placeOrder( trade_id: "tradeId_example", user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", wait_to_confirm: True ); ``` @@ -1743,7 +1746,12 @@ Optional, defaults to true. Determines if a wait is performed to check on order ### `snaptrade.transactionsAndReporting.getActivities` -Returns activities (transactions) for a user. Specifying start and end date is highly recommended for better performance +Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. + +There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. + +The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + #### πŸ› οΈ Usage @@ -1751,12 +1759,12 @@ Returns activities (transactions) for a user. Specifying start and end date is h ```php $result = $snaptrade->transactionsAndReporting->getActivities( user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", start_date: "2022-01-24", end_date: "2022-01-24", accounts: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2", brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2", - type: "DIVIDEND" + type: "BUY,SELL,DIVIDEND" ); ``` @@ -1768,19 +1776,23 @@ $result = $snaptrade->transactionsAndReporting->getActivities( ##### start_date: `\DateTime` +The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. + ##### end_date: `\DateTime` +The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. + ##### accounts: `string` -Optional comma seperated list of account IDs used to filter the request on specific accounts +Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. ##### brokerage_authorizations: `string` -Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations +Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. ##### type: `string` -Optional comma seperated list of types to filter activities by. This is not an exhaustive list, if we fail to match to these types, we will return the raw description from the brokerage. Potential values include - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT +Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE #### πŸ”„ Return @@ -1809,7 +1821,7 @@ $result = $snaptrade->transactionsAndReporting->getReportingCustomRange( start_date: "2022-01-24", end_date: "2022-01-24", user_id: "snaptrade-user-123", - user_secret: "USERSECRET123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", accounts: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2", detailed: True, frequency: "monthly" @@ -1828,7 +1840,7 @@ $result = $snaptrade->transactionsAndReporting->getReportingCustomRange( ##### accounts: `string` -Optional comma seperated list of account IDs used to filter the request on specific accounts +Optional comma separated list of account IDs used to filter the request on specific accounts ##### detailed: `bool` diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 38852f5..745aaa7 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -161,9 +161,11 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * List all accounts for the user, plus balances, positions, and orders for each account. * + * **Deprecated, please use the account-specific holdings endpoint instead.** List all accounts for the user, plus balances, positions, and orders for each account. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $brokerage_authorizations Optional. Comma seperated list of authorization IDs (only use if filtering is needed on one or more authorizations). (optional) + * @param string $brokerage_authorizations Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations). (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllUserHoldings'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -189,9 +191,11 @@ public function getAllUserHoldings( * * List all accounts for the user, plus balances, positions, and orders for each account. * + * **Deprecated, please use the account-specific holdings endpoint instead.** List all accounts for the user, plus balances, positions, and orders for each account. + * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $brokerage_authorizations Optional. Comma seperated list of authorization IDs (only use if filtering is needed on one or more authorizations). (optional) + * @param string $brokerage_authorizations Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations). (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllUserHoldings'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -355,9 +359,11 @@ public function getAllUserHoldingsWithHttpInfo($user_id, $user_secret, $brokerag * * List all accounts for the user, plus balances, positions, and orders for each account. * + * **Deprecated, please use the account-specific holdings endpoint instead.** List all accounts for the user, plus balances, positions, and orders for each account. + * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $brokerage_authorizations Optional. Comma seperated list of authorization IDs (only use if filtering is needed on one or more authorizations). (optional) + * @param string $brokerage_authorizations Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations). (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllUserHoldings'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -386,9 +392,11 @@ function ($response) { * * List all accounts for the user, plus balances, positions, and orders for each account. * + * **Deprecated, please use the account-specific holdings endpoint instead.** List all accounts for the user, plus balances, positions, and orders for each account. + * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $brokerage_authorizations Optional. Comma seperated list of authorization IDs (only use if filtering is needed on one or more authorizations). (optional) + * @param string $brokerage_authorizations Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations). (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllUserHoldings'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -444,7 +452,7 @@ function ($exception) { * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $brokerage_authorizations Optional. Comma seperated list of authorization IDs (only use if filtering is needed on one or more authorizations). (optional) + * @param string $brokerage_authorizations Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations). (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllUserHoldings'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -603,6 +611,8 @@ public function getAllUserHoldingsRequest($user_id, $user_secret, $brokerage_aut * * List account balances * + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) @@ -630,6 +640,8 @@ public function getUserAccountBalance( * * List account balances * + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -749,6 +761,8 @@ public function getUserAccountBalanceWithHttpInfo($user_id, $user_secret, $accou * * List account balances * + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -779,6 +793,8 @@ function ($response) { * * List account balances * + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -997,6 +1013,8 @@ public function getUserAccountBalanceRequest($user_id, $user_secret, $account_id * * Get account detail * + * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) @@ -1024,6 +1042,8 @@ public function getUserAccountDetails( * * Get account detail * + * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -1143,6 +1163,8 @@ public function getUserAccountDetailsWithHttpInfo($user_id, $user_secret, $accou * * Get account detail * + * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -1173,6 +1195,8 @@ function ($response) { * * Get account detail * + * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -1391,6 +1415,8 @@ public function getUserAccountDetailsRequest($user_id, $user_secret, $account_id * * List account recent orders * + * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) @@ -1422,6 +1448,8 @@ public function getUserAccountOrders( * * List account recent orders * + * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -1568,6 +1596,8 @@ public function getUserAccountOrdersWithHttpInfo($user_id, $user_secret, $accoun * * List account recent orders * + * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -1602,6 +1632,8 @@ function ($response) { * * List account recent orders * + * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -1853,6 +1885,8 @@ public function getUserAccountOrdersRequest($user_id, $user_secret, $account_id, * * List account positions * + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) @@ -1880,6 +1914,8 @@ public function getUserAccountPositions( * * List account positions * + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -1999,6 +2035,8 @@ public function getUserAccountPositionsWithHttpInfo($user_id, $user_secret, $acc * * List account positions * + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -2029,6 +2067,8 @@ function ($response) { * * List account positions * + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -2247,6 +2287,8 @@ public function getUserAccountPositionsRequest($user_id, $user_secret, $account_ * * List account holdings * + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $account_id account_id (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -2274,6 +2316,8 @@ public function getUserHoldings( * * List account holdings * + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $account_id (required) * @param string $user_id (required) * @param string $user_secret (required) @@ -2439,6 +2483,8 @@ public function getUserHoldingsWithHttpInfo($account_id, $user_id, $user_secret, * * List account holdings * + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $account_id (required) * @param string $user_id (required) * @param string $user_secret (required) @@ -2469,6 +2515,8 @@ function ($response) { * * List account holdings * + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $account_id (required) * @param string $user_id (required) * @param string $user_secret (required) @@ -2687,6 +2735,8 @@ public function getUserHoldingsRequest($account_id, $user_id, $user_secret, stri * * List accounts * + * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listUserAccounts'] to see the possible values for this operation @@ -2712,6 +2762,8 @@ public function listUserAccounts( * * List accounts * + * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listUserAccounts'] to see the possible values for this operation @@ -2829,6 +2881,8 @@ public function listUserAccountsWithHttpInfo($user_id, $user_secret, string $con * * List accounts * + * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listUserAccounts'] to see the possible values for this operation @@ -2857,6 +2911,8 @@ function ($response) { * * List accounts * + * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listUserAccounts'] to see the possible values for this operation @@ -3055,6 +3111,8 @@ public function listUserAccountsRequest($user_id, $user_secret, string $contentT * * Update details of an investment account * + * Updates various properties of a specified account. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id The ID of the account to update. (required) @@ -3082,6 +3140,8 @@ public function updateUserAccount( * * Update details of an investment account * + * Updates various properties of a specified account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to update. (required) @@ -3201,6 +3261,8 @@ public function updateUserAccountWithHttpInfo($user_id, $user_secret, $account_i * * Update details of an investment account * + * Updates various properties of a specified account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to update. (required) @@ -3231,6 +3293,8 @@ function ($response) { * * Update details of an investment account * + * Updates various properties of a specified account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to update. (required) diff --git a/lib/Api/ApiStatusApi.php b/lib/Api/ApiStatusApi.php index f635aeb..85e85d3 100644 --- a/lib/Api/ApiStatusApi.php +++ b/lib/Api/ApiStatusApi.php @@ -140,6 +140,8 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * Get API Status * + * Check whether the API is operational and verify timestamps. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['check'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -162,6 +164,8 @@ public function check( * * Get API Status * + * Check whether the API is operational and verify timestamps. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['check'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -275,6 +279,8 @@ public function checkWithHttpInfo(string $contentType = self::contentTypes['chec * * Get API Status * + * Check whether the API is operational and verify timestamps. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['check'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -300,6 +306,8 @@ function ($response) { * * Get API Status * + * Check whether the API is operational and verify timestamps. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['check'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/lib/Api/AuthenticationApi.php b/lib/Api/AuthenticationApi.php index 176a1ad..8e34f78 100644 --- a/lib/Api/AuthenticationApi.php +++ b/lib/Api/AuthenticationApi.php @@ -150,7 +150,9 @@ private function setRequestBodyProperty(&$body, $property, $value) { /** * Operation deleteSnapTradeUser * - * Delete SnapTrade user + * Delete user + * + * Deletes a registered user and all associated data. This action is irreversible. This API is asynchronous and will return a 200 status code if the request is accepted. The user and all associated data will be queued for deletion. Once deleted, a `USER_DELETED` webhook will be sent. * * @param string $user_id user_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteSnapTradeUser'] to see the possible values for this operation @@ -173,7 +175,9 @@ public function deleteSnapTradeUser( /** * Operation deleteSnapTradeUserWithHttpInfo * - * Delete SnapTrade user + * Delete user + * + * Deletes a registered user and all associated data. This action is irreversible. This API is asynchronous and will return a 200 status code if the request is accepted. The user and all associated data will be queued for deletion. Once deleted, a `USER_DELETED` webhook will be sent. * * @param string $user_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteSnapTradeUser'] to see the possible values for this operation @@ -357,7 +361,9 @@ public function deleteSnapTradeUserWithHttpInfo($user_id, string $contentType = /** * Operation deleteSnapTradeUserAsync * - * Delete SnapTrade user + * Delete user + * + * Deletes a registered user and all associated data. This action is irreversible. This API is asynchronous and will return a 200 status code if the request is accepted. The user and all associated data will be queued for deletion. Once deleted, a `USER_DELETED` webhook will be sent. * * @param string $user_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteSnapTradeUser'] to see the possible values for this operation @@ -383,7 +389,9 @@ function ($response) { /** * Operation deleteSnapTradeUserAsyncWithHttpInfo * - * Delete SnapTrade user + * Delete user + * + * Deletes a registered user and all associated data. This action is irreversible. This API is asynchronous and will return a 200 status code if the request is accepted. The user and all associated data will be queued for deletion. Once deleted, a `USER_DELETED` webhook will be sent. * * @param string $user_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteSnapTradeUser'] to see the possible values for this operation @@ -558,7 +566,9 @@ public function deleteSnapTradeUserRequest($user_id, string $contentType = self: /** * Operation listSnapTradeUsers * - * List SnapTrade users + * List all users + * + * Returns a list of all registered user IDs. Please note that the response is not currently paginated. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listSnapTradeUsers'] to see the possible values for this operation * @@ -580,7 +590,9 @@ public function listSnapTradeUsers( /** * Operation listSnapTradeUsersWithHttpInfo * - * List SnapTrade users + * List all users + * + * Returns a list of all registered user IDs. Please note that the response is not currently paginated. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listSnapTradeUsers'] to see the possible values for this operation * @@ -762,7 +774,9 @@ public function listSnapTradeUsersWithHttpInfo(string $contentType = self::conte /** * Operation listSnapTradeUsersAsync * - * List SnapTrade users + * List all users + * + * Returns a list of all registered user IDs. Please note that the response is not currently paginated. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listSnapTradeUsers'] to see the possible values for this operation * @@ -787,7 +801,9 @@ function ($response) { /** * Operation listSnapTradeUsersAsyncWithHttpInfo * - * List SnapTrade users + * List all users + * + * Returns a list of all registered user IDs. Please note that the response is not currently paginated. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listSnapTradeUsers'] to see the possible values for this operation * @@ -941,6 +957,8 @@ public function listSnapTradeUsersRequest(string $contentType = self::contentTyp * * Login user & generate connection link * + * Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param \SnapTrade\Model\SnapTradeLoginUserRequestBody $snap_trade_login_user_request_body snap_trade_login_user_request_body (optional) @@ -957,8 +975,8 @@ public function loginSnapTradeUser( $immediate_redirect = SENTINEL_VALUE, $custom_redirect = SENTINEL_VALUE, $reconnect = SENTINEL_VALUE, - $connection_type = SENTINEL_VALUE, - $connection_portal_version = SENTINEL_VALUE, + $connection_type = 'read', + $connection_portal_version = 'v3', string $contentType = self::contentTypes['loginSnapTradeUser'][0] ) @@ -981,6 +999,8 @@ public function loginSnapTradeUser( * * Login user & generate connection link * + * Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\SnapTradeLoginUserRequestBody $snap_trade_login_user_request_body (optional) @@ -1169,6 +1189,8 @@ public function loginSnapTradeUserWithHttpInfo($user_id, $user_secret, $snap_tra * * Login user & generate connection link * + * Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\SnapTradeLoginUserRequestBody $snap_trade_login_user_request_body (optional) @@ -1184,8 +1206,8 @@ public function loginSnapTradeUserAsync( $immediate_redirect = SENTINEL_VALUE, $custom_redirect = SENTINEL_VALUE, $reconnect = SENTINEL_VALUE, - $connection_type = SENTINEL_VALUE, - $connection_portal_version = SENTINEL_VALUE, + $connection_type = 'read', + $connection_portal_version = 'v3', string $contentType = self::contentTypes['loginSnapTradeUser'][0] ) @@ -1212,6 +1234,8 @@ function ($response) { * * Login user & generate connection link * + * Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\SnapTradeLoginUserRequestBody $snap_trade_login_user_request_body (optional) @@ -1425,7 +1449,9 @@ public function loginSnapTradeUserRequest($user_id, $user_secret, $snap_trade_lo /** * Operation registerSnapTradeUser * - * Create SnapTrade user + * Register user + * + * Registers a new SnapTrade user under your Client ID. A user secret will be automatically generated for you and must be properly stored in your system. Most SnapTrade operations require a user ID and user secret to be passed in as parameters. * * @param \SnapTrade\Model\SnapTradeRegisterUserRequestBody $snap_trade_register_user_request_body snap_trade_register_user_request_body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['registerSnapTradeUser'] to see the possible values for this operation @@ -1451,7 +1477,9 @@ public function registerSnapTradeUser( /** * Operation registerSnapTradeUserWithHttpInfo * - * Create SnapTrade user + * Register user + * + * Registers a new SnapTrade user under your Client ID. A user secret will be automatically generated for you and must be properly stored in your system. Most SnapTrade operations require a user ID and user secret to be passed in as parameters. * * @param \SnapTrade\Model\SnapTradeRegisterUserRequestBody $snap_trade_register_user_request_body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['registerSnapTradeUser'] to see the possible values for this operation @@ -1635,7 +1663,9 @@ public function registerSnapTradeUserWithHttpInfo($snap_trade_register_user_requ /** * Operation registerSnapTradeUserAsync * - * Create SnapTrade user + * Register user + * + * Registers a new SnapTrade user under your Client ID. A user secret will be automatically generated for you and must be properly stored in your system. Most SnapTrade operations require a user ID and user secret to be passed in as parameters. * * @param \SnapTrade\Model\SnapTradeRegisterUserRequestBody $snap_trade_register_user_request_body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['registerSnapTradeUser'] to see the possible values for this operation @@ -1664,7 +1694,9 @@ function ($response) { /** * Operation registerSnapTradeUserAsyncWithHttpInfo * - * Create SnapTrade user + * Register user + * + * Registers a new SnapTrade user under your Client ID. A user secret will be automatically generated for you and must be properly stored in your system. Most SnapTrade operations require a user ID and user secret to be passed in as parameters. * * @param \SnapTrade\Model\SnapTradeRegisterUserRequestBody $snap_trade_register_user_request_body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['registerSnapTradeUser'] to see the possible values for this operation @@ -1839,7 +1871,9 @@ public function registerSnapTradeUserRequest($snap_trade_register_user_request_b /** * Operation resetSnapTradeUserSecret * - * Obtain a new user secret for a user + * Rotate user secret + * + * Rotates the secret for a SnapTrade user. You might use this if `userSecret` is compromised. Please note that if you call this endpoint and fail to save the new secret, you'll no longer be able to access any data for this user, and your only option will be to delete and recreate the user, then ask them to reconnect. * * @param \SnapTrade\Model\UserIDandSecret $user_i_dand_secret user_i_dand_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetSnapTradeUserSecret'] to see the possible values for this operation @@ -1867,7 +1901,9 @@ public function resetSnapTradeUserSecret( /** * Operation resetSnapTradeUserSecretWithHttpInfo * - * Obtain a new user secret for a user + * Rotate user secret + * + * Rotates the secret for a SnapTrade user. You might use this if `userSecret` is compromised. Please note that if you call this endpoint and fail to save the new secret, you'll no longer be able to access any data for this user, and your only option will be to delete and recreate the user, then ask them to reconnect. * * @param \SnapTrade\Model\UserIDandSecret $user_i_dand_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetSnapTradeUserSecret'] to see the possible values for this operation @@ -2051,7 +2087,9 @@ public function resetSnapTradeUserSecretWithHttpInfo($user_i_dand_secret, string /** * Operation resetSnapTradeUserSecretAsync * - * Obtain a new user secret for a user + * Rotate user secret + * + * Rotates the secret for a SnapTrade user. You might use this if `userSecret` is compromised. Please note that if you call this endpoint and fail to save the new secret, you'll no longer be able to access any data for this user, and your only option will be to delete and recreate the user, then ask them to reconnect. * * @param \SnapTrade\Model\UserIDandSecret $user_i_dand_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetSnapTradeUserSecret'] to see the possible values for this operation @@ -2082,7 +2120,9 @@ function ($response) { /** * Operation resetSnapTradeUserSecretAsyncWithHttpInfo * - * Obtain a new user secret for a user + * Rotate user secret + * + * Rotates the secret for a SnapTrade user. You might use this if `userSecret` is compromised. Please note that if you call this endpoint and fail to save the new secret, you'll no longer be able to access any data for this user, and your only option will be to delete and recreate the user, then ask them to reconnect. * * @param \SnapTrade\Model\UserIDandSecret $user_i_dand_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetSnapTradeUserSecret'] to see the possible values for this operation diff --git a/lib/Api/ConnectionsApi.php b/lib/Api/ConnectionsApi.php index 43f4cb3..d59b7ab 100644 --- a/lib/Api/ConnectionsApi.php +++ b/lib/Api/ConnectionsApi.php @@ -153,9 +153,11 @@ private function setRequestBodyProperty(&$body, $property, $value) { /** * Operation detailBrokerageAuthorization * - * Get brokerage authorization details + * Get connection detail * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * Returns a single connection for the specified ID. + * + * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detailBrokerageAuthorization'] to see the possible values for this operation @@ -180,9 +182,11 @@ public function detailBrokerageAuthorization( /** * Operation detailBrokerageAuthorizationWithHttpInfo * - * Get brokerage authorization details + * Get connection detail + * + * Returns a single connection for the specified ID. * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detailBrokerageAuthorization'] to see the possible values for this operation @@ -299,9 +303,11 @@ public function detailBrokerageAuthorizationWithHttpInfo($authorization_id, $use /** * Operation detailBrokerageAuthorizationAsync * - * Get brokerage authorization details + * Get connection detail + * + * Returns a single connection for the specified ID. * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detailBrokerageAuthorization'] to see the possible values for this operation @@ -329,9 +335,11 @@ function ($response) { /** * Operation detailBrokerageAuthorizationAsyncWithHttpInfo * - * Get brokerage authorization details + * Get connection detail * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * Returns a single connection for the specified ID. + * + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detailBrokerageAuthorization'] to see the possible values for this operation @@ -386,7 +394,7 @@ function ($exception) { /** * Create request for operation 'detailBrokerageAuthorization' * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detailBrokerageAuthorization'] to see the possible values for this operation @@ -547,9 +555,11 @@ public function detailBrokerageAuthorizationRequest($authorization_id, $user_id, /** * Operation disableBrokerageAuthorization * - * Manually disable a connection for testing + * Force disable connection + * + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['disableBrokerageAuthorization'] to see the possible values for this operation @@ -574,9 +584,11 @@ public function disableBrokerageAuthorization( /** * Operation disableBrokerageAuthorizationWithHttpInfo * - * Manually disable a connection for testing + * Force disable connection + * + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['disableBrokerageAuthorization'] to see the possible values for this operation @@ -785,9 +797,11 @@ public function disableBrokerageAuthorizationWithHttpInfo($authorization_id, $us /** * Operation disableBrokerageAuthorizationAsync * - * Manually disable a connection for testing + * Force disable connection * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* + * + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['disableBrokerageAuthorization'] to see the possible values for this operation @@ -815,9 +829,11 @@ function ($response) { /** * Operation disableBrokerageAuthorizationAsyncWithHttpInfo * - * Manually disable a connection for testing + * Force disable connection + * + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['disableBrokerageAuthorization'] to see the possible values for this operation @@ -872,7 +888,7 @@ function ($exception) { /** * Create request for operation 'disableBrokerageAuthorization' * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['disableBrokerageAuthorization'] to see the possible values for this operation @@ -1033,7 +1049,9 @@ public function disableBrokerageAuthorizationRequest($authorization_id, $user_id /** * Operation listBrokerageAuthorizations * - * List all brokerage authorizations for the User + * List all connections + * + * Returns a list of all connections for the specified user. Note that `Connection` and `Brokerage Authorization` are interchangeable, but the term `Connection` is preferred and used in the doc for consistency. A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts. SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -1058,7 +1076,9 @@ public function listBrokerageAuthorizations( /** * Operation listBrokerageAuthorizationsWithHttpInfo * - * List all brokerage authorizations for the User + * List all connections + * + * Returns a list of all connections for the specified user. Note that `Connection` and `Brokerage Authorization` are interchangeable, but the term `Connection` is preferred and used in the doc for consistency. A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts. SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1175,7 +1195,9 @@ public function listBrokerageAuthorizationsWithHttpInfo($user_id, $user_secret, /** * Operation listBrokerageAuthorizationsAsync * - * List all brokerage authorizations for the User + * List all connections + * + * Returns a list of all connections for the specified user. Note that `Connection` and `Brokerage Authorization` are interchangeable, but the term `Connection` is preferred and used in the doc for consistency. A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts. SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1203,7 +1225,9 @@ function ($response) { /** * Operation listBrokerageAuthorizationsAsyncWithHttpInfo * - * List all brokerage authorizations for the User + * List all connections + * + * Returns a list of all connections for the specified user. Note that `Connection` and `Brokerage Authorization` are interchangeable, but the term `Connection` is preferred and used in the doc for consistency. A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts. SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1403,7 +1427,9 @@ public function listBrokerageAuthorizationsRequest($user_id, $user_secret, strin * * Refresh holdings for a connection * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * + * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshBrokerageAuthorization'] to see the possible values for this operation @@ -1430,7 +1456,9 @@ public function refreshBrokerageAuthorization( * * Refresh holdings for a connection * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshBrokerageAuthorization'] to see the possible values for this operation @@ -1641,7 +1669,9 @@ public function refreshBrokerageAuthorizationWithHttpInfo($authorization_id, $us * * Refresh holdings for a connection * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshBrokerageAuthorization'] to see the possible values for this operation @@ -1671,7 +1701,9 @@ function ($response) { * * Refresh holdings for a connection * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshBrokerageAuthorization'] to see the possible values for this operation @@ -1726,7 +1758,7 @@ function ($exception) { /** * Create request for operation 'refreshBrokerageAuthorization' * - * @param string $authorization_id The ID of a brokerage authorization object. (required) + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshBrokerageAuthorization'] to see the possible values for this operation @@ -1887,9 +1919,11 @@ public function refreshBrokerageAuthorizationRequest($authorization_id, $user_id /** * Operation removeBrokerageAuthorization * - * Delete brokerage authorization + * Delete connection + * + * Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted. * - * @param string $authorization_id The ID of the Authorization to delete. (required) + * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['removeBrokerageAuthorization'] to see the possible values for this operation @@ -1913,9 +1947,11 @@ public function removeBrokerageAuthorization( /** * Operation removeBrokerageAuthorizationWithHttpInfo * - * Delete brokerage authorization + * Delete connection + * + * Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted. * - * @param string $authorization_id The ID of the Authorization to delete. (required) + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['removeBrokerageAuthorization'] to see the possible values for this operation @@ -1992,9 +2028,11 @@ public function removeBrokerageAuthorizationWithHttpInfo($authorization_id, $use /** * Operation removeBrokerageAuthorizationAsync * - * Delete brokerage authorization + * Delete connection * - * @param string $authorization_id The ID of the Authorization to delete. (required) + * Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted. + * + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['removeBrokerageAuthorization'] to see the possible values for this operation @@ -2022,9 +2060,11 @@ function ($response) { /** * Operation removeBrokerageAuthorizationAsyncWithHttpInfo * - * Delete brokerage authorization + * Delete connection + * + * Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted. * - * @param string $authorization_id The ID of the Authorization to delete. (required) + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['removeBrokerageAuthorization'] to see the possible values for this operation @@ -2066,7 +2106,7 @@ function ($exception) { /** * Create request for operation 'removeBrokerageAuthorization' * - * @param string $authorization_id The ID of the Authorization to delete. (required) + * @param string $authorization_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['removeBrokerageAuthorization'] to see the possible values for this operation @@ -2229,9 +2269,11 @@ public function removeBrokerageAuthorizationRequest($authorization_id, $user_id, * * Get all session events for a user * + * Returns a list of session events associated with a user. + * * @param string $partner_client_id partner_client_id (required) - * @param string $user_id Optional comma seperated list of user IDs used to filter the request on specific users (optional) - * @param string $session_id Optional comma seperated list of session IDs used to filter the request on specific users (optional) + * @param string $user_id Optional comma separated list of user IDs used to filter the request on specific users (optional) + * @param string $session_id Optional comma separated list of session IDs used to filter the request on specific users (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sessionEvents'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -2256,9 +2298,11 @@ public function sessionEvents( * * Get all session events for a user * + * Returns a list of session events associated with a user. + * * @param string $partner_client_id (required) - * @param string $user_id Optional comma seperated list of user IDs used to filter the request on specific users (optional) - * @param string $session_id Optional comma seperated list of session IDs used to filter the request on specific users (optional) + * @param string $user_id Optional comma separated list of user IDs used to filter the request on specific users (optional) + * @param string $session_id Optional comma separated list of session IDs used to filter the request on specific users (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sessionEvents'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -2375,9 +2419,11 @@ public function sessionEventsWithHttpInfo($partner_client_id, $user_id = null, $ * * Get all session events for a user * + * Returns a list of session events associated with a user. + * * @param string $partner_client_id (required) - * @param string $user_id Optional comma seperated list of user IDs used to filter the request on specific users (optional) - * @param string $session_id Optional comma seperated list of session IDs used to filter the request on specific users (optional) + * @param string $user_id Optional comma separated list of user IDs used to filter the request on specific users (optional) + * @param string $session_id Optional comma separated list of session IDs used to filter the request on specific users (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sessionEvents'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -2405,9 +2451,11 @@ function ($response) { * * Get all session events for a user * + * Returns a list of session events associated with a user. + * * @param string $partner_client_id (required) - * @param string $user_id Optional comma seperated list of user IDs used to filter the request on specific users (optional) - * @param string $session_id Optional comma seperated list of session IDs used to filter the request on specific users (optional) + * @param string $user_id Optional comma separated list of user IDs used to filter the request on specific users (optional) + * @param string $session_id Optional comma separated list of session IDs used to filter the request on specific users (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sessionEvents'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -2461,8 +2509,8 @@ function ($exception) { * Create request for operation 'sessionEvents' * * @param string $partner_client_id (required) - * @param string $user_id Optional comma seperated list of user IDs used to filter the request on specific users (optional) - * @param string $session_id Optional comma seperated list of session IDs used to filter the request on specific users (optional) + * @param string $user_id Optional comma separated list of user IDs used to filter the request on specific users (optional) + * @param string $session_id Optional comma separated list of session IDs used to filter the request on specific users (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sessionEvents'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/lib/Api/OptionsApi.php b/lib/Api/OptionsApi.php index 4f2b154..039c278 100644 --- a/lib/Api/OptionsApi.php +++ b/lib/Api/OptionsApi.php @@ -152,6 +152,8 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * Create options strategy * + * Creates an option strategy object that will be used to place an option strategy order. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id The ID of the account to create the option strategy object in. (required) @@ -188,6 +190,8 @@ public function getOptionStrategy( * * Create options strategy * + * Creates an option strategy object that will be used to place an option strategy order. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to create the option strategy object in. (required) @@ -332,6 +336,8 @@ public function getOptionStrategyWithHttpInfo($user_id, $user_secret, $account_i * * Create options strategy * + * Creates an option strategy object that will be used to place an option strategy order. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to create the option strategy object in. (required) @@ -371,6 +377,8 @@ function ($response) { * * Create options strategy * + * Creates an option strategy object that will be used to place an option strategy order. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to create the option strategy object in. (required) @@ -612,6 +620,8 @@ public function getOptionStrategyRequest($user_id, $user_secret, $account_id, $o * * Get the options chain for a symbol * + * Returns the option chain for the specified symbol in the specified account. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id The ID of the account to get the options chain from. (required) @@ -641,6 +651,8 @@ public function getOptionsChain( * * Get the options chain for a symbol * + * Returns the option chain for the specified symbol in the specified account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to get the options chain from. (required) @@ -785,6 +797,8 @@ public function getOptionsChainWithHttpInfo($user_id, $user_secret, $account_id, * * Get the options chain for a symbol * + * Returns the option chain for the specified symbol in the specified account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to get the options chain from. (required) @@ -817,6 +831,8 @@ function ($response) { * * Get the options chain for a symbol * + * Returns the option chain for the specified symbol in the specified account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to get the options chain from. (required) @@ -1058,6 +1074,8 @@ public function getOptionsChainRequest($user_id, $user_secret, $account_id, $sym * * Get options strategy quotes * + * Returns a Strategy Quotes object which has latest market data of the specified option strategy. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id The ID of the account the strategy will be placed in. (required) @@ -1087,6 +1105,8 @@ public function getOptionsStrategyQuote( * * Get options strategy quotes * + * Returns a Strategy Quotes object which has latest market data of the specified option strategy. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account the strategy will be placed in. (required) @@ -1231,6 +1251,8 @@ public function getOptionsStrategyQuoteWithHttpInfo($user_id, $user_secret, $acc * * Get options strategy quotes * + * Returns a Strategy Quotes object which has latest market data of the specified option strategy. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account the strategy will be placed in. (required) @@ -1263,6 +1285,8 @@ function ($response) { * * Get options strategy quotes * + * Returns a Strategy Quotes object which has latest market data of the specified option strategy. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account the strategy will be placed in. (required) @@ -1501,6 +1525,8 @@ public function getOptionsStrategyQuoteRequest($user_id, $user_secret, $account_ * * List account option positions * + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) @@ -1528,6 +1554,8 @@ public function listOptionHoldings( * * List account option positions * + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -1670,6 +1698,8 @@ public function listOptionHoldingsWithHttpInfo($user_id, $user_secret, $account_ * * List account option positions * + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -1700,6 +1730,8 @@ function ($response) { * * List account option positions * + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) @@ -1918,6 +1950,8 @@ public function listOptionHoldingsRequest($user_id, $user_secret, $account_id, s * * Place an option strategy order * + * Places the option strategy order and returns the order record received from the brokerage. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id The ID of the account to execute the strategy in. (required) @@ -1956,6 +1990,8 @@ public function placeOptionStrategy( * * Place an option strategy order * + * Places the option strategy order and returns the order record received from the brokerage. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to execute the strategy in. (required) @@ -2102,6 +2138,8 @@ public function placeOptionStrategyWithHttpInfo($user_id, $user_secret, $account * * Place an option strategy order * + * Places the option strategy order and returns the order record received from the brokerage. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to execute the strategy in. (required) @@ -2143,6 +2181,8 @@ function ($response) { * * Place an option strategy order * + * Places the option strategy order and returns the order record received from the brokerage. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to execute the strategy in. (required) diff --git a/lib/Api/ReferenceDataApi.php b/lib/Api/ReferenceDataApi.php index bbebb48..5b1df6b 100644 --- a/lib/Api/ReferenceDataApi.php +++ b/lib/Api/ReferenceDataApi.php @@ -170,6 +170,8 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * Get exchange rate of a currency pair * + * Returns an Exchange Rate Pair object for the specified Currency Pair. + * * @param string $currency_pair A currency pair based on currency code for example, {CAD-USD} (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCurrencyExchangeRatePair'] to see the possible values for this operation * @@ -193,6 +195,8 @@ public function getCurrencyExchangeRatePair( * * Get exchange rate of a currency pair * + * Returns an Exchange Rate Pair object for the specified Currency Pair. + * * @param string $currency_pair A currency pair based on currency code for example, {CAD-USD} (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCurrencyExchangeRatePair'] to see the possible values for this operation * @@ -308,6 +312,8 @@ public function getCurrencyExchangeRatePairWithHttpInfo($currency_pair, string $ * * Get exchange rate of a currency pair * + * Returns an Exchange Rate Pair object for the specified Currency Pair. + * * @param string $currency_pair A currency pair based on currency code for example, {CAD-USD} (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCurrencyExchangeRatePair'] to see the possible values for this operation * @@ -334,6 +340,8 @@ function ($response) { * * Get exchange rate of a currency pair * + * Returns an Exchange Rate Pair object for the specified Currency Pair. + * * @param string $currency_pair A currency pair based on currency code for example, {CAD-USD} (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCurrencyExchangeRatePair'] to see the possible values for this operation * @@ -506,6 +514,8 @@ public function getCurrencyExchangeRatePairRequest($currency_pair, string $conte * * Get metadata related to Snaptrade partner * + * Returns useful data related to the specified ClientID, including allowed brokerages and data access. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPartnerInfo'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -528,6 +538,8 @@ public function getPartnerInfo( * * Get metadata related to Snaptrade partner * + * Returns useful data related to the specified ClientID, including allowed brokerages and data access. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPartnerInfo'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -710,6 +722,8 @@ public function getPartnerInfoWithHttpInfo(string $contentType = self::contentTy * * Get metadata related to Snaptrade partner * + * Returns useful data related to the specified ClientID, including allowed brokerages and data access. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPartnerInfo'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -735,6 +749,8 @@ function ($response) { * * Get metadata related to Snaptrade partner * + * Returns useful data related to the specified ClientID, including allowed brokerages and data access. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPartnerInfo'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -887,6 +903,8 @@ public function getPartnerInfoRequest(string $contentType = self::contentTypes[' * * List of all security types * + * List security types available on SnapTrade. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSecurityTypes'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -909,6 +927,8 @@ public function getSecurityTypes( * * List of all security types * + * List security types available on SnapTrade. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSecurityTypes'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -1022,6 +1042,8 @@ public function getSecurityTypesWithHttpInfo(string $contentType = self::content * * List of all security types * + * List security types available on SnapTrade. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSecurityTypes'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1047,6 +1069,8 @@ function ($response) { * * List of all security types * + * List security types available on SnapTrade. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSecurityTypes'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1199,6 +1223,8 @@ public function getSecurityTypesRequest(string $contentType = self::contentTypes * * Get exchanges * + * Returns a list of all supported Exchanges. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStockExchanges'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -1221,6 +1247,8 @@ public function getStockExchanges( * * Get exchanges * + * Returns a list of all supported Exchanges. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStockExchanges'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -1334,6 +1362,8 @@ public function getStockExchangesWithHttpInfo(string $contentType = self::conten * * Get exchanges * + * Returns a list of all supported Exchanges. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStockExchanges'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1359,6 +1389,8 @@ function ($response) { * * Get exchanges * + * Returns a list of all supported Exchanges. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStockExchanges'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1511,6 +1543,8 @@ public function getStockExchangesRequest(string $contentType = self::contentType * * Search for symbols * + * Returns a list of Universal Symbol objects that match a defined string. Matches on ticker or name. + * * @param \SnapTrade\Model\SymbolQuery $symbol_query symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbols'] to see the possible values for this operation * @@ -1537,6 +1571,8 @@ public function getSymbols( * * Search for symbols * + * Returns a list of Universal Symbol objects that match a defined string. Matches on ticker or name. + * * @param \SnapTrade\Model\SymbolQuery $symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbols'] to see the possible values for this operation * @@ -1652,6 +1688,8 @@ public function getSymbolsWithHttpInfo($symbol_query = null, string $contentType * * Search for symbols * + * Returns a list of Universal Symbol objects that match a defined string. Matches on ticker or name. + * * @param \SnapTrade\Model\SymbolQuery $symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbols'] to see the possible values for this operation * @@ -1681,6 +1719,8 @@ function ($response) { * * Search for symbols * + * Returns a list of Universal Symbol objects that match a defined string. Matches on ticker or name. + * * @param \SnapTrade\Model\SymbolQuery $symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbols'] to see the possible values for this operation * @@ -1850,6 +1890,8 @@ public function getSymbolsRequest($symbol_query = SENTINEL_VALUE, string $conten * * Get details of a symbol * + * Returns the Universal Symbol object specified by the ticker or the universal_symbol_id. + * * @param string $query The ticker or universal_symbol_id of the UniversalSymbol to get. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbolsByTicker'] to see the possible values for this operation * @@ -1873,6 +1915,8 @@ public function getSymbolsByTicker( * * Get details of a symbol * + * Returns the Universal Symbol object specified by the ticker or the universal_symbol_id. + * * @param string $query The ticker or universal_symbol_id of the UniversalSymbol to get. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbolsByTicker'] to see the possible values for this operation * @@ -1988,6 +2032,8 @@ public function getSymbolsByTickerWithHttpInfo($query, string $contentType = sel * * Get details of a symbol * + * Returns the Universal Symbol object specified by the ticker or the universal_symbol_id. + * * @param string $query The ticker or universal_symbol_id of the UniversalSymbol to get. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbolsByTicker'] to see the possible values for this operation * @@ -2014,6 +2060,8 @@ function ($response) { * * Get details of a symbol * + * Returns the Universal Symbol object specified by the ticker or the universal_symbol_id. + * * @param string $query The ticker or universal_symbol_id of the UniversalSymbol to get. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbolsByTicker'] to see the possible values for this operation * @@ -2186,6 +2234,8 @@ public function getSymbolsByTickerRequest($query, string $contentType = self::co * * Get all brokerage authorization types * + * Returns a list of all defined Brokerage authorization Type objects. + * * @param string $brokerage Comma separated value of brokerage slugs (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageAuthorizationType'] to see the possible values for this operation * @@ -2209,6 +2259,8 @@ public function listAllBrokerageAuthorizationType( * * Get all brokerage authorization types * + * Returns a list of all defined Brokerage authorization Type objects. + * * @param string $brokerage Comma separated value of brokerage slugs (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageAuthorizationType'] to see the possible values for this operation * @@ -2324,6 +2376,8 @@ public function listAllBrokerageAuthorizationTypeWithHttpInfo($brokerage = null, * * Get all brokerage authorization types * + * Returns a list of all defined Brokerage authorization Type objects. + * * @param string $brokerage Comma separated value of brokerage slugs (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageAuthorizationType'] to see the possible values for this operation * @@ -2350,6 +2404,8 @@ function ($response) { * * Get all brokerage authorization types * + * Returns a list of all defined Brokerage authorization Type objects. + * * @param string $brokerage Comma separated value of brokerage slugs (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageAuthorizationType'] to see the possible values for this operation * @@ -2519,6 +2575,8 @@ public function listAllBrokerageAuthorizationTypeRequest($brokerage = SENTINEL_V * * Get brokerages * + * Returns a list of all defined Brokerage objects. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerages'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -2541,6 +2599,8 @@ public function listAllBrokerages( * * Get brokerages * + * Returns a list of all defined Brokerage objects. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerages'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -2654,6 +2714,8 @@ public function listAllBrokeragesWithHttpInfo(string $contentType = self::conten * * Get brokerages * + * Returns a list of all defined Brokerage objects. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerages'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -2679,6 +2741,8 @@ function ($response) { * * Get brokerages * + * Returns a list of all defined Brokerage objects. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerages'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -2831,6 +2895,8 @@ public function listAllBrokeragesRequest(string $contentType = self::contentType * * Get currencies * + * Returns a list of all defined Currency objects. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllCurrencies'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -2853,6 +2919,8 @@ public function listAllCurrencies( * * Get currencies * + * Returns a list of all defined Currency objects. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllCurrencies'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -2966,6 +3034,8 @@ public function listAllCurrenciesWithHttpInfo(string $contentType = self::conten * * Get currencies * + * Returns a list of all defined Currency objects. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllCurrencies'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -2991,6 +3061,8 @@ function ($response) { * * Get currencies * + * Returns a list of all defined Currency objects. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllCurrencies'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -3143,6 +3215,8 @@ public function listAllCurrenciesRequest(string $contentType = self::contentType * * Get currency exchange rates * + * Returns a list of all Exchange Rate Pairs for all supported Currencies. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllCurrenciesRates'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -3165,6 +3239,8 @@ public function listAllCurrenciesRates( * * Get currency exchange rates * + * Returns a list of all Exchange Rate Pairs for all supported Currencies. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllCurrenciesRates'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -3278,6 +3354,8 @@ public function listAllCurrenciesRatesWithHttpInfo(string $contentType = self::c * * Get currency exchange rates * + * Returns a list of all Exchange Rate Pairs for all supported Currencies. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllCurrenciesRates'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -3303,6 +3381,8 @@ function ($response) { * * Get currency exchange rates * + * Returns a list of all Exchange Rate Pairs for all supported Currencies. + * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllCurrenciesRates'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -3455,6 +3535,8 @@ public function listAllCurrenciesRatesRequest(string $contentType = self::conten * * Search for symbols available in an account * + * Returns a list of universal symbols that are supported by the specificied account. Returned symbols are based on the provided search string, matching on ticker and name. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id The ID of the account to search for symbols within. (required) @@ -3487,6 +3569,8 @@ public function symbolSearchUserAccount( * * Search for symbols available in an account * + * Returns a list of universal symbols that are supported by the specificied account. Returned symbols are based on the provided search string, matching on ticker and name. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to search for symbols within. (required) @@ -3608,6 +3692,8 @@ public function symbolSearchUserAccountWithHttpInfo($user_id, $user_secret, $acc * * Search for symbols available in an account * + * Returns a list of universal symbols that are supported by the specificied account. Returned symbols are based on the provided search string, matching on ticker and name. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to search for symbols within. (required) @@ -3643,6 +3729,8 @@ function ($response) { * * Search for symbols available in an account * + * Returns a list of universal symbols that are supported by the specificied account. Returned symbols are based on the provided search string, matching on ticker and name. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to search for symbols within. (required) diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 2e1a4ac..98fdfe2 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -152,6 +152,8 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * Cancel open order in account * + * Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id The ID of the account to cancel the order in. (required) @@ -184,6 +186,8 @@ public function cancelUserAccountOrder( * * Cancel open order in account * + * Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to cancel the order in. (required) @@ -351,6 +355,8 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco * * Cancel open order in account * + * Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to cancel the order in. (required) @@ -386,6 +392,8 @@ function ($response) { * * Cancel open order in account * + * Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed. + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id The ID of the account to cancel the order in. (required) @@ -627,6 +635,8 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i * * Check the impact of a trade on an account * + * Return the trade object and it's impact on the account for the specified order. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form manual_trade_form (required) @@ -673,6 +683,8 @@ public function getOrderImpact( * * Check the impact of a trade on an account * + * Return the trade object and it's impact on the account for the specified order. + * * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) @@ -838,6 +850,8 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade * * Check the impact of a trade on an account * + * Return the trade object and it's impact on the account for the specified order. + * * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) @@ -887,6 +901,8 @@ function ($response) { * * Check the impact of a trade on an account * + * Return the trade object and it's impact on the account for the specified order. + * * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) @@ -1108,6 +1124,8 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form * * Get symbol quotes * + * Returns quote(s) from the brokerage for the specified symbol(s). + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $symbols List of universal_symbol_id or tickers to get quotes for. (required) @@ -1139,6 +1157,8 @@ public function getUserAccountQuotes( * * Get symbol quotes * + * Returns quote(s) from the brokerage for the specified symbol(s). + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $symbols List of universal_symbol_id or tickers to get quotes for. (required) @@ -1285,6 +1305,8 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol * * Get symbol quotes * + * Returns quote(s) from the brokerage for the specified symbol(s). + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $symbols List of universal_symbol_id or tickers to get quotes for. (required) @@ -1319,6 +1341,8 @@ function ($response) { * * Get symbol quotes * + * Returns quote(s) from the brokerage for the specified symbol(s). + * * @param string $user_id (required) * @param string $user_secret (required) * @param string $symbols List of universal_symbol_id or tickers to get quotes for. (required) @@ -1573,6 +1597,8 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a * * Place a trade with NO validation. * + * Places a specified trade in the specified account. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form manual_trade_form (required) @@ -1619,6 +1645,8 @@ public function placeForceOrder( * * Place a trade with NO validation. * + * Places a specified trade in the specified account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) @@ -1784,6 +1812,8 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad * * Place a trade with NO validation. * + * Places a specified trade in the specified account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) @@ -1833,6 +1863,8 @@ function ($response) { * * Place a trade with NO validation. * + * Places a specified trade in the specified account. + * * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) @@ -2054,6 +2086,8 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for * * Place order * + * Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage. + * * @param string $trade_id The ID of trade object obtained from trade/impact endpoint (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -2086,6 +2120,8 @@ public function placeOrder( * * Place order * + * Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage. + * * @param string $trade_id The ID of trade object obtained from trade/impact endpoint (required) * @param string $user_id (required) * @param string $user_secret (required) @@ -2230,6 +2266,8 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid * * Place order * + * Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage. + * * @param string $trade_id The ID of trade object obtained from trade/impact endpoint (required) * @param string $user_id (required) * @param string $user_secret (required) @@ -2265,6 +2303,8 @@ function ($response) { * * Place order * + * Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage. + * * @param string $trade_id The ID of trade object obtained from trade/impact endpoint (required) * @param string $user_id (required) * @param string $user_secret (required) diff --git a/lib/Api/TransactionsAndReportingApi.php b/lib/Api/TransactionsAndReportingApi.php index d81c657..4b1e00c 100644 --- a/lib/Api/TransactionsAndReportingApi.php +++ b/lib/Api/TransactionsAndReportingApi.php @@ -143,13 +143,15 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * Get transaction history for a user * + * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \DateTime $start_date start_date (optional) - * @param \DateTime $end_date end_date (optional) - * @param string $accounts Optional comma seperated list of account IDs used to filter the request on specific accounts (optional) - * @param string $brokerage_authorizations Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations (optional) - * @param string $type Optional comma seperated list of types to filter activities by. This is not an exhaustive list, if we fail to match to these types, we will return the raw description from the brokerage. Potential values include - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT (optional) + * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) + * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) + * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -178,13 +180,15 @@ public function getActivities( * * Get transaction history for a user * + * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) - * @param \DateTime $start_date (optional) - * @param \DateTime $end_date (optional) - * @param string $accounts Optional comma seperated list of account IDs used to filter the request on specific accounts (optional) - * @param string $brokerage_authorizations Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations (optional) - * @param string $type Optional comma seperated list of types to filter activities by. This is not an exhaustive list, if we fail to match to these types, we will return the raw description from the brokerage. Potential values include - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT (optional) + * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) + * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) + * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -305,13 +309,15 @@ public function getActivitiesWithHttpInfo($user_id, $user_secret, $start_date = * * Get transaction history for a user * + * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) - * @param \DateTime $start_date (optional) - * @param \DateTime $end_date (optional) - * @param string $accounts Optional comma seperated list of account IDs used to filter the request on specific accounts (optional) - * @param string $brokerage_authorizations Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations (optional) - * @param string $type Optional comma seperated list of types to filter activities by. This is not an exhaustive list, if we fail to match to these types, we will return the raw description from the brokerage. Potential values include - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT (optional) + * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) + * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) + * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -343,13 +349,15 @@ function ($response) { * * Get transaction history for a user * + * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * * @param string $user_id (required) * @param string $user_secret (required) - * @param \DateTime $start_date (optional) - * @param \DateTime $end_date (optional) - * @param string $accounts Optional comma seperated list of account IDs used to filter the request on specific accounts (optional) - * @param string $brokerage_authorizations Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations (optional) - * @param string $type Optional comma seperated list of types to filter activities by. This is not an exhaustive list, if we fail to match to these types, we will return the raw description from the brokerage. Potential values include - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT (optional) + * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) + * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) + * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -404,11 +412,11 @@ function ($exception) { * * @param string $user_id (required) * @param string $user_secret (required) - * @param \DateTime $start_date (optional) - * @param \DateTime $end_date (optional) - * @param string $accounts Optional comma seperated list of account IDs used to filter the request on specific accounts (optional) - * @param string $brokerage_authorizations Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations (optional) - * @param string $type Optional comma seperated list of types to filter activities by. This is not an exhaustive list, if we fail to match to these types, we will return the raw description from the brokerage. Potential values include - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT (optional) + * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) + * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) + * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -618,11 +626,13 @@ public function getActivitiesRequest($user_id, $user_secret, $start_date = SENTI * * Get performance information for a specific timeframe * + * Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Please note that Total Equity Timeframe and Rate of Returns are experimental features. Please contact support@snaptrade.com if you notice any inconsistencies. + * * @param \DateTime $start_date start_date (required) * @param \DateTime $end_date end_date (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $accounts Optional comma seperated list of account IDs used to filter the request on specific accounts (optional) + * @param string $accounts Optional comma separated list of account IDs used to filter the request on specific accounts (optional) * @param bool $detailed Optional, increases frequency of data points for the total value and contribution charts if set to true (optional) * @param string $frequency Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportingCustomRange'] to see the possible values for this operation @@ -654,11 +664,13 @@ public function getReportingCustomRange( * * Get performance information for a specific timeframe * + * Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Please note that Total Equity Timeframe and Rate of Returns are experimental features. Please contact support@snaptrade.com if you notice any inconsistencies. + * * @param \DateTime $start_date (required) * @param \DateTime $end_date (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $accounts Optional comma seperated list of account IDs used to filter the request on specific accounts (optional) + * @param string $accounts Optional comma separated list of account IDs used to filter the request on specific accounts (optional) * @param bool $detailed Optional, increases frequency of data points for the total value and contribution charts if set to true (optional) * @param string $frequency Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportingCustomRange'] to see the possible values for this operation @@ -782,11 +794,13 @@ public function getReportingCustomRangeWithHttpInfo($start_date, $end_date, $use * * Get performance information for a specific timeframe * + * Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Please note that Total Equity Timeframe and Rate of Returns are experimental features. Please contact support@snaptrade.com if you notice any inconsistencies. + * * @param \DateTime $start_date (required) * @param \DateTime $end_date (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $accounts Optional comma seperated list of account IDs used to filter the request on specific accounts (optional) + * @param string $accounts Optional comma separated list of account IDs used to filter the request on specific accounts (optional) * @param bool $detailed Optional, increases frequency of data points for the total value and contribution charts if set to true (optional) * @param string $frequency Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportingCustomRange'] to see the possible values for this operation @@ -821,11 +835,13 @@ function ($response) { * * Get performance information for a specific timeframe * + * Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Please note that Total Equity Timeframe and Rate of Returns are experimental features. Please contact support@snaptrade.com if you notice any inconsistencies. + * * @param \DateTime $start_date (required) * @param \DateTime $end_date (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $accounts Optional comma seperated list of account IDs used to filter the request on specific accounts (optional) + * @param string $accounts Optional comma separated list of account IDs used to filter the request on specific accounts (optional) * @param bool $detailed Optional, increases frequency of data points for the total value and contribution charts if set to true (optional) * @param string $frequency Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportingCustomRange'] to see the possible values for this operation @@ -885,7 +901,7 @@ function ($exception) { * @param \DateTime $end_date (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $accounts Optional comma seperated list of account IDs used to filter the request on specific accounts (optional) + * @param string $accounts Optional comma separated list of account IDs used to filter the request on specific accounts (optional) * @param bool $detailed Optional, increases frequency of data points for the total value and contribution charts if set to true (optional) * @param string $frequency Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportingCustomRange'] to see the possible values for this operation diff --git a/lib/Configuration.php b/lib/Configuration.php index 3b0a423..79ff133 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.32/PHP'; + protected $userAgent = 'Konfig/2.0.36/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.32' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.36' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; diff --git a/lib/Model/Account.php b/lib/Model/Account.php index 4676599..63f72fa 100644 --- a/lib/Model/Account.php +++ b/lib/Model/Account.php @@ -30,7 +30,7 @@ * Account Class Doc Comment * * @category Class - * @description A single brokerage account at a financial institution. + * @description A single account at a brokerage. * @package SnapTrade * @implements \ArrayAccess */ @@ -366,7 +366,7 @@ public function getId() /** * Sets id * - * @param string|null $id Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. This ID should not change for as long as the connection stays active. If the connection is deleted and re-added, a new account ID will be generated. If you want a stable identifier for the account, use the `number` field. + * @param string|null $id Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. This ID should not change for as long as the connection stays active. If the connection is deleted and re-added, a new account ID will be generated. * * @return self */ @@ -395,7 +395,7 @@ public function getBrokerageAuthorization() /** * Sets brokerage_authorization * - * @param string|null $brokerage_authorization Unique identifier for the connection (brokerage authorization). This is the UUID used to reference the connection in SnapTrade. + * @param string|null $brokerage_authorization Unique identifier for the connection. This is the UUID used to reference the connection in SnapTrade. * * @return self */ @@ -455,7 +455,7 @@ public function getName() /** * Sets name * - * @param string|null $name A display name for the account. Either assigned by the user or by the financial institution itself. For certain institutions, SnapTrade appends the institution name to the account name for clarity. + * @param string|null $name A display name for the account. Either assigned by the user or by the brokerage itself. For certain brokerages, SnapTrade appends the brokerage name to the account name for clarity. * * @return self */ @@ -491,7 +491,7 @@ public function getNumber() /** * Sets number * - * @param string|null $number The account number assigned by the financial institution. + * @param string|null $number The account number assigned by the brokerage. For some brokerages, this field may be masked for security reasons. * * @return self */ @@ -520,7 +520,7 @@ public function getInstitutionName() /** * Sets institution_name * - * @param string|null $institution_name The name of the financial institution that holds the account. + * @param string|null $institution_name The name of the brokerage that holds the account. * * @return self */ @@ -549,7 +549,7 @@ public function getCreatedDate() /** * Sets created_date * - * @param \DateTime|null $created_date Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the account was created in SnapTrade. This is _not_ the account opening date at the financial institution. + * @param \DateTime|null $created_date Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the account was created in SnapTrade. This is _not_ the account opening date at the brokerage. * * @return self */ @@ -579,7 +579,7 @@ public function getMeta() /** * Sets meta * - * @param array|null $meta Additional information about the account, such as account type, status, etc. This information is specific to the financial institution and there's no standard format for this data. Please use at your own risk. + * @param array|null $meta Additional information about the account, such as account type, status, etc. This information is specific to the brokerage and there's no standard format for this data. This field is deprecated and subject to removal in a future version. * * @return self * @deprecated diff --git a/lib/Model/AccountOrderRecord.php b/lib/Model/AccountOrderRecord.php index 00d6445..ac621a6 100644 --- a/lib/Model/AccountOrderRecord.php +++ b/lib/Model/AccountOrderRecord.php @@ -886,7 +886,7 @@ public function getTimeInForce() /** * Sets time_in_force * - * @param string|null $time_in_force The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. We try our best to map brokerage time in force values to the following. When mapping fails, we will return the brokerage's time in force value. - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. + * @param string|null $time_in_force The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. We try our best to map brokerage time in force values to the following. When mapping fails, we will return the brokerage's time in force value. - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. - `MOO` - Market On Open. The order is to be executed at the day's opening price. - `EHP` - Extended Hours P.M. The order is to be placed during extended hour trading, after markets close. * * @return self */ diff --git a/lib/Model/AccountOrderRecordUniversalSymbol.php b/lib/Model/AccountOrderRecordUniversalSymbol.php index 656f3af..bb2fc0f 100644 --- a/lib/Model/AccountOrderRecordUniversalSymbol.php +++ b/lib/Model/AccountOrderRecordUniversalSymbol.php @@ -55,8 +55,8 @@ class AccountOrderRecordUniversalSymbol implements ModelInterface, ArrayAccess, 'symbol' => 'string', 'raw_symbol' => 'string', 'description' => 'string', - 'currency' => '\SnapTrade\Model\UniversalSymbolCurrency', - 'exchange' => '\SnapTrade\Model\UniversalSymbolExchange', + 'currency' => '\SnapTrade\Model\SymbolCurrency', + 'exchange' => '\SnapTrade\Model\SymbolExchange', 'type' => '\SnapTrade\Model\SecurityType', 'currencies' => '\SnapTrade\Model\Currency[]', 'figi_code' => 'string', @@ -490,7 +490,7 @@ public function setDescription($description) /** * Gets currency * - * @return \SnapTrade\Model\UniversalSymbolCurrency + * @return \SnapTrade\Model\SymbolCurrency */ public function getCurrency() { @@ -500,7 +500,7 @@ public function getCurrency() /** * Sets currency * - * @param \SnapTrade\Model\UniversalSymbolCurrency $currency currency + * @param \SnapTrade\Model\SymbolCurrency $currency currency * * @return self */ @@ -519,7 +519,7 @@ public function setCurrency($currency) /** * Gets exchange * - * @return \SnapTrade\Model\UniversalSymbolExchange|null + * @return \SnapTrade\Model\SymbolExchange|null */ public function getExchange() { @@ -529,7 +529,7 @@ public function getExchange() /** * Sets exchange * - * @param \SnapTrade\Model\UniversalSymbolExchange|null $exchange exchange + * @param \SnapTrade\Model\SymbolExchange|null $exchange exchange * * @return self */ diff --git a/lib/Model/AccountSimple.php b/lib/Model/AccountSimple.php index b6d9a39..d3140ac 100644 --- a/lib/Model/AccountSimple.php +++ b/lib/Model/AccountSimple.php @@ -30,7 +30,7 @@ * AccountSimple Class Doc Comment * * @category Class - * @description SnapTradeUser Investment Account + * @description A single account at a brokerage. * @package SnapTrade * @implements \ArrayAccess */ @@ -317,7 +317,7 @@ public function getId() /** * Sets id * - * @param string|null $id id + * @param string|null $id Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. * * @return self */ @@ -346,7 +346,7 @@ public function getName() /** * Sets name * - * @param string|null $name name + * @param string|null $name A display name for the account. Either assigned by the user or by the brokerage itself. For certain brokerages, SnapTrade appends the brokerage name to the account name for clarity. * * @return self */ @@ -375,7 +375,7 @@ public function getNumber() /** * Sets number * - * @param string|null $number number + * @param string|null $number The account number assigned by the brokerage. For some brokerages, this field may be masked for security reasons. * * @return self */ diff --git a/lib/Model/AuthenticationLoginSnapTradeUser200Response.php b/lib/Model/AuthenticationLoginSnapTradeUser200Response.php index 07dca9e..bf7f308 100644 --- a/lib/Model/AuthenticationLoginSnapTradeUser200Response.php +++ b/lib/Model/AuthenticationLoginSnapTradeUser200Response.php @@ -50,7 +50,7 @@ class AuthenticationLoginSnapTradeUser200Response implements ModelInterface, Arr * @var string[] */ protected static $openAPITypes = [ - 'redirect_uri' => 'mixed', + 'redirect_uri' => 'string', 'session_id' => 'string', 'encrypted_shared_key' => 'string', 'encrypted_message_data' => '\SnapTrade\Model\EncryptedResponseEncryptedMessageData' @@ -76,7 +76,7 @@ class AuthenticationLoginSnapTradeUser200Response implements ModelInterface, Arr * @var boolean[] */ protected static array $openAPINullables = [ - 'redirect_uri' => true, + 'redirect_uri' => false, 'session_id' => false, 'encrypted_shared_key' => false, 'encrypted_message_data' => false @@ -306,7 +306,7 @@ public function valid() /** * Gets redirect_uri * - * @return mixed|null + * @return string|null */ public function getRedirectUri() { @@ -316,7 +316,7 @@ public function getRedirectUri() /** * Sets redirect_uri * - * @param mixed|null $redirect_uri redirect_uri + * @param string|null $redirect_uri Connection Portal link to redirect user to connect a brokerage account. * * @return self */ @@ -324,14 +324,7 @@ public function setRedirectUri($redirect_uri) { if (is_null($redirect_uri)) { - array_push($this->openAPINullablesSetToNull, 'redirect_uri'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('redirect_uri', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } + throw new \InvalidArgumentException('non-nullable redirect_uri cannot be null'); } $this->container['redirect_uri'] = $redirect_uri; @@ -352,7 +345,7 @@ public function getSessionId() /** * Sets session_id * - * @param string|null $session_id session_id + * @param string|null $session_id ID to identify the connection portal session. * * @return self */ diff --git a/lib/Model/Brokerage.php b/lib/Model/Brokerage.php index c015202..29cc33d 100644 --- a/lib/Model/Brokerage.php +++ b/lib/Model/Brokerage.php @@ -30,6 +30,7 @@ * Brokerage Class Doc Comment * * @category Class + * @description Describes a brokerage that SnapTrade supports. * @package SnapTrade * @implements \ArrayAccess */ @@ -51,13 +52,13 @@ class Brokerage implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static $openAPITypes = [ 'id' => 'string', + 'slug' => 'string', 'name' => 'string', 'display_name' => 'string', 'description' => 'string', 'aws_s3_logo_url' => 'string', 'aws_s3_square_logo_url' => 'string', 'open_url' => 'string', - 'slug' => 'string', 'url' => 'string', 'enabled' => 'bool', 'maintenance_mode' => 'bool', @@ -65,9 +66,6 @@ class Brokerage implements ModelInterface, ArrayAccess, \JsonSerializable 'allows_trading' => 'bool', 'has_reporting' => 'bool', 'is_real_time_connection' => 'bool', - 'allows_trading_through_snaptrade_api' => 'bool', - 'is_scraping_integration' => 'bool', - 'default_currency' => 'string', 'brokerage_type' => '\SnapTrade\Model\BrokerageType', 'exchanges' => 'mixed[]' ]; @@ -81,13 +79,13 @@ class Brokerage implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static $openAPIFormats = [ 'id' => 'uuid', + 'slug' => null, 'name' => null, 'display_name' => null, 'description' => null, 'aws_s3_logo_url' => 'url', 'aws_s3_square_logo_url' => 'url', 'open_url' => 'url', - 'slug' => null, 'url' => 'url', 'enabled' => null, 'maintenance_mode' => null, @@ -95,9 +93,6 @@ class Brokerage implements ModelInterface, ArrayAccess, \JsonSerializable 'allows_trading' => null, 'has_reporting' => null, 'is_real_time_connection' => null, - 'allows_trading_through_snaptrade_api' => null, - 'is_scraping_integration' => null, - 'default_currency' => 'uuid', 'brokerage_type' => null, 'exchanges' => null ]; @@ -109,13 +104,13 @@ class Brokerage implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static array $openAPINullables = [ 'id' => false, + 'slug' => false, 'name' => false, 'display_name' => false, 'description' => false, 'aws_s3_logo_url' => false, 'aws_s3_square_logo_url' => true, 'open_url' => true, - 'slug' => false, 'url' => false, 'enabled' => false, 'maintenance_mode' => false, @@ -123,9 +118,6 @@ class Brokerage implements ModelInterface, ArrayAccess, \JsonSerializable 'allows_trading' => true, 'has_reporting' => true, 'is_real_time_connection' => false, - 'allows_trading_through_snaptrade_api' => true, - 'is_scraping_integration' => false, - 'default_currency' => false, 'brokerage_type' => false, 'exchanges' => false ]; @@ -217,13 +209,13 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'id' => 'id', + 'slug' => 'slug', 'name' => 'name', 'display_name' => 'display_name', 'description' => 'description', 'aws_s3_logo_url' => 'aws_s3_logo_url', 'aws_s3_square_logo_url' => 'aws_s3_square_logo_url', 'open_url' => 'open_url', - 'slug' => 'slug', 'url' => 'url', 'enabled' => 'enabled', 'maintenance_mode' => 'maintenance_mode', @@ -231,9 +223,6 @@ public function isNullableSetToNull(string $property): bool 'allows_trading' => 'allows_trading', 'has_reporting' => 'has_reporting', 'is_real_time_connection' => 'is_real_time_connection', - 'allows_trading_through_snaptrade_api' => 'allows_trading_through_snaptrade_api', - 'is_scraping_integration' => 'is_scraping_integration', - 'default_currency' => 'default_currency', 'brokerage_type' => 'brokerage_type', 'exchanges' => 'exchanges' ]; @@ -245,13 +234,13 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'id' => 'setId', + 'slug' => 'setSlug', 'name' => 'setName', 'display_name' => 'setDisplayName', 'description' => 'setDescription', 'aws_s3_logo_url' => 'setAwsS3LogoUrl', 'aws_s3_square_logo_url' => 'setAwsS3SquareLogoUrl', 'open_url' => 'setOpenUrl', - 'slug' => 'setSlug', 'url' => 'setUrl', 'enabled' => 'setEnabled', 'maintenance_mode' => 'setMaintenanceMode', @@ -259,9 +248,6 @@ public function isNullableSetToNull(string $property): bool 'allows_trading' => 'setAllowsTrading', 'has_reporting' => 'setHasReporting', 'is_real_time_connection' => 'setIsRealTimeConnection', - 'allows_trading_through_snaptrade_api' => 'setAllowsTradingThroughSnaptradeApi', - 'is_scraping_integration' => 'setIsScrapingIntegration', - 'default_currency' => 'setDefaultCurrency', 'brokerage_type' => 'setBrokerageType', 'exchanges' => 'setExchanges' ]; @@ -273,13 +259,13 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'id' => 'getId', + 'slug' => 'getSlug', 'name' => 'getName', 'display_name' => 'getDisplayName', 'description' => 'getDescription', 'aws_s3_logo_url' => 'getAwsS3LogoUrl', 'aws_s3_square_logo_url' => 'getAwsS3SquareLogoUrl', 'open_url' => 'getOpenUrl', - 'slug' => 'getSlug', 'url' => 'getUrl', 'enabled' => 'getEnabled', 'maintenance_mode' => 'getMaintenanceMode', @@ -287,9 +273,6 @@ public function isNullableSetToNull(string $property): bool 'allows_trading' => 'getAllowsTrading', 'has_reporting' => 'getHasReporting', 'is_real_time_connection' => 'getIsRealTimeConnection', - 'allows_trading_through_snaptrade_api' => 'getAllowsTradingThroughSnaptradeApi', - 'is_scraping_integration' => 'getIsScrapingIntegration', - 'default_currency' => 'getDefaultCurrency', 'brokerage_type' => 'getBrokerageType', 'exchanges' => 'getExchanges' ]; @@ -352,13 +335,13 @@ public function getModelName() public function __construct(array $data = null) { $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('slug', $data ?? [], null); $this->setIfExists('name', $data ?? [], null); $this->setIfExists('display_name', $data ?? [], null); $this->setIfExists('description', $data ?? [], null); $this->setIfExists('aws_s3_logo_url', $data ?? [], null); $this->setIfExists('aws_s3_square_logo_url', $data ?? [], null); $this->setIfExists('open_url', $data ?? [], null); - $this->setIfExists('slug', $data ?? [], null); $this->setIfExists('url', $data ?? [], null); $this->setIfExists('enabled', $data ?? [], null); $this->setIfExists('maintenance_mode', $data ?? [], null); @@ -366,9 +349,6 @@ public function __construct(array $data = null) $this->setIfExists('allows_trading', $data ?? [], null); $this->setIfExists('has_reporting', $data ?? [], null); $this->setIfExists('is_real_time_connection', $data ?? [], null); - $this->setIfExists('allows_trading_through_snaptrade_api', $data ?? [], null); - $this->setIfExists('is_scraping_integration', $data ?? [], null); - $this->setIfExists('default_currency', $data ?? [], null); $this->setIfExists('brokerage_type', $data ?? [], null); $this->setIfExists('exchanges', $data ?? [], null); } @@ -428,7 +408,7 @@ public function getId() /** * Sets id * - * @param string|null $id id + * @param string|null $id Unique identifier for the brokerage firm. This is the UUID used to reference the brokerage in SnapTrade. * * @return self */ @@ -444,6 +424,35 @@ public function setId($id) return $this; } + /** + * Gets slug + * + * @return string|null + */ + public function getSlug() + { + return $this->container['slug']; + } + + /** + * Sets slug + * + * @param string|null $slug A short, unique identifier for the brokerage. It is usually the name of the brokerage in capital letters and will never change. + * + * @return self + */ + public function setSlug($slug) + { + + if (is_null($slug)) { + throw new \InvalidArgumentException('non-nullable slug cannot be null'); + } + + $this->container['slug'] = $slug; + + return $this; + } + /** * Gets name * @@ -515,7 +524,7 @@ public function getDescription() /** * Sets description * - * @param string|null $description description + * @param string|null $description A brief description of the brokerage. * * @return self */ @@ -544,7 +553,7 @@ public function getAwsS3LogoUrl() /** * Sets aws_s3_logo_url * - * @param string|null $aws_s3_logo_url aws_s3_logo_url + * @param string|null $aws_s3_logo_url URL to the brokerage's logo. * * @return self */ @@ -573,7 +582,7 @@ public function getAwsS3SquareLogoUrl() /** * Sets aws_s3_square_logo_url * - * @param string|null $aws_s3_square_logo_url aws_s3_square_logo_url + * @param string|null $aws_s3_square_logo_url URL to the brokerage's logo in square format. * * @return self */ @@ -600,6 +609,7 @@ public function setAwsS3SquareLogoUrl($aws_s3_square_logo_url) * Gets open_url * * @return string|null + * @deprecated */ public function getOpenUrl() { @@ -609,9 +619,10 @@ public function getOpenUrl() /** * Sets open_url * - * @param string|null $open_url open_url + * @param string|null $open_url This field is deprecated. * * @return self + * @deprecated */ public function setOpenUrl($open_url) { @@ -632,35 +643,6 @@ public function setOpenUrl($open_url) return $this; } - /** - * Gets slug - * - * @return string|null - */ - public function getSlug() - { - return $this->container['slug']; - } - - /** - * Sets slug - * - * @param string|null $slug A unique identifier for that brokerage. It is usually the name of the brokerage in capital letters and will never change. - * - * @return self - */ - public function setSlug($slug) - { - - if (is_null($slug)) { - throw new \InvalidArgumentException('non-nullable slug cannot be null'); - } - - $this->container['slug'] = $slug; - - return $this; - } - /** * Gets url * @@ -674,7 +656,7 @@ public function getUrl() /** * Sets url * - * @param string|null $url url + * @param string|null $url URL to the brokerage's website. * * @return self */ @@ -703,7 +685,7 @@ public function getEnabled() /** * Sets enabled * - * @param bool|null $enabled enabled + * @param bool|null $enabled Whether the brokerage is enabled in SnapTrade. A disabled brokerage will not be available for new connections. * * @return self */ @@ -732,7 +714,7 @@ public function getMaintenanceMode() /** * Sets maintenance_mode * - * @param bool|null $maintenance_mode maintenance_mode + * @param bool|null $maintenance_mode Whether the brokerage is currently in maintenance mode. A brokerage in maintenance mode will not be available for new connections. * * @return self */ @@ -752,6 +734,7 @@ public function setMaintenanceMode($maintenance_mode) * Gets allows_fractional_units * * @return bool|null + * @deprecated */ public function getAllowsFractionalUnits() { @@ -761,9 +744,10 @@ public function getAllowsFractionalUnits() /** * Sets allows_fractional_units * - * @param bool|null $allows_fractional_units allows_fractional_units + * @param bool|null $allows_fractional_units This field is deprecated. Please contact us if you have a valid use case for it. * * @return self + * @deprecated */ public function setAllowsFractionalUnits($allows_fractional_units) { @@ -797,7 +781,7 @@ public function getAllowsTrading() /** * Sets allows_trading * - * @param bool|null $allows_trading allows_trading + * @param bool|null $allows_trading Whether the brokerage allows trading through SnapTrade. * * @return self */ @@ -824,6 +808,7 @@ public function setAllowsTrading($allows_trading) * Gets has_reporting * * @return bool|null + * @deprecated */ public function getHasReporting() { @@ -833,9 +818,10 @@ public function getHasReporting() /** * Sets has_reporting * - * @param bool|null $has_reporting has_reporting + * @param bool|null $has_reporting This field is deprecated. Please contact us if you have a valid use case for it. * * @return self + * @deprecated */ public function setHasReporting($has_reporting) { @@ -860,6 +846,7 @@ public function setHasReporting($has_reporting) * Gets is_real_time_connection * * @return bool|null + * @deprecated */ public function getIsRealTimeConnection() { @@ -869,9 +856,10 @@ public function getIsRealTimeConnection() /** * Sets is_real_time_connection * - * @param bool|null $is_real_time_connection is_real_time_connection + * @param bool|null $is_real_time_connection This field is deprecated. Please contact us if you have a valid use case for it. * * @return self + * @deprecated */ public function setIsRealTimeConnection($is_real_time_connection) { @@ -885,100 +873,6 @@ public function setIsRealTimeConnection($is_real_time_connection) return $this; } - /** - * Gets allows_trading_through_snaptrade_api - * - * @return bool|null - */ - public function getAllowsTradingThroughSnaptradeApi() - { - return $this->container['allows_trading_through_snaptrade_api']; - } - - /** - * Sets allows_trading_through_snaptrade_api - * - * @param bool|null $allows_trading_through_snaptrade_api allows_trading_through_snaptrade_api - * - * @return self - */ - public function setAllowsTradingThroughSnaptradeApi($allows_trading_through_snaptrade_api) - { - - if (is_null($allows_trading_through_snaptrade_api)) { - array_push($this->openAPINullablesSetToNull, 'allows_trading_through_snaptrade_api'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('allows_trading_through_snaptrade_api', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - - $this->container['allows_trading_through_snaptrade_api'] = $allows_trading_through_snaptrade_api; - - return $this; - } - - /** - * Gets is_scraping_integration - * - * @return bool|null - */ - public function getIsScrapingIntegration() - { - return $this->container['is_scraping_integration']; - } - - /** - * Sets is_scraping_integration - * - * @param bool|null $is_scraping_integration is_scraping_integration - * - * @return self - */ - public function setIsScrapingIntegration($is_scraping_integration) - { - - if (is_null($is_scraping_integration)) { - throw new \InvalidArgumentException('non-nullable is_scraping_integration cannot be null'); - } - - $this->container['is_scraping_integration'] = $is_scraping_integration; - - return $this; - } - - /** - * Gets default_currency - * - * @return string|null - */ - public function getDefaultCurrency() - { - return $this->container['default_currency']; - } - - /** - * Sets default_currency - * - * @param string|null $default_currency default_currency - * - * @return self - */ - public function setDefaultCurrency($default_currency) - { - - if (is_null($default_currency)) { - throw new \InvalidArgumentException('non-nullable default_currency cannot be null'); - } - - $this->container['default_currency'] = $default_currency; - - return $this; - } - /** * Gets brokerage_type * @@ -1012,6 +906,7 @@ public function setBrokerageType($brokerage_type) * Gets exchanges * * @return mixed[]|null + * @deprecated */ public function getExchanges() { @@ -1021,9 +916,10 @@ public function getExchanges() /** * Sets exchanges * - * @param mixed[]|null $exchanges List of exchange ID supported by brokerage + * @param mixed[]|null $exchanges This field is deprecated. Please contact us if you have a valid use case for it. * * @return self + * @deprecated */ public function setExchanges($exchanges) { diff --git a/lib/Model/BrokerageAuthorization.php b/lib/Model/BrokerageAuthorization.php index 90f74bd..5871927 100644 --- a/lib/Model/BrokerageAuthorization.php +++ b/lib/Model/BrokerageAuthorization.php @@ -30,6 +30,7 @@ * BrokerageAuthorization Class Doc Comment * * @category Class + * @description A single connection with a brokerage. Note that `Connection` and `Brokerage Authorization` are interchangeable, but the term `Connection` is preferred and used in the doc for consistency. A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts. SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one. * @package SnapTrade * @implements \ArrayAccess */ @@ -51,13 +52,13 @@ class BrokerageAuthorization implements ModelInterface, ArrayAccess, \JsonSerial */ protected static $openAPITypes = [ 'id' => 'string', - 'created_date' => 'string', - 'updated_date' => 'string', + 'created_date' => '\DateTime', + 'updated_date' => '\DateTime', 'brokerage' => '\SnapTrade\Model\Brokerage', 'name' => 'string', 'type' => 'string', 'disabled' => 'bool', - 'disabled_date' => 'string', + 'disabled_date' => '\DateTime', 'meta' => 'array' ]; @@ -70,13 +71,13 @@ class BrokerageAuthorization implements ModelInterface, ArrayAccess, \JsonSerial */ protected static $openAPIFormats = [ 'id' => 'uuid', - 'created_date' => null, - 'updated_date' => null, + 'created_date' => 'date-time', + 'updated_date' => 'date-time', 'brokerage' => null, 'name' => null, 'type' => null, 'disabled' => null, - 'disabled_date' => null, + 'disabled_date' => 'date-time', 'meta' => null ]; @@ -351,7 +352,7 @@ public function getId() /** * Sets id * - * @param string|null $id id + * @param string|null $id Unique identifier for the connection. This is the UUID used to reference the connection in SnapTrade. * * @return self */ @@ -370,7 +371,7 @@ public function setId($id) /** * Gets created_date * - * @return string|null + * @return \DateTime|null */ public function getCreatedDate() { @@ -380,7 +381,7 @@ public function getCreatedDate() /** * Sets created_date * - * @param string|null $created_date Time + * @param \DateTime|null $created_date Timestamp of when the connection was established in SnapTrade. * * @return self */ @@ -399,7 +400,8 @@ public function setCreatedDate($created_date) /** * Gets updated_date * - * @return string|null + * @return \DateTime|null + * @deprecated */ public function getUpdatedDate() { @@ -409,9 +411,10 @@ public function getUpdatedDate() /** * Sets updated_date * - * @param string|null $updated_date Time + * @param \DateTime|null $updated_date Timestamp of when the connection was last updated in SnapTrade. This field is deprecated. Please let us know if you have a valid use case for this field. * * @return self + * @deprecated */ public function setUpdatedDate($updated_date) { @@ -467,7 +470,7 @@ public function getName() /** * Sets name * - * @param string|null $name Connection Name + * @param string|null $name A short, human-readable name for the connection. * * @return self */ @@ -496,7 +499,7 @@ public function getType() /** * Sets type * - * @param string|null $type type + * @param string|null $type Whether the connection is read-only or trade-enabled. A read-only connection can only be used to fetch data, while a trade-enabled connection can be used to place trades. Valid values are `read` and `trade`. * * @return self */ @@ -525,7 +528,7 @@ public function getDisabled() /** * Sets disabled * - * @param bool|null $disabled disabled + * @param bool|null $disabled Whether the connection is disabled. A disabled connection can no longer access the latest data from the brokerage, but will continue to return the last cached state. A connection can become disabled for many reasons and differs by brokerage. Here are some common scenarios: - The user has changed their username or password at the brokerage. - The user has explicitly removed the access grant at the brokerage. - The session has expired at the brokerage and now requires explicit user re-authentication. Please see [this guide](https://docs.snaptrade.com/docs/fix-broken-connections) on how to fix a disabled connection. * * @return self */ @@ -544,7 +547,7 @@ public function setDisabled($disabled) /** * Gets disabled_date * - * @return string|null + * @return \DateTime|null */ public function getDisabledDate() { @@ -554,7 +557,7 @@ public function getDisabledDate() /** * Sets disabled_date * - * @param string|null $disabled_date Disabled date + * @param \DateTime|null $disabled_date Timestamp of when the connection was disabled in SnapTrade. * * @return self */ @@ -581,6 +584,7 @@ public function setDisabledDate($disabled_date) * Gets meta * * @return array|null + * @deprecated */ public function getMeta() { @@ -590,9 +594,10 @@ public function getMeta() /** * Sets meta * - * @param array|null $meta Additional data about brokerage authorization + * @param array|null $meta Additional data about the connection. This information is specific to the brokerage and there's no standard format for this data. This field is deprecated and subject to removal in a future version. * * @return self + * @deprecated */ public function setMeta($meta) { diff --git a/lib/Model/BrokerageAuthorizationDisabledConfirmation.php b/lib/Model/BrokerageAuthorizationDisabledConfirmation.php index ad43858..90b9171 100644 --- a/lib/Model/BrokerageAuthorizationDisabledConfirmation.php +++ b/lib/Model/BrokerageAuthorizationDisabledConfirmation.php @@ -30,6 +30,7 @@ * BrokerageAuthorizationDisabledConfirmation Class Doc Comment * * @category Class + * @description Confirmation that the connection has been disabled. * @package SnapTrade * @implements \ArrayAccess */ diff --git a/lib/Model/BrokerageAuthorizationRefreshConfirmation.php b/lib/Model/BrokerageAuthorizationRefreshConfirmation.php index 0b053bd..662cc5e 100644 --- a/lib/Model/BrokerageAuthorizationRefreshConfirmation.php +++ b/lib/Model/BrokerageAuthorizationRefreshConfirmation.php @@ -30,6 +30,7 @@ * BrokerageAuthorizationRefreshConfirmation Class Doc Comment * * @category Class + * @description Confirmation that the syncs have been scheduled. * @package SnapTrade * @implements \ArrayAccess */ diff --git a/lib/Model/BrokerageType.php b/lib/Model/BrokerageType.php index 9bbd4b8..1162a75 100644 --- a/lib/Model/BrokerageType.php +++ b/lib/Model/BrokerageType.php @@ -30,7 +30,7 @@ * BrokerageType Class Doc Comment * * @category Class - * @description Type of brokerage + * @description Type of brokerage. Currently supports traditional brokerages and crypto exchanges. * @package SnapTrade * @implements \ArrayAccess */ diff --git a/lib/Model/DeleteUserResponse.php b/lib/Model/DeleteUserResponse.php index 4571d1e..7d68eb2 100644 --- a/lib/Model/DeleteUserResponse.php +++ b/lib/Model/DeleteUserResponse.php @@ -30,7 +30,6 @@ * DeleteUserResponse Class Doc Comment * * @category Class - * @description Response when delete user is successful * @package SnapTrade * @implements \ArrayAccess */ @@ -52,6 +51,7 @@ class DeleteUserResponse implements ModelInterface, ArrayAccess, \JsonSerializab */ protected static $openAPITypes = [ 'status' => 'string', + 'detail' => 'string', 'user_id' => 'string' ]; @@ -64,6 +64,7 @@ class DeleteUserResponse implements ModelInterface, ArrayAccess, \JsonSerializab */ protected static $openAPIFormats = [ 'status' => null, + 'detail' => null, 'user_id' => null ]; @@ -74,6 +75,7 @@ class DeleteUserResponse implements ModelInterface, ArrayAccess, \JsonSerializab */ protected static array $openAPINullables = [ 'status' => false, + 'detail' => false, 'user_id' => false ]; @@ -164,6 +166,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'status' => 'status', + 'detail' => 'detail', 'user_id' => 'userId' ]; @@ -174,6 +177,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'status' => 'setStatus', + 'detail' => 'setDetail', 'user_id' => 'setUserId' ]; @@ -184,6 +188,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'status' => 'getStatus', + 'detail' => 'getDetail', 'user_id' => 'getUserId' ]; @@ -245,6 +250,7 @@ public function getModelName() public function __construct(array $data = null) { $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('detail', $data ?? [], null); $this->setIfExists('user_id', $data ?? [], null); } @@ -303,7 +309,7 @@ public function getStatus() /** * Sets status * - * @param string|null $status Delete status + * @param string|null $status This is always `deleted` when a user is queued for deletion. * * @return self */ @@ -319,6 +325,35 @@ public function setStatus($status) return $this; } + /** + * Gets detail + * + * @return string|null + */ + public function getDetail() + { + return $this->container['detail']; + } + + /** + * Sets detail + * + * @param string|null $detail Human friendly message about the deletion status. + * + * @return self + */ + public function setDetail($detail) + { + + if (is_null($detail)) { + throw new \InvalidArgumentException('non-nullable detail cannot be null'); + } + + $this->container['detail'] = $detail; + + return $this; + } + /** * Gets user_id * diff --git a/lib/Model/LoginRedirectURI.php b/lib/Model/LoginRedirectURI.php index 027d13f..ffc286d 100644 --- a/lib/Model/LoginRedirectURI.php +++ b/lib/Model/LoginRedirectURI.php @@ -51,7 +51,7 @@ class LoginRedirectURI implements ModelInterface, ArrayAccess, \JsonSerializable * @var string[] */ protected static $openAPITypes = [ - 'redirect_uri' => 'mixed', + 'redirect_uri' => 'string', 'session_id' => 'string' ]; @@ -73,7 +73,7 @@ class LoginRedirectURI implements ModelInterface, ArrayAccess, \JsonSerializable * @var boolean[] */ protected static array $openAPINullables = [ - 'redirect_uri' => true, + 'redirect_uri' => false, 'session_id' => false ]; @@ -293,7 +293,7 @@ public function valid() /** * Gets redirect_uri * - * @return mixed|null + * @return string|null */ public function getRedirectUri() { @@ -303,7 +303,7 @@ public function getRedirectUri() /** * Sets redirect_uri * - * @param mixed|null $redirect_uri redirect_uri + * @param string|null $redirect_uri Connection Portal link to redirect user to connect a brokerage account. * * @return self */ @@ -311,14 +311,7 @@ public function setRedirectUri($redirect_uri) { if (is_null($redirect_uri)) { - array_push($this->openAPINullablesSetToNull, 'redirect_uri'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('redirect_uri', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } + throw new \InvalidArgumentException('non-nullable redirect_uri cannot be null'); } $this->container['redirect_uri'] = $redirect_uri; @@ -339,7 +332,7 @@ public function getSessionId() /** * Sets session_id * - * @param string|null $session_id session_id + * @param string|null $session_id ID to identify the connection portal session. * * @return self */ diff --git a/lib/Model/SnapTradeLoginUserRequestBody.php b/lib/Model/SnapTradeLoginUserRequestBody.php index aead6c1..461dba5 100644 --- a/lib/Model/SnapTradeLoginUserRequestBody.php +++ b/lib/Model/SnapTradeLoginUserRequestBody.php @@ -302,8 +302,8 @@ public function __construct(array $data = null) $this->setIfExists('immediate_redirect', $data ?? [], null); $this->setIfExists('custom_redirect', $data ?? [], null); $this->setIfExists('reconnect', $data ?? [], null); - $this->setIfExists('connection_type', $data ?? [], null); - $this->setIfExists('connection_portal_version', $data ?? [], null); + $this->setIfExists('connection_type', $data ?? [], 'read'); + $this->setIfExists('connection_portal_version', $data ?? [], 'v3'); } /** @@ -379,7 +379,7 @@ public function getBroker() /** * Sets broker * - * @param string|null $broker Slug of the brokerage to connect the user to. See [this document](https://snaptrade.notion.site/SnapTrade-Brokerage-Integrations-f83946a714a84c3caf599f6a945f0ead) for a list of supported brokerages and their slugs. + * @param string|null $broker Slug of the brokerage to connect the user to. See [the integrations page](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=3cfea70ef4254afc89704e47275a7a9a&pvs=4) for a list of supported brokerages and their slugs. * * @return self */ @@ -408,7 +408,7 @@ public function getImmediateRedirect() /** * Sets immediate_redirect * - * @param bool|null $immediate_redirect When set to True, user will be redirected back to the partner's site instead of the connection portal + * @param bool|null $immediate_redirect When set to `true`, user will be redirected back to the partner's site instead of the connection portal. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](https://docs.snaptrade.com/docs/implement-connection-portal) for more information. * * @return self */ @@ -437,7 +437,7 @@ public function getCustomRedirect() /** * Sets custom_redirect * - * @param string|null $custom_redirect URL to redirect the user to after the user connects their brokerage account + * @param string|null $custom_redirect URL to redirect the user to after the user connects their brokerage account. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](https://docs.snaptrade.com/docs/implement-connection-portal) for more information. * * @return self */ @@ -466,7 +466,7 @@ public function getReconnect() /** * Sets reconnect * - * @param string|null $reconnect The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See β€˜Reconnecting Accounts’ for more information. + * @param string|null $reconnect The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See the [guide on fixing broken connections](https://docs.snaptrade.com/docs/fix-broken-connections) for more information. * * @return self */ @@ -495,7 +495,7 @@ public function getConnectionType() /** * Sets connection_type * - * @param string|null $connection_type Sets whether the connection should be read or trade + * @param string|null $connection_type Sets whether the connection should be read-only or trade-enabled. * * @return self */ @@ -534,7 +534,7 @@ public function getConnectionPortalVersion() /** * Sets connection_portal_version * - * @param string|null $connection_portal_version Sets the version of the connection portal to render, with a default to 'v3' + * @param string|null $connection_portal_version Sets the version of the connection portal to render. * * @return self */ diff --git a/lib/Model/Symbol.php b/lib/Model/Symbol.php index a04755b..c07643c 100644 --- a/lib/Model/Symbol.php +++ b/lib/Model/Symbol.php @@ -30,7 +30,7 @@ * Symbol Class Doc Comment * * @category Class - * @description Symbol + * @description Uniquely describes a single security + exchange combination across all brokerages. * @package SnapTrade * @implements \ArrayAccess */ @@ -54,9 +54,9 @@ class Symbol implements ModelInterface, ArrayAccess, \JsonSerializable 'id' => 'string', 'symbol' => 'string', 'raw_symbol' => 'string', - 'name' => 'string', - 'currency' => '\SnapTrade\Model\Currency', - 'exchange' => '\SnapTrade\Model\Exchange', + 'description' => 'string', + 'currency' => '\SnapTrade\Model\SymbolCurrency', + 'exchange' => '\SnapTrade\Model\SymbolExchange', 'type' => '\SnapTrade\Model\SecurityType', 'figi_code' => 'string', 'figi_instrument' => '\SnapTrade\Model\SymbolFigiInstrument' @@ -73,7 +73,7 @@ class Symbol implements ModelInterface, ArrayAccess, \JsonSerializable 'id' => 'uuid', 'symbol' => null, 'raw_symbol' => null, - 'name' => null, + 'description' => null, 'currency' => null, 'exchange' => null, 'type' => null, @@ -90,7 +90,7 @@ class Symbol implements ModelInterface, ArrayAccess, \JsonSerializable 'id' => false, 'symbol' => false, 'raw_symbol' => false, - 'name' => false, + 'description' => true, 'currency' => false, 'exchange' => false, 'type' => false, @@ -187,7 +187,7 @@ public function isNullableSetToNull(string $property): bool 'id' => 'id', 'symbol' => 'symbol', 'raw_symbol' => 'raw_symbol', - 'name' => 'name', + 'description' => 'description', 'currency' => 'currency', 'exchange' => 'exchange', 'type' => 'type', @@ -204,7 +204,7 @@ public function isNullableSetToNull(string $property): bool 'id' => 'setId', 'symbol' => 'setSymbol', 'raw_symbol' => 'setRawSymbol', - 'name' => 'setName', + 'description' => 'setDescription', 'currency' => 'setCurrency', 'exchange' => 'setExchange', 'type' => 'setType', @@ -221,7 +221,7 @@ public function isNullableSetToNull(string $property): bool 'id' => 'getId', 'symbol' => 'getSymbol', 'raw_symbol' => 'getRawSymbol', - 'name' => 'getName', + 'description' => 'getDescription', 'currency' => 'getCurrency', 'exchange' => 'getExchange', 'type' => 'getType', @@ -289,7 +289,7 @@ public function __construct(array $data = null) $this->setIfExists('id', $data ?? [], null); $this->setIfExists('symbol', $data ?? [], null); $this->setIfExists('raw_symbol', $data ?? [], null); - $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); $this->setIfExists('currency', $data ?? [], null); $this->setIfExists('exchange', $data ?? [], null); $this->setIfExists('type', $data ?? [], null); @@ -352,7 +352,7 @@ public function getId() /** * Sets id * - * @param string|null $id id + * @param string|null $id Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls. * * @return self */ @@ -381,7 +381,7 @@ public function getSymbol() /** * Sets symbol * - * @param string|null $symbol symbol + * @param string|null $symbol The security's trading ticker symbol. For example \"AAPL\" for Apple Inc. We largely follow the [Yahoo Finance ticker format](https://help.yahoo.com/kb/SLN2310.html)(click on \"Yahoo Finance Market Coverage and Data Delays\"). For example, for securities traded on the Toronto Stock Exchange, the symbol has a '.TO' suffix. For securities traded on NASDAQ or NYSE, the symbol does not have a suffix. * * @return self */ @@ -410,7 +410,7 @@ public function getRawSymbol() /** * Sets raw_symbol * - * @param string|null $raw_symbol raw_symbol + * @param string|null $raw_symbol The raw symbol is `symbol` with the exchange suffix removed. For example, if `symbol` is \"VAB.TO\", then `raw_symbol` is \"VAB\". * * @return self */ @@ -427,30 +427,37 @@ public function setRawSymbol($raw_symbol) } /** - * Gets name + * Gets description * * @return string|null */ - public function getName() + public function getDescription() { - return $this->container['name']; + return $this->container['description']; } /** - * Sets name + * Sets description * - * @param string|null $name name + * @param string|null $description A human-readable description of the security. This is usually the company name or ETF name. * * @return self */ - public function setName($name) + public function setDescription($description) { - if (is_null($name)) { - throw new \InvalidArgumentException('non-nullable name cannot be null'); + if (is_null($description)) { + array_push($this->openAPINullablesSetToNull, 'description'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('description', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } } - $this->container['name'] = $name; + $this->container['description'] = $description; return $this; } @@ -458,7 +465,7 @@ public function setName($name) /** * Gets currency * - * @return \SnapTrade\Model\Currency|null + * @return \SnapTrade\Model\SymbolCurrency|null */ public function getCurrency() { @@ -468,7 +475,7 @@ public function getCurrency() /** * Sets currency * - * @param \SnapTrade\Model\Currency|null $currency currency + * @param \SnapTrade\Model\SymbolCurrency|null $currency currency * * @return self */ @@ -487,7 +494,7 @@ public function setCurrency($currency) /** * Gets exchange * - * @return \SnapTrade\Model\Exchange|null + * @return \SnapTrade\Model\SymbolExchange|null */ public function getExchange() { @@ -497,7 +504,7 @@ public function getExchange() /** * Sets exchange * - * @param \SnapTrade\Model\Exchange|null $exchange exchange + * @param \SnapTrade\Model\SymbolExchange|null $exchange exchange * * @return self */ @@ -555,7 +562,7 @@ public function getFigiCode() /** * Sets figi_code * - * @param string|null $figi_code figi_code + * @param string|null $figi_code This identifier is unique per security per trading venue. See section 1.4.1 of the [FIGI Standard](https://www.openfigi.com/assets/local/figi-allocation-rules.pdf) for more information. This value should be the same as the `figi_code` in the `figi_instrument` child property. * * @return self */ diff --git a/lib/Model/UniversalSymbolCurrency.php b/lib/Model/SymbolCurrency.php similarity index 97% rename from lib/Model/UniversalSymbolCurrency.php rename to lib/Model/SymbolCurrency.php index a0e4a92..52381d1 100644 --- a/lib/Model/UniversalSymbolCurrency.php +++ b/lib/Model/SymbolCurrency.php @@ -1,6 +1,6 @@ */ -class UniversalSymbolCurrency implements ModelInterface, ArrayAccess, \JsonSerializable +class SymbolCurrency implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -43,7 +43,7 @@ class UniversalSymbolCurrency implements ModelInterface, ArrayAccess, \JsonSeria * * @var string */ - protected static $openAPIModelName = 'UniversalSymbol_currency'; + protected static $openAPIModelName = 'Symbol_currency'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/lib/Model/UniversalSymbolExchange.php b/lib/Model/SymbolExchange.php similarity index 98% rename from lib/Model/UniversalSymbolExchange.php rename to lib/Model/SymbolExchange.php index 89d533a..31e375a 100644 --- a/lib/Model/UniversalSymbolExchange.php +++ b/lib/Model/SymbolExchange.php @@ -1,6 +1,6 @@ */ -class UniversalSymbolExchange implements ModelInterface, ArrayAccess, \JsonSerializable +class SymbolExchange implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -43,7 +43,7 @@ class UniversalSymbolExchange implements ModelInterface, ArrayAccess, \JsonSeria * * @var string */ - protected static $openAPIModelName = 'UniversalSymbol_exchange'; + protected static $openAPIModelName = 'Symbol_exchange'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/lib/Model/UnderlyingSymbol.php b/lib/Model/UnderlyingSymbol.php index 2e412ae..837857a 100644 --- a/lib/Model/UnderlyingSymbol.php +++ b/lib/Model/UnderlyingSymbol.php @@ -55,7 +55,7 @@ class UnderlyingSymbol implements ModelInterface, ArrayAccess, \JsonSerializable 'symbol' => 'string', 'raw_symbol' => 'string', 'description' => 'string', - 'currency' => '\SnapTrade\Model\UniversalSymbolCurrency', + 'currency' => '\SnapTrade\Model\SymbolCurrency', 'exchange' => '\SnapTrade\Model\UnderlyingSymbolExchange', 'type' => '\SnapTrade\Model\UnderlyingSymbolType', 'currencies' => '\SnapTrade\Model\Currency[]', @@ -472,7 +472,7 @@ public function setDescription($description) /** * Gets currency * - * @return \SnapTrade\Model\UniversalSymbolCurrency|null + * @return \SnapTrade\Model\SymbolCurrency|null */ public function getCurrency() { @@ -482,7 +482,7 @@ public function getCurrency() /** * Sets currency * - * @param \SnapTrade\Model\UniversalSymbolCurrency|null $currency currency + * @param \SnapTrade\Model\SymbolCurrency|null $currency currency * * @return self */ diff --git a/lib/Model/UniversalActivity.php b/lib/Model/UniversalActivity.php index 5ea6d39..c1d6888 100644 --- a/lib/Model/UniversalActivity.php +++ b/lib/Model/UniversalActivity.php @@ -53,21 +53,21 @@ class UniversalActivity implements ModelInterface, ArrayAccess, \JsonSerializabl protected static $openAPITypes = [ 'id' => 'string', 'account' => '\SnapTrade\Model\AccountSimple', + 'symbol' => '\SnapTrade\Model\UniversalActivitySymbol', + 'option_symbol' => '\SnapTrade\Model\UniversalActivityOptionSymbol', + 'price' => 'float', + 'units' => 'float', 'amount' => 'float', - 'currency' => '\SnapTrade\Model\Currency', + 'currency' => '\SnapTrade\Model\UniversalActivityCurrency', + 'type' => 'string', + 'option_type' => 'string', 'description' => 'string', + 'trade_date' => '\DateTime', + 'settlement_date' => '\DateTime', 'fee' => 'float', 'fx_rate' => 'float', 'institution' => 'string', - 'option_type' => 'string', - 'price' => 'float', - 'settlement_date' => 'string', - 'external_reference_id' => 'string', - 'symbol' => '\SnapTrade\Model\Symbol', - 'option_symbol' => '\SnapTrade\Model\OptionsSymbol', - 'trade_date' => 'string', - 'type' => 'string', - 'units' => 'float' + 'external_reference_id' => 'string' ]; /** @@ -80,21 +80,21 @@ class UniversalActivity implements ModelInterface, ArrayAccess, \JsonSerializabl protected static $openAPIFormats = [ 'id' => null, 'account' => null, + 'symbol' => null, + 'option_symbol' => null, + 'price' => null, + 'units' => null, 'amount' => null, 'currency' => null, + 'type' => null, + 'option_type' => null, 'description' => null, + 'trade_date' => 'date-time', + 'settlement_date' => 'date-time', 'fee' => null, 'fx_rate' => null, 'institution' => null, - 'option_type' => null, - 'price' => null, - 'settlement_date' => null, - 'external_reference_id' => null, - 'symbol' => null, - 'option_symbol' => null, - 'trade_date' => null, - 'type' => null, - 'units' => null + 'external_reference_id' => null ]; /** @@ -105,21 +105,21 @@ class UniversalActivity implements ModelInterface, ArrayAccess, \JsonSerializabl protected static array $openAPINullables = [ 'id' => false, 'account' => false, + 'symbol' => true, + 'option_symbol' => true, + 'price' => false, + 'units' => false, 'amount' => true, 'currency' => false, + 'type' => false, + 'option_type' => false, 'description' => false, + 'trade_date' => true, + 'settlement_date' => false, 'fee' => false, 'fx_rate' => true, 'institution' => false, - 'option_type' => false, - 'price' => false, - 'settlement_date' => false, - 'external_reference_id' => true, - 'symbol' => false, - 'option_symbol' => false, - 'trade_date' => true, - 'type' => false, - 'units' => false + 'external_reference_id' => true ]; /** @@ -210,21 +210,21 @@ public function isNullableSetToNull(string $property): bool protected static $attributeMap = [ 'id' => 'id', 'account' => 'account', + 'symbol' => 'symbol', + 'option_symbol' => 'option_symbol', + 'price' => 'price', + 'units' => 'units', 'amount' => 'amount', 'currency' => 'currency', + 'type' => 'type', + 'option_type' => 'option_type', 'description' => 'description', + 'trade_date' => 'trade_date', + 'settlement_date' => 'settlement_date', 'fee' => 'fee', 'fx_rate' => 'fx_rate', 'institution' => 'institution', - 'option_type' => 'option_type', - 'price' => 'price', - 'settlement_date' => 'settlement_date', - 'external_reference_id' => 'external_reference_id', - 'symbol' => 'symbol', - 'option_symbol' => 'option_symbol', - 'trade_date' => 'trade_date', - 'type' => 'type', - 'units' => 'units' + 'external_reference_id' => 'external_reference_id' ]; /** @@ -235,21 +235,21 @@ public function isNullableSetToNull(string $property): bool protected static $setters = [ 'id' => 'setId', 'account' => 'setAccount', + 'symbol' => 'setSymbol', + 'option_symbol' => 'setOptionSymbol', + 'price' => 'setPrice', + 'units' => 'setUnits', 'amount' => 'setAmount', 'currency' => 'setCurrency', + 'type' => 'setType', + 'option_type' => 'setOptionType', 'description' => 'setDescription', + 'trade_date' => 'setTradeDate', + 'settlement_date' => 'setSettlementDate', 'fee' => 'setFee', 'fx_rate' => 'setFxRate', 'institution' => 'setInstitution', - 'option_type' => 'setOptionType', - 'price' => 'setPrice', - 'settlement_date' => 'setSettlementDate', - 'external_reference_id' => 'setExternalReferenceId', - 'symbol' => 'setSymbol', - 'option_symbol' => 'setOptionSymbol', - 'trade_date' => 'setTradeDate', - 'type' => 'setType', - 'units' => 'setUnits' + 'external_reference_id' => 'setExternalReferenceId' ]; /** @@ -260,21 +260,21 @@ public function isNullableSetToNull(string $property): bool protected static $getters = [ 'id' => 'getId', 'account' => 'getAccount', + 'symbol' => 'getSymbol', + 'option_symbol' => 'getOptionSymbol', + 'price' => 'getPrice', + 'units' => 'getUnits', 'amount' => 'getAmount', 'currency' => 'getCurrency', + 'type' => 'getType', + 'option_type' => 'getOptionType', 'description' => 'getDescription', + 'trade_date' => 'getTradeDate', + 'settlement_date' => 'getSettlementDate', 'fee' => 'getFee', 'fx_rate' => 'getFxRate', 'institution' => 'getInstitution', - 'option_type' => 'getOptionType', - 'price' => 'getPrice', - 'settlement_date' => 'getSettlementDate', - 'external_reference_id' => 'getExternalReferenceId', - 'symbol' => 'getSymbol', - 'option_symbol' => 'getOptionSymbol', - 'trade_date' => 'getTradeDate', - 'type' => 'getType', - 'units' => 'getUnits' + 'external_reference_id' => 'getExternalReferenceId' ]; /** @@ -336,21 +336,21 @@ public function __construct(array $data = null) { $this->setIfExists('id', $data ?? [], null); $this->setIfExists('account', $data ?? [], null); + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('option_symbol', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('units', $data ?? [], null); $this->setIfExists('amount', $data ?? [], null); $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('option_type', $data ?? [], null); $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('trade_date', $data ?? [], null); + $this->setIfExists('settlement_date', $data ?? [], null); $this->setIfExists('fee', $data ?? [], null); $this->setIfExists('fx_rate', $data ?? [], null); $this->setIfExists('institution', $data ?? [], null); - $this->setIfExists('option_type', $data ?? [], null); - $this->setIfExists('price', $data ?? [], null); - $this->setIfExists('settlement_date', $data ?? [], null); $this->setIfExists('external_reference_id', $data ?? [], null); - $this->setIfExists('symbol', $data ?? [], null); - $this->setIfExists('option_symbol', $data ?? [], null); - $this->setIfExists('trade_date', $data ?? [], null); - $this->setIfExists('type', $data ?? [], null); - $this->setIfExists('units', $data ?? [], null); } /** @@ -408,7 +408,7 @@ public function getId() /** * Sets id * - * @param string|null $id id + * @param string|null $id Unique identifier for the transaction. This is the ID used to reference the transaction in SnapTrade. Please note that this ID _can_ change if the transaction is deleted and re-added. Under normal circumstances, SnapTrade does not delete transactions. The only time this would happen is if SnapTrade re-fetches and reprocesses the data from the brokerage, which is rare. If you require a stable ID, please let us know and we can work with you to provide one. * * @return self */ @@ -454,464 +454,478 @@ public function setAccount($account) } /** - * Gets amount + * Gets symbol * - * @return float|null + * @return \SnapTrade\Model\UniversalActivitySymbol|null */ - public function getAmount() + public function getSymbol() { - return $this->container['amount']; + return $this->container['symbol']; } /** - * Sets amount + * Sets symbol * - * @param float|null $amount amount + * @param \SnapTrade\Model\UniversalActivitySymbol|null $symbol symbol * * @return self */ - public function setAmount($amount) + public function setSymbol($symbol) { - if (is_null($amount)) { - array_push($this->openAPINullablesSetToNull, 'amount'); + if (is_null($symbol)) { + array_push($this->openAPINullablesSetToNull, 'symbol'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('amount', $nullablesSetToNull); + $index = array_search('symbol', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } - $this->container['amount'] = $amount; + $this->container['symbol'] = $symbol; return $this; } /** - * Gets currency + * Gets option_symbol * - * @return \SnapTrade\Model\Currency|null + * @return \SnapTrade\Model\UniversalActivityOptionSymbol|null */ - public function getCurrency() + public function getOptionSymbol() { - return $this->container['currency']; + return $this->container['option_symbol']; } /** - * Sets currency + * Sets option_symbol * - * @param \SnapTrade\Model\Currency|null $currency currency + * @param \SnapTrade\Model\UniversalActivityOptionSymbol|null $option_symbol option_symbol * * @return self */ - public function setCurrency($currency) + public function setOptionSymbol($option_symbol) { - if (is_null($currency)) { - throw new \InvalidArgumentException('non-nullable currency cannot be null'); + if (is_null($option_symbol)) { + array_push($this->openAPINullablesSetToNull, 'option_symbol'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('option_symbol', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } } - $this->container['currency'] = $currency; + $this->container['option_symbol'] = $option_symbol; return $this; } /** - * Gets description + * Gets price * - * @return string|null + * @return float|null */ - public function getDescription() + public function getPrice() { - return $this->container['description']; + return $this->container['price']; } /** - * Sets description + * Sets price * - * @param string|null $description description + * @param float|null $price The price of the security for the transaction. This is mostly applicable to `BUY`, `SELL`, and `DIVIDEND` transactions. * * @return self */ - public function setDescription($description) + public function setPrice($price) { - if (is_null($description)) { - throw new \InvalidArgumentException('non-nullable description cannot be null'); + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); } - $this->container['description'] = $description; + $this->container['price'] = $price; return $this; } /** - * Gets fee + * Gets units * * @return float|null */ - public function getFee() + public function getUnits() { - return $this->container['fee']; + return $this->container['units']; } /** - * Sets fee + * Sets units * - * @param float|null $fee fee + * @param float|null $units The number of units of the security for the transaction. This is mostly applicable to `BUY`, `SELL`, and `DIVIDEND` transactions. * * @return self */ - public function setFee($fee) + public function setUnits($units) { - if (is_null($fee)) { - throw new \InvalidArgumentException('non-nullable fee cannot be null'); + if (is_null($units)) { + throw new \InvalidArgumentException('non-nullable units cannot be null'); } - $this->container['fee'] = $fee; + $this->container['units'] = $units; return $this; } /** - * Gets fx_rate + * Gets amount * * @return float|null */ - public function getFxRate() + public function getAmount() { - return $this->container['fx_rate']; + return $this->container['amount']; } /** - * Sets fx_rate + * Sets amount * - * @param float|null $fx_rate The forex conversion rate involved in the transaction if provided by the brokerage. Used in cases where securities of one currency are purchased in a different currency, and the forex conversion is automatic. In those cases, price, amount and fee will be in the top level currency (activity -> currency) + * @param float|null $amount The amount of the transaction denominated in `currency`. This can be positive or negative. In general, transactions that positively affect the account balance (like sell, deposits, dividends, etc) will have a positive amount, while transactions that negatively affect the account balance (like buy, withdrawals, fees, etc) will have a negative amount. * * @return self */ - public function setFxRate($fx_rate) + public function setAmount($amount) { - if (is_null($fx_rate)) { - array_push($this->openAPINullablesSetToNull, 'fx_rate'); + if (is_null($amount)) { + array_push($this->openAPINullablesSetToNull, 'amount'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('fx_rate', $nullablesSetToNull); + $index = array_search('amount', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } - $this->container['fx_rate'] = $fx_rate; + $this->container['amount'] = $amount; return $this; } /** - * Gets institution + * Gets currency * - * @return string|null + * @return \SnapTrade\Model\UniversalActivityCurrency|null */ - public function getInstitution() + public function getCurrency() { - return $this->container['institution']; + return $this->container['currency']; } /** - * Sets institution + * Sets currency * - * @param string|null $institution institution + * @param \SnapTrade\Model\UniversalActivityCurrency|null $currency currency * * @return self */ - public function setInstitution($institution) + public function setCurrency($currency) { - if (is_null($institution)) { - throw new \InvalidArgumentException('non-nullable institution cannot be null'); + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); } - $this->container['institution'] = $institution; + $this->container['currency'] = $currency; return $this; } /** - * Gets option_type + * Gets type * * @return string|null */ - public function getOptionType() + public function getType() { - return $this->container['option_type']; + return $this->container['type']; } /** - * Sets option_type + * Sets type * - * @param string|null $option_type If an option transaction, then it's type (BUY_TO_OPEN, SELL_TO_CLOSE, etc), otherwise empty string + * @param string|null $type A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE * * @return self */ - public function setOptionType($option_type) + public function setType($type) { - if (is_null($option_type)) { - throw new \InvalidArgumentException('non-nullable option_type cannot be null'); + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); } - $this->container['option_type'] = $option_type; + $this->container['type'] = $type; return $this; } /** - * Gets price + * Gets option_type * - * @return float|null + * @return string|null */ - public function getPrice() + public function getOptionType() { - return $this->container['price']; + return $this->container['option_type']; } /** - * Sets price + * Sets option_type * - * @param float|null $price price + * @param string|null $option_type If an option `BUY` or `SELL` transaction, this further specifies the type of action. The possible values are: - BUY_TO_OPEN - BUY_TO_CLOSE - SELL_TO_OPEN - SELL_TO_CLOSE * * @return self */ - public function setPrice($price) + public function setOptionType($option_type) { - if (is_null($price)) { - throw new \InvalidArgumentException('non-nullable price cannot be null'); + if (is_null($option_type)) { + throw new \InvalidArgumentException('non-nullable option_type cannot be null'); } - $this->container['price'] = $price; + $this->container['option_type'] = $option_type; return $this; } /** - * Gets settlement_date + * Gets description * * @return string|null */ - public function getSettlementDate() + public function getDescription() { - return $this->container['settlement_date']; + return $this->container['description']; } /** - * Sets settlement_date + * Sets description * - * @param string|null $settlement_date settlement_date + * @param string|null $description A human-readable description of the transaction. This is usually the brokerage's description of the transaction. * * @return self */ - public function setSettlementDate($settlement_date) + public function setDescription($description) { - if (is_null($settlement_date)) { - throw new \InvalidArgumentException('non-nullable settlement_date cannot be null'); + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); } - $this->container['settlement_date'] = $settlement_date; + $this->container['description'] = $description; return $this; } /** - * Gets external_reference_id + * Gets trade_date * - * @return string|null + * @return \DateTime|null */ - public function getExternalReferenceId() + public function getTradeDate() { - return $this->container['external_reference_id']; + return $this->container['trade_date']; } /** - * Sets external_reference_id + * Sets trade_date * - * @param string|null $external_reference_id Reference ID from brokerage used to identify related transactions. For example if an order comprises of several transactions (buy, fee, fx), they can be grouped if they share the same external_reference_id + * @param \DateTime|null $trade_date The recorded time for the transaction. The granularity of this timestamp depends on the brokerage. Some brokerages provide the exact time of the transaction, while others provide only the date. Please check the [integrations page](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=6fab8012ade6441fa0c6d9af9c55ce3a) for the specific brokerage to see the granularity of the timestamps. Note that even though the field is named `trade_date`, it can represent any type of transaction, not just trades. * * @return self */ - public function setExternalReferenceId($external_reference_id) + public function setTradeDate($trade_date) { - if (is_null($external_reference_id)) { - array_push($this->openAPINullablesSetToNull, 'external_reference_id'); + if (is_null($trade_date)) { + array_push($this->openAPINullablesSetToNull, 'trade_date'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('external_reference_id', $nullablesSetToNull); + $index = array_search('trade_date', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } - $this->container['external_reference_id'] = $external_reference_id; + $this->container['trade_date'] = $trade_date; return $this; } /** - * Gets symbol + * Gets settlement_date * - * @return \SnapTrade\Model\Symbol|null + * @return \DateTime|null */ - public function getSymbol() + public function getSettlementDate() { - return $this->container['symbol']; + return $this->container['settlement_date']; } /** - * Sets symbol + * Sets settlement_date * - * @param \SnapTrade\Model\Symbol|null $symbol symbol + * @param \DateTime|null $settlement_date The date on which the transaction is settled. * * @return self */ - public function setSymbol($symbol) + public function setSettlementDate($settlement_date) { - if (is_null($symbol)) { - throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + if (is_null($settlement_date)) { + throw new \InvalidArgumentException('non-nullable settlement_date cannot be null'); } - $this->container['symbol'] = $symbol; + $this->container['settlement_date'] = $settlement_date; return $this; } /** - * Gets option_symbol + * Gets fee * - * @return \SnapTrade\Model\OptionsSymbol|null + * @return float|null */ - public function getOptionSymbol() + public function getFee() { - return $this->container['option_symbol']; + return $this->container['fee']; } /** - * Sets option_symbol + * Sets fee * - * @param \SnapTrade\Model\OptionsSymbol|null $option_symbol option_symbol + * @param float|null $fee Any fee associated with the transaction if provided by the brokerage. * * @return self */ - public function setOptionSymbol($option_symbol) + public function setFee($fee) { - if (is_null($option_symbol)) { - throw new \InvalidArgumentException('non-nullable option_symbol cannot be null'); + if (is_null($fee)) { + throw new \InvalidArgumentException('non-nullable fee cannot be null'); } - $this->container['option_symbol'] = $option_symbol; + $this->container['fee'] = $fee; return $this; } /** - * Gets trade_date + * Gets fx_rate * - * @return string|null + * @return float|null */ - public function getTradeDate() + public function getFxRate() { - return $this->container['trade_date']; + return $this->container['fx_rate']; } /** - * Sets trade_date + * Sets fx_rate * - * @param string|null $trade_date trade_date + * @param float|null $fx_rate The forex conversion rate involved in the transaction if provided by the brokerage. Used in cases where securities of one currency are purchased in a different currency, and the forex conversion is automatic. In those cases, price, amount and fee will be in the top level currency (activity -> currency) * * @return self */ - public function setTradeDate($trade_date) + public function setFxRate($fx_rate) { - if (is_null($trade_date)) { - array_push($this->openAPINullablesSetToNull, 'trade_date'); + if (is_null($fx_rate)) { + array_push($this->openAPINullablesSetToNull, 'fx_rate'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('trade_date', $nullablesSetToNull); + $index = array_search('fx_rate', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } - $this->container['trade_date'] = $trade_date; + $this->container['fx_rate'] = $fx_rate; return $this; } /** - * Gets type + * Gets institution * * @return string|null */ - public function getType() + public function getInstitution() { - return $this->container['type']; + return $this->container['institution']; } /** - * Sets type + * Sets institution * - * @param string|null $type Potential values include (but are not limited to) - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT + * @param string|null $institution The institution that the transaction is associated with. This is usually the brokerage name. * * @return self */ - public function setType($type) + public function setInstitution($institution) { - if (is_null($type)) { - throw new \InvalidArgumentException('non-nullable type cannot be null'); + if (is_null($institution)) { + throw new \InvalidArgumentException('non-nullable institution cannot be null'); } - $this->container['type'] = $type; + $this->container['institution'] = $institution; return $this; } /** - * Gets units + * Gets external_reference_id * - * @return float|null + * @return string|null */ - public function getUnits() + public function getExternalReferenceId() { - return $this->container['units']; + return $this->container['external_reference_id']; } /** - * Sets units + * Sets external_reference_id * - * @param float|null $units Usually but not necessarily an integer + * @param string|null $external_reference_id Reference ID from brokerage used to identify related transactions. For example if an order comprises of several transactions (buy, fee, fx), they can be grouped if they share the same `external_reference_id` * * @return self */ - public function setUnits($units) + public function setExternalReferenceId($external_reference_id) { - if (is_null($units)) { - throw new \InvalidArgumentException('non-nullable units cannot be null'); + if (is_null($external_reference_id)) { + array_push($this->openAPINullablesSetToNull, 'external_reference_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('external_reference_id', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } } - $this->container['units'] = $units; + $this->container['external_reference_id'] = $external_reference_id; return $this; } diff --git a/lib/Model/UniversalActivityCurrency.php b/lib/Model/UniversalActivityCurrency.php new file mode 100644 index 0000000..3a55a27 --- /dev/null +++ b/lib/Model/UniversalActivityCurrency.php @@ -0,0 +1,477 @@ + + */ +class UniversalActivityCurrency implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UniversalActivity_currency'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'code' => 'string', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'uuid', + 'code' => null, + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'code' => false, + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'code' => 'code', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'code' => 'setCode', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'code' => 'getCode', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('code', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for the currency. This is the UUID used to reference the currency in SnapTrade. + * + * @return self + */ + public function setId($id) + { + + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code The ISO-4217 currency code for the currency. + * + * @return self + */ + public function setCode($code) + { + + if (is_null($code)) { + throw new \InvalidArgumentException('non-nullable code cannot be null'); + } + + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name A human-friendly name of the currency. + * + * @return self + */ + public function setName($name) + { + + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/UniversalActivityOptionSymbol.php b/lib/Model/UniversalActivityOptionSymbol.php new file mode 100644 index 0000000..40e4e58 --- /dev/null +++ b/lib/Model/UniversalActivityOptionSymbol.php @@ -0,0 +1,673 @@ + + */ +class UniversalActivityOptionSymbol implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UniversalActivity_option_symbol'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'ticker' => 'string', + 'option_type' => 'string', + 'strike_price' => 'float', + 'expiration_date' => '\DateTime', + 'is_mini_option' => 'bool', + 'underlying_symbol' => '\SnapTrade\Model\UnderlyingSymbol' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'uuid', + 'ticker' => null, + 'option_type' => null, + 'strike_price' => null, + 'expiration_date' => 'date', + 'is_mini_option' => null, + 'underlying_symbol' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'ticker' => false, + 'option_type' => false, + 'strike_price' => false, + 'expiration_date' => false, + 'is_mini_option' => false, + 'underlying_symbol' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'ticker' => 'ticker', + 'option_type' => 'option_type', + 'strike_price' => 'strike_price', + 'expiration_date' => 'expiration_date', + 'is_mini_option' => 'is_mini_option', + 'underlying_symbol' => 'underlying_symbol' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'ticker' => 'setTicker', + 'option_type' => 'setOptionType', + 'strike_price' => 'setStrikePrice', + 'expiration_date' => 'setExpirationDate', + 'is_mini_option' => 'setIsMiniOption', + 'underlying_symbol' => 'setUnderlyingSymbol' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'ticker' => 'getTicker', + 'option_type' => 'getOptionType', + 'strike_price' => 'getStrikePrice', + 'expiration_date' => 'getExpirationDate', + 'is_mini_option' => 'getIsMiniOption', + 'underlying_symbol' => 'getUnderlyingSymbol' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const OPTION_TYPE_CALL = 'CALL'; + public const OPTION_TYPE_PUT = 'PUT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getOptionTypeAllowableValues() + { + return [ + self::OPTION_TYPE_CALL, + self::OPTION_TYPE_PUT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('ticker', $data ?? [], null); + $this->setIfExists('option_type', $data ?? [], null); + $this->setIfExists('strike_price', $data ?? [], null); + $this->setIfExists('expiration_date', $data ?? [], null); + $this->setIfExists('is_mini_option', $data ?? [], null); + $this->setIfExists('underlying_symbol', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['ticker'] === null) { + $invalidProperties[] = "'ticker' can't be null"; + } + if ($this->container['option_type'] === null) { + $invalidProperties[] = "'option_type' can't be null"; + } + $allowedValues = $this->getOptionTypeAllowableValues(); + if (!is_null($this->container['option_type']) && !in_array($this->container['option_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'option_type', must be one of '%s'", + $this->container['option_type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['strike_price'] === null) { + $invalidProperties[] = "'strike_price' can't be null"; + } + if ($this->container['expiration_date'] === null) { + $invalidProperties[] = "'expiration_date' can't be null"; + } + if ($this->container['underlying_symbol'] === null) { + $invalidProperties[] = "'underlying_symbol' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id Unique identifier for the option symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls. + * + * @return self + */ + public function setId($id) + { + + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets ticker + * + * @return string + */ + public function getTicker() + { + return $this->container['ticker']; + } + + /** + * Sets ticker + * + * @param string $ticker The [OCC symbol](https://en.wikipedia.org/wiki/Option_symbol) for the option. + * + * @return self + */ + public function setTicker($ticker) + { + + if (is_null($ticker)) { + throw new \InvalidArgumentException('non-nullable ticker cannot be null'); + } + + $this->container['ticker'] = $ticker; + + return $this; + } + + /** + * Gets option_type + * + * @return string + */ + public function getOptionType() + { + return $this->container['option_type']; + } + + /** + * Sets option_type + * + * @param string $option_type The type of option. Either \"CALL\" or \"PUT\". + * + * @return self + */ + public function setOptionType($option_type) + { + $allowedValues = $this->getOptionTypeAllowableValues(); + if (!in_array($option_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'option_type', must be one of '%s'", + $option_type, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($option_type)) { + throw new \InvalidArgumentException('non-nullable option_type cannot be null'); + } + + $this->container['option_type'] = $option_type; + + return $this; + } + + /** + * Gets strike_price + * + * @return float + */ + public function getStrikePrice() + { + return $this->container['strike_price']; + } + + /** + * Sets strike_price + * + * @param float $strike_price The option strike price. + * + * @return self + */ + public function setStrikePrice($strike_price) + { + + if (is_null($strike_price)) { + throw new \InvalidArgumentException('non-nullable strike_price cannot be null'); + } + + $this->container['strike_price'] = $strike_price; + + return $this; + } + + /** + * Gets expiration_date + * + * @return \DateTime + */ + public function getExpirationDate() + { + return $this->container['expiration_date']; + } + + /** + * Sets expiration_date + * + * @param \DateTime $expiration_date The option expiration date. + * + * @return self + */ + public function setExpirationDate($expiration_date) + { + + if (is_null($expiration_date)) { + throw new \InvalidArgumentException('non-nullable expiration_date cannot be null'); + } + + $this->container['expiration_date'] = $expiration_date; + + return $this; + } + + /** + * Gets is_mini_option + * + * @return bool|null + */ + public function getIsMiniOption() + { + return $this->container['is_mini_option']; + } + + /** + * Sets is_mini_option + * + * @param bool|null $is_mini_option Whether the option is a mini option. Mini options have 10 underlying shares per contract instead of the standard 100. + * + * @return self + */ + public function setIsMiniOption($is_mini_option) + { + + if (is_null($is_mini_option)) { + throw new \InvalidArgumentException('non-nullable is_mini_option cannot be null'); + } + + $this->container['is_mini_option'] = $is_mini_option; + + return $this; + } + + /** + * Gets underlying_symbol + * + * @return \SnapTrade\Model\UnderlyingSymbol + */ + public function getUnderlyingSymbol() + { + return $this->container['underlying_symbol']; + } + + /** + * Sets underlying_symbol + * + * @param \SnapTrade\Model\UnderlyingSymbol $underlying_symbol underlying_symbol + * + * @return self + */ + public function setUnderlyingSymbol($underlying_symbol) + { + + if (is_null($underlying_symbol)) { + throw new \InvalidArgumentException('non-nullable underlying_symbol cannot be null'); + } + + $this->container['underlying_symbol'] = $underlying_symbol; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/UniversalActivitySymbol.php b/lib/Model/UniversalActivitySymbol.php new file mode 100644 index 0000000..088b65e --- /dev/null +++ b/lib/Model/UniversalActivitySymbol.php @@ -0,0 +1,714 @@ + + */ +class UniversalActivitySymbol implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UniversalActivity_symbol'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'symbol' => 'string', + 'raw_symbol' => 'string', + 'description' => 'string', + 'currency' => '\SnapTrade\Model\SymbolCurrency', + 'exchange' => '\SnapTrade\Model\SymbolExchange', + 'type' => '\SnapTrade\Model\SecurityType', + 'figi_code' => 'string', + 'figi_instrument' => '\SnapTrade\Model\SymbolFigiInstrument' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'uuid', + 'symbol' => null, + 'raw_symbol' => null, + 'description' => null, + 'currency' => null, + 'exchange' => null, + 'type' => null, + 'figi_code' => null, + 'figi_instrument' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'symbol' => false, + 'raw_symbol' => false, + 'description' => true, + 'currency' => false, + 'exchange' => false, + 'type' => false, + 'figi_code' => true, + 'figi_instrument' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'symbol' => 'symbol', + 'raw_symbol' => 'raw_symbol', + 'description' => 'description', + 'currency' => 'currency', + 'exchange' => 'exchange', + 'type' => 'type', + 'figi_code' => 'figi_code', + 'figi_instrument' => 'figi_instrument' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'symbol' => 'setSymbol', + 'raw_symbol' => 'setRawSymbol', + 'description' => 'setDescription', + 'currency' => 'setCurrency', + 'exchange' => 'setExchange', + 'type' => 'setType', + 'figi_code' => 'setFigiCode', + 'figi_instrument' => 'setFigiInstrument' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'symbol' => 'getSymbol', + 'raw_symbol' => 'getRawSymbol', + 'description' => 'getDescription', + 'currency' => 'getCurrency', + 'exchange' => 'getExchange', + 'type' => 'getType', + 'figi_code' => 'getFigiCode', + 'figi_instrument' => 'getFigiInstrument' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('raw_symbol', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('exchange', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('figi_code', $data ?? [], null); + $this->setIfExists('figi_instrument', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls. + * + * @return self + */ + public function setId($id) + { + + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets symbol + * + * @return string|null + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string|null $symbol The security's trading ticker symbol. For example \"AAPL\" for Apple Inc. We largely follow the [Yahoo Finance ticker format](https://help.yahoo.com/kb/SLN2310.html)(click on \"Yahoo Finance Market Coverage and Data Delays\"). For example, for securities traded on the Toronto Stock Exchange, the symbol has a '.TO' suffix. For securities traded on NASDAQ or NYSE, the symbol does not have a suffix. + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets raw_symbol + * + * @return string|null + */ + public function getRawSymbol() + { + return $this->container['raw_symbol']; + } + + /** + * Sets raw_symbol + * + * @param string|null $raw_symbol The raw symbol is `symbol` with the exchange suffix removed. For example, if `symbol` is \"VAB.TO\", then `raw_symbol` is \"VAB\". + * + * @return self + */ + public function setRawSymbol($raw_symbol) + { + + if (is_null($raw_symbol)) { + throw new \InvalidArgumentException('non-nullable raw_symbol cannot be null'); + } + + $this->container['raw_symbol'] = $raw_symbol; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description A human-readable description of the security. This is usually the company name or ETF name. + * + * @return self + */ + public function setDescription($description) + { + + if (is_null($description)) { + array_push($this->openAPINullablesSetToNull, 'description'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('description', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets currency + * + * @return \SnapTrade\Model\SymbolCurrency|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \SnapTrade\Model\SymbolCurrency|null $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets exchange + * + * @return \SnapTrade\Model\SymbolExchange|null + */ + public function getExchange() + { + return $this->container['exchange']; + } + + /** + * Sets exchange + * + * @param \SnapTrade\Model\SymbolExchange|null $exchange exchange + * + * @return self + */ + public function setExchange($exchange) + { + + if (is_null($exchange)) { + throw new \InvalidArgumentException('non-nullable exchange cannot be null'); + } + + $this->container['exchange'] = $exchange; + + return $this; + } + + /** + * Gets type + * + * @return \SnapTrade\Model\SecurityType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \SnapTrade\Model\SecurityType|null $type type + * + * @return self + */ + public function setType($type) + { + + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets figi_code + * + * @return string|null + */ + public function getFigiCode() + { + return $this->container['figi_code']; + } + + /** + * Sets figi_code + * + * @param string|null $figi_code This identifier is unique per security per trading venue. See section 1.4.1 of the [FIGI Standard](https://www.openfigi.com/assets/local/figi-allocation-rules.pdf) for more information. This value should be the same as the `figi_code` in the `figi_instrument` child property. + * + * @return self + */ + public function setFigiCode($figi_code) + { + + if (is_null($figi_code)) { + array_push($this->openAPINullablesSetToNull, 'figi_code'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('figi_code', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['figi_code'] = $figi_code; + + return $this; + } + + /** + * Gets figi_instrument + * + * @return \SnapTrade\Model\SymbolFigiInstrument|null + */ + public function getFigiInstrument() + { + return $this->container['figi_instrument']; + } + + /** + * Sets figi_instrument + * + * @param \SnapTrade\Model\SymbolFigiInstrument|null $figi_instrument figi_instrument + * + * @return self + */ + public function setFigiInstrument($figi_instrument) + { + + if (is_null($figi_instrument)) { + array_push($this->openAPINullablesSetToNull, 'figi_instrument'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('figi_instrument', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['figi_instrument'] = $figi_instrument; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/UniversalSymbol.php b/lib/Model/UniversalSymbol.php index 90c9276..bc3059f 100644 --- a/lib/Model/UniversalSymbol.php +++ b/lib/Model/UniversalSymbol.php @@ -55,8 +55,8 @@ class UniversalSymbol implements ModelInterface, ArrayAccess, \JsonSerializable 'symbol' => 'string', 'raw_symbol' => 'string', 'description' => 'string', - 'currency' => '\SnapTrade\Model\UniversalSymbolCurrency', - 'exchange' => '\SnapTrade\Model\UniversalSymbolExchange', + 'currency' => '\SnapTrade\Model\SymbolCurrency', + 'exchange' => '\SnapTrade\Model\SymbolExchange', 'type' => '\SnapTrade\Model\SecurityType', 'currencies' => '\SnapTrade\Model\Currency[]', 'figi_code' => 'string', @@ -490,7 +490,7 @@ public function setDescription($description) /** * Gets currency * - * @return \SnapTrade\Model\UniversalSymbolCurrency + * @return \SnapTrade\Model\SymbolCurrency */ public function getCurrency() { @@ -500,7 +500,7 @@ public function getCurrency() /** * Sets currency * - * @param \SnapTrade\Model\UniversalSymbolCurrency $currency currency + * @param \SnapTrade\Model\SymbolCurrency $currency currency * * @return self */ @@ -519,7 +519,7 @@ public function setCurrency($currency) /** * Gets exchange * - * @return \SnapTrade\Model\UniversalSymbolExchange|null + * @return \SnapTrade\Model\SymbolExchange|null */ public function getExchange() { @@ -529,7 +529,7 @@ public function getExchange() /** * Sets exchange * - * @param \SnapTrade\Model\UniversalSymbolExchange|null $exchange exchange + * @param \SnapTrade\Model\SymbolExchange|null $exchange exchange * * @return self */ diff --git a/lib/Model/UserIDandSecret.php b/lib/Model/UserIDandSecret.php index 831d173..be17fcd 100644 --- a/lib/Model/UserIDandSecret.php +++ b/lib/Model/UserIDandSecret.php @@ -30,7 +30,6 @@ * UserIDandSecret Class Doc Comment * * @category Class - * @description Response when register user is successful * @package SnapTrade * @implements \ArrayAccess */ @@ -332,7 +331,7 @@ public function getUserSecret() /** * Sets user_secret * - * @param string|null $user_secret SnapTrade User Secret randomly generated by SnapTrade. This is privileged information and if compromised, should be rotated via the SnapTrade API. + * @param string|null $user_secret SnapTrade User Secret. This is a randomly generated string and should be stored securely. If compromised, please rotate it via the [rotate user secret endpoint](/reference/Authentication/Authentication_resetSnapTradeUserSecret). * * @return self */ diff --git a/test/Api/AuthenticationApiTest.php b/test/Api/AuthenticationApiTest.php index 5b9803c..0811252 100644 --- a/test/Api/AuthenticationApiTest.php +++ b/test/Api/AuthenticationApiTest.php @@ -61,7 +61,7 @@ public static function tearDownAfterClass(): void /** * Test case for deleteSnapTradeUser * - * Delete SnapTrade user. + * Delete user. * */ public function testDeleteSnapTradeUser() @@ -73,7 +73,7 @@ public function testDeleteSnapTradeUser() /** * Test case for listSnapTradeUsers * - * List SnapTrade users. + * List all users. * */ public function testListSnapTradeUsers() @@ -97,7 +97,7 @@ public function testLoginSnapTradeUser() /** * Test case for registerSnapTradeUser * - * Create SnapTrade user. + * Register user. * */ public function testRegisterSnapTradeUser() @@ -109,7 +109,7 @@ public function testRegisterSnapTradeUser() /** * Test case for resetSnapTradeUserSecret * - * Obtain a new user secret for a user. + * Rotate user secret. * */ public function testResetSnapTradeUserSecret() diff --git a/test/Api/ConnectionsApiTest.php b/test/Api/ConnectionsApiTest.php index 61ae906..bfa7d66 100644 --- a/test/Api/ConnectionsApiTest.php +++ b/test/Api/ConnectionsApiTest.php @@ -61,7 +61,7 @@ public static function tearDownAfterClass(): void /** * Test case for detailBrokerageAuthorization * - * Get brokerage authorization details. + * Get connection detail. * */ public function testDetailBrokerageAuthorization() @@ -73,7 +73,7 @@ public function testDetailBrokerageAuthorization() /** * Test case for disableBrokerageAuthorization * - * Manually disable a connection for testing. + * Force disable connection. * */ public function testDisableBrokerageAuthorization() @@ -85,7 +85,7 @@ public function testDisableBrokerageAuthorization() /** * Test case for listBrokerageAuthorizations * - * List all brokerage authorizations for the User. + * List all connections. * */ public function testListBrokerageAuthorizations() @@ -109,7 +109,7 @@ public function testRefreshBrokerageAuthorization() /** * Test case for removeBrokerageAuthorization * - * Delete brokerage authorization. + * Delete connection. * */ public function testRemoveBrokerageAuthorization() diff --git a/test/Model/AccountSimpleTest.php b/test/Model/AccountSimpleTest.php index ec124c6..173fb71 100644 --- a/test/Model/AccountSimpleTest.php +++ b/test/Model/AccountSimpleTest.php @@ -29,7 +29,7 @@ * AccountSimpleTest Class Doc Comment * * @category Class - * @description SnapTradeUser Investment Account + * @description A single account at a brokerage. * @package SnapTrade */ class AccountSimpleTest extends TestCase diff --git a/test/Model/AccountTest.php b/test/Model/AccountTest.php index 913d525..6e9c6f2 100644 --- a/test/Model/AccountTest.php +++ b/test/Model/AccountTest.php @@ -29,7 +29,7 @@ * AccountTest Class Doc Comment * * @category Class - * @description A single brokerage account at a financial institution. + * @description A single account at a brokerage. * @package SnapTrade */ class AccountTest extends TestCase diff --git a/test/Model/BrokerageAuthorizationDisabledConfirmationTest.php b/test/Model/BrokerageAuthorizationDisabledConfirmationTest.php index 3c21dad..666f883 100644 --- a/test/Model/BrokerageAuthorizationDisabledConfirmationTest.php +++ b/test/Model/BrokerageAuthorizationDisabledConfirmationTest.php @@ -29,7 +29,7 @@ * BrokerageAuthorizationDisabledConfirmationTest Class Doc Comment * * @category Class - * @description BrokerageAuthorizationDisabledConfirmation + * @description Confirmation that the connection has been disabled. * @package SnapTrade */ class BrokerageAuthorizationDisabledConfirmationTest extends TestCase diff --git a/test/Model/BrokerageAuthorizationRefreshConfirmationTest.php b/test/Model/BrokerageAuthorizationRefreshConfirmationTest.php index 3da580b..a908783 100644 --- a/test/Model/BrokerageAuthorizationRefreshConfirmationTest.php +++ b/test/Model/BrokerageAuthorizationRefreshConfirmationTest.php @@ -29,7 +29,7 @@ * BrokerageAuthorizationRefreshConfirmationTest Class Doc Comment * * @category Class - * @description BrokerageAuthorizationRefreshConfirmation + * @description Confirmation that the syncs have been scheduled. * @package SnapTrade */ class BrokerageAuthorizationRefreshConfirmationTest extends TestCase diff --git a/test/Model/BrokerageAuthorizationTest.php b/test/Model/BrokerageAuthorizationTest.php index a285a17..d54de0a 100644 --- a/test/Model/BrokerageAuthorizationTest.php +++ b/test/Model/BrokerageAuthorizationTest.php @@ -29,7 +29,7 @@ * BrokerageAuthorizationTest Class Doc Comment * * @category Class - * @description BrokerageAuthorization + * @description A single connection with a brokerage. Note that `Connection` and `Brokerage Authorization` are interchangeable, but the term `Connection` is preferred and used in the doc for consistency. A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts. SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one. * @package SnapTrade */ class BrokerageAuthorizationTest extends TestCase diff --git a/test/Model/BrokerageTest.php b/test/Model/BrokerageTest.php index afabe73..662e69f 100644 --- a/test/Model/BrokerageTest.php +++ b/test/Model/BrokerageTest.php @@ -29,7 +29,7 @@ * BrokerageTest Class Doc Comment * * @category Class - * @description Brokerage + * @description Describes a brokerage that SnapTrade supports. * @package SnapTrade */ class BrokerageTest extends TestCase @@ -81,6 +81,15 @@ public function testPropertyId() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "slug" + */ + public function testPropertySlug() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "name" */ @@ -135,15 +144,6 @@ public function testPropertyOpenUrl() $this->markTestIncomplete('Not implemented'); } - /** - * Test attribute "slug" - */ - public function testPropertySlug() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test attribute "url" */ @@ -207,33 +207,6 @@ public function testPropertyIsRealTimeConnection() $this->markTestIncomplete('Not implemented'); } - /** - * Test attribute "allows_trading_through_snaptrade_api" - */ - public function testPropertyAllowsTradingThroughSnaptradeApi() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "is_scraping_integration" - */ - public function testPropertyIsScrapingIntegration() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "default_currency" - */ - public function testPropertyDefaultCurrency() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test attribute "brokerage_type" */ diff --git a/test/Model/BrokerageTypeTest.php b/test/Model/BrokerageTypeTest.php index 530afc2..3298e91 100644 --- a/test/Model/BrokerageTypeTest.php +++ b/test/Model/BrokerageTypeTest.php @@ -29,7 +29,7 @@ * BrokerageTypeTest Class Doc Comment * * @category Class - * @description Type of brokerage + * @description Type of brokerage. Currently supports traditional brokerages and crypto exchanges. * @package SnapTrade */ class BrokerageTypeTest extends TestCase diff --git a/test/Model/DeleteUserResponseTest.php b/test/Model/DeleteUserResponseTest.php index b17ecc1..a56ac8e 100644 --- a/test/Model/DeleteUserResponseTest.php +++ b/test/Model/DeleteUserResponseTest.php @@ -29,7 +29,7 @@ * DeleteUserResponseTest Class Doc Comment * * @category Class - * @description Response when delete user is successful + * @description DeleteUserResponse * @package SnapTrade */ class DeleteUserResponseTest extends TestCase @@ -81,6 +81,15 @@ public function testPropertyStatus() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "detail" + */ + public function testPropertyDetail() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "user_id" */ diff --git a/test/Model/UniversalSymbolCurrencyTest.php b/test/Model/SymbolCurrencyTest.php similarity index 88% rename from test/Model/UniversalSymbolCurrencyTest.php rename to test/Model/SymbolCurrencyTest.php index 2ff2502..208649b 100644 --- a/test/Model/UniversalSymbolCurrencyTest.php +++ b/test/Model/SymbolCurrencyTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); diff --git a/test/Model/UniversalSymbolExchangeTest.php b/test/Model/SymbolExchangeTest.php similarity index 92% rename from test/Model/UniversalSymbolExchangeTest.php rename to test/Model/SymbolExchangeTest.php index 7cd361f..089eea7 100644 --- a/test/Model/UniversalSymbolExchangeTest.php +++ b/test/Model/SymbolExchangeTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); diff --git a/test/Model/SymbolTest.php b/test/Model/SymbolTest.php index 64dd26d..d947992 100644 --- a/test/Model/SymbolTest.php +++ b/test/Model/SymbolTest.php @@ -29,7 +29,7 @@ * SymbolTest Class Doc Comment * * @category Class - * @description Symbol + * @description Uniquely describes a single security + exchange combination across all brokerages. * @package SnapTrade */ class SymbolTest extends TestCase @@ -100,9 +100,9 @@ public function testPropertyRawSymbol() } /** - * Test attribute "name" + * Test attribute "description" */ - public function testPropertyName() + public function testPropertyDescription() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/UniversalActivityCurrencyTest.php b/test/Model/UniversalActivityCurrencyTest.php new file mode 100644 index 0000000..1eb799f --- /dev/null +++ b/test/Model/UniversalActivityCurrencyTest.php @@ -0,0 +1,101 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "id" + */ + public function testPropertyId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "code" + */ + public function testPropertyCode() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "name" + */ + public function testPropertyName() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/UniversalActivityOptionSymbolTest.php b/test/Model/UniversalActivityOptionSymbolTest.php new file mode 100644 index 0000000..bf151e6 --- /dev/null +++ b/test/Model/UniversalActivityOptionSymbolTest.php @@ -0,0 +1,137 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "id" + */ + public function testPropertyId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "ticker" + */ + public function testPropertyTicker() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "option_type" + */ + public function testPropertyOptionType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "strike_price" + */ + public function testPropertyStrikePrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "expiration_date" + */ + public function testPropertyExpirationDate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "is_mini_option" + */ + public function testPropertyIsMiniOption() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "underlying_symbol" + */ + public function testPropertyUnderlyingSymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/UniversalActivitySymbolTest.php b/test/Model/UniversalActivitySymbolTest.php new file mode 100644 index 0000000..428a8df --- /dev/null +++ b/test/Model/UniversalActivitySymbolTest.php @@ -0,0 +1,155 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "id" + */ + public function testPropertyId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "raw_symbol" + */ + public function testPropertyRawSymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "description" + */ + public function testPropertyDescription() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "currency" + */ + public function testPropertyCurrency() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "exchange" + */ + public function testPropertyExchange() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "figi_code" + */ + public function testPropertyFigiCode() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "figi_instrument" + */ + public function testPropertyFigiInstrument() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/UniversalActivityTest.php b/test/Model/UniversalActivityTest.php index 1fa588d..7c835a8 100644 --- a/test/Model/UniversalActivityTest.php +++ b/test/Model/UniversalActivityTest.php @@ -91,135 +91,135 @@ public function testPropertyAccount() } /** - * Test attribute "amount" + * Test attribute "symbol" */ - public function testPropertyAmount() + public function testPropertySymbol() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "currency" + * Test attribute "option_symbol" */ - public function testPropertyCurrency() + public function testPropertyOptionSymbol() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "description" + * Test attribute "price" */ - public function testPropertyDescription() + public function testPropertyPrice() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "fee" + * Test attribute "units" */ - public function testPropertyFee() + public function testPropertyUnits() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "fx_rate" + * Test attribute "amount" */ - public function testPropertyFxRate() + public function testPropertyAmount() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "institution" + * Test attribute "currency" */ - public function testPropertyInstitution() + public function testPropertyCurrency() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "option_type" + * Test attribute "type" */ - public function testPropertyOptionType() + public function testPropertyType() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "price" + * Test attribute "option_type" */ - public function testPropertyPrice() + public function testPropertyOptionType() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "settlement_date" + * Test attribute "description" */ - public function testPropertySettlementDate() + public function testPropertyDescription() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "external_reference_id" + * Test attribute "trade_date" */ - public function testPropertyExternalReferenceId() + public function testPropertyTradeDate() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "symbol" + * Test attribute "settlement_date" */ - public function testPropertySymbol() + public function testPropertySettlementDate() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "option_symbol" + * Test attribute "fee" */ - public function testPropertyOptionSymbol() + public function testPropertyFee() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "trade_date" + * Test attribute "fx_rate" */ - public function testPropertyTradeDate() + public function testPropertyFxRate() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "type" + * Test attribute "institution" */ - public function testPropertyType() + public function testPropertyInstitution() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "units" + * Test attribute "external_reference_id" */ - public function testPropertyUnits() + public function testPropertyExternalReferenceId() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/UserIDandSecretTest.php b/test/Model/UserIDandSecretTest.php index 9b8f44a..db98450 100644 --- a/test/Model/UserIDandSecretTest.php +++ b/test/Model/UserIDandSecretTest.php @@ -29,7 +29,7 @@ * UserIDandSecretTest Class Doc Comment * * @category Class - * @description Response when register user is successful + * @description UserIDandSecret * @package SnapTrade */ class UserIDandSecretTest extends TestCase From 3f846b9cf1f099b339bee3dff2c592b7480959ee Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 22:36:33 +0000 Subject: [PATCH 002/252] Version Bump SDKs (#13) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 7aa31df..3f7b5da 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d3d97da5-f1b6-4f18-806f-d1175b962165 \ No newline at end of file +f0afe0fb-5d7b-4b66-b3b3-84b060a496ab \ No newline at end of file diff --git a/README.md b/README.md index 59e43d7..b84dc7b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.36-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.37-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.36" + "konfig/snaptrade-php-sdk": "2.0.37" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 79ff133..4d8f026 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.36/PHP'; + protected $userAgent = 'Konfig/2.0.37/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.36' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.37' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 537240e37b3756273c90e7bb41b8ae139165bbc4 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 22:16:57 +0000 Subject: [PATCH 003/252] Regenerate SDKs (#14) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 107 ++-- lib/Api/TradingApi.php | 188 +++--- lib/Model/ActionStrict.php | 2 +- lib/Model/ManualTrade.php | 14 +- lib/Model/ManualTradeAndImpact.php | 7 +- lib/Model/ManualTradeBalance.php | 10 +- lib/Model/ManualTradeForm.php | 177 +++--- lib/Model/ManualTradeImpact.php | 569 ++++++++++++++++++ lib/Model/ManualTradeSymbol.php | 20 +- lib/Model/NotionalValue.php | 2 +- lib/Model/OrderTypeStrict.php | 2 +- lib/Model/SymbolsQuotesInner.php | 72 +-- lib/Model/TimeInForceStrict.php | 2 +- .../TradingCancelUserAccountOrderRequest.php | 4 +- lib/Model/ValidatedTradeBody.php | 3 +- test/Api/TradingApiTest.php | 8 +- test/Model/ActionStrictTest.php | 2 +- test/Model/ManualTradeAndImpactTest.php | 2 +- test/Model/ManualTradeBalanceTest.php | 2 +- test/Model/ManualTradeFormTest.php | 26 +- test/Model/ManualTradeImpactTest.php | 119 ++++ test/Model/ManualTradeSymbolTest.php | 2 +- test/Model/ManualTradeTest.php | 2 +- test/Model/NotionalValueTest.php | 2 +- test/Model/OrderTypeStrictTest.php | 2 +- test/Model/SymbolsQuotesInnerTest.php | 12 +- test/Model/TimeInForceStrictTest.php | 2 +- test/Model/ValidatedTradeBodyTest.php | 2 +- 29 files changed, 1040 insertions(+), 324 deletions(-) create mode 100644 lib/Model/ManualTradeImpact.php create mode 100644 test/Model/ManualTradeImpactTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 3f7b5da..c8b1378 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f0afe0fb-5d7b-4b66-b3b3-84b060a496ab \ No newline at end of file +81b14b50-3280-483c-ae3d-052f538020aa \ No newline at end of file diff --git a/README.md b/README.md index b84dc7b..b60988b 100644 --- a/README.md +++ b/README.md @@ -1101,7 +1101,7 @@ Places the option strategy order and returns the order record received from the ```php $result = $snaptrade->options->placeOptionStrategy( - order_type: "Limit", + order_type: "Market", time_in_force: "FOK", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", @@ -1477,8 +1477,7 @@ The ID of the account to search for symbols within. ### `snaptrade.trading.cancelUserAccountOrder` -Sends a signal to the brokerage to cancel the specified order. -This will only work if the order has not yet been executed. +Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. @@ -1489,7 +1488,7 @@ $result = $snaptrade->trading->cancelUserAccountOrder( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - brokerage_order_id: "2bcd7cc3-e922-4976-bce1-9858296801c3" + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e" ); ``` @@ -1501,10 +1500,10 @@ $result = $snaptrade->trading->cancelUserAccountOrder( ##### account_id: `string` -The ID of the account to cancel the order in. - ##### brokerage_order_id: `string` +Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + #### πŸ”„ Return @@ -1521,53 +1520,57 @@ The ID of the account to cancel the order in. ### `snaptrade.trading.getOrderImpact` -Return the trade object and it's impact on the account for the specified order. +Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. #### πŸ› οΈ Usage ```php $result = $snaptrade->trading->getOrderImpact( + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + action: "BUY", + universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", + order_type: "Market", + time_in_force: "FOK", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", - action: "BUY", - order_type: "Limit", price: 31.33, stop: 31.33, - time_in_force: "FOK", - units: 3.14, - universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", + units: 10.5, notional_value: None ); ``` #### βš™οΈ Parameters -##### user_id: `string` - -##### user_secret: `string` - ##### account_id: `string` +Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. + ##### action: +##### universal_symbol_id: `string` + +Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls. + ##### order_type: +##### time_in_force: + +##### user_id: `string` + +##### user_secret: `string` + ##### price: `float` -Trade Price if limit or stop limit order +The limit price for `Limit` and `StopLimit` orders. ##### stop: `float` -Stop Price. If stop loss or stop limit order, the price to trigger the stop - -##### time_in_force: +The price at which a stop order is triggered for `Stop` and `StopLimit` orders. ##### units: [`float`](./lib/Model/float.php) -##### universal_symbol_id: `string` - ##### notional_value: [`ManualTradeFormNotionalValue`](./lib/Model/ManualTradeFormNotionalValue.php) @@ -1586,7 +1589,7 @@ Stop Price. If stop loss or stop limit order, the price to trigger the stop ### `snaptrade.trading.getUserAccountQuotes` -Returns quote(s) from the brokerage for the specified symbol(s). +Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. #### πŸ› οΈ Usage @@ -1609,15 +1612,13 @@ $result = $snaptrade->trading->getUserAccountQuotes( ##### symbols: `string` -List of universal_symbol_id or tickers to get quotes for. +List of Universal Symbol IDs or tickers to get quotes for. ##### account_id: `string` -The ID of the account to get quotes. - ##### use_ticker: `bool` -Should be set to True if providing tickers. +Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. #### πŸ”„ Return @@ -1635,53 +1636,60 @@ Should be set to True if providing tickers. ### `snaptrade.trading.placeForceOrder` -Places a specified trade in the specified account. +Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. + +This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). + #### πŸ› οΈ Usage ```php $result = $snaptrade->trading->placeForceOrder( + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + action: "BUY", + universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", + order_type: "Market", + time_in_force: "FOK", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", - action: "BUY", - order_type: "Limit", price: 31.33, stop: 31.33, - time_in_force: "FOK", - units: 3.14, - universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", + units: 10.5, notional_value: None ); ``` #### βš™οΈ Parameters -##### user_id: `string` - -##### user_secret: `string` - ##### account_id: `string` +Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. + ##### action: +##### universal_symbol_id: `string` + +Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls. + ##### order_type: +##### time_in_force: + +##### user_id: `string` + +##### user_secret: `string` + ##### price: `float` -Trade Price if limit or stop limit order +The limit price for `Limit` and `StopLimit` orders. ##### stop: `float` -Stop Price. If stop loss or stop limit order, the price to trigger the stop - -##### time_in_force: +The price at which a stop order is triggered for `Stop` and `StopLimit` orders. ##### units: [`float`](./lib/Model/float.php) -##### universal_symbol_id: `string` - ##### notional_value: [`ManualTradeFormNotionalValue`](./lib/Model/ManualTradeFormNotionalValue.php) @@ -1700,8 +1708,7 @@ Stop Price. If stop loss or stop limit order, the price to trigger the stop ### `snaptrade.trading.placeOrder` -Places the specified trade object. This places the order in the account and -returns the status of the order from the brokerage. +Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). @@ -1709,7 +1716,7 @@ returns the status of the order from the brokerage. ```php $result = $snaptrade->trading->placeOrder( - trade_id: "tradeId_example", + trade_id: "139e307a-82f7-4402-b39e-4da7baa87758", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", wait_to_confirm: True @@ -1720,7 +1727,7 @@ $result = $snaptrade->trading->placeOrder( ##### trade_id: `string` -The ID of trade object obtained from trade/impact endpoint +Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) ##### user_id: `string` @@ -1728,7 +1735,7 @@ The ID of trade object obtained from trade/impact endpoint ##### wait_to_confirm: `bool` -Optional, defaults to true. Determines if a wait is performed to check on order status. If false, latency will be reduced but orders returned will be more likely to be of status PENDING as we will not wait to check on the status before responding to the request +Optional, defaults to true. Determines if a wait is performed to check on order status. If false, latency will be reduced but orders returned will be more likely to be of status `PENDING` as we will not wait to check on the status before responding to the request. #### πŸ”„ Return diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 98fdfe2..0c59d5a 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -150,14 +150,14 @@ private function setRequestBodyProperty(&$body, $property, $value) { /** * Operation cancelUserAccountOrder * - * Cancel open order in account + * Cancel order * - * Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed. + * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id The ID of the account to cancel the order in. (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request The Order ID to be canceled (required) + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request trading_cancel_user_account_order_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -184,14 +184,14 @@ public function cancelUserAccountOrder( /** * Operation cancelUserAccountOrderWithHttpInfo * - * Cancel open order in account + * Cancel order * - * Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed. + * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to cancel the order in. (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request The Order ID to be canceled (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -353,14 +353,14 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco /** * Operation cancelUserAccountOrderAsync * - * Cancel open order in account + * Cancel order * - * Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed. + * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to cancel the order in. (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request The Order ID to be canceled (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -390,14 +390,14 @@ function ($response) { /** * Operation cancelUserAccountOrderAsyncWithHttpInfo * - * Cancel open order in account + * Cancel order * - * Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed. + * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to cancel the order in. (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request The Order ID to be canceled (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -452,8 +452,8 @@ function ($exception) { * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to cancel the order in. (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request The Order ID to be canceled (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -633,9 +633,9 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i /** * Operation getOrderImpact * - * Check the impact of a trade on an account + * Check order impact * - * Return the trade object and it's impact on the account for the specified order. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -648,16 +648,16 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i */ public function getOrderImpact( + $account_id, + $action, + $universal_symbol_id, + $order_type, + $time_in_force, $user_id, $user_secret, - $account_id = SENTINEL_VALUE, - $action = SENTINEL_VALUE, - $order_type = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, - $time_in_force = SENTINEL_VALUE, $units = SENTINEL_VALUE, - $universal_symbol_id = SENTINEL_VALUE, $notional_value = SENTINEL_VALUE, string $contentType = self::contentTypes['getOrderImpact'][0] ) @@ -665,12 +665,12 @@ public function getOrderImpact( $_body = []; $this->setRequestBodyProperty($_body, "account_id", $account_id); $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); $this->setRequestBodyProperty($_body, "notional_value", $notional_value); $manual_trade_form = $_body; @@ -681,9 +681,9 @@ public function getOrderImpact( /** * Operation getOrderImpactWithHttpInfo * - * Check the impact of a trade on an account + * Check order impact * - * Return the trade object and it's impact on the account for the specified order. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) @@ -848,9 +848,9 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade /** * Operation getOrderImpactAsync * - * Check the impact of a trade on an account + * Check order impact * - * Return the trade object and it's impact on the account for the specified order. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) @@ -862,16 +862,16 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade */ public function getOrderImpactAsync( + $account_id, + $action, + $universal_symbol_id, + $order_type, + $time_in_force, $user_id, $user_secret, - $account_id = SENTINEL_VALUE, - $action = SENTINEL_VALUE, - $order_type = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, - $time_in_force = SENTINEL_VALUE, $units = SENTINEL_VALUE, - $universal_symbol_id = SENTINEL_VALUE, $notional_value = SENTINEL_VALUE, string $contentType = self::contentTypes['getOrderImpact'][0] ) @@ -879,12 +879,12 @@ public function getOrderImpactAsync( $_body = []; $this->setRequestBodyProperty($_body, "account_id", $account_id); $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); $this->setRequestBodyProperty($_body, "notional_value", $notional_value); $manual_trade_form = $_body; @@ -899,9 +899,9 @@ function ($response) { /** * Operation getOrderImpactAsyncWithHttpInfo * - * Check the impact of a trade on an account + * Check order impact * - * Return the trade object and it's impact on the account for the specified order. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1124,13 +1124,13 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form * * Get symbol quotes * - * Returns quote(s) from the brokerage for the specified symbol(s). + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $symbols List of universal_symbol_id or tickers to get quotes for. (required) - * @param string $account_id The ID of the account to get quotes. (required) - * @param bool $use_ticker Should be set to True if providing tickers. (optional) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. (required) + * @param string $account_id account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -1157,13 +1157,13 @@ public function getUserAccountQuotes( * * Get symbol quotes * - * Returns quote(s) from the brokerage for the specified symbol(s). + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of universal_symbol_id or tickers to get quotes for. (required) - * @param string $account_id The ID of the account to get quotes. (required) - * @param bool $use_ticker Should be set to True if providing tickers. (optional) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -1305,13 +1305,13 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol * * Get symbol quotes * - * Returns quote(s) from the brokerage for the specified symbol(s). + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of universal_symbol_id or tickers to get quotes for. (required) - * @param string $account_id The ID of the account to get quotes. (required) - * @param bool $use_ticker Should be set to True if providing tickers. (optional) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1341,13 +1341,13 @@ function ($response) { * * Get symbol quotes * - * Returns quote(s) from the brokerage for the specified symbol(s). + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of universal_symbol_id or tickers to get quotes for. (required) - * @param string $account_id The ID of the account to get quotes. (required) - * @param bool $use_ticker Should be set to True if providing tickers. (optional) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1402,9 +1402,9 @@ function ($exception) { * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of universal_symbol_id or tickers to get quotes for. (required) - * @param string $account_id The ID of the account to get quotes. (required) - * @param bool $use_ticker Should be set to True if providing tickers. (optional) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1595,9 +1595,9 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a /** * Operation placeForceOrder * - * Place a trade with NO validation. + * Place order * - * Places a specified trade in the specified account. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -1610,16 +1610,16 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a */ public function placeForceOrder( + $account_id, + $action, + $universal_symbol_id, + $order_type, + $time_in_force, $user_id, $user_secret, - $account_id = SENTINEL_VALUE, - $action = SENTINEL_VALUE, - $order_type = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, - $time_in_force = SENTINEL_VALUE, $units = SENTINEL_VALUE, - $universal_symbol_id = SENTINEL_VALUE, $notional_value = SENTINEL_VALUE, string $contentType = self::contentTypes['placeForceOrder'][0] ) @@ -1627,12 +1627,12 @@ public function placeForceOrder( $_body = []; $this->setRequestBodyProperty($_body, "account_id", $account_id); $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); $this->setRequestBodyProperty($_body, "notional_value", $notional_value); $manual_trade_form = $_body; @@ -1643,9 +1643,9 @@ public function placeForceOrder( /** * Operation placeForceOrderWithHttpInfo * - * Place a trade with NO validation. + * Place order * - * Places a specified trade in the specified account. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). * * @param string $user_id (required) * @param string $user_secret (required) @@ -1810,9 +1810,9 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad /** * Operation placeForceOrderAsync * - * Place a trade with NO validation. + * Place order * - * Places a specified trade in the specified account. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). * * @param string $user_id (required) * @param string $user_secret (required) @@ -1824,16 +1824,16 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad */ public function placeForceOrderAsync( + $account_id, + $action, + $universal_symbol_id, + $order_type, + $time_in_force, $user_id, $user_secret, - $account_id = SENTINEL_VALUE, - $action = SENTINEL_VALUE, - $order_type = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, - $time_in_force = SENTINEL_VALUE, $units = SENTINEL_VALUE, - $universal_symbol_id = SENTINEL_VALUE, $notional_value = SENTINEL_VALUE, string $contentType = self::contentTypes['placeForceOrder'][0] ) @@ -1841,12 +1841,12 @@ public function placeForceOrderAsync( $_body = []; $this->setRequestBodyProperty($_body, "account_id", $account_id); $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); $this->setRequestBodyProperty($_body, "notional_value", $notional_value); $manual_trade_form = $_body; @@ -1861,9 +1861,9 @@ function ($response) { /** * Operation placeForceOrderAsyncWithHttpInfo * - * Place a trade with NO validation. + * Place order * - * Places a specified trade in the specified account. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). * * @param string $user_id (required) * @param string $user_secret (required) @@ -2084,11 +2084,11 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for /** * Operation placeOrder * - * Place order + * Place checked order * - * Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). * - * @param string $trade_id The ID of trade object obtained from trade/impact endpoint (required) + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body validated_trade_body (optional) @@ -2118,11 +2118,11 @@ public function placeOrder( /** * Operation placeOrderWithHttpInfo * - * Place order + * Place checked order * - * Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). * - * @param string $trade_id The ID of trade object obtained from trade/impact endpoint (required) + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) @@ -2264,11 +2264,11 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid /** * Operation placeOrderAsync * - * Place order + * Place checked order * - * Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). * - * @param string $trade_id The ID of trade object obtained from trade/impact endpoint (required) + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) @@ -2301,11 +2301,11 @@ function ($response) { /** * Operation placeOrderAsyncWithHttpInfo * - * Place order + * Place checked order * - * Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). * - * @param string $trade_id The ID of trade object obtained from trade/impact endpoint (required) + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) @@ -2361,7 +2361,7 @@ function ($exception) { /** * Create request for operation 'placeOrder' * - * @param string $trade_id The ID of trade object obtained from trade/impact endpoint (required) + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) diff --git a/lib/Model/ActionStrict.php b/lib/Model/ActionStrict.php index 36c3ddc..0f952a3 100644 --- a/lib/Model/ActionStrict.php +++ b/lib/Model/ActionStrict.php @@ -28,7 +28,7 @@ * ActionStrict Class Doc Comment * * @category Class - * @description Trade Action + * @description The action describes the intent or side of a trade. This is either `BUY` or `SELL` * @package SnapTrade */ class ActionStrict diff --git a/lib/Model/ManualTrade.php b/lib/Model/ManualTrade.php index 5beeace..f39acaa 100644 --- a/lib/Model/ManualTrade.php +++ b/lib/Model/ManualTrade.php @@ -30,7 +30,7 @@ * ManualTrade Class Doc Comment * * @category Class - * @description A manual trade object + * @description Contains the details of a submitted order. * @package SnapTrade * @implements \ArrayAccess */ @@ -54,7 +54,7 @@ class ManualTrade implements ModelInterface, ArrayAccess, \JsonSerializable 'id' => 'string', 'account' => 'string', 'order_type' => '\SnapTrade\Model\OrderTypeStrict', - 'time_in_force' => 'string', + 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', 'symbol' => '\SnapTrade\Model\ManualTradeSymbol', 'action' => '\SnapTrade\Model\ActionStrict', 'units' => 'float', @@ -70,7 +70,7 @@ class ManualTrade implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static $openAPIFormats = [ 'id' => 'uuid', - 'account' => null, + 'account' => 'uuid', 'order_type' => null, 'time_in_force' => null, 'symbol' => null, @@ -345,7 +345,7 @@ public function getId() /** * Sets id * - * @param string|null $id id + * @param string|null $id Unique identifier for the submitted order through SnapTrade. * * @return self */ @@ -374,7 +374,7 @@ public function getAccount() /** * Sets account * - * @param string|null $account account + * @param string|null $account Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. * * @return self */ @@ -422,7 +422,7 @@ public function setOrderType($order_type) /** * Gets time_in_force * - * @return string|null + * @return \SnapTrade\Model\TimeInForceStrict|null */ public function getTimeInForce() { @@ -432,7 +432,7 @@ public function getTimeInForce() /** * Sets time_in_force * - * @param string|null $time_in_force Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled * GTD - Good Til Date + * @param \SnapTrade\Model\TimeInForceStrict|null $time_in_force time_in_force * * @return self */ diff --git a/lib/Model/ManualTradeAndImpact.php b/lib/Model/ManualTradeAndImpact.php index 5fb47b2..0639899 100644 --- a/lib/Model/ManualTradeAndImpact.php +++ b/lib/Model/ManualTradeAndImpact.php @@ -30,7 +30,6 @@ * ManualTradeAndImpact Class Doc Comment * * @category Class - * @description Manual Trade and Impact object * @package SnapTrade * @implements \ArrayAccess */ @@ -52,7 +51,7 @@ class ManualTradeAndImpact implements ModelInterface, ArrayAccess, \JsonSerializ */ protected static $openAPITypes = [ 'trade' => '\SnapTrade\Model\ManualTrade', - 'trade_impacts' => '\SnapTrade\Model\ManualTrade[]', + 'trade_impacts' => '\SnapTrade\Model\ManualTradeImpact[]', 'combined_remaining_balance' => '\SnapTrade\Model\ManualTradeBalance' ]; @@ -329,7 +328,7 @@ public function setTrade($trade) /** * Gets trade_impacts * - * @return \SnapTrade\Model\ManualTrade[]|null + * @return \SnapTrade\Model\ManualTradeImpact[]|null */ public function getTradeImpacts() { @@ -339,7 +338,7 @@ public function getTradeImpacts() /** * Sets trade_impacts * - * @param \SnapTrade\Model\ManualTrade[]|null $trade_impacts trade_impacts + * @param \SnapTrade\Model\ManualTradeImpact[]|null $trade_impacts List of impacts of the trade on the account. The list always contains one value at the moment. * * @return self */ diff --git a/lib/Model/ManualTradeBalance.php b/lib/Model/ManualTradeBalance.php index 7ddc936..8b64369 100644 --- a/lib/Model/ManualTradeBalance.php +++ b/lib/Model/ManualTradeBalance.php @@ -30,7 +30,7 @@ * ManualTradeBalance Class Doc Comment * * @category Class - * @description Balance + * @description Estimated remaining balance of the account after the trade is executed. * @package SnapTrade * @implements \ArrayAccess */ @@ -51,7 +51,7 @@ class ManualTradeBalance implements ModelInterface, ArrayAccess, \JsonSerializab * @var string[] */ protected static $openAPITypes = [ - 'account' => '\SnapTrade\Model\Account', + 'account' => '\SnapTrade\Model\AccountSimple', 'currency' => '\SnapTrade\Model\Currency', 'cash' => 'float' ]; @@ -300,7 +300,7 @@ public function valid() /** * Gets account * - * @return \SnapTrade\Model\Account|null + * @return \SnapTrade\Model\AccountSimple|null */ public function getAccount() { @@ -310,7 +310,7 @@ public function getAccount() /** * Sets account * - * @param \SnapTrade\Model\Account|null $account account + * @param \SnapTrade\Model\AccountSimple|null $account account * * @return self */ @@ -368,7 +368,7 @@ public function getCash() /** * Sets cash * - * @param float|null $cash Cash + * @param float|null $cash Estimated amount of cash remaining in the account after the trade. At the moment this is the same as `remaining_cash` under `trade_impacts`. * * @return self */ diff --git a/lib/Model/ManualTradeForm.php b/lib/Model/ManualTradeForm.php index 9c9048c..7df6daf 100644 --- a/lib/Model/ManualTradeForm.php +++ b/lib/Model/ManualTradeForm.php @@ -30,7 +30,7 @@ * ManualTradeForm Class Doc Comment * * @category Class - * @description Manual Trade Form + * @description Inputs for placing an order with the brokerage. * @package SnapTrade * @implements \ArrayAccess */ @@ -53,12 +53,12 @@ class ManualTradeForm implements ModelInterface, ArrayAccess, \JsonSerializable protected static $openAPITypes = [ 'account_id' => 'string', 'action' => '\SnapTrade\Model\ActionStrict', + 'universal_symbol_id' => 'string', 'order_type' => '\SnapTrade\Model\OrderTypeStrict', + 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', 'price' => 'float', 'stop' => 'float', - 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', 'units' => 'float', - 'universal_symbol_id' => 'string', 'notional_value' => '\SnapTrade\Model\ManualTradeFormNotionalValue' ]; @@ -72,12 +72,12 @@ class ManualTradeForm implements ModelInterface, ArrayAccess, \JsonSerializable protected static $openAPIFormats = [ 'account_id' => 'uuid', 'action' => null, + 'universal_symbol_id' => 'uuid', 'order_type' => null, + 'time_in_force' => null, 'price' => null, 'stop' => null, - 'time_in_force' => null, 'units' => null, - 'universal_symbol_id' => 'uuid', 'notional_value' => null ]; @@ -89,12 +89,12 @@ class ManualTradeForm implements ModelInterface, ArrayAccess, \JsonSerializable protected static array $openAPINullables = [ 'account_id' => false, 'action' => false, + 'universal_symbol_id' => false, 'order_type' => false, + 'time_in_force' => false, 'price' => true, 'stop' => true, - 'time_in_force' => false, 'units' => true, - 'universal_symbol_id' => false, 'notional_value' => true ]; @@ -186,12 +186,12 @@ public function isNullableSetToNull(string $property): bool protected static $attributeMap = [ 'account_id' => 'account_id', 'action' => 'action', + 'universal_symbol_id' => 'universal_symbol_id', 'order_type' => 'order_type', + 'time_in_force' => 'time_in_force', 'price' => 'price', 'stop' => 'stop', - 'time_in_force' => 'time_in_force', 'units' => 'units', - 'universal_symbol_id' => 'universal_symbol_id', 'notional_value' => 'notional_value' ]; @@ -203,12 +203,12 @@ public function isNullableSetToNull(string $property): bool protected static $setters = [ 'account_id' => 'setAccountId', 'action' => 'setAction', + 'universal_symbol_id' => 'setUniversalSymbolId', 'order_type' => 'setOrderType', + 'time_in_force' => 'setTimeInForce', 'price' => 'setPrice', 'stop' => 'setStop', - 'time_in_force' => 'setTimeInForce', 'units' => 'setUnits', - 'universal_symbol_id' => 'setUniversalSymbolId', 'notional_value' => 'setNotionalValue' ]; @@ -220,12 +220,12 @@ public function isNullableSetToNull(string $property): bool protected static $getters = [ 'account_id' => 'getAccountId', 'action' => 'getAction', + 'universal_symbol_id' => 'getUniversalSymbolId', 'order_type' => 'getOrderType', + 'time_in_force' => 'getTimeInForce', 'price' => 'getPrice', 'stop' => 'getStop', - 'time_in_force' => 'getTimeInForce', 'units' => 'getUnits', - 'universal_symbol_id' => 'getUniversalSymbolId', 'notional_value' => 'getNotionalValue' ]; @@ -288,12 +288,12 @@ public function __construct(array $data = null) { $this->setIfExists('account_id', $data ?? [], null); $this->setIfExists('action', $data ?? [], null); + $this->setIfExists('universal_symbol_id', $data ?? [], null); $this->setIfExists('order_type', $data ?? [], null); + $this->setIfExists('time_in_force', $data ?? [], null); $this->setIfExists('price', $data ?? [], null); $this->setIfExists('stop', $data ?? [], null); - $this->setIfExists('time_in_force', $data ?? [], null); $this->setIfExists('units', $data ?? [], null); - $this->setIfExists('universal_symbol_id', $data ?? [], null); $this->setIfExists('notional_value', $data ?? [], null); } @@ -324,6 +324,21 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['account_id'] === null) { + $invalidProperties[] = "'account_id' can't be null"; + } + if ($this->container['action'] === null) { + $invalidProperties[] = "'action' can't be null"; + } + if ($this->container['universal_symbol_id'] === null) { + $invalidProperties[] = "'universal_symbol_id' can't be null"; + } + if ($this->container['order_type'] === null) { + $invalidProperties[] = "'order_type' can't be null"; + } + if ($this->container['time_in_force'] === null) { + $invalidProperties[] = "'time_in_force' can't be null"; + } return $invalidProperties; } @@ -342,7 +357,7 @@ public function valid() /** * Gets account_id * - * @return string|null + * @return string */ public function getAccountId() { @@ -352,7 +367,7 @@ public function getAccountId() /** * Sets account_id * - * @param string|null $account_id account_id + * @param string $account_id Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. * * @return self */ @@ -371,7 +386,7 @@ public function setAccountId($account_id) /** * Gets action * - * @return \SnapTrade\Model\ActionStrict|null + * @return \SnapTrade\Model\ActionStrict */ public function getAction() { @@ -381,7 +396,7 @@ public function getAction() /** * Sets action * - * @param \SnapTrade\Model\ActionStrict|null $action action + * @param \SnapTrade\Model\ActionStrict $action action * * @return self */ @@ -397,10 +412,39 @@ public function setAction($action) return $this; } + /** + * Gets universal_symbol_id + * + * @return string + */ + public function getUniversalSymbolId() + { + return $this->container['universal_symbol_id']; + } + + /** + * Sets universal_symbol_id + * + * @param string $universal_symbol_id Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls. + * + * @return self + */ + public function setUniversalSymbolId($universal_symbol_id) + { + + if (is_null($universal_symbol_id)) { + throw new \InvalidArgumentException('non-nullable universal_symbol_id cannot be null'); + } + + $this->container['universal_symbol_id'] = $universal_symbol_id; + + return $this; + } + /** * Gets order_type * - * @return \SnapTrade\Model\OrderTypeStrict|null + * @return \SnapTrade\Model\OrderTypeStrict */ public function getOrderType() { @@ -410,7 +454,7 @@ public function getOrderType() /** * Sets order_type * - * @param \SnapTrade\Model\OrderTypeStrict|null $order_type order_type + * @param \SnapTrade\Model\OrderTypeStrict $order_type order_type * * @return self */ @@ -426,6 +470,35 @@ public function setOrderType($order_type) return $this; } + /** + * Gets time_in_force + * + * @return \SnapTrade\Model\TimeInForceStrict + */ + public function getTimeInForce() + { + return $this->container['time_in_force']; + } + + /** + * Sets time_in_force + * + * @param \SnapTrade\Model\TimeInForceStrict $time_in_force time_in_force + * + * @return self + */ + public function setTimeInForce($time_in_force) + { + + if (is_null($time_in_force)) { + throw new \InvalidArgumentException('non-nullable time_in_force cannot be null'); + } + + $this->container['time_in_force'] = $time_in_force; + + return $this; + } + /** * Gets price * @@ -439,7 +512,7 @@ public function getPrice() /** * Sets price * - * @param float|null $price Trade Price if limit or stop limit order + * @param float|null $price The limit price for `Limit` and `StopLimit` orders. * * @return self */ @@ -475,7 +548,7 @@ public function getStop() /** * Sets stop * - * @param float|null $stop Stop Price. If stop loss or stop limit order, the price to trigger the stop + * @param float|null $stop The price at which a stop order is triggered for `Stop` and `StopLimit` orders. * * @return self */ @@ -498,35 +571,6 @@ public function setStop($stop) return $this; } - /** - * Gets time_in_force - * - * @return \SnapTrade\Model\TimeInForceStrict|null - */ - public function getTimeInForce() - { - return $this->container['time_in_force']; - } - - /** - * Sets time_in_force - * - * @param \SnapTrade\Model\TimeInForceStrict|null $time_in_force time_in_force - * - * @return self - */ - public function setTimeInForce($time_in_force) - { - - if (is_null($time_in_force)) { - throw new \InvalidArgumentException('non-nullable time_in_force cannot be null'); - } - - $this->container['time_in_force'] = $time_in_force; - - return $this; - } - /** * Gets units * @@ -563,35 +607,6 @@ public function setUnits($units) return $this; } - /** - * Gets universal_symbol_id - * - * @return string|null - */ - public function getUniversalSymbolId() - { - return $this->container['universal_symbol_id']; - } - - /** - * Sets universal_symbol_id - * - * @param string|null $universal_symbol_id universal_symbol_id - * - * @return self - */ - public function setUniversalSymbolId($universal_symbol_id) - { - - if (is_null($universal_symbol_id)) { - throw new \InvalidArgumentException('non-nullable universal_symbol_id cannot be null'); - } - - $this->container['universal_symbol_id'] = $universal_symbol_id; - - return $this; - } - /** * Gets notional_value * diff --git a/lib/Model/ManualTradeImpact.php b/lib/Model/ManualTradeImpact.php new file mode 100644 index 0000000..360ca4a --- /dev/null +++ b/lib/Model/ManualTradeImpact.php @@ -0,0 +1,569 @@ + + */ +class ManualTradeImpact implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ManualTradeImpact'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'account' => 'string', + 'currency' => 'string', + 'remaining_cash' => 'float', + 'estimated_commission' => 'float', + 'forex_fees' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'account' => 'uuid', + 'currency' => 'uuid', + 'remaining_cash' => null, + 'estimated_commission' => null, + 'forex_fees' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'account' => false, + 'currency' => false, + 'remaining_cash' => true, + 'estimated_commission' => true, + 'forex_fees' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'account' => 'account', + 'currency' => 'currency', + 'remaining_cash' => 'remaining_cash', + 'estimated_commission' => 'estimated_commission', + 'forex_fees' => 'forex_fees' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'account' => 'setAccount', + 'currency' => 'setCurrency', + 'remaining_cash' => 'setRemainingCash', + 'estimated_commission' => 'setEstimatedCommission', + 'forex_fees' => 'setForexFees' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'account' => 'getAccount', + 'currency' => 'getCurrency', + 'remaining_cash' => 'getRemainingCash', + 'estimated_commission' => 'getEstimatedCommission', + 'forex_fees' => 'getForexFees' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('account', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('remaining_cash', $data ?? [], null); + $this->setIfExists('estimated_commission', $data ?? [], null); + $this->setIfExists('forex_fees', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets account + * + * @return string|null + */ + public function getAccount() + { + return $this->container['account']; + } + + /** + * Sets account + * + * @param string|null $account Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. + * + * @return self + */ + public function setAccount($account) + { + + if (is_null($account)) { + throw new \InvalidArgumentException('non-nullable account cannot be null'); + } + + $this->container['account'] = $account; + + return $this; + } + + /** + * Gets currency + * + * @return string|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string|null $currency Unique identifier for the currency. This is the UUID used to reference the currency in SnapTrade. + * + * @return self + */ + public function setCurrency($currency) + { + + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets remaining_cash + * + * @return float|null + */ + public function getRemainingCash() + { + return $this->container['remaining_cash']; + } + + /** + * Sets remaining_cash + * + * @param float|null $remaining_cash Estimated amount of cash remaining in the account after the trade. + * + * @return self + */ + public function setRemainingCash($remaining_cash) + { + + if (is_null($remaining_cash)) { + array_push($this->openAPINullablesSetToNull, 'remaining_cash'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('remaining_cash', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['remaining_cash'] = $remaining_cash; + + return $this; + } + + /** + * Gets estimated_commission + * + * @return float|null + */ + public function getEstimatedCommission() + { + return $this->container['estimated_commission']; + } + + /** + * Sets estimated_commission + * + * @param float|null $estimated_commission Estimated commission for the trade. + * + * @return self + */ + public function setEstimatedCommission($estimated_commission) + { + + if (is_null($estimated_commission)) { + array_push($this->openAPINullablesSetToNull, 'estimated_commission'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('estimated_commission', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['estimated_commission'] = $estimated_commission; + + return $this; + } + + /** + * Gets forex_fees + * + * @return float|null + */ + public function getForexFees() + { + return $this->container['forex_fees']; + } + + /** + * Sets forex_fees + * + * @param float|null $forex_fees Estimated foreign transaction fees for the trade. + * + * @return self + */ + public function setForexFees($forex_fees) + { + + if (is_null($forex_fees)) { + array_push($this->openAPINullablesSetToNull, 'forex_fees'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('forex_fees', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['forex_fees'] = $forex_fees; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/ManualTradeSymbol.php b/lib/Model/ManualTradeSymbol.php index ff46c66..a24a97e 100644 --- a/lib/Model/ManualTradeSymbol.php +++ b/lib/Model/ManualTradeSymbol.php @@ -30,7 +30,7 @@ * ManualTradeSymbol Class Doc Comment * * @category Class - * @description Manual trade symbol object + * @description Information about the security for the order. * @package SnapTrade * @implements \ArrayAccess */ @@ -322,6 +322,7 @@ public function valid() * Gets brokerage_symbol_id * * @return string|null + * @deprecated */ public function getBrokerageSymbolId() { @@ -331,9 +332,10 @@ public function getBrokerageSymbolId() /** * Sets brokerage_symbol_id * - * @param string|null $brokerage_symbol_id brokerage_symbol_id + * @param string|null $brokerage_symbol_id A unique ID for the security within SnapTrade, scoped to the brokerage account that the security belongs to. This is a legacy field and should not be used. Do not rely on this being a stable ID as it can change. * * @return self + * @deprecated */ public function setBrokerageSymbolId($brokerage_symbol_id) { @@ -360,7 +362,7 @@ public function getUniversalSymbolId() /** * Sets universal_symbol_id * - * @param string|null $universal_symbol_id universal_symbol_id + * @param string|null $universal_symbol_id Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls. * * @return self */ @@ -409,6 +411,7 @@ public function setCurrency($currency) * Gets local_id * * @return string|null + * @deprecated */ public function getLocalId() { @@ -418,9 +421,10 @@ public function getLocalId() /** * Sets local_id * - * @param string|null $local_id local_id + * @param string|null $local_id This field is deprecated and should not be used. * * @return self + * @deprecated */ public function setLocalId($local_id) { @@ -438,6 +442,7 @@ public function setLocalId($local_id) * Gets description * * @return string|null + * @deprecated */ public function getDescription() { @@ -447,9 +452,10 @@ public function getDescription() /** * Sets description * - * @param string|null $description description + * @param string|null $description This field is deprecated and should not be used. * * @return self + * @deprecated */ public function setDescription($description) { @@ -474,6 +480,7 @@ public function setDescription($description) * Gets symbol * * @return string|null + * @deprecated */ public function getSymbol() { @@ -483,9 +490,10 @@ public function getSymbol() /** * Sets symbol * - * @param string|null $symbol symbol + * @param string|null $symbol This field is deprecated and should not be used. * * @return self + * @deprecated */ public function setSymbol($symbol) { diff --git a/lib/Model/NotionalValue.php b/lib/Model/NotionalValue.php index c4a3fd9..96c7c25 100644 --- a/lib/Model/NotionalValue.php +++ b/lib/Model/NotionalValue.php @@ -30,7 +30,7 @@ * NotionalValue Class Doc Comment * * @category Class - * @description Dollar amount to trade. Cannot work with units. Can only work for market order types and day for time in force. **Only available for Alpaca, Alpaca Paper, and Robinhood.** + * @description Total notional amount for the order. Must be `null` if `units` is provided. Can only work with `Market` for `order_type` and `Day` for `time_in_force`. This is only available for certain brokerages. Please check the [integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=e7bbcbf9f272441593f93decde660687) for more information. * @package SnapTrade * @implements \ArrayAccess */ diff --git a/lib/Model/OrderTypeStrict.php b/lib/Model/OrderTypeStrict.php index bef8532..1a09675 100644 --- a/lib/Model/OrderTypeStrict.php +++ b/lib/Model/OrderTypeStrict.php @@ -28,7 +28,7 @@ * OrderTypeStrict Class Doc Comment * * @category Class - * @description Order Type + * @description The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required. * @package SnapTrade */ class OrderTypeStrict diff --git a/lib/Model/SymbolsQuotesInner.php b/lib/Model/SymbolsQuotesInner.php index 505d2f7..5f0bbce 100644 --- a/lib/Model/SymbolsQuotesInner.php +++ b/lib/Model/SymbolsQuotesInner.php @@ -51,9 +51,9 @@ class SymbolsQuotesInner implements ModelInterface, ArrayAccess, \JsonSerializab */ protected static $openAPITypes = [ 'symbol' => '\SnapTrade\Model\UniversalSymbol', + 'last_trade_price' => 'float', 'bid_price' => 'float', 'ask_price' => 'float', - 'last_trade_price' => 'float', 'bid_size' => 'float', 'ask_size' => 'float' ]; @@ -67,9 +67,9 @@ class SymbolsQuotesInner implements ModelInterface, ArrayAccess, \JsonSerializab */ protected static $openAPIFormats = [ 'symbol' => null, + 'last_trade_price' => null, 'bid_price' => null, 'ask_price' => null, - 'last_trade_price' => null, 'bid_size' => null, 'ask_size' => null ]; @@ -81,9 +81,9 @@ class SymbolsQuotesInner implements ModelInterface, ArrayAccess, \JsonSerializab */ protected static array $openAPINullables = [ 'symbol' => false, + 'last_trade_price' => false, 'bid_price' => false, 'ask_price' => false, - 'last_trade_price' => false, 'bid_size' => false, 'ask_size' => false ]; @@ -175,9 +175,9 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'symbol' => 'symbol', + 'last_trade_price' => 'last_trade_price', 'bid_price' => 'bid_price', 'ask_price' => 'ask_price', - 'last_trade_price' => 'last_trade_price', 'bid_size' => 'bid_size', 'ask_size' => 'ask_size' ]; @@ -189,9 +189,9 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'symbol' => 'setSymbol', + 'last_trade_price' => 'setLastTradePrice', 'bid_price' => 'setBidPrice', 'ask_price' => 'setAskPrice', - 'last_trade_price' => 'setLastTradePrice', 'bid_size' => 'setBidSize', 'ask_size' => 'setAskSize' ]; @@ -203,9 +203,9 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'symbol' => 'getSymbol', + 'last_trade_price' => 'getLastTradePrice', 'bid_price' => 'getBidPrice', 'ask_price' => 'getAskPrice', - 'last_trade_price' => 'getLastTradePrice', 'bid_size' => 'getBidSize', 'ask_size' => 'getAskSize' ]; @@ -268,9 +268,9 @@ public function getModelName() public function __construct(array $data = null) { $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('last_trade_price', $data ?? [], null); $this->setIfExists('bid_price', $data ?? [], null); $this->setIfExists('ask_price', $data ?? [], null); - $this->setIfExists('last_trade_price', $data ?? [], null); $this->setIfExists('bid_size', $data ?? [], null); $this->setIfExists('ask_size', $data ?? [], null); } @@ -347,88 +347,88 @@ public function setSymbol($symbol) } /** - * Gets bid_price + * Gets last_trade_price * * @return float|null */ - public function getBidPrice() + public function getLastTradePrice() { - return $this->container['bid_price']; + return $this->container['last_trade_price']; } /** - * Sets bid_price + * Sets last_trade_price * - * @param float|null $bid_price bid_price + * @param float|null $last_trade_price The most recent trade price from the brokerage. * * @return self */ - public function setBidPrice($bid_price) + public function setLastTradePrice($last_trade_price) { - if (is_null($bid_price)) { - throw new \InvalidArgumentException('non-nullable bid_price cannot be null'); + if (is_null($last_trade_price)) { + throw new \InvalidArgumentException('non-nullable last_trade_price cannot be null'); } - $this->container['bid_price'] = $bid_price; + $this->container['last_trade_price'] = $last_trade_price; return $this; } /** - * Gets ask_price + * Gets bid_price * * @return float|null */ - public function getAskPrice() + public function getBidPrice() { - return $this->container['ask_price']; + return $this->container['bid_price']; } /** - * Sets ask_price + * Sets bid_price * - * @param float|null $ask_price ask_price + * @param float|null $bid_price The most recent bid price from the brokerage. * * @return self */ - public function setAskPrice($ask_price) + public function setBidPrice($bid_price) { - if (is_null($ask_price)) { - throw new \InvalidArgumentException('non-nullable ask_price cannot be null'); + if (is_null($bid_price)) { + throw new \InvalidArgumentException('non-nullable bid_price cannot be null'); } - $this->container['ask_price'] = $ask_price; + $this->container['bid_price'] = $bid_price; return $this; } /** - * Gets last_trade_price + * Gets ask_price * * @return float|null */ - public function getLastTradePrice() + public function getAskPrice() { - return $this->container['last_trade_price']; + return $this->container['ask_price']; } /** - * Sets last_trade_price + * Sets ask_price * - * @param float|null $last_trade_price last_trade_price + * @param float|null $ask_price The most recent price from the brokerage. * * @return self */ - public function setLastTradePrice($last_trade_price) + public function setAskPrice($ask_price) { - if (is_null($last_trade_price)) { - throw new \InvalidArgumentException('non-nullable last_trade_price cannot be null'); + if (is_null($ask_price)) { + throw new \InvalidArgumentException('non-nullable ask_price cannot be null'); } - $this->container['last_trade_price'] = $last_trade_price; + $this->container['ask_price'] = $ask_price; return $this; } @@ -446,7 +446,7 @@ public function getBidSize() /** * Sets bid_size * - * @param float|null $bid_size bid_size + * @param float|null $bid_size The most recent bid size from the brokerage. * * @return self */ @@ -475,7 +475,7 @@ public function getAskSize() /** * Sets ask_size * - * @param float|null $ask_size ask_size + * @param float|null $ask_size The most recent ask size from the brokerage. * * @return self */ diff --git a/lib/Model/TimeInForceStrict.php b/lib/Model/TimeInForceStrict.php index e1874ac..66ae91c 100644 --- a/lib/Model/TimeInForceStrict.php +++ b/lib/Model/TimeInForceStrict.php @@ -28,7 +28,7 @@ * TimeInForceStrict Class Doc Comment * * @category Class - * @description Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled + * @description The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. * @package SnapTrade */ class TimeInForceStrict diff --git a/lib/Model/TradingCancelUserAccountOrderRequest.php b/lib/Model/TradingCancelUserAccountOrderRequest.php index 70f4351..25ccf9d 100644 --- a/lib/Model/TradingCancelUserAccountOrderRequest.php +++ b/lib/Model/TradingCancelUserAccountOrderRequest.php @@ -61,7 +61,7 @@ class TradingCancelUserAccountOrderRequest implements ModelInterface, ArrayAcces * @psalm-var array */ protected static $openAPIFormats = [ - 'brokerage_order_id' => 'uuid' + 'brokerage_order_id' => null ]; /** @@ -295,7 +295,7 @@ public function getBrokerageOrderId() /** * Sets brokerage_order_id * - * @param string|null $brokerage_order_id brokerage_order_id + * @param string|null $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. * * @return self */ diff --git a/lib/Model/ValidatedTradeBody.php b/lib/Model/ValidatedTradeBody.php index 893308d..77fd981 100644 --- a/lib/Model/ValidatedTradeBody.php +++ b/lib/Model/ValidatedTradeBody.php @@ -30,7 +30,6 @@ * ValidatedTradeBody Class Doc Comment * * @category Class - * @description Validated Trade Form * @package SnapTrade * @implements \ArrayAccess */ @@ -296,7 +295,7 @@ public function getWaitToConfirm() /** * Sets wait_to_confirm * - * @param bool|null $wait_to_confirm Optional, defaults to true. Determines if a wait is performed to check on order status. If false, latency will be reduced but orders returned will be more likely to be of status PENDING as we will not wait to check on the status before responding to the request + * @param bool|null $wait_to_confirm Optional, defaults to true. Determines if a wait is performed to check on order status. If false, latency will be reduced but orders returned will be more likely to be of status `PENDING` as we will not wait to check on the status before responding to the request. * * @return self */ diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 55e4928..6a6ca9b 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -61,7 +61,7 @@ public static function tearDownAfterClass(): void /** * Test case for cancelUserAccountOrder * - * Cancel open order in account. + * Cancel order. * */ public function testCancelUserAccountOrder() @@ -73,7 +73,7 @@ public function testCancelUserAccountOrder() /** * Test case for getOrderImpact * - * Check the impact of a trade on an account. + * Check order impact. * */ public function testGetOrderImpact() @@ -97,7 +97,7 @@ public function testGetUserAccountQuotes() /** * Test case for placeForceOrder * - * Place a trade with NO validation.. + * Place order. * */ public function testPlaceForceOrder() @@ -109,7 +109,7 @@ public function testPlaceForceOrder() /** * Test case for placeOrder * - * Place order. + * Place checked order. * */ public function testPlaceOrder() diff --git a/test/Model/ActionStrictTest.php b/test/Model/ActionStrictTest.php index b74cf72..fd585db 100644 --- a/test/Model/ActionStrictTest.php +++ b/test/Model/ActionStrictTest.php @@ -29,7 +29,7 @@ * ActionStrictTest Class Doc Comment * * @category Class - * @description Trade Action + * @description The action describes the intent or side of a trade. This is either `BUY` or `SELL` * @package SnapTrade */ class ActionStrictTest extends TestCase diff --git a/test/Model/ManualTradeAndImpactTest.php b/test/Model/ManualTradeAndImpactTest.php index c81698e..4d5fbde 100644 --- a/test/Model/ManualTradeAndImpactTest.php +++ b/test/Model/ManualTradeAndImpactTest.php @@ -29,7 +29,7 @@ * ManualTradeAndImpactTest Class Doc Comment * * @category Class - * @description Manual Trade and Impact object + * @description ManualTradeAndImpact * @package SnapTrade */ class ManualTradeAndImpactTest extends TestCase diff --git a/test/Model/ManualTradeBalanceTest.php b/test/Model/ManualTradeBalanceTest.php index cc9fac4..a7e0c85 100644 --- a/test/Model/ManualTradeBalanceTest.php +++ b/test/Model/ManualTradeBalanceTest.php @@ -29,7 +29,7 @@ * ManualTradeBalanceTest Class Doc Comment * * @category Class - * @description Balance + * @description Estimated remaining balance of the account after the trade is executed. * @package SnapTrade */ class ManualTradeBalanceTest extends TestCase diff --git a/test/Model/ManualTradeFormTest.php b/test/Model/ManualTradeFormTest.php index 424f600..2c596d1 100644 --- a/test/Model/ManualTradeFormTest.php +++ b/test/Model/ManualTradeFormTest.php @@ -29,7 +29,7 @@ * ManualTradeFormTest Class Doc Comment * * @category Class - * @description Manual Trade Form + * @description Inputs for placing an order with the brokerage. * @package SnapTrade */ class ManualTradeFormTest extends TestCase @@ -91,54 +91,54 @@ public function testPropertyAction() } /** - * Test attribute "order_type" + * Test attribute "universal_symbol_id" */ - public function testPropertyOrderType() + public function testPropertyUniversalSymbolId() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "price" + * Test attribute "order_type" */ - public function testPropertyPrice() + public function testPropertyOrderType() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "stop" + * Test attribute "time_in_force" */ - public function testPropertyStop() + public function testPropertyTimeInForce() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "time_in_force" + * Test attribute "price" */ - public function testPropertyTimeInForce() + public function testPropertyPrice() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "units" + * Test attribute "stop" */ - public function testPropertyUnits() + public function testPropertyStop() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "universal_symbol_id" + * Test attribute "units" */ - public function testPropertyUniversalSymbolId() + public function testPropertyUnits() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/ManualTradeImpactTest.php b/test/Model/ManualTradeImpactTest.php new file mode 100644 index 0000000..2393215 --- /dev/null +++ b/test/Model/ManualTradeImpactTest.php @@ -0,0 +1,119 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "account" + */ + public function testPropertyAccount() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "currency" + */ + public function testPropertyCurrency() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "remaining_cash" + */ + public function testPropertyRemainingCash() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "estimated_commission" + */ + public function testPropertyEstimatedCommission() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "forex_fees" + */ + public function testPropertyForexFees() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/ManualTradeSymbolTest.php b/test/Model/ManualTradeSymbolTest.php index 158da6d..a79811a 100644 --- a/test/Model/ManualTradeSymbolTest.php +++ b/test/Model/ManualTradeSymbolTest.php @@ -29,7 +29,7 @@ * ManualTradeSymbolTest Class Doc Comment * * @category Class - * @description Manual trade symbol object + * @description Information about the security for the order. * @package SnapTrade */ class ManualTradeSymbolTest extends TestCase diff --git a/test/Model/ManualTradeTest.php b/test/Model/ManualTradeTest.php index 77bf928..a1364ab 100644 --- a/test/Model/ManualTradeTest.php +++ b/test/Model/ManualTradeTest.php @@ -29,7 +29,7 @@ * ManualTradeTest Class Doc Comment * * @category Class - * @description A manual trade object + * @description Contains the details of a submitted order. * @package SnapTrade */ class ManualTradeTest extends TestCase diff --git a/test/Model/NotionalValueTest.php b/test/Model/NotionalValueTest.php index 03caf24..e0d6e70 100644 --- a/test/Model/NotionalValueTest.php +++ b/test/Model/NotionalValueTest.php @@ -29,7 +29,7 @@ * NotionalValueTest Class Doc Comment * * @category Class - * @description Dollar amount to trade. Cannot work with units. Can only work for market order types and day for time in force. **Only available for Alpaca, Alpaca Paper, and Robinhood.** + * @description Total notional amount for the order. Must be `null` if `units` is provided. Can only work with `Market` for `order_type` and `Day` for `time_in_force`. This is only available for certain brokerages. Please check the [integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=e7bbcbf9f272441593f93decde660687) for more information. * @package SnapTrade */ class NotionalValueTest extends TestCase diff --git a/test/Model/OrderTypeStrictTest.php b/test/Model/OrderTypeStrictTest.php index b9e4d47..ac99fce 100644 --- a/test/Model/OrderTypeStrictTest.php +++ b/test/Model/OrderTypeStrictTest.php @@ -29,7 +29,7 @@ * OrderTypeStrictTest Class Doc Comment * * @category Class - * @description Order Type + * @description The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required. * @package SnapTrade */ class OrderTypeStrictTest extends TestCase diff --git a/test/Model/SymbolsQuotesInnerTest.php b/test/Model/SymbolsQuotesInnerTest.php index dc70272..cd9ae3e 100644 --- a/test/Model/SymbolsQuotesInnerTest.php +++ b/test/Model/SymbolsQuotesInnerTest.php @@ -82,27 +82,27 @@ public function testPropertySymbol() } /** - * Test attribute "bid_price" + * Test attribute "last_trade_price" */ - public function testPropertyBidPrice() + public function testPropertyLastTradePrice() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "ask_price" + * Test attribute "bid_price" */ - public function testPropertyAskPrice() + public function testPropertyBidPrice() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "last_trade_price" + * Test attribute "ask_price" */ - public function testPropertyLastTradePrice() + public function testPropertyAskPrice() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/TimeInForceStrictTest.php b/test/Model/TimeInForceStrictTest.php index 05b2fa9..228e9c8 100644 --- a/test/Model/TimeInForceStrictTest.php +++ b/test/Model/TimeInForceStrictTest.php @@ -29,7 +29,7 @@ * TimeInForceStrictTest Class Doc Comment * * @category Class - * @description Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled + * @description The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. * @package SnapTrade */ class TimeInForceStrictTest extends TestCase diff --git a/test/Model/ValidatedTradeBodyTest.php b/test/Model/ValidatedTradeBodyTest.php index ec859b3..ca000ee 100644 --- a/test/Model/ValidatedTradeBodyTest.php +++ b/test/Model/ValidatedTradeBodyTest.php @@ -29,7 +29,7 @@ * ValidatedTradeBodyTest Class Doc Comment * * @category Class - * @description Validated Trade Form + * @description ValidatedTradeBody * @package SnapTrade */ class ValidatedTradeBodyTest extends TestCase From c39dbe2ecf1d452bfb870c5c4810c5465e5e801b Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 22:20:13 +0000 Subject: [PATCH 004/252] Version Bump SDKs (#15) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index c8b1378..0e7f903 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -81b14b50-3280-483c-ae3d-052f538020aa \ No newline at end of file +f4480b1b-b814-44d6-b9db-6ecd676aefd1 \ No newline at end of file diff --git a/README.md b/README.md index b60988b..4fbd8d4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.37-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.38-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.37" + "konfig/snaptrade-php-sdk": "2.0.38" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 4d8f026..017bb75 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.37/PHP'; + protected $userAgent = 'Konfig/2.0.38/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.37' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.38' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From c9a79487cbc4d832a2fe4b6e6a4649711ea5b558 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:33:00 +0000 Subject: [PATCH 005/252] Regenerate SDKs (#16) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 19 +++++++++++++------ lib/Api/AuthenticationApi.php | 16 ++++++++-------- lib/Api/ConnectionsApi.php | 16 ++++++++-------- lib/Api/TradingApi.php | 16 ++++++++-------- lib/Model/BrokerageAuthorization.php | 2 +- lib/Model/SnapTradeLoginUserRequestBody.php | 6 +++--- test/Api/AuthenticationApiTest.php | 2 +- 8 files changed, 43 insertions(+), 36 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0e7f903..88e1e17 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f4480b1b-b814-44d6-b9db-6ecd676aefd1 \ No newline at end of file +54c7c51f-7615-42db-b733-aafc271d19be \ No newline at end of file diff --git a/README.md b/README.md index 4fbd8d4..75fc017 100644 --- a/README.md +++ b/README.md @@ -537,7 +537,10 @@ $result = $snaptrade->authentication->listSnapTradeUsers(); ### `snaptrade.authentication.loginSnapTradeUser` -Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account. +Authenticates a SnapTrade user and returns the Connection Portal URL used for connecting brokerage accounts. Please check [this guide](/docs/implement-connection-portal) for how to integrate the Connection Portal into your app. + +Please note that the returned URL expires in 5 minutes. + #### πŸ› οΈ Usage @@ -567,15 +570,15 @@ Slug of the brokerage to connect the user to. See [the integrations page](https: ##### immediateRedirect: `bool` -When set to `true`, user will be redirected back to the partner's site instead of the connection portal. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](https://docs.snaptrade.com/docs/implement-connection-portal) for more information. +When set to `true`, user will be redirected back to the partner's site instead of the connection portal. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](/docs/implement-connection-portal) for more information. ##### customRedirect: `string` -URL to redirect the user to after the user connects their brokerage account. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](https://docs.snaptrade.com/docs/implement-connection-portal) for more information. +URL to redirect the user to after the user connects their brokerage account. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](/docs/implement-connection-portal) for more information. ##### reconnect: `string` -The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See the [guide on fixing broken connections](https://docs.snaptrade.com/docs/fix-broken-connections) for more information. +The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See the [guide on fixing broken connections](/docs/fix-broken-connections) for more information. ##### connectionType: `string` @@ -713,7 +716,7 @@ $result = $snaptrade->connections->detailBrokerageAuthorization( ### `snaptrade.connections.disableBrokerageAuthorization` Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. -Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_broken) for the connection. +Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* @@ -792,7 +795,7 @@ $result = $snaptrade->connections->listBrokerageAuthorizations( ### `snaptrade.connections.refreshBrokerageAuthorization` -Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. +Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* @@ -1640,6 +1643,8 @@ Places a brokerage order in the specified account. The order could be rejected b This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). +It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + #### πŸ› οΈ Usage @@ -1710,6 +1715,8 @@ The price at which a stop order is triggered for `Stop` and `StopLimit` orders. Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). +It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + #### πŸ› οΈ Usage diff --git a/lib/Api/AuthenticationApi.php b/lib/Api/AuthenticationApi.php index 8e34f78..2690d7a 100644 --- a/lib/Api/AuthenticationApi.php +++ b/lib/Api/AuthenticationApi.php @@ -955,9 +955,9 @@ public function listSnapTradeUsersRequest(string $contentType = self::contentTyp /** * Operation loginSnapTradeUser * - * Login user & generate connection link + * Generate Connection Portal URL * - * Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account. + * Authenticates a SnapTrade user and returns the Connection Portal URL used for connecting brokerage accounts. Please check [this guide](/docs/implement-connection-portal) for how to integrate the Connection Portal into your app. Please note that the returned URL expires in 5 minutes. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -997,9 +997,9 @@ public function loginSnapTradeUser( /** * Operation loginSnapTradeUserWithHttpInfo * - * Login user & generate connection link + * Generate Connection Portal URL * - * Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account. + * Authenticates a SnapTrade user and returns the Connection Portal URL used for connecting brokerage accounts. Please check [this guide](/docs/implement-connection-portal) for how to integrate the Connection Portal into your app. Please note that the returned URL expires in 5 minutes. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1187,9 +1187,9 @@ public function loginSnapTradeUserWithHttpInfo($user_id, $user_secret, $snap_tra /** * Operation loginSnapTradeUserAsync * - * Login user & generate connection link + * Generate Connection Portal URL * - * Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account. + * Authenticates a SnapTrade user and returns the Connection Portal URL used for connecting brokerage accounts. Please check [this guide](/docs/implement-connection-portal) for how to integrate the Connection Portal into your app. Please note that the returned URL expires in 5 minutes. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1232,9 +1232,9 @@ function ($response) { /** * Operation loginSnapTradeUserAsyncWithHttpInfo * - * Login user & generate connection link + * Generate Connection Portal URL * - * Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account. + * Authenticates a SnapTrade user and returns the Connection Portal URL used for connecting brokerage accounts. Please check [this guide](/docs/implement-connection-portal) for how to integrate the Connection Portal into your app. Please note that the returned URL expires in 5 minutes. * * @param string $user_id (required) * @param string $user_secret (required) diff --git a/lib/Api/ConnectionsApi.php b/lib/Api/ConnectionsApi.php index d59b7ab..ec06743 100644 --- a/lib/Api/ConnectionsApi.php +++ b/lib/Api/ConnectionsApi.php @@ -557,7 +557,7 @@ public function detailBrokerageAuthorizationRequest($authorization_id, $user_id, * * Force disable connection * - * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* * * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) @@ -586,7 +586,7 @@ public function disableBrokerageAuthorization( * * Force disable connection * - * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* * * @param string $authorization_id (required) * @param string $user_id (required) @@ -799,7 +799,7 @@ public function disableBrokerageAuthorizationWithHttpInfo($authorization_id, $us * * Force disable connection * - * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* * * @param string $authorization_id (required) * @param string $user_id (required) @@ -831,7 +831,7 @@ function ($response) { * * Force disable connection * - * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1427,7 +1427,7 @@ public function listBrokerageAuthorizationsRequest($user_id, $user_secret, strin * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* * * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) @@ -1456,7 +1456,7 @@ public function refreshBrokerageAuthorization( * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1669,7 +1669,7 @@ public function refreshBrokerageAuthorizationWithHttpInfo($authorization_id, $us * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1701,7 +1701,7 @@ function ($response) { * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](https://docs.snaptrade.com/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* * * @param string $authorization_id (required) * @param string $user_id (required) diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 0c59d5a..f6f476e 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -1597,7 +1597,7 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a * * Place order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -1645,7 +1645,7 @@ public function placeForceOrder( * * Place order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1812,7 +1812,7 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad * * Place order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1863,7 +1863,7 @@ function ($response) { * * Place order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2086,7 +2086,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for * * Place checked order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id user_id (required) @@ -2120,7 +2120,7 @@ public function placeOrder( * * Place checked order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) @@ -2266,7 +2266,7 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid * * Place checked order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) @@ -2303,7 +2303,7 @@ function ($response) { * * Place checked order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) diff --git a/lib/Model/BrokerageAuthorization.php b/lib/Model/BrokerageAuthorization.php index 5871927..6337e2d 100644 --- a/lib/Model/BrokerageAuthorization.php +++ b/lib/Model/BrokerageAuthorization.php @@ -528,7 +528,7 @@ public function getDisabled() /** * Sets disabled * - * @param bool|null $disabled Whether the connection is disabled. A disabled connection can no longer access the latest data from the brokerage, but will continue to return the last cached state. A connection can become disabled for many reasons and differs by brokerage. Here are some common scenarios: - The user has changed their username or password at the brokerage. - The user has explicitly removed the access grant at the brokerage. - The session has expired at the brokerage and now requires explicit user re-authentication. Please see [this guide](https://docs.snaptrade.com/docs/fix-broken-connections) on how to fix a disabled connection. + * @param bool|null $disabled Whether the connection is disabled. A disabled connection can no longer access the latest data from the brokerage, but will continue to return the last cached state. A connection can become disabled for many reasons and differs by brokerage. Here are some common scenarios: - The user has changed their username or password at the brokerage. - The user has explicitly removed the access grant at the brokerage. - The session has expired at the brokerage and now requires explicit user re-authentication. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @return self */ diff --git a/lib/Model/SnapTradeLoginUserRequestBody.php b/lib/Model/SnapTradeLoginUserRequestBody.php index 461dba5..6f353be 100644 --- a/lib/Model/SnapTradeLoginUserRequestBody.php +++ b/lib/Model/SnapTradeLoginUserRequestBody.php @@ -408,7 +408,7 @@ public function getImmediateRedirect() /** * Sets immediate_redirect * - * @param bool|null $immediate_redirect When set to `true`, user will be redirected back to the partner's site instead of the connection portal. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](https://docs.snaptrade.com/docs/implement-connection-portal) for more information. + * @param bool|null $immediate_redirect When set to `true`, user will be redirected back to the partner's site instead of the connection portal. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](/docs/implement-connection-portal) for more information. * * @return self */ @@ -437,7 +437,7 @@ public function getCustomRedirect() /** * Sets custom_redirect * - * @param string|null $custom_redirect URL to redirect the user to after the user connects their brokerage account. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](https://docs.snaptrade.com/docs/implement-connection-portal) for more information. + * @param string|null $custom_redirect URL to redirect the user to after the user connects their brokerage account. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](/docs/implement-connection-portal) for more information. * * @return self */ @@ -466,7 +466,7 @@ public function getReconnect() /** * Sets reconnect * - * @param string|null $reconnect The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See the [guide on fixing broken connections](https://docs.snaptrade.com/docs/fix-broken-connections) for more information. + * @param string|null $reconnect The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See the [guide on fixing broken connections](/docs/fix-broken-connections) for more information. * * @return self */ diff --git a/test/Api/AuthenticationApiTest.php b/test/Api/AuthenticationApiTest.php index 0811252..f670ab8 100644 --- a/test/Api/AuthenticationApiTest.php +++ b/test/Api/AuthenticationApiTest.php @@ -85,7 +85,7 @@ public function testListSnapTradeUsers() /** * Test case for loginSnapTradeUser * - * Login user & generate connection link. + * Generate Connection Portal URL. * */ public function testLoginSnapTradeUser() From 46aefde1d2bfc9483b7ea83f21ab7190dce1b11f Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:36:32 +0000 Subject: [PATCH 006/252] Version Bump SDKs (#17) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 88e1e17..f84686d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -54c7c51f-7615-42db-b733-aafc271d19be \ No newline at end of file +84d3076b-f7d8-4207-bc25-1473a353cedf \ No newline at end of file diff --git a/README.md b/README.md index 75fc017..b64659c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.38-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.39-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.38" + "konfig/snaptrade-php-sdk": "2.0.39" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 017bb75..3ad0792 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.38/PHP'; + protected $userAgent = 'Konfig/2.0.39/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.38' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.39' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 6241e645352d5c1368b98cbea86a4add64d6dfeb Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 01:13:10 +0000 Subject: [PATCH 007/252] Regenerate SDKs (#19) * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/TradingApi.php | 8 ++++---- lib/Model/OptionsPosition.php | 2 +- lib/Model/SnapTradeLoginUserRequestBody.php | 6 ++++-- lib/Model/UniversalActivity.php | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f84686d..6293906 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -84d3076b-f7d8-4207-bc25-1473a353cedf \ No newline at end of file +ca174a71-c585-468e-bdeb-f93640a516cb \ No newline at end of file diff --git a/README.md b/README.md index b64659c..e324ef8 100644 --- a/README.md +++ b/README.md @@ -1639,7 +1639,7 @@ Should be set to `True` if `symbols` are comprised of tickers. Defaults to `Fals ### `snaptrade.trading.placeForceOrder` -Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. +Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index f6f476e..8aa5832 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -1597,7 +1597,7 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a * * Place order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -1645,7 +1645,7 @@ public function placeForceOrder( * * Place order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1812,7 +1812,7 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad * * Place order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1863,7 +1863,7 @@ function ($response) { * * Place order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id (required) * @param string $user_secret (required) diff --git a/lib/Model/OptionsPosition.php b/lib/Model/OptionsPosition.php index e533867..2c426e2 100644 --- a/lib/Model/OptionsPosition.php +++ b/lib/Model/OptionsPosition.php @@ -353,7 +353,7 @@ public function getPrice() /** * Sets price * - * @param float|null $price Last known market price for the option contract. The freshness of this price depends on the brokerage. Some brokerages provide real-time prices, while others provide delayed prices. It is recommended that you rely on your own third-party market data provider for most up to date prices. + * @param float|null $price Last known market price _per share_ of the option contract. The freshness of this price depends on the brokerage. Some brokerages provide real-time prices, while others provide delayed prices. It is recommended that you rely on your own third-party market data provider for most up to date prices. * * @return self */ diff --git a/lib/Model/SnapTradeLoginUserRequestBody.php b/lib/Model/SnapTradeLoginUserRequestBody.php index 6f353be..ff5099f 100644 --- a/lib/Model/SnapTradeLoginUserRequestBody.php +++ b/lib/Model/SnapTradeLoginUserRequestBody.php @@ -254,8 +254,9 @@ public function getModelName() public const CONNECTION_TYPE_READ = 'read'; public const CONNECTION_TYPE_TRADE = 'trade'; - public const CONNECTION_PORTAL_VERSION_V2 = 'v2'; + public const CONNECTION_PORTAL_VERSION_V4 = 'v4'; public const CONNECTION_PORTAL_VERSION_V3 = 'v3'; + public const CONNECTION_PORTAL_VERSION_V2 = 'v2'; /** * Gets allowable values of the enum @@ -278,8 +279,9 @@ public function getConnectionTypeAllowableValues() public function getConnectionPortalVersionAllowableValues() { return [ - self::CONNECTION_PORTAL_VERSION_V2, + self::CONNECTION_PORTAL_VERSION_V4, self::CONNECTION_PORTAL_VERSION_V3, + self::CONNECTION_PORTAL_VERSION_V2, ]; } diff --git a/lib/Model/UniversalActivity.php b/lib/Model/UniversalActivity.php index c1d6888..1092047 100644 --- a/lib/Model/UniversalActivity.php +++ b/lib/Model/UniversalActivity.php @@ -408,7 +408,7 @@ public function getId() /** * Sets id * - * @param string|null $id Unique identifier for the transaction. This is the ID used to reference the transaction in SnapTrade. Please note that this ID _can_ change if the transaction is deleted and re-added. Under normal circumstances, SnapTrade does not delete transactions. The only time this would happen is if SnapTrade re-fetches and reprocesses the data from the brokerage, which is rare. If you require a stable ID, please let us know and we can work with you to provide one. + * @param string|null $id Unique identifier for the transaction. This is the ID used to reference the transaction in SnapTrade. Please note that this ID _can_ change if the transaction is deleted and re-added. Under normal circumstances, SnapTrade does not delete transactions. The only time this would happen is if SnapTrade re-fetches and reprocesses the data from the brokerage, which is rare. If you require a stable ID, please let us know and we can work with you to provide one. * * @return self */ From 3537e9adee74d2d327940c7b6df4b57851e74b2b Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 01:16:41 +0000 Subject: [PATCH 008/252] Version Bump SDKs (#20) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 6293906..443b91d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ca174a71-c585-468e-bdeb-f93640a516cb \ No newline at end of file +5bf896f7-e811-420d-b057-575a53b1ff80 \ No newline at end of file diff --git a/README.md b/README.md index e324ef8..361c49f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.39-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.40-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.39" + "konfig/snaptrade-php-sdk": "2.0.40" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 3ad0792..2d8bddc 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.39/PHP'; + protected $userAgent = 'Konfig/2.0.40/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.39' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.40' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From c9fd4f8c6dabb6831e0f1f73eb8572e202e0d32b Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:25:29 +0000 Subject: [PATCH 009/252] Regenerate SDKs (#21) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 25 ++++---- lib/Api/ReferenceDataApi.php | 99 +++++++++++++++++++------------ lib/Model/SymbolQuery.php | 3 +- test/Api/ReferenceDataApiTest.php | 6 +- test/Model/SymbolQueryTest.php | 2 +- 6 files changed, 80 insertions(+), 57 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 443b91d..f0999b4 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -5bf896f7-e811-420d-b057-575a53b1ff80 \ No newline at end of file +a3dd9305-648e-4e1a-a12f-43ccc2513335 \ No newline at end of file diff --git a/README.md b/README.md index 361c49f..c4b8d84 100644 --- a/README.md +++ b/README.md @@ -1260,9 +1260,7 @@ $result = $snaptrade->referenceData->getStockExchanges(); ### `snaptrade.referenceData.getSymbols` -Returns a list of Universal Symbol objects that match a defined string. - -Matches on ticker or name. +Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. @@ -1270,7 +1268,7 @@ Matches on ticker or name. ```php $result = $snaptrade->referenceData->getSymbols( - substring: "apple" + substring: "AAPL" ); ``` @@ -1278,6 +1276,8 @@ $result = $snaptrade->referenceData->getSymbols( ##### substring: `string` +The search query for symbols. + #### πŸ”„ Return @@ -1294,7 +1294,8 @@ $result = $snaptrade->referenceData->getSymbols( ### `snaptrade.referenceData.getSymbolsByTicker` -Returns the Universal Symbol object specified by the ticker or the universal_symbol_id. +Returns the Universal Symbol object specified by the ticker or the Universal Symbol ID. When a ticker is specified, the first matching result is returned. We largely follow the [Yahoo Finance ticker format](https://help.yahoo.com/kb/SLN2310.html)(click on "Yahoo Finance Market Coverage and Data Delays"). For example, for securities traded on the Toronto Stock Exchange, the symbol has a '.TO' suffix. For securities traded on NASDAQ or NYSE, the symbol does not have a suffix. Please use the ticker with the proper suffix for the best results. + #### πŸ› οΈ Usage @@ -1309,7 +1310,7 @@ $result = $snaptrade->referenceData->getSymbolsByTicker( ##### query: `string` -The ticker or universal_symbol_id of the UniversalSymbol to get. +The ticker or Universal Symbol ID to look up the symbol with. #### πŸ”„ Return @@ -1435,9 +1436,9 @@ $result = $snaptrade->referenceData->listAllCurrenciesRates(); ### `snaptrade.referenceData.symbolSearchUserAccount` -Returns a list of universal symbols that are supported by -the specificied account. Returned symbols are based on the -provided search string, matching on ticker and name. +Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. + +The search results are further limited to the symbols supported by the brokerage for which the account is under. @@ -1448,7 +1449,7 @@ $result = $snaptrade->referenceData->symbolSearchUserAccount( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - substring: "apple" + substring: "AAPL" ); ``` @@ -1460,10 +1461,10 @@ $result = $snaptrade->referenceData->symbolSearchUserAccount( ##### account_id: `string` -The ID of the account to search for symbols within. - ##### substring: `string` +The search query for symbols. + #### πŸ”„ Return diff --git a/lib/Api/ReferenceDataApi.php b/lib/Api/ReferenceDataApi.php index 5b1df6b..db7f919 100644 --- a/lib/Api/ReferenceDataApi.php +++ b/lib/Api/ReferenceDataApi.php @@ -1541,9 +1541,9 @@ public function getStockExchangesRequest(string $contentType = self::contentType /** * Operation getSymbols * - * Search for symbols + * Search symbols * - * Returns a list of Universal Symbol objects that match a defined string. Matches on ticker or name. + * Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. * * @param \SnapTrade\Model\SymbolQuery $symbol_query symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbols'] to see the possible values for this operation @@ -1569,9 +1569,9 @@ public function getSymbols( /** * Operation getSymbolsWithHttpInfo * - * Search for symbols + * Search symbols * - * Returns a list of Universal Symbol objects that match a defined string. Matches on ticker or name. + * Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. * * @param \SnapTrade\Model\SymbolQuery $symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbols'] to see the possible values for this operation @@ -1686,9 +1686,9 @@ public function getSymbolsWithHttpInfo($symbol_query = null, string $contentType /** * Operation getSymbolsAsync * - * Search for symbols + * Search symbols * - * Returns a list of Universal Symbol objects that match a defined string. Matches on ticker or name. + * Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. * * @param \SnapTrade\Model\SymbolQuery $symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbols'] to see the possible values for this operation @@ -1717,9 +1717,9 @@ function ($response) { /** * Operation getSymbolsAsyncWithHttpInfo * - * Search for symbols + * Search symbols * - * Returns a list of Universal Symbol objects that match a defined string. Matches on ticker or name. + * Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. * * @param \SnapTrade\Model\SymbolQuery $symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbols'] to see the possible values for this operation @@ -1888,16 +1888,16 @@ public function getSymbolsRequest($symbol_query = SENTINEL_VALUE, string $conten /** * Operation getSymbolsByTicker * - * Get details of a symbol + * Get symbol detail * - * Returns the Universal Symbol object specified by the ticker or the universal_symbol_id. + * Returns the Universal Symbol object specified by the ticker or the Universal Symbol ID. When a ticker is specified, the first matching result is returned. We largely follow the [Yahoo Finance ticker format](https://help.yahoo.com/kb/SLN2310.html)(click on \"Yahoo Finance Market Coverage and Data Delays\"). For example, for securities traded on the Toronto Stock Exchange, the symbol has a '.TO' suffix. For securities traded on NASDAQ or NYSE, the symbol does not have a suffix. Please use the ticker with the proper suffix for the best results. * - * @param string $query The ticker or universal_symbol_id of the UniversalSymbol to get. (required) + * @param string $query The ticker or Universal Symbol ID to look up the symbol with. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbolsByTicker'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\UniversalSymbol + * @return \SnapTrade\Model\UniversalSymbol|\SnapTrade\Model\Model404FailedRequestResponse */ public function getSymbolsByTicker( $query, @@ -1913,16 +1913,16 @@ public function getSymbolsByTicker( /** * Operation getSymbolsByTickerWithHttpInfo * - * Get details of a symbol + * Get symbol detail * - * Returns the Universal Symbol object specified by the ticker or the universal_symbol_id. + * Returns the Universal Symbol object specified by the ticker or the Universal Symbol ID. When a ticker is specified, the first matching result is returned. We largely follow the [Yahoo Finance ticker format](https://help.yahoo.com/kb/SLN2310.html)(click on \"Yahoo Finance Market Coverage and Data Delays\"). For example, for securities traded on the Toronto Stock Exchange, the symbol has a '.TO' suffix. For securities traded on NASDAQ or NYSE, the symbol does not have a suffix. Please use the ticker with the proper suffix for the best results. * - * @param string $query The ticker or universal_symbol_id of the UniversalSymbol to get. (required) + * @param string $query The ticker or Universal Symbol ID to look up the symbol with. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbolsByTicker'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\UniversalSymbol, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\UniversalSymbol|\SnapTrade\Model\Model404FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ public function getSymbolsByTickerWithHttpInfo($query, string $contentType = self::contentTypes['getSymbolsByTicker'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { @@ -1994,6 +1994,21 @@ public function getSymbolsByTickerWithHttpInfo($query, string $contentType = sel $response->getStatusCode(), $response->getHeaders() ]; + case 404: + if ('\SnapTrade\Model\Model404FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model404FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model404FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } $returnType = '\SnapTrade\Model\UniversalSymbol'; @@ -2022,6 +2037,14 @@ public function getSymbolsByTickerWithHttpInfo($query, string $contentType = sel ); $e->setResponseObject($data); break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model404FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } @@ -2030,11 +2053,11 @@ public function getSymbolsByTickerWithHttpInfo($query, string $contentType = sel /** * Operation getSymbolsByTickerAsync * - * Get details of a symbol + * Get symbol detail * - * Returns the Universal Symbol object specified by the ticker or the universal_symbol_id. + * Returns the Universal Symbol object specified by the ticker or the Universal Symbol ID. When a ticker is specified, the first matching result is returned. We largely follow the [Yahoo Finance ticker format](https://help.yahoo.com/kb/SLN2310.html)(click on \"Yahoo Finance Market Coverage and Data Delays\"). For example, for securities traded on the Toronto Stock Exchange, the symbol has a '.TO' suffix. For securities traded on NASDAQ or NYSE, the symbol does not have a suffix. Please use the ticker with the proper suffix for the best results. * - * @param string $query The ticker or universal_symbol_id of the UniversalSymbol to get. (required) + * @param string $query The ticker or Universal Symbol ID to look up the symbol with. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbolsByTicker'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -2058,11 +2081,11 @@ function ($response) { /** * Operation getSymbolsByTickerAsyncWithHttpInfo * - * Get details of a symbol + * Get symbol detail * - * Returns the Universal Symbol object specified by the ticker or the universal_symbol_id. + * Returns the Universal Symbol object specified by the ticker or the Universal Symbol ID. When a ticker is specified, the first matching result is returned. We largely follow the [Yahoo Finance ticker format](https://help.yahoo.com/kb/SLN2310.html)(click on \"Yahoo Finance Market Coverage and Data Delays\"). For example, for securities traded on the Toronto Stock Exchange, the symbol has a '.TO' suffix. For securities traded on NASDAQ or NYSE, the symbol does not have a suffix. Please use the ticker with the proper suffix for the best results. * - * @param string $query The ticker or universal_symbol_id of the UniversalSymbol to get. (required) + * @param string $query The ticker or Universal Symbol ID to look up the symbol with. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbolsByTicker'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -2115,7 +2138,7 @@ function ($exception) { /** * Create request for operation 'getSymbolsByTicker' * - * @param string $query The ticker or universal_symbol_id of the UniversalSymbol to get. (required) + * @param string $query The ticker or Universal Symbol ID to look up the symbol with. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSymbolsByTicker'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -2156,7 +2179,7 @@ public function getSymbolsByTickerRequest($query, string $contentType = self::co $headers = $this->headerSelector->selectHeaders( - ['*/*', ], + ['application/json', ], $contentType, $multipart ); @@ -3533,13 +3556,13 @@ public function listAllCurrenciesRatesRequest(string $contentType = self::conten /** * Operation symbolSearchUserAccount * - * Search for symbols available in an account + * Search account symbols * - * Returns a list of universal symbols that are supported by the specificied account. Returned symbols are based on the provided search string, matching on ticker and name. + * Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. The search results are further limited to the symbols supported by the brokerage for which the account is under. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id The ID of the account to search for symbols within. (required) + * @param string $account_id account_id (required) * @param \SnapTrade\Model\SymbolQuery $symbol_query symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['symbolSearchUserAccount'] to see the possible values for this operation * @@ -3567,13 +3590,13 @@ public function symbolSearchUserAccount( /** * Operation symbolSearchUserAccountWithHttpInfo * - * Search for symbols available in an account + * Search account symbols * - * Returns a list of universal symbols that are supported by the specificied account. Returned symbols are based on the provided search string, matching on ticker and name. + * Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. The search results are further limited to the symbols supported by the brokerage for which the account is under. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to search for symbols within. (required) + * @param string $account_id (required) * @param \SnapTrade\Model\SymbolQuery $symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['symbolSearchUserAccount'] to see the possible values for this operation * @@ -3690,13 +3713,13 @@ public function symbolSearchUserAccountWithHttpInfo($user_id, $user_secret, $acc /** * Operation symbolSearchUserAccountAsync * - * Search for symbols available in an account + * Search account symbols * - * Returns a list of universal symbols that are supported by the specificied account. Returned symbols are based on the provided search string, matching on ticker and name. + * Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. The search results are further limited to the symbols supported by the brokerage for which the account is under. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to search for symbols within. (required) + * @param string $account_id (required) * @param \SnapTrade\Model\SymbolQuery $symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['symbolSearchUserAccount'] to see the possible values for this operation * @@ -3727,13 +3750,13 @@ function ($response) { /** * Operation symbolSearchUserAccountAsyncWithHttpInfo * - * Search for symbols available in an account + * Search account symbols * - * Returns a list of universal symbols that are supported by the specificied account. Returned symbols are based on the provided search string, matching on ticker and name. + * Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. The search results are further limited to the symbols supported by the brokerage for which the account is under. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to search for symbols within. (required) + * @param string $account_id (required) * @param \SnapTrade\Model\SymbolQuery $symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['symbolSearchUserAccount'] to see the possible values for this operation * @@ -3789,7 +3812,7 @@ function ($exception) { * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to search for symbols within. (required) + * @param string $account_id (required) * @param \SnapTrade\Model\SymbolQuery $symbol_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['symbolSearchUserAccount'] to see the possible values for this operation * @@ -3881,7 +3904,7 @@ public function symbolSearchUserAccountRequest($user_id, $user_secret, $account_ $headers = $this->headerSelector->selectHeaders( - ['*/*', ], + ['application/json', ], $contentType, $multipart ); diff --git a/lib/Model/SymbolQuery.php b/lib/Model/SymbolQuery.php index 40aee0c..e944e7a 100644 --- a/lib/Model/SymbolQuery.php +++ b/lib/Model/SymbolQuery.php @@ -30,7 +30,6 @@ * SymbolQuery Class Doc Comment * * @category Class - * @description Symbol query for searching for symbols * @package SnapTrade * @implements \ArrayAccess */ @@ -296,7 +295,7 @@ public function getSubstring() /** * Sets substring * - * @param string|null $substring substring + * @param string|null $substring The search query for symbols. * * @return self */ diff --git a/test/Api/ReferenceDataApiTest.php b/test/Api/ReferenceDataApiTest.php index 45f477c..e980878 100644 --- a/test/Api/ReferenceDataApiTest.php +++ b/test/Api/ReferenceDataApiTest.php @@ -109,7 +109,7 @@ public function testGetStockExchanges() /** * Test case for getSymbols * - * Search for symbols. + * Search symbols. * */ public function testGetSymbols() @@ -121,7 +121,7 @@ public function testGetSymbols() /** * Test case for getSymbolsByTicker * - * Get details of a symbol. + * Get symbol detail. * */ public function testGetSymbolsByTicker() @@ -181,7 +181,7 @@ public function testListAllCurrenciesRates() /** * Test case for symbolSearchUserAccount * - * Search for symbols available in an account. + * Search account symbols. * */ public function testSymbolSearchUserAccount() diff --git a/test/Model/SymbolQueryTest.php b/test/Model/SymbolQueryTest.php index 60fa376..7bf8a53 100644 --- a/test/Model/SymbolQueryTest.php +++ b/test/Model/SymbolQueryTest.php @@ -29,7 +29,7 @@ * SymbolQueryTest Class Doc Comment * * @category Class - * @description Symbol query for searching for symbols + * @description SymbolQuery * @package SnapTrade */ class SymbolQueryTest extends TestCase From b31055c81dcf08d9ec70ec1379837f49382a2def Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:29:06 +0000 Subject: [PATCH 010/252] Version Bump SDKs (#22) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f0999b4..efe5f3b 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -a3dd9305-648e-4e1a-a12f-43ccc2513335 \ No newline at end of file +bcf01185-de7e-42fd-84d6-100100588c5f \ No newline at end of file diff --git a/README.md b/README.md index c4b8d84..aeda0a8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.40-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.41-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.40" + "konfig/snaptrade-php-sdk": "2.0.41" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 2d8bddc..09b7afa 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.40/PHP'; + protected $userAgent = 'Konfig/2.0.41/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.40' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.41' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 087bfdf40c8e7b13c9198c9121c98d5172be3e2d Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 22:20:42 +0000 Subject: [PATCH 011/252] Regenerate SDKs (#23) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 +- lib/Api/ReferenceDataApi.php | 32 ++-- lib/Model/PartnerData.php | 242 +++++++++++++++--------------- test/Api/ReferenceDataApiTest.php | 4 +- test/Model/PartnerDataTest.php | 46 +++--- 6 files changed, 166 insertions(+), 164 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index efe5f3b..7125c72 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -bcf01185-de7e-42fd-84d6-100100588c5f \ No newline at end of file +2d3240c1-1c79-4375-9749-3bb548d47ade \ No newline at end of file diff --git a/README.md b/README.md index aeda0a8..7e7a39c 100644 --- a/README.md +++ b/README.md @@ -1185,7 +1185,7 @@ A currency pair based on currency code for example, {CAD-USD} ### `snaptrade.referenceData.getPartnerInfo` -Returns useful data related to the specified ClientID, including allowed brokerages and data access. +Returns configurations for your SnapTrade Client ID, including allowed brokerages and data access. #### πŸ› οΈ Usage @@ -1210,7 +1210,7 @@ $result = $snaptrade->referenceData->getPartnerInfo(); ### `snaptrade.referenceData.getSecurityTypes` -List security types available on SnapTrade. +Return all available security types supported by SnapTrade. #### πŸ› οΈ Usage diff --git a/lib/Api/ReferenceDataApi.php b/lib/Api/ReferenceDataApi.php index db7f919..e5a1a8f 100644 --- a/lib/Api/ReferenceDataApi.php +++ b/lib/Api/ReferenceDataApi.php @@ -512,9 +512,9 @@ public function getCurrencyExchangeRatePairRequest($currency_pair, string $conte /** * Operation getPartnerInfo * - * Get metadata related to Snaptrade partner + * Get Client Info * - * Returns useful data related to the specified ClientID, including allowed brokerages and data access. + * Returns configurations for your SnapTrade Client ID, including allowed brokerages and data access. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPartnerInfo'] to see the possible values for this operation * @@ -536,9 +536,9 @@ public function getPartnerInfo( /** * Operation getPartnerInfoWithHttpInfo * - * Get metadata related to Snaptrade partner + * Get Client Info * - * Returns useful data related to the specified ClientID, including allowed brokerages and data access. + * Returns configurations for your SnapTrade Client ID, including allowed brokerages and data access. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPartnerInfo'] to see the possible values for this operation * @@ -720,9 +720,9 @@ public function getPartnerInfoWithHttpInfo(string $contentType = self::contentTy /** * Operation getPartnerInfoAsync * - * Get metadata related to Snaptrade partner + * Get Client Info * - * Returns useful data related to the specified ClientID, including allowed brokerages and data access. + * Returns configurations for your SnapTrade Client ID, including allowed brokerages and data access. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPartnerInfo'] to see the possible values for this operation * @@ -747,9 +747,9 @@ function ($response) { /** * Operation getPartnerInfoAsyncWithHttpInfo * - * Get metadata related to Snaptrade partner + * Get Client Info * - * Returns useful data related to the specified ClientID, including allowed brokerages and data access. + * Returns configurations for your SnapTrade Client ID, including allowed brokerages and data access. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPartnerInfo'] to see the possible values for this operation * @@ -901,9 +901,9 @@ public function getPartnerInfoRequest(string $contentType = self::contentTypes[' /** * Operation getSecurityTypes * - * List of all security types + * List security types * - * List security types available on SnapTrade. + * Return all available security types supported by SnapTrade. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSecurityTypes'] to see the possible values for this operation * @@ -925,9 +925,9 @@ public function getSecurityTypes( /** * Operation getSecurityTypesWithHttpInfo * - * List of all security types + * List security types * - * List security types available on SnapTrade. + * Return all available security types supported by SnapTrade. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSecurityTypes'] to see the possible values for this operation * @@ -1040,9 +1040,9 @@ public function getSecurityTypesWithHttpInfo(string $contentType = self::content /** * Operation getSecurityTypesAsync * - * List of all security types + * List security types * - * List security types available on SnapTrade. + * Return all available security types supported by SnapTrade. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSecurityTypes'] to see the possible values for this operation * @@ -1067,9 +1067,9 @@ function ($response) { /** * Operation getSecurityTypesAsyncWithHttpInfo * - * List of all security types + * List security types * - * List security types available on SnapTrade. + * Return all available security types supported by SnapTrade. * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSecurityTypes'] to see the possible values for this operation * diff --git a/lib/Model/PartnerData.php b/lib/Model/PartnerData.php index 15e20a6..5e18096 100644 --- a/lib/Model/PartnerData.php +++ b/lib/Model/PartnerData.php @@ -30,7 +30,7 @@ * PartnerData Class Doc Comment * * @category Class - * @description SnapTrade Partner metadata + * @description Configurations for your SnapTrade Client ID, including allowed brokerages and data access. * @package SnapTrade * @implements \ArrayAccess */ @@ -51,18 +51,18 @@ class PartnerData implements ModelInterface, ArrayAccess, \JsonSerializable * @var string[] */ protected static $openAPITypes = [ - 'redirect_uri' => 'string', - 'allowed_brokerages' => '\SnapTrade\Model\Brokerage[]', - 'name' => 'string', 'slug' => 'string', + 'name' => 'string', 'logo_url' => 'string', - 'pin_required' => 'bool', + 'allowed_brokerages' => '\SnapTrade\Model\Brokerage[]', 'can_access_trades' => 'bool', 'can_access_holdings' => 'bool', 'can_access_account_history' => 'bool', 'can_access_reference_data' => 'bool', 'can_access_portfolio_management' => 'bool', - 'can_access_orders' => 'bool' + 'can_access_orders' => 'bool', + 'redirect_uri' => 'string', + 'pin_required' => 'bool' ]; /** @@ -73,18 +73,18 @@ class PartnerData implements ModelInterface, ArrayAccess, \JsonSerializable * @psalm-var array */ protected static $openAPIFormats = [ - 'redirect_uri' => null, - 'allowed_brokerages' => null, - 'name' => null, 'slug' => null, + 'name' => null, 'logo_url' => null, - 'pin_required' => null, + 'allowed_brokerages' => null, 'can_access_trades' => null, 'can_access_holdings' => null, 'can_access_account_history' => null, 'can_access_reference_data' => null, 'can_access_portfolio_management' => null, - 'can_access_orders' => null + 'can_access_orders' => null, + 'redirect_uri' => null, + 'pin_required' => null ]; /** @@ -93,18 +93,18 @@ class PartnerData implements ModelInterface, ArrayAccess, \JsonSerializable * @var boolean[] */ protected static array $openAPINullables = [ - 'redirect_uri' => false, - 'allowed_brokerages' => false, + 'slug' => false, 'name' => false, - 'slug' => false, 'logo_url' => false, - 'pin_required' => false, + 'allowed_brokerages' => false, 'can_access_trades' => false, 'can_access_holdings' => false, 'can_access_account_history' => false, 'can_access_reference_data' => false, 'can_access_portfolio_management' => false, - 'can_access_orders' => false + 'can_access_orders' => false, + 'redirect_uri' => false, + 'pin_required' => false ]; /** @@ -193,18 +193,18 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'redirect_uri' => 'redirect_uri', - 'allowed_brokerages' => 'allowed_brokerages', - 'name' => 'name', 'slug' => 'slug', + 'name' => 'name', 'logo_url' => 'logo_url', - 'pin_required' => 'pin_required', + 'allowed_brokerages' => 'allowed_brokerages', 'can_access_trades' => 'can_access_trades', 'can_access_holdings' => 'can_access_holdings', 'can_access_account_history' => 'can_access_account_history', 'can_access_reference_data' => 'can_access_reference_data', 'can_access_portfolio_management' => 'can_access_portfolio_management', - 'can_access_orders' => 'can_access_orders' + 'can_access_orders' => 'can_access_orders', + 'redirect_uri' => 'redirect_uri', + 'pin_required' => 'pin_required' ]; /** @@ -213,18 +213,18 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'redirect_uri' => 'setRedirectUri', - 'allowed_brokerages' => 'setAllowedBrokerages', - 'name' => 'setName', 'slug' => 'setSlug', + 'name' => 'setName', 'logo_url' => 'setLogoUrl', - 'pin_required' => 'setPinRequired', + 'allowed_brokerages' => 'setAllowedBrokerages', 'can_access_trades' => 'setCanAccessTrades', 'can_access_holdings' => 'setCanAccessHoldings', 'can_access_account_history' => 'setCanAccessAccountHistory', 'can_access_reference_data' => 'setCanAccessReferenceData', 'can_access_portfolio_management' => 'setCanAccessPortfolioManagement', - 'can_access_orders' => 'setCanAccessOrders' + 'can_access_orders' => 'setCanAccessOrders', + 'redirect_uri' => 'setRedirectUri', + 'pin_required' => 'setPinRequired' ]; /** @@ -233,18 +233,18 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'redirect_uri' => 'getRedirectUri', - 'allowed_brokerages' => 'getAllowedBrokerages', - 'name' => 'getName', 'slug' => 'getSlug', + 'name' => 'getName', 'logo_url' => 'getLogoUrl', - 'pin_required' => 'getPinRequired', + 'allowed_brokerages' => 'getAllowedBrokerages', 'can_access_trades' => 'getCanAccessTrades', 'can_access_holdings' => 'getCanAccessHoldings', 'can_access_account_history' => 'getCanAccessAccountHistory', 'can_access_reference_data' => 'getCanAccessReferenceData', 'can_access_portfolio_management' => 'getCanAccessPortfolioManagement', - 'can_access_orders' => 'getCanAccessOrders' + 'can_access_orders' => 'getCanAccessOrders', + 'redirect_uri' => 'getRedirectUri', + 'pin_required' => 'getPinRequired' ]; /** @@ -304,18 +304,18 @@ public function getModelName() */ public function __construct(array $data = null) { - $this->setIfExists('redirect_uri', $data ?? [], null); - $this->setIfExists('allowed_brokerages', $data ?? [], null); - $this->setIfExists('name', $data ?? [], null); $this->setIfExists('slug', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); $this->setIfExists('logo_url', $data ?? [], null); - $this->setIfExists('pin_required', $data ?? [], null); + $this->setIfExists('allowed_brokerages', $data ?? [], null); $this->setIfExists('can_access_trades', $data ?? [], null); $this->setIfExists('can_access_holdings', $data ?? [], null); $this->setIfExists('can_access_account_history', $data ?? [], null); $this->setIfExists('can_access_reference_data', $data ?? [], null); $this->setIfExists('can_access_portfolio_management', $data ?? [], null); $this->setIfExists('can_access_orders', $data ?? [], null); + $this->setIfExists('redirect_uri', $data ?? [], null); + $this->setIfExists('pin_required', $data ?? [], null); } /** @@ -361,59 +361,30 @@ public function valid() /** - * Gets redirect_uri + * Gets slug * * @return string|null */ - public function getRedirectUri() - { - return $this->container['redirect_uri']; - } - - /** - * Sets redirect_uri - * - * @param string|null $redirect_uri URI to redirect user back to after user is done adding brokerage connections - * - * @return self - */ - public function setRedirectUri($redirect_uri) - { - - if (is_null($redirect_uri)) { - throw new \InvalidArgumentException('non-nullable redirect_uri cannot be null'); - } - - $this->container['redirect_uri'] = $redirect_uri; - - return $this; - } - - /** - * Gets allowed_brokerages - * - * @return \SnapTrade\Model\Brokerage[]|null - */ - public function getAllowedBrokerages() + public function getSlug() { - return $this->container['allowed_brokerages']; + return $this->container['slug']; } /** - * Sets allowed_brokerages + * Sets slug * - * @param \SnapTrade\Model\Brokerage[]|null $allowed_brokerages Brokerages that can be accessed by partners + * @param string|null $slug A short, unique identifier for your company or product. * * @return self */ - public function setAllowedBrokerages($allowed_brokerages) + public function setSlug($slug) { - if (is_null($allowed_brokerages)) { - throw new \InvalidArgumentException('non-nullable allowed_brokerages cannot be null'); + if (is_null($slug)) { + throw new \InvalidArgumentException('non-nullable slug cannot be null'); } - $this->container['allowed_brokerages'] = $allowed_brokerages; + $this->container['slug'] = $slug; return $this; } @@ -431,7 +402,7 @@ public function getName() /** * Sets name * - * @param string|null $name Name of Snaptrade Partner + * @param string|null $name Your company or product name. * * @return self */ @@ -447,35 +418,6 @@ public function setName($name) return $this; } - /** - * Gets slug - * - * @return string|null - */ - public function getSlug() - { - return $this->container['slug']; - } - - /** - * Sets slug - * - * @param string|null $slug Slug of Snaptrade Partner - * - * @return self - */ - public function setSlug($slug) - { - - if (is_null($slug)) { - throw new \InvalidArgumentException('non-nullable slug cannot be null'); - } - - $this->container['slug'] = $slug; - - return $this; - } - /** * Gets logo_url * @@ -489,7 +431,7 @@ public function getLogoUrl() /** * Sets logo_url * - * @param string|null $logo_url URL to partner's logo + * @param string|null $logo_url URL to your company or product logo. * * @return self */ @@ -506,30 +448,30 @@ public function setLogoUrl($logo_url) } /** - * Gets pin_required + * Gets allowed_brokerages * - * @return bool|null + * @return \SnapTrade\Model\Brokerage[]|null */ - public function getPinRequired() + public function getAllowedBrokerages() { - return $this->container['pin_required']; + return $this->container['allowed_brokerages']; } /** - * Sets pin_required + * Sets allowed_brokerages * - * @param bool|null $pin_required Shows if pin is required by users to access connection page + * @param \SnapTrade\Model\Brokerage[]|null $allowed_brokerages Brokerages that can be accessed by your Client ID. * * @return self */ - public function setPinRequired($pin_required) + public function setAllowedBrokerages($allowed_brokerages) { - if (is_null($pin_required)) { - throw new \InvalidArgumentException('non-nullable pin_required cannot be null'); + if (is_null($allowed_brokerages)) { + throw new \InvalidArgumentException('non-nullable allowed_brokerages cannot be null'); } - $this->container['pin_required'] = $pin_required; + $this->container['allowed_brokerages'] = $allowed_brokerages; return $this; } @@ -547,7 +489,7 @@ public function getCanAccessTrades() /** * Sets can_access_trades * - * @param bool|null $can_access_trades Shows if users of Snaptrade partners can access trade endpoints + * @param bool|null $can_access_trades Whether trading is enabled for your SnapTrade Client ID. * * @return self */ @@ -576,7 +518,7 @@ public function getCanAccessHoldings() /** * Sets can_access_holdings * - * @param bool|null $can_access_holdings Shows if Snaptrade partners can get user holdings data + * @param bool|null $can_access_holdings Whether holdings data is enabled for your SnapTrade Client ID. * * @return self */ @@ -605,7 +547,7 @@ public function getCanAccessAccountHistory() /** * Sets can_access_account_history * - * @param bool|null $can_access_account_history Shows if Snaptrade partners can get users account history data + * @param bool|null $can_access_account_history Whether account historical transactions is enabled for your SnapTrade Client ID. * * @return self */ @@ -634,7 +576,7 @@ public function getCanAccessReferenceData() /** * Sets can_access_reference_data * - * @param bool|null $can_access_reference_data Shows if Snaptrade partners can get users holdings data + * @param bool|null $can_access_reference_data Whether reference data is enabled for your SnapTrade Client ID. * * @return self */ @@ -663,7 +605,7 @@ public function getCanAccessPortfolioManagement() /** * Sets can_access_portfolio_management * - * @param bool|null $can_access_portfolio_management Shows if users Snaptrade partners can access portfolio group management features + * @param bool|null $can_access_portfolio_management Whether portfolio management is enabled for your SnapTrade Client ID. * * @return self */ @@ -692,7 +634,7 @@ public function getCanAccessOrders() /** * Sets can_access_orders * - * @param bool|null $can_access_orders Shows if Snaptrade partners can get users account order history + * @param bool|null $can_access_orders Whether recent order history is enabled for your SnapTrade Client ID. * * @return self */ @@ -707,6 +649,66 @@ public function setCanAccessOrders($can_access_orders) return $this; } + + /** + * Gets redirect_uri + * + * @return string|null + */ + public function getRedirectUri() + { + return $this->container['redirect_uri']; + } + + /** + * Sets redirect_uri + * + * @param string|null $redirect_uri URI to redirect user back to after user is done adding brokerage connections. + * + * @return self + */ + public function setRedirectUri($redirect_uri) + { + + if (is_null($redirect_uri)) { + throw new \InvalidArgumentException('non-nullable redirect_uri cannot be null'); + } + + $this->container['redirect_uri'] = $redirect_uri; + + return $this; + } + + /** + * Gets pin_required + * + * @return bool|null + * @deprecated + */ + public function getPinRequired() + { + return $this->container['pin_required']; + } + + /** + * Sets pin_required + * + * @param bool|null $pin_required Shows if pin is required by users to access connection page. This field has been deprecated. + * + * @return self + * @deprecated + */ + public function setPinRequired($pin_required) + { + + if (is_null($pin_required)) { + throw new \InvalidArgumentException('non-nullable pin_required cannot be null'); + } + + $this->container['pin_required'] = $pin_required; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/test/Api/ReferenceDataApiTest.php b/test/Api/ReferenceDataApiTest.php index e980878..0671507 100644 --- a/test/Api/ReferenceDataApiTest.php +++ b/test/Api/ReferenceDataApiTest.php @@ -73,7 +73,7 @@ public function testGetCurrencyExchangeRatePair() /** * Test case for getPartnerInfo * - * Get metadata related to Snaptrade partner. + * Get Client Info. * */ public function testGetPartnerInfo() @@ -85,7 +85,7 @@ public function testGetPartnerInfo() /** * Test case for getSecurityTypes * - * List of all security types. + * List security types. * */ public function testGetSecurityTypes() diff --git a/test/Model/PartnerDataTest.php b/test/Model/PartnerDataTest.php index a09c6c1..697850b 100644 --- a/test/Model/PartnerDataTest.php +++ b/test/Model/PartnerDataTest.php @@ -29,7 +29,7 @@ * PartnerDataTest Class Doc Comment * * @category Class - * @description SnapTrade Partner metadata + * @description Configurations for your SnapTrade Client ID, including allowed brokerages and data access. * @package SnapTrade */ class PartnerDataTest extends TestCase @@ -73,18 +73,9 @@ public function testPartnerData() } /** - * Test attribute "redirect_uri" - */ - public function testPropertyRedirectUri() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "allowed_brokerages" + * Test attribute "slug" */ - public function testPropertyAllowedBrokerages() + public function testPropertySlug() { // TODO: implement $this->markTestIncomplete('Not implemented'); @@ -99,15 +90,6 @@ public function testPropertyName() $this->markTestIncomplete('Not implemented'); } - /** - * Test attribute "slug" - */ - public function testPropertySlug() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test attribute "logo_url" */ @@ -118,9 +100,9 @@ public function testPropertyLogoUrl() } /** - * Test attribute "pin_required" + * Test attribute "allowed_brokerages" */ - public function testPropertyPinRequired() + public function testPropertyAllowedBrokerages() { // TODO: implement $this->markTestIncomplete('Not implemented'); @@ -179,4 +161,22 @@ public function testPropertyCanAccessOrders() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "redirect_uri" + */ + public function testPropertyRedirectUri() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "pin_required" + */ + public function testPropertyPinRequired() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } From 3466fa8212096632e969f8a6ec210c98adc12301 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 22:24:04 +0000 Subject: [PATCH 012/252] Version Bump SDKs (#24) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 7125c72..db55716 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2d3240c1-1c79-4375-9749-3bb548d47ade \ No newline at end of file +31ad0d85-37dc-4445-94b2-9bc5ccd7d927 \ No newline at end of file diff --git a/README.md b/README.md index 7e7a39c..d88c367 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.41-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.42-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.41" + "konfig/snaptrade-php-sdk": "2.0.42" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 09b7afa..30f4535 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.41/PHP'; + protected $userAgent = 'Konfig/2.0.42/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.41' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.42' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 25e707b3a235ec61f5d9919c96af43a3f23b8b62 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 20:00:17 +0000 Subject: [PATCH 013/252] Regenerate SDKs (#25) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/TransactionsAndReportingApi.php | 10 +++++----- lib/Model/UniversalActivity.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index db55716..05f0b4f 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -31ad0d85-37dc-4445-94b2-9bc5ccd7d927 \ No newline at end of file +3020bea9-cb03-4f07-a1e8-45493f888351 \ No newline at end of file diff --git a/README.md b/README.md index d88c367..a23c8ac 100644 --- a/README.md +++ b/README.md @@ -1807,7 +1807,7 @@ Optional comma separated list of SnapTrade Connection (Brokerage Authorization) ##### type: `string` -Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE +Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. #### πŸ”„ Return diff --git a/lib/Api/TransactionsAndReportingApi.php b/lib/Api/TransactionsAndReportingApi.php index 4b1e00c..1a214ac 100644 --- a/lib/Api/TransactionsAndReportingApi.php +++ b/lib/Api/TransactionsAndReportingApi.php @@ -151,7 +151,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -188,7 +188,7 @@ public function getActivities( * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -317,7 +317,7 @@ public function getActivitiesWithHttpInfo($user_id, $user_secret, $start_date = * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -357,7 +357,7 @@ function ($response) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -416,7 +416,7 @@ function ($exception) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/lib/Model/UniversalActivity.php b/lib/Model/UniversalActivity.php index 1092047..e19b4ae 100644 --- a/lib/Model/UniversalActivity.php +++ b/lib/Model/UniversalActivity.php @@ -661,7 +661,7 @@ public function getType() /** * Sets type * - * @param string|null $type A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE + * @param string|null $type A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. * * @return self */ From d6baf4b02e9c4977b1c3f77aeb5fa615b85f68e3 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 20:03:50 +0000 Subject: [PATCH 014/252] Version Bump SDKs (#26) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 05f0b4f..f4f8f13 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -3020bea9-cb03-4f07-a1e8-45493f888351 \ No newline at end of file +6f0bb338-c317-4bd7-bd37-4b46f6d6be1c \ No newline at end of file diff --git a/README.md b/README.md index a23c8ac..01fc065 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.42-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.43-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.42" + "konfig/snaptrade-php-sdk": "2.0.43" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 30f4535..b080bfc 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.42/PHP'; + protected $userAgent = 'Konfig/2.0.43/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.42' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.43' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From b4ac78c1963ea5e67b48ce33746e9bdcd8a408de Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:36:25 +0000 Subject: [PATCH 015/252] Regenerate SDKs (#27) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f4f8f13..9bbb0e0 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -6f0bb338-c317-4bd7-bd37-4b46f6d6be1c \ No newline at end of file +ea5a44de-6e93-4191-94a2-ea5c224e3ae6 \ No newline at end of file From e697c7dcc9f713de944b961c5b1923c5c549753f Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:39:58 +0000 Subject: [PATCH 016/252] Version Bump SDKs (#28) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 9bbb0e0..d804695 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ea5a44de-6e93-4191-94a2-ea5c224e3ae6 \ No newline at end of file +36049dd8-8f8b-4d25-aec0-25a6ff63c997 \ No newline at end of file diff --git a/README.md b/README.md index 01fc065..2530f65 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.43-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.44-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.43" + "konfig/snaptrade-php-sdk": "2.0.44" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index b080bfc..56dc35e 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.43/PHP'; + protected $userAgent = 'Konfig/2.0.44/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.43' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.44' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 6878efc8f348356af78574ed669d57fa421a9d16 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 04:06:08 +0000 Subject: [PATCH 017/252] Regenerate SDKs (#29) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- lib/Model/Account.php | 248 ++++++++++++++++++++----------------- test/Model/AccountTest.php | 34 ++--- 3 files changed, 154 insertions(+), 130 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index d804695..595276d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -36049dd8-8f8b-4d25-aec0-25a6ff63c997 \ No newline at end of file +bab76566-5d62-450d-b69e-75b186bfd06b \ No newline at end of file diff --git a/lib/Model/Account.php b/lib/Model/Account.php index 63f72fa..ebd5609 100644 --- a/lib/Model/Account.php +++ b/lib/Model/Account.php @@ -53,15 +53,15 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable protected static $openAPITypes = [ 'id' => 'string', 'brokerage_authorization' => 'string', - 'portfolio_group' => 'string', 'name' => 'string', 'number' => 'string', 'institution_name' => 'string', 'created_date' => '\DateTime', - 'meta' => 'array', - 'cash_restrictions' => 'string[]', 'sync_status' => '\SnapTrade\Model\AccountSyncStatus', - 'balance' => '\SnapTrade\Model\AccountBalance' + 'balance' => '\SnapTrade\Model\AccountBalance', + 'meta' => 'array', + 'portfolio_group' => 'string', + 'cash_restrictions' => 'string[]' ]; /** @@ -74,15 +74,15 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable protected static $openAPIFormats = [ 'id' => null, 'brokerage_authorization' => 'uuid', - 'portfolio_group' => 'uuid', 'name' => null, 'number' => null, 'institution_name' => null, 'created_date' => 'date-time', - 'meta' => null, - 'cash_restrictions' => null, 'sync_status' => null, - 'balance' => null + 'balance' => null, + 'meta' => null, + 'portfolio_group' => 'uuid', + 'cash_restrictions' => null ]; /** @@ -93,15 +93,15 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable protected static array $openAPINullables = [ 'id' => false, 'brokerage_authorization' => false, - 'portfolio_group' => false, 'name' => true, 'number' => false, 'institution_name' => false, 'created_date' => false, - 'meta' => false, - 'cash_restrictions' => false, 'sync_status' => false, - 'balance' => false + 'balance' => false, + 'meta' => false, + 'portfolio_group' => false, + 'cash_restrictions' => false ]; /** @@ -192,15 +192,15 @@ public function isNullableSetToNull(string $property): bool protected static $attributeMap = [ 'id' => 'id', 'brokerage_authorization' => 'brokerage_authorization', - 'portfolio_group' => 'portfolio_group', 'name' => 'name', 'number' => 'number', 'institution_name' => 'institution_name', 'created_date' => 'created_date', - 'meta' => 'meta', - 'cash_restrictions' => 'cash_restrictions', 'sync_status' => 'sync_status', - 'balance' => 'balance' + 'balance' => 'balance', + 'meta' => 'meta', + 'portfolio_group' => 'portfolio_group', + 'cash_restrictions' => 'cash_restrictions' ]; /** @@ -211,15 +211,15 @@ public function isNullableSetToNull(string $property): bool protected static $setters = [ 'id' => 'setId', 'brokerage_authorization' => 'setBrokerageAuthorization', - 'portfolio_group' => 'setPortfolioGroup', 'name' => 'setName', 'number' => 'setNumber', 'institution_name' => 'setInstitutionName', 'created_date' => 'setCreatedDate', - 'meta' => 'setMeta', - 'cash_restrictions' => 'setCashRestrictions', 'sync_status' => 'setSyncStatus', - 'balance' => 'setBalance' + 'balance' => 'setBalance', + 'meta' => 'setMeta', + 'portfolio_group' => 'setPortfolioGroup', + 'cash_restrictions' => 'setCashRestrictions' ]; /** @@ -230,15 +230,15 @@ public function isNullableSetToNull(string $property): bool protected static $getters = [ 'id' => 'getId', 'brokerage_authorization' => 'getBrokerageAuthorization', - 'portfolio_group' => 'getPortfolioGroup', 'name' => 'getName', 'number' => 'getNumber', 'institution_name' => 'getInstitutionName', 'created_date' => 'getCreatedDate', - 'meta' => 'getMeta', - 'cash_restrictions' => 'getCashRestrictions', 'sync_status' => 'getSyncStatus', - 'balance' => 'getBalance' + 'balance' => 'getBalance', + 'meta' => 'getMeta', + 'portfolio_group' => 'getPortfolioGroup', + 'cash_restrictions' => 'getCashRestrictions' ]; /** @@ -300,15 +300,15 @@ public function __construct(array $data = null) { $this->setIfExists('id', $data ?? [], null); $this->setIfExists('brokerage_authorization', $data ?? [], null); - $this->setIfExists('portfolio_group', $data ?? [], null); $this->setIfExists('name', $data ?? [], null); $this->setIfExists('number', $data ?? [], null); $this->setIfExists('institution_name', $data ?? [], null); $this->setIfExists('created_date', $data ?? [], null); - $this->setIfExists('meta', $data ?? [], null); - $this->setIfExists('cash_restrictions', $data ?? [], null); $this->setIfExists('sync_status', $data ?? [], null); $this->setIfExists('balance', $data ?? [], null); + $this->setIfExists('meta', $data ?? [], null); + $this->setIfExists('portfolio_group', $data ?? [], null); + $this->setIfExists('cash_restrictions', $data ?? [], null); } /** @@ -338,6 +338,30 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['brokerage_authorization'] === null) { + $invalidProperties[] = "'brokerage_authorization' can't be null"; + } + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['number'] === null) { + $invalidProperties[] = "'number' can't be null"; + } + if ($this->container['institution_name'] === null) { + $invalidProperties[] = "'institution_name' can't be null"; + } + if ($this->container['created_date'] === null) { + $invalidProperties[] = "'created_date' can't be null"; + } + if ($this->container['sync_status'] === null) { + $invalidProperties[] = "'sync_status' can't be null"; + } + if ($this->container['balance'] === null) { + $invalidProperties[] = "'balance' can't be null"; + } return $invalidProperties; } @@ -356,7 +380,7 @@ public function valid() /** * Gets id * - * @return string|null + * @return string */ public function getId() { @@ -366,7 +390,7 @@ public function getId() /** * Sets id * - * @param string|null $id Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. This ID should not change for as long as the connection stays active. If the connection is deleted and re-added, a new account ID will be generated. + * @param string $id Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. This ID should not change for as long as the connection stays active. If the connection is deleted and re-added, a new account ID will be generated. * * @return self */ @@ -385,7 +409,7 @@ public function setId($id) /** * Gets brokerage_authorization * - * @return string|null + * @return string */ public function getBrokerageAuthorization() { @@ -395,7 +419,7 @@ public function getBrokerageAuthorization() /** * Sets brokerage_authorization * - * @param string|null $brokerage_authorization Unique identifier for the connection. This is the UUID used to reference the connection in SnapTrade. + * @param string $brokerage_authorization Unique identifier for the connection. This is the UUID used to reference the connection in SnapTrade. * * @return self */ @@ -411,41 +435,10 @@ public function setBrokerageAuthorization($brokerage_authorization) return $this; } - /** - * Gets portfolio_group - * - * @return string|null - * @deprecated - */ - public function getPortfolioGroup() - { - return $this->container['portfolio_group']; - } - - /** - * Sets portfolio_group - * - * @param string|null $portfolio_group Portfolio Group ID. Portfolio Groups have been deprecated. Please contact support if you have a usecase for it. - * - * @return self - * @deprecated - */ - public function setPortfolioGroup($portfolio_group) - { - - if (is_null($portfolio_group)) { - throw new \InvalidArgumentException('non-nullable portfolio_group cannot be null'); - } - - $this->container['portfolio_group'] = $portfolio_group; - - return $this; - } - /** * Gets name * - * @return string|null + * @return string */ public function getName() { @@ -455,7 +448,7 @@ public function getName() /** * Sets name * - * @param string|null $name A display name for the account. Either assigned by the user or by the brokerage itself. For certain brokerages, SnapTrade appends the brokerage name to the account name for clarity. + * @param string $name A display name for the account. Either assigned by the user or by the brokerage itself. For certain brokerages, SnapTrade appends the brokerage name to the account name for clarity. * * @return self */ @@ -481,7 +474,7 @@ public function setName($name) /** * Gets number * - * @return string|null + * @return string */ public function getNumber() { @@ -491,7 +484,7 @@ public function getNumber() /** * Sets number * - * @param string|null $number The account number assigned by the brokerage. For some brokerages, this field may be masked for security reasons. + * @param string $number The account number assigned by the brokerage. For some brokerages, this field may be masked for security reasons. * * @return self */ @@ -510,7 +503,7 @@ public function setNumber($number) /** * Gets institution_name * - * @return string|null + * @return string */ public function getInstitutionName() { @@ -520,7 +513,7 @@ public function getInstitutionName() /** * Sets institution_name * - * @param string|null $institution_name The name of the brokerage that holds the account. + * @param string $institution_name The name of the brokerage that holds the account. * * @return self */ @@ -539,7 +532,7 @@ public function setInstitutionName($institution_name) /** * Gets created_date * - * @return \DateTime|null + * @return \DateTime */ public function getCreatedDate() { @@ -549,7 +542,7 @@ public function getCreatedDate() /** * Sets created_date * - * @param \DateTime|null $created_date Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the account was created in SnapTrade. This is _not_ the account opening date at the brokerage. + * @param \DateTime $created_date Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the account was created in SnapTrade. This is _not_ the account opening date at the brokerage. * * @return self */ @@ -566,121 +559,152 @@ public function setCreatedDate($created_date) } /** - * Gets meta + * Gets sync_status * - * @return array|null - * @deprecated + * @return \SnapTrade\Model\AccountSyncStatus */ - public function getMeta() + public function getSyncStatus() { - return $this->container['meta']; + return $this->container['sync_status']; } /** - * Sets meta + * Sets sync_status * - * @param array|null $meta Additional information about the account, such as account type, status, etc. This information is specific to the brokerage and there's no standard format for this data. This field is deprecated and subject to removal in a future version. + * @param \SnapTrade\Model\AccountSyncStatus $sync_status sync_status * * @return self - * @deprecated */ - public function setMeta($meta) + public function setSyncStatus($sync_status) { - if (is_null($meta)) { - throw new \InvalidArgumentException('non-nullable meta cannot be null'); + if (is_null($sync_status)) { + throw new \InvalidArgumentException('non-nullable sync_status cannot be null'); } - $this->container['meta'] = $meta; + $this->container['sync_status'] = $sync_status; return $this; } /** - * Gets cash_restrictions + * Gets balance * - * @return string[]|null + * @return \SnapTrade\Model\AccountBalance + */ + public function getBalance() + { + return $this->container['balance']; + } + + /** + * Sets balance + * + * @param \SnapTrade\Model\AccountBalance $balance balance + * + * @return self + */ + public function setBalance($balance) + { + + if (is_null($balance)) { + throw new \InvalidArgumentException('non-nullable balance cannot be null'); + } + + $this->container['balance'] = $balance; + + return $this; + } + + /** + * Gets meta + * + * @return array|null * @deprecated */ - public function getCashRestrictions() + public function getMeta() { - return $this->container['cash_restrictions']; + return $this->container['meta']; } /** - * Sets cash_restrictions + * Sets meta * - * @param string[]|null $cash_restrictions This field is deprecated. + * @param array|null $meta Additional information about the account, such as account type, status, etc. This information is specific to the brokerage and there's no standard format for this data. This field is deprecated and subject to removal in a future version. * * @return self * @deprecated */ - public function setCashRestrictions($cash_restrictions) + public function setMeta($meta) { - if (is_null($cash_restrictions)) { - throw new \InvalidArgumentException('non-nullable cash_restrictions cannot be null'); + if (is_null($meta)) { + throw new \InvalidArgumentException('non-nullable meta cannot be null'); } - $this->container['cash_restrictions'] = $cash_restrictions; + $this->container['meta'] = $meta; return $this; } /** - * Gets sync_status + * Gets portfolio_group * - * @return \SnapTrade\Model\AccountSyncStatus|null + * @return string|null + * @deprecated */ - public function getSyncStatus() + public function getPortfolioGroup() { - return $this->container['sync_status']; + return $this->container['portfolio_group']; } /** - * Sets sync_status + * Sets portfolio_group * - * @param \SnapTrade\Model\AccountSyncStatus|null $sync_status sync_status + * @param string|null $portfolio_group Portfolio Group ID. Portfolio Groups have been deprecated. Please contact support if you have a usecase for it. * * @return self + * @deprecated */ - public function setSyncStatus($sync_status) + public function setPortfolioGroup($portfolio_group) { - if (is_null($sync_status)) { - throw new \InvalidArgumentException('non-nullable sync_status cannot be null'); + if (is_null($portfolio_group)) { + throw new \InvalidArgumentException('non-nullable portfolio_group cannot be null'); } - $this->container['sync_status'] = $sync_status; + $this->container['portfolio_group'] = $portfolio_group; return $this; } /** - * Gets balance + * Gets cash_restrictions * - * @return \SnapTrade\Model\AccountBalance|null + * @return string[]|null + * @deprecated */ - public function getBalance() + public function getCashRestrictions() { - return $this->container['balance']; + return $this->container['cash_restrictions']; } /** - * Sets balance + * Sets cash_restrictions * - * @param \SnapTrade\Model\AccountBalance|null $balance balance + * @param string[]|null $cash_restrictions This field is deprecated. * * @return self + * @deprecated */ - public function setBalance($balance) + public function setCashRestrictions($cash_restrictions) { - if (is_null($balance)) { - throw new \InvalidArgumentException('non-nullable balance cannot be null'); + if (is_null($cash_restrictions)) { + throw new \InvalidArgumentException('non-nullable cash_restrictions cannot be null'); } - $this->container['balance'] = $balance; + $this->container['cash_restrictions'] = $cash_restrictions; return $this; } diff --git a/test/Model/AccountTest.php b/test/Model/AccountTest.php index 6e9c6f2..3e1937e 100644 --- a/test/Model/AccountTest.php +++ b/test/Model/AccountTest.php @@ -90,15 +90,6 @@ public function testPropertyBrokerageAuthorization() $this->markTestIncomplete('Not implemented'); } - /** - * Test attribute "portfolio_group" - */ - public function testPropertyPortfolioGroup() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test attribute "name" */ @@ -136,36 +127,45 @@ public function testPropertyCreatedDate() } /** - * Test attribute "meta" + * Test attribute "sync_status" */ - public function testPropertyMeta() + public function testPropertySyncStatus() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "cash_restrictions" + * Test attribute "balance" */ - public function testPropertyCashRestrictions() + public function testPropertyBalance() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "sync_status" + * Test attribute "meta" */ - public function testPropertySyncStatus() + public function testPropertyMeta() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "balance" + * Test attribute "portfolio_group" */ - public function testPropertyBalance() + public function testPropertyPortfolioGroup() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "cash_restrictions" + */ + public function testPropertyCashRestrictions() { // TODO: implement $this->markTestIncomplete('Not implemented'); From 2521bf46b3798b8ff6dd2af0a25cc76ab3fe049c Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 04:09:33 +0000 Subject: [PATCH 018/252] Version Bump SDKs (#30) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 595276d..80f5fb1 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -bab76566-5d62-450d-b69e-75b186bfd06b \ No newline at end of file +3ffcb949-cc9a-4373-a99c-20b04e6e6973 \ No newline at end of file diff --git a/README.md b/README.md index 2530f65..f0cb38e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.44-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.45-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.44" + "konfig/snaptrade-php-sdk": "2.0.45" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 56dc35e..2827437 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.44/PHP'; + protected $userAgent = 'Konfig/2.0.45/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.44' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.45' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 13e13f4fdb9a25cf2c9bd92d7e6373440f5579a7 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 19:21:21 +0000 Subject: [PATCH 019/252] Regenerate SDKs (#31) * Regenerate SDKs * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 17 +- lib/Api/TradingApi.php | 60 +- lib/Model/ActionStrict.php | 2 +- lib/Model/ActionStrictWithOptions.php | 68 ++ lib/Model/HoldingsStatus.php | 11 +- lib/Model/ManualTradeFormWithOptions.php | 783 ++++++++++++++++++ lib/Model/TransactionsStatus.php | 11 +- test/Model/ActionStrictTest.php | 2 +- test/Model/ActionStrictWithOptionsTest.php | 74 ++ test/Model/ManualTradeFormWithOptionsTest.php | 164 ++++ 11 files changed, 1154 insertions(+), 40 deletions(-) create mode 100644 lib/Model/ActionStrictWithOptions.php create mode 100644 lib/Model/ManualTradeFormWithOptions.php create mode 100644 test/Model/ActionStrictWithOptionsTest.php create mode 100644 test/Model/ManualTradeFormWithOptionsTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 80f5fb1..70ef3cb 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -3ffcb949-cc9a-4373-a99c-20b04e6e6973 \ No newline at end of file +30ac9a97-da1b-471e-bd20-099ae29966d1 \ No newline at end of file diff --git a/README.md b/README.md index f0cb38e..a19538d 100644 --- a/README.md +++ b/README.md @@ -1654,11 +1654,12 @@ It's recommended to trigger a manual refresh of the account after placing an ord $result = $snaptrade->trading->placeForceOrder( account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", action: "BUY", - universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", order_type: "Market", time_in_force: "FOK", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", + symbol: "AAPL 131124C00240000", price: 31.33, stop: 31.33, units: 10.5, @@ -1674,10 +1675,6 @@ Unique identifier for the connected brokerage account. This is the UUID used to ##### action: -##### universal_symbol_id: `string` - -Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls. - ##### order_type: ##### time_in_force: @@ -1686,6 +1683,14 @@ Unique identifier for the symbol within SnapTrade. This is the ID used to refere ##### user_secret: `string` +##### universal_symbol_id: [`string`](./lib/Model/string.php) + +The universal symbol ID of the security to trade. Must be 'null' if `symbol` is provided, otherwise must be provided. + +##### symbol: `string` + +The security's trading ticker symbol. This currently only support Options symbols in the 21 character OCC format. For example \\\"AAPL 131124C00240000\\\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. + ##### price: `float` The limit price for `Limit` and `StopLimit` orders. @@ -1696,6 +1701,8 @@ The price at which a stop order is triggered for `Stop` and `StopLimit` orders. ##### units: [`float`](./lib/Model/float.php) +For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares). + ##### notional_value: [`ManualTradeFormNotionalValue`](./lib/Model/ManualTradeFormNotionalValue.php) diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 8aa5832..cbd553f 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -1601,7 +1601,7 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form manual_trade_form (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options manual_trade_form_with_options (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -1612,11 +1612,12 @@ public function placeForceOrder( $account_id, $action, - $universal_symbol_id, $order_type, $time_in_force, $user_id, $user_secret, + $universal_symbol_id = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, @@ -1628,15 +1629,16 @@ public function placeForceOrder( $this->setRequestBodyProperty($_body, "account_id", $account_id); $this->setRequestBodyProperty($_body, "action", $action); $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form = $_body; + $manual_trade_form_with_options = $_body; - list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType); + list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); return $response; } @@ -1649,16 +1651,16 @@ public function placeForceOrder( * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -1676,7 +1678,7 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad return $this->placeForceOrderWithHttpInfo( $user_id, $user_secret, - $manual_trade_form, + $manual_trade_form_with_options, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -1816,7 +1818,7 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -1826,11 +1828,12 @@ public function placeForceOrderAsync( $account_id, $action, - $universal_symbol_id, $order_type, $time_in_force, $user_id, $user_secret, + $universal_symbol_id = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, @@ -1842,15 +1845,16 @@ public function placeForceOrderAsync( $this->setRequestBodyProperty($_body, "account_id", $account_id); $this->setRequestBodyProperty($_body, "action", $action); $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form = $_body; + $manual_trade_form_with_options = $_body; - return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType) + return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) ->then( function ($response) { return $response[0]; @@ -1867,16 +1871,16 @@ function ($response) { * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -1922,13 +1926,13 @@ function ($exception) { * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['placeForceOrder'][0]) + public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0]) { // Check if $user_id is a string @@ -1951,18 +1955,18 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for 'Missing the required parameter user_secret when calling placeForceOrder' ); } - if ($manual_trade_form !== SENTINEL_VALUE) { - if (!($manual_trade_form instanceof \SnapTrade\Model\ManualTradeForm)) { - if (!is_array($manual_trade_form)) - throw new \InvalidArgumentException('"manual_trade_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeForm TradingApi.placeForceOrder.'); + if ($manual_trade_form_with_options !== SENTINEL_VALUE) { + if (!($manual_trade_form_with_options instanceof \SnapTrade\Model\ManualTradeFormWithOptions)) { + if (!is_array($manual_trade_form_with_options)) + throw new \InvalidArgumentException('"manual_trade_form_with_options" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormWithOptions TradingApi.placeForceOrder.'); else - $manual_trade_form = new \SnapTrade\Model\ManualTradeForm($manual_trade_form); + $manual_trade_form_with_options = new \SnapTrade\Model\ManualTradeFormWithOptions($manual_trade_form_with_options); } } - // verify the required parameter 'manual_trade_form' is set - if ($manual_trade_form === SENTINEL_VALUE || (is_array($manual_trade_form) && count($manual_trade_form) === 0)) { + // verify the required parameter 'manual_trade_form_with_options' is set + if ($manual_trade_form_with_options === SENTINEL_VALUE || (is_array($manual_trade_form_with_options) && count($manual_trade_form_with_options) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form when calling placeForceOrder' + 'Missing the required parameter manual_trade_form_with_options when calling placeForceOrder' ); } @@ -2007,12 +2011,12 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for ); // for model (json/xml) - if (isset($manual_trade_form)) { + if (isset($manual_trade_form_with_options)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_with_options)); } else { - $httpBody = $manual_trade_form; + $httpBody = $manual_trade_form_with_options; } } elseif (count($formParams) > 0) { if ($multipart) { diff --git a/lib/Model/ActionStrict.php b/lib/Model/ActionStrict.php index 0f952a3..3e5447b 100644 --- a/lib/Model/ActionStrict.php +++ b/lib/Model/ActionStrict.php @@ -28,7 +28,7 @@ * ActionStrict Class Doc Comment * * @category Class - * @description The action describes the intent or side of a trade. This is either `BUY` or `SELL` + * @description The action describes the intent or side of a trade. This is either `BUY` or `SELL`. * @package SnapTrade */ class ActionStrict diff --git a/lib/Model/ActionStrictWithOptions.php b/lib/Model/ActionStrictWithOptions.php new file mode 100644 index 0000000..2bf0a45 --- /dev/null +++ b/lib/Model/ActionStrictWithOptions.php @@ -0,0 +1,68 @@ + false, - 'last_successful_sync' => false + 'last_successful_sync' => true ]; /** @@ -340,7 +340,14 @@ public function setLastSuccessfulSync($last_successful_sync) { if (is_null($last_successful_sync)) { - throw new \InvalidArgumentException('non-nullable last_successful_sync cannot be null'); + array_push($this->openAPINullablesSetToNull, 'last_successful_sync'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('last_successful_sync', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } } $this->container['last_successful_sync'] = $last_successful_sync; diff --git a/lib/Model/ManualTradeFormWithOptions.php b/lib/Model/ManualTradeFormWithOptions.php new file mode 100644 index 0000000..079ba2a --- /dev/null +++ b/lib/Model/ManualTradeFormWithOptions.php @@ -0,0 +1,783 @@ + + */ +class ManualTradeFormWithOptions implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ManualTradeFormWithOptions'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'account_id' => 'string', + 'action' => '\SnapTrade\Model\ActionStrictWithOptions', + 'universal_symbol_id' => 'string', + 'symbol' => 'string', + 'order_type' => '\SnapTrade\Model\OrderTypeStrict', + 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', + 'price' => 'float', + 'stop' => 'float', + 'units' => 'float', + 'notional_value' => '\SnapTrade\Model\ManualTradeFormNotionalValue' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'account_id' => 'uuid', + 'action' => null, + 'universal_symbol_id' => null, + 'symbol' => null, + 'order_type' => null, + 'time_in_force' => null, + 'price' => null, + 'stop' => null, + 'units' => null, + 'notional_value' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'account_id' => false, + 'action' => false, + 'universal_symbol_id' => true, + 'symbol' => true, + 'order_type' => false, + 'time_in_force' => false, + 'price' => true, + 'stop' => true, + 'units' => true, + 'notional_value' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'account_id' => 'account_id', + 'action' => 'action', + 'universal_symbol_id' => 'universal_symbol_id', + 'symbol' => 'symbol', + 'order_type' => 'order_type', + 'time_in_force' => 'time_in_force', + 'price' => 'price', + 'stop' => 'stop', + 'units' => 'units', + 'notional_value' => 'notional_value' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'account_id' => 'setAccountId', + 'action' => 'setAction', + 'universal_symbol_id' => 'setUniversalSymbolId', + 'symbol' => 'setSymbol', + 'order_type' => 'setOrderType', + 'time_in_force' => 'setTimeInForce', + 'price' => 'setPrice', + 'stop' => 'setStop', + 'units' => 'setUnits', + 'notional_value' => 'setNotionalValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'account_id' => 'getAccountId', + 'action' => 'getAction', + 'universal_symbol_id' => 'getUniversalSymbolId', + 'symbol' => 'getSymbol', + 'order_type' => 'getOrderType', + 'time_in_force' => 'getTimeInForce', + 'price' => 'getPrice', + 'stop' => 'getStop', + 'units' => 'getUnits', + 'notional_value' => 'getNotionalValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('action', $data ?? [], null); + $this->setIfExists('universal_symbol_id', $data ?? [], null); + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('order_type', $data ?? [], null); + $this->setIfExists('time_in_force', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('stop', $data ?? [], null); + $this->setIfExists('units', $data ?? [], null); + $this->setIfExists('notional_value', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['account_id'] === null) { + $invalidProperties[] = "'account_id' can't be null"; + } + if ($this->container['action'] === null) { + $invalidProperties[] = "'action' can't be null"; + } + if ($this->container['order_type'] === null) { + $invalidProperties[] = "'order_type' can't be null"; + } + if ($this->container['time_in_force'] === null) { + $invalidProperties[] = "'time_in_force' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets account_id + * + * @return string + */ + public function getAccountId() + { + return $this->container['account_id']; + } + + /** + * Sets account_id + * + * @param string $account_id Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. + * + * @return self + */ + public function setAccountId($account_id) + { + + if (is_null($account_id)) { + throw new \InvalidArgumentException('non-nullable account_id cannot be null'); + } + + $this->container['account_id'] = $account_id; + + return $this; + } + + /** + * Gets action + * + * @return \SnapTrade\Model\ActionStrictWithOptions + */ + public function getAction() + { + return $this->container['action']; + } + + /** + * Sets action + * + * @param \SnapTrade\Model\ActionStrictWithOptions $action action + * + * @return self + */ + public function setAction($action) + { + + if (is_null($action)) { + throw new \InvalidArgumentException('non-nullable action cannot be null'); + } + + $this->container['action'] = $action; + + return $this; + } + + /** + * Gets universal_symbol_id + * + * @return string|null + */ + public function getUniversalSymbolId() + { + return $this->container['universal_symbol_id']; + } + + /** + * Sets universal_symbol_id + * + * @param string|null $universal_symbol_id The universal symbol ID of the security to trade. Must be 'null' if `symbol` is provided, otherwise must be provided. + * + * @return self + */ + public function setUniversalSymbolId($universal_symbol_id) + { + + if (is_null($universal_symbol_id)) { + array_push($this->openAPINullablesSetToNull, 'universal_symbol_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('universal_symbol_id', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['universal_symbol_id'] = $universal_symbol_id; + + return $this; + } + + /** + * Gets symbol + * + * @return string|null + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string|null $symbol The security's trading ticker symbol. This currently only support Options symbols in the 21 character OCC format. For example \"AAPL 131124C00240000\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + array_push($this->openAPINullablesSetToNull, 'symbol'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('symbol', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets order_type + * + * @return \SnapTrade\Model\OrderTypeStrict + */ + public function getOrderType() + { + return $this->container['order_type']; + } + + /** + * Sets order_type + * + * @param \SnapTrade\Model\OrderTypeStrict $order_type order_type + * + * @return self + */ + public function setOrderType($order_type) + { + + if (is_null($order_type)) { + throw new \InvalidArgumentException('non-nullable order_type cannot be null'); + } + + $this->container['order_type'] = $order_type; + + return $this; + } + + /** + * Gets time_in_force + * + * @return \SnapTrade\Model\TimeInForceStrict + */ + public function getTimeInForce() + { + return $this->container['time_in_force']; + } + + /** + * Sets time_in_force + * + * @param \SnapTrade\Model\TimeInForceStrict $time_in_force time_in_force + * + * @return self + */ + public function setTimeInForce($time_in_force) + { + + if (is_null($time_in_force)) { + throw new \InvalidArgumentException('non-nullable time_in_force cannot be null'); + } + + $this->container['time_in_force'] = $time_in_force; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price The limit price for `Limit` and `StopLimit` orders. + * + * @return self + */ + public function setPrice($price) + { + + if (is_null($price)) { + array_push($this->openAPINullablesSetToNull, 'price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets stop + * + * @return float|null + */ + public function getStop() + { + return $this->container['stop']; + } + + /** + * Sets stop + * + * @param float|null $stop The price at which a stop order is triggered for `Stop` and `StopLimit` orders. + * + * @return self + */ + public function setStop($stop) + { + + if (is_null($stop)) { + array_push($this->openAPINullablesSetToNull, 'stop'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('stop', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['stop'] = $stop; + + return $this; + } + + /** + * Gets units + * + * @return float|null + */ + public function getUnits() + { + return $this->container['units']; + } + + /** + * Sets units + * + * @param float|null $units For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares). + * + * @return self + */ + public function setUnits($units) + { + + if (is_null($units)) { + array_push($this->openAPINullablesSetToNull, 'units'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('units', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['units'] = $units; + + return $this; + } + + /** + * Gets notional_value + * + * @return \SnapTrade\Model\ManualTradeFormNotionalValue|null + */ + public function getNotionalValue() + { + return $this->container['notional_value']; + } + + /** + * Sets notional_value + * + * @param \SnapTrade\Model\ManualTradeFormNotionalValue|null $notional_value notional_value + * + * @return self + */ + public function setNotionalValue($notional_value) + { + + if (is_null($notional_value)) { + array_push($this->openAPINullablesSetToNull, 'notional_value'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('notional_value', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['notional_value'] = $notional_value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/TransactionsStatus.php b/lib/Model/TransactionsStatus.php index 93d6331..3452dc5 100644 --- a/lib/Model/TransactionsStatus.php +++ b/lib/Model/TransactionsStatus.php @@ -76,7 +76,7 @@ class TransactionsStatus implements ModelInterface, ArrayAccess, \JsonSerializab */ protected static array $openAPINullables = [ 'initial_sync_completed' => false, - 'last_successful_sync' => false, + 'last_successful_sync' => true, 'first_transaction_date' => false ]; @@ -347,7 +347,14 @@ public function setLastSuccessfulSync($last_successful_sync) { if (is_null($last_successful_sync)) { - throw new \InvalidArgumentException('non-nullable last_successful_sync cannot be null'); + array_push($this->openAPINullablesSetToNull, 'last_successful_sync'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('last_successful_sync', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } } $this->container['last_successful_sync'] = $last_successful_sync; diff --git a/test/Model/ActionStrictTest.php b/test/Model/ActionStrictTest.php index fd585db..6bfe9b9 100644 --- a/test/Model/ActionStrictTest.php +++ b/test/Model/ActionStrictTest.php @@ -29,7 +29,7 @@ * ActionStrictTest Class Doc Comment * * @category Class - * @description The action describes the intent or side of a trade. This is either `BUY` or `SELL` + * @description The action describes the intent or side of a trade. This is either `BUY` or `SELL`. * @package SnapTrade */ class ActionStrictTest extends TestCase diff --git a/test/Model/ActionStrictWithOptionsTest.php b/test/Model/ActionStrictWithOptionsTest.php new file mode 100644 index 0000000..cdaafa7 --- /dev/null +++ b/test/Model/ActionStrictWithOptionsTest.php @@ -0,0 +1,74 @@ +markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/ManualTradeFormWithOptionsTest.php b/test/Model/ManualTradeFormWithOptionsTest.php new file mode 100644 index 0000000..7aa386f --- /dev/null +++ b/test/Model/ManualTradeFormWithOptionsTest.php @@ -0,0 +1,164 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "account_id" + */ + public function testPropertyAccountId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "action" + */ + public function testPropertyAction() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "universal_symbol_id" + */ + public function testPropertyUniversalSymbolId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "order_type" + */ + public function testPropertyOrderType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "time_in_force" + */ + public function testPropertyTimeInForce() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "price" + */ + public function testPropertyPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop" + */ + public function testPropertyStop() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "units" + */ + public function testPropertyUnits() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "notional_value" + */ + public function testPropertyNotionalValue() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From 59d0fa09ceffad11ffbbf72053a04de442e67105 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 19:24:55 +0000 Subject: [PATCH 020/252] Version Bump SDKs (#32) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 70ef3cb..8e17b96 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -30ac9a97-da1b-471e-bd20-099ae29966d1 \ No newline at end of file +4b0c788f-7cfa-4ab9-8f4d-574ade39154f \ No newline at end of file diff --git a/README.md b/README.md index a19538d..adabacc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.45-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.46-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.45" + "konfig/snaptrade-php-sdk": "2.0.46" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 2827437..b0d3315 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.45/PHP'; + protected $userAgent = 'Konfig/2.0.46/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.45' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.46' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From bf1181fb9ab037661e486d8b6fa25729aa5c4a13 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:46:01 +0000 Subject: [PATCH 021/252] Regenerate SDKs (#33) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/TransactionsAndReportingApi.php | 10 +- lib/Model/AccountOrderRecord.php | 88 +++++----- .../AccountOrderRecordUniversalSymbol.php | 88 +++++----- lib/Model/Brokerage.php | 160 +++++++++--------- lib/Model/BrokerageAuthorization.php | 88 +++++----- lib/Model/ManualTradeSymbol.php | 90 +++++----- lib/Model/OptionBrokerageSymbol.php | 86 +++++----- lib/Model/OptionsPosition.php | 74 ++++---- lib/Model/Position.php | 70 ++++---- lib/Model/PositionSymbol.php | 74 ++++---- lib/Model/UnderlyingSymbol.php | 88 +++++----- lib/Model/UniversalActivity.php | 2 +- lib/Model/UniversalSymbol.php | 88 +++++----- test/Model/AccountOrderRecordTest.php | 18 +- .../AccountOrderRecordUniversalSymbolTest.php | 12 +- test/Model/BrokerageAuthorizationTest.php | 18 +- test/Model/BrokerageTest.php | 26 +-- test/Model/ManualTradeSymbolTest.php | 18 +- test/Model/OptionBrokerageSymbolTest.php | 12 +- test/Model/OptionsPositionTest.php | 8 +- test/Model/PositionSymbolTest.php | 12 +- test/Model/PositionTest.php | 8 +- test/Model/UnderlyingSymbolTest.php | 12 +- test/Model/UniversalSymbolTest.php | 12 +- 26 files changed, 583 insertions(+), 583 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 8e17b96..b816d4c 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -4b0c788f-7cfa-4ab9-8f4d-574ade39154f \ No newline at end of file +6642171d-955a-4c0d-b6c9-327622a62fde \ No newline at end of file diff --git a/README.md b/README.md index adabacc..4fc4ad4 100644 --- a/README.md +++ b/README.md @@ -1814,7 +1814,7 @@ Optional comma separated list of SnapTrade Connection (Brokerage Authorization) ##### type: `string` -Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. +Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. #### πŸ”„ Return diff --git a/lib/Api/TransactionsAndReportingApi.php b/lib/Api/TransactionsAndReportingApi.php index 1a214ac..c11db2a 100644 --- a/lib/Api/TransactionsAndReportingApi.php +++ b/lib/Api/TransactionsAndReportingApi.php @@ -151,7 +151,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -188,7 +188,7 @@ public function getActivities( * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -317,7 +317,7 @@ public function getActivitiesWithHttpInfo($user_id, $user_secret, $start_date = * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -357,7 +357,7 @@ function ($response) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -416,7 +416,7 @@ function ($exception) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/lib/Model/AccountOrderRecord.php b/lib/Model/AccountOrderRecord.php index ac621a6..4f04f54 100644 --- a/lib/Model/AccountOrderRecord.php +++ b/lib/Model/AccountOrderRecord.php @@ -53,7 +53,6 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab protected static $openAPITypes = [ 'brokerage_order_id' => 'string', 'status' => '\SnapTrade\Model\AccountOrderRecordStatus', - 'symbol' => 'string', 'universal_symbol' => '\SnapTrade\Model\AccountOrderRecordUniversalSymbol', 'option_symbol' => '\SnapTrade\Model\AccountOrderRecordOptionSymbol', 'action' => 'string', @@ -69,7 +68,8 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab 'time_placed' => '\DateTime', 'time_updated' => '\DateTime', 'time_executed' => '\DateTime', - 'expiry_date' => '\DateTime' + 'expiry_date' => '\DateTime', + 'symbol' => 'string' ]; /** @@ -82,7 +82,6 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab protected static $openAPIFormats = [ 'brokerage_order_id' => null, 'status' => null, - 'symbol' => 'uuid', 'universal_symbol' => null, 'option_symbol' => null, 'action' => null, @@ -98,7 +97,8 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab 'time_placed' => 'date-time', 'time_updated' => 'date-time', 'time_executed' => 'date-time', - 'expiry_date' => 'date-time' + 'expiry_date' => 'date-time', + 'symbol' => 'uuid' ]; /** @@ -109,7 +109,6 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab protected static array $openAPINullables = [ 'brokerage_order_id' => false, 'status' => false, - 'symbol' => false, 'universal_symbol' => false, 'option_symbol' => false, 'action' => false, @@ -125,7 +124,8 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab 'time_placed' => false, 'time_updated' => true, 'time_executed' => true, - 'expiry_date' => true + 'expiry_date' => true, + 'symbol' => false ]; /** @@ -216,7 +216,6 @@ public function isNullableSetToNull(string $property): bool protected static $attributeMap = [ 'brokerage_order_id' => 'brokerage_order_id', 'status' => 'status', - 'symbol' => 'symbol', 'universal_symbol' => 'universal_symbol', 'option_symbol' => 'option_symbol', 'action' => 'action', @@ -232,7 +231,8 @@ public function isNullableSetToNull(string $property): bool 'time_placed' => 'time_placed', 'time_updated' => 'time_updated', 'time_executed' => 'time_executed', - 'expiry_date' => 'expiry_date' + 'expiry_date' => 'expiry_date', + 'symbol' => 'symbol' ]; /** @@ -243,7 +243,6 @@ public function isNullableSetToNull(string $property): bool protected static $setters = [ 'brokerage_order_id' => 'setBrokerageOrderId', 'status' => 'setStatus', - 'symbol' => 'setSymbol', 'universal_symbol' => 'setUniversalSymbol', 'option_symbol' => 'setOptionSymbol', 'action' => 'setAction', @@ -259,7 +258,8 @@ public function isNullableSetToNull(string $property): bool 'time_placed' => 'setTimePlaced', 'time_updated' => 'setTimeUpdated', 'time_executed' => 'setTimeExecuted', - 'expiry_date' => 'setExpiryDate' + 'expiry_date' => 'setExpiryDate', + 'symbol' => 'setSymbol' ]; /** @@ -270,7 +270,6 @@ public function isNullableSetToNull(string $property): bool protected static $getters = [ 'brokerage_order_id' => 'getBrokerageOrderId', 'status' => 'getStatus', - 'symbol' => 'getSymbol', 'universal_symbol' => 'getUniversalSymbol', 'option_symbol' => 'getOptionSymbol', 'action' => 'getAction', @@ -286,7 +285,8 @@ public function isNullableSetToNull(string $property): bool 'time_placed' => 'getTimePlaced', 'time_updated' => 'getTimeUpdated', 'time_executed' => 'getTimeExecuted', - 'expiry_date' => 'getExpiryDate' + 'expiry_date' => 'getExpiryDate', + 'symbol' => 'getSymbol' ]; /** @@ -348,7 +348,6 @@ public function __construct(array $data = null) { $this->setIfExists('brokerage_order_id', $data ?? [], null); $this->setIfExists('status', $data ?? [], null); - $this->setIfExists('symbol', $data ?? [], null); $this->setIfExists('universal_symbol', $data ?? [], null); $this->setIfExists('option_symbol', $data ?? [], null); $this->setIfExists('action', $data ?? [], null); @@ -365,6 +364,7 @@ public function __construct(array $data = null) $this->setIfExists('time_updated', $data ?? [], null); $this->setIfExists('time_executed', $data ?? [], null); $this->setIfExists('expiry_date', $data ?? [], null); + $this->setIfExists('symbol', $data ?? [], null); } /** @@ -467,37 +467,6 @@ public function setStatus($status) return $this; } - /** - * Gets symbol - * - * @return string|null - * @deprecated - */ - public function getSymbol() - { - return $this->container['symbol']; - } - - /** - * Sets symbol - * - * @param string|null $symbol A unique ID for the security within SnapTrade, scoped to the brokerage account that the security belongs to. This is a legacy field and should not be used. Do not rely on this being a stable ID as it can change. - * - * @return self - * @deprecated - */ - public function setSymbol($symbol) - { - - if (is_null($symbol)) { - throw new \InvalidArgumentException('non-nullable symbol cannot be null'); - } - - $this->container['symbol'] = $symbol; - - return $this; - } - /** * Gets universal_symbol * @@ -1038,6 +1007,37 @@ public function setExpiryDate($expiry_date) return $this; } + + /** + * Gets symbol + * + * @return string|null + * @deprecated + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string|null $symbol A unique ID for the security within SnapTrade, scoped to the brokerage account that the security belongs to. This is a legacy field and should not be used. Do not rely on this being a stable ID as it can change. + * + * @return self + * @deprecated + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/AccountOrderRecordUniversalSymbol.php b/lib/Model/AccountOrderRecordUniversalSymbol.php index bb2fc0f..95d7cbb 100644 --- a/lib/Model/AccountOrderRecordUniversalSymbol.php +++ b/lib/Model/AccountOrderRecordUniversalSymbol.php @@ -58,9 +58,9 @@ class AccountOrderRecordUniversalSymbol implements ModelInterface, ArrayAccess, 'currency' => '\SnapTrade\Model\SymbolCurrency', 'exchange' => '\SnapTrade\Model\SymbolExchange', 'type' => '\SnapTrade\Model\SecurityType', - 'currencies' => '\SnapTrade\Model\Currency[]', 'figi_code' => 'string', - 'figi_instrument' => '\SnapTrade\Model\SymbolFigiInstrument' + 'figi_instrument' => '\SnapTrade\Model\SymbolFigiInstrument', + 'currencies' => '\SnapTrade\Model\Currency[]' ]; /** @@ -78,9 +78,9 @@ class AccountOrderRecordUniversalSymbol implements ModelInterface, ArrayAccess, 'currency' => null, 'exchange' => null, 'type' => null, - 'currencies' => null, 'figi_code' => null, - 'figi_instrument' => null + 'figi_instrument' => null, + 'currencies' => null ]; /** @@ -96,9 +96,9 @@ class AccountOrderRecordUniversalSymbol implements ModelInterface, ArrayAccess, 'currency' => false, 'exchange' => false, 'type' => false, - 'currencies' => false, 'figi_code' => true, - 'figi_instrument' => true + 'figi_instrument' => true, + 'currencies' => false ]; /** @@ -194,9 +194,9 @@ public function isNullableSetToNull(string $property): bool 'currency' => 'currency', 'exchange' => 'exchange', 'type' => 'type', - 'currencies' => 'currencies', 'figi_code' => 'figi_code', - 'figi_instrument' => 'figi_instrument' + 'figi_instrument' => 'figi_instrument', + 'currencies' => 'currencies' ]; /** @@ -212,9 +212,9 @@ public function isNullableSetToNull(string $property): bool 'currency' => 'setCurrency', 'exchange' => 'setExchange', 'type' => 'setType', - 'currencies' => 'setCurrencies', 'figi_code' => 'setFigiCode', - 'figi_instrument' => 'setFigiInstrument' + 'figi_instrument' => 'setFigiInstrument', + 'currencies' => 'setCurrencies' ]; /** @@ -230,9 +230,9 @@ public function isNullableSetToNull(string $property): bool 'currency' => 'getCurrency', 'exchange' => 'getExchange', 'type' => 'getType', - 'currencies' => 'getCurrencies', 'figi_code' => 'getFigiCode', - 'figi_instrument' => 'getFigiInstrument' + 'figi_instrument' => 'getFigiInstrument', + 'currencies' => 'getCurrencies' ]; /** @@ -299,9 +299,9 @@ public function __construct(array $data = null) $this->setIfExists('currency', $data ?? [], null); $this->setIfExists('exchange', $data ?? [], null); $this->setIfExists('type', $data ?? [], null); - $this->setIfExists('currencies', $data ?? [], null); $this->setIfExists('figi_code', $data ?? [], null); $this->setIfExists('figi_instrument', $data ?? [], null); + $this->setIfExists('currencies', $data ?? [], null); } /** @@ -574,37 +574,6 @@ public function setType($type) return $this; } - /** - * Gets currencies - * - * @return \SnapTrade\Model\Currency[] - * @deprecated - */ - public function getCurrencies() - { - return $this->container['currencies']; - } - - /** - * Sets currencies - * - * @param \SnapTrade\Model\Currency[] $currencies This field is deprecated and should not be used. Please reach out to SnapTrade support if you have a valid usecase for this. - * - * @return self - * @deprecated - */ - public function setCurrencies($currencies) - { - - if (is_null($currencies)) { - throw new \InvalidArgumentException('non-nullable currencies cannot be null'); - } - - $this->container['currencies'] = $currencies; - - return $this; - } - /** * Gets figi_code * @@ -676,6 +645,37 @@ public function setFigiInstrument($figi_instrument) return $this; } + + /** + * Gets currencies + * + * @return \SnapTrade\Model\Currency[] + * @deprecated + */ + public function getCurrencies() + { + return $this->container['currencies']; + } + + /** + * Sets currencies + * + * @param \SnapTrade\Model\Currency[] $currencies This field is deprecated and should not be used. Please reach out to SnapTrade support if you have a valid usecase for this. + * + * @return self + * @deprecated + */ + public function setCurrencies($currencies) + { + + if (is_null($currencies)) { + throw new \InvalidArgumentException('non-nullable currencies cannot be null'); + } + + $this->container['currencies'] = $currencies; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/Brokerage.php b/lib/Model/Brokerage.php index 29cc33d..903c882 100644 --- a/lib/Model/Brokerage.php +++ b/lib/Model/Brokerage.php @@ -58,16 +58,16 @@ class Brokerage implements ModelInterface, ArrayAccess, \JsonSerializable 'description' => 'string', 'aws_s3_logo_url' => 'string', 'aws_s3_square_logo_url' => 'string', - 'open_url' => 'string', 'url' => 'string', 'enabled' => 'bool', 'maintenance_mode' => 'bool', - 'allows_fractional_units' => 'bool', 'allows_trading' => 'bool', + 'allows_fractional_units' => 'bool', 'has_reporting' => 'bool', 'is_real_time_connection' => 'bool', 'brokerage_type' => '\SnapTrade\Model\BrokerageType', - 'exchanges' => 'mixed[]' + 'exchanges' => 'mixed[]', + 'open_url' => 'string' ]; /** @@ -85,16 +85,16 @@ class Brokerage implements ModelInterface, ArrayAccess, \JsonSerializable 'description' => null, 'aws_s3_logo_url' => 'url', 'aws_s3_square_logo_url' => 'url', - 'open_url' => 'url', 'url' => 'url', 'enabled' => null, 'maintenance_mode' => null, - 'allows_fractional_units' => null, 'allows_trading' => null, + 'allows_fractional_units' => null, 'has_reporting' => null, 'is_real_time_connection' => null, 'brokerage_type' => null, - 'exchanges' => null + 'exchanges' => null, + 'open_url' => 'url' ]; /** @@ -110,16 +110,16 @@ class Brokerage implements ModelInterface, ArrayAccess, \JsonSerializable 'description' => false, 'aws_s3_logo_url' => false, 'aws_s3_square_logo_url' => true, - 'open_url' => true, 'url' => false, 'enabled' => false, 'maintenance_mode' => false, - 'allows_fractional_units' => true, 'allows_trading' => true, + 'allows_fractional_units' => true, 'has_reporting' => true, 'is_real_time_connection' => false, 'brokerage_type' => false, - 'exchanges' => false + 'exchanges' => false, + 'open_url' => true ]; /** @@ -215,16 +215,16 @@ public function isNullableSetToNull(string $property): bool 'description' => 'description', 'aws_s3_logo_url' => 'aws_s3_logo_url', 'aws_s3_square_logo_url' => 'aws_s3_square_logo_url', - 'open_url' => 'open_url', 'url' => 'url', 'enabled' => 'enabled', 'maintenance_mode' => 'maintenance_mode', - 'allows_fractional_units' => 'allows_fractional_units', 'allows_trading' => 'allows_trading', + 'allows_fractional_units' => 'allows_fractional_units', 'has_reporting' => 'has_reporting', 'is_real_time_connection' => 'is_real_time_connection', 'brokerage_type' => 'brokerage_type', - 'exchanges' => 'exchanges' + 'exchanges' => 'exchanges', + 'open_url' => 'open_url' ]; /** @@ -240,16 +240,16 @@ public function isNullableSetToNull(string $property): bool 'description' => 'setDescription', 'aws_s3_logo_url' => 'setAwsS3LogoUrl', 'aws_s3_square_logo_url' => 'setAwsS3SquareLogoUrl', - 'open_url' => 'setOpenUrl', 'url' => 'setUrl', 'enabled' => 'setEnabled', 'maintenance_mode' => 'setMaintenanceMode', - 'allows_fractional_units' => 'setAllowsFractionalUnits', 'allows_trading' => 'setAllowsTrading', + 'allows_fractional_units' => 'setAllowsFractionalUnits', 'has_reporting' => 'setHasReporting', 'is_real_time_connection' => 'setIsRealTimeConnection', 'brokerage_type' => 'setBrokerageType', - 'exchanges' => 'setExchanges' + 'exchanges' => 'setExchanges', + 'open_url' => 'setOpenUrl' ]; /** @@ -265,16 +265,16 @@ public function isNullableSetToNull(string $property): bool 'description' => 'getDescription', 'aws_s3_logo_url' => 'getAwsS3LogoUrl', 'aws_s3_square_logo_url' => 'getAwsS3SquareLogoUrl', - 'open_url' => 'getOpenUrl', 'url' => 'getUrl', 'enabled' => 'getEnabled', 'maintenance_mode' => 'getMaintenanceMode', - 'allows_fractional_units' => 'getAllowsFractionalUnits', 'allows_trading' => 'getAllowsTrading', + 'allows_fractional_units' => 'getAllowsFractionalUnits', 'has_reporting' => 'getHasReporting', 'is_real_time_connection' => 'getIsRealTimeConnection', 'brokerage_type' => 'getBrokerageType', - 'exchanges' => 'getExchanges' + 'exchanges' => 'getExchanges', + 'open_url' => 'getOpenUrl' ]; /** @@ -341,16 +341,16 @@ public function __construct(array $data = null) $this->setIfExists('description', $data ?? [], null); $this->setIfExists('aws_s3_logo_url', $data ?? [], null); $this->setIfExists('aws_s3_square_logo_url', $data ?? [], null); - $this->setIfExists('open_url', $data ?? [], null); $this->setIfExists('url', $data ?? [], null); $this->setIfExists('enabled', $data ?? [], null); $this->setIfExists('maintenance_mode', $data ?? [], null); - $this->setIfExists('allows_fractional_units', $data ?? [], null); $this->setIfExists('allows_trading', $data ?? [], null); + $this->setIfExists('allows_fractional_units', $data ?? [], null); $this->setIfExists('has_reporting', $data ?? [], null); $this->setIfExists('is_real_time_connection', $data ?? [], null); $this->setIfExists('brokerage_type', $data ?? [], null); $this->setIfExists('exchanges', $data ?? [], null); + $this->setIfExists('open_url', $data ?? [], null); } /** @@ -605,44 +605,6 @@ public function setAwsS3SquareLogoUrl($aws_s3_square_logo_url) return $this; } - /** - * Gets open_url - * - * @return string|null - * @deprecated - */ - public function getOpenUrl() - { - return $this->container['open_url']; - } - - /** - * Sets open_url - * - * @param string|null $open_url This field is deprecated. - * - * @return self - * @deprecated - */ - public function setOpenUrl($open_url) - { - - if (is_null($open_url)) { - array_push($this->openAPINullablesSetToNull, 'open_url'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('open_url', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - - $this->container['open_url'] = $open_url; - - return $this; - } - /** * Gets url * @@ -731,75 +693,75 @@ public function setMaintenanceMode($maintenance_mode) } /** - * Gets allows_fractional_units + * Gets allows_trading * * @return bool|null - * @deprecated */ - public function getAllowsFractionalUnits() + public function getAllowsTrading() { - return $this->container['allows_fractional_units']; + return $this->container['allows_trading']; } /** - * Sets allows_fractional_units + * Sets allows_trading * - * @param bool|null $allows_fractional_units This field is deprecated. Please contact us if you have a valid use case for it. + * @param bool|null $allows_trading Whether the brokerage allows trading through SnapTrade. * * @return self - * @deprecated */ - public function setAllowsFractionalUnits($allows_fractional_units) + public function setAllowsTrading($allows_trading) { - if (is_null($allows_fractional_units)) { - array_push($this->openAPINullablesSetToNull, 'allows_fractional_units'); + if (is_null($allows_trading)) { + array_push($this->openAPINullablesSetToNull, 'allows_trading'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('allows_fractional_units', $nullablesSetToNull); + $index = array_search('allows_trading', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } - $this->container['allows_fractional_units'] = $allows_fractional_units; + $this->container['allows_trading'] = $allows_trading; return $this; } /** - * Gets allows_trading + * Gets allows_fractional_units * * @return bool|null + * @deprecated */ - public function getAllowsTrading() + public function getAllowsFractionalUnits() { - return $this->container['allows_trading']; + return $this->container['allows_fractional_units']; } /** - * Sets allows_trading + * Sets allows_fractional_units * - * @param bool|null $allows_trading Whether the brokerage allows trading through SnapTrade. + * @param bool|null $allows_fractional_units This field is deprecated. Please contact us if you have a valid use case for it. * * @return self + * @deprecated */ - public function setAllowsTrading($allows_trading) + public function setAllowsFractionalUnits($allows_fractional_units) { - if (is_null($allows_trading)) { - array_push($this->openAPINullablesSetToNull, 'allows_trading'); + if (is_null($allows_fractional_units)) { + array_push($this->openAPINullablesSetToNull, 'allows_fractional_units'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('allows_trading', $nullablesSetToNull); + $index = array_search('allows_fractional_units', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } - $this->container['allows_trading'] = $allows_trading; + $this->container['allows_fractional_units'] = $allows_fractional_units; return $this; } @@ -932,6 +894,44 @@ public function setExchanges($exchanges) return $this; } + + /** + * Gets open_url + * + * @return string|null + * @deprecated + */ + public function getOpenUrl() + { + return $this->container['open_url']; + } + + /** + * Sets open_url + * + * @param string|null $open_url This field is deprecated. + * + * @return self + * @deprecated + */ + public function setOpenUrl($open_url) + { + + if (is_null($open_url)) { + array_push($this->openAPINullablesSetToNull, 'open_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('open_url', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['open_url'] = $open_url; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/BrokerageAuthorization.php b/lib/Model/BrokerageAuthorization.php index 6337e2d..8affc92 100644 --- a/lib/Model/BrokerageAuthorization.php +++ b/lib/Model/BrokerageAuthorization.php @@ -53,13 +53,13 @@ class BrokerageAuthorization implements ModelInterface, ArrayAccess, \JsonSerial protected static $openAPITypes = [ 'id' => 'string', 'created_date' => '\DateTime', - 'updated_date' => '\DateTime', 'brokerage' => '\SnapTrade\Model\Brokerage', 'name' => 'string', 'type' => 'string', 'disabled' => 'bool', 'disabled_date' => '\DateTime', - 'meta' => 'array' + 'meta' => 'array', + 'updated_date' => '\DateTime' ]; /** @@ -72,13 +72,13 @@ class BrokerageAuthorization implements ModelInterface, ArrayAccess, \JsonSerial protected static $openAPIFormats = [ 'id' => 'uuid', 'created_date' => 'date-time', - 'updated_date' => 'date-time', 'brokerage' => null, 'name' => null, 'type' => null, 'disabled' => null, 'disabled_date' => 'date-time', - 'meta' => null + 'meta' => null, + 'updated_date' => 'date-time' ]; /** @@ -89,13 +89,13 @@ class BrokerageAuthorization implements ModelInterface, ArrayAccess, \JsonSerial protected static array $openAPINullables = [ 'id' => false, 'created_date' => false, - 'updated_date' => false, 'brokerage' => false, 'name' => false, 'type' => false, 'disabled' => false, 'disabled_date' => true, - 'meta' => false + 'meta' => false, + 'updated_date' => false ]; /** @@ -186,13 +186,13 @@ public function isNullableSetToNull(string $property): bool protected static $attributeMap = [ 'id' => 'id', 'created_date' => 'created_date', - 'updated_date' => 'updated_date', 'brokerage' => 'brokerage', 'name' => 'name', 'type' => 'type', 'disabled' => 'disabled', 'disabled_date' => 'disabled_date', - 'meta' => 'meta' + 'meta' => 'meta', + 'updated_date' => 'updated_date' ]; /** @@ -203,13 +203,13 @@ public function isNullableSetToNull(string $property): bool protected static $setters = [ 'id' => 'setId', 'created_date' => 'setCreatedDate', - 'updated_date' => 'setUpdatedDate', 'brokerage' => 'setBrokerage', 'name' => 'setName', 'type' => 'setType', 'disabled' => 'setDisabled', 'disabled_date' => 'setDisabledDate', - 'meta' => 'setMeta' + 'meta' => 'setMeta', + 'updated_date' => 'setUpdatedDate' ]; /** @@ -220,13 +220,13 @@ public function isNullableSetToNull(string $property): bool protected static $getters = [ 'id' => 'getId', 'created_date' => 'getCreatedDate', - 'updated_date' => 'getUpdatedDate', 'brokerage' => 'getBrokerage', 'name' => 'getName', 'type' => 'getType', 'disabled' => 'getDisabled', 'disabled_date' => 'getDisabledDate', - 'meta' => 'getMeta' + 'meta' => 'getMeta', + 'updated_date' => 'getUpdatedDate' ]; /** @@ -288,13 +288,13 @@ public function __construct(array $data = null) { $this->setIfExists('id', $data ?? [], null); $this->setIfExists('created_date', $data ?? [], null); - $this->setIfExists('updated_date', $data ?? [], null); $this->setIfExists('brokerage', $data ?? [], null); $this->setIfExists('name', $data ?? [], null); $this->setIfExists('type', $data ?? [], null); $this->setIfExists('disabled', $data ?? [], null); $this->setIfExists('disabled_date', $data ?? [], null); $this->setIfExists('meta', $data ?? [], null); + $this->setIfExists('updated_date', $data ?? [], null); } /** @@ -397,37 +397,6 @@ public function setCreatedDate($created_date) return $this; } - /** - * Gets updated_date - * - * @return \DateTime|null - * @deprecated - */ - public function getUpdatedDate() - { - return $this->container['updated_date']; - } - - /** - * Sets updated_date - * - * @param \DateTime|null $updated_date Timestamp of when the connection was last updated in SnapTrade. This field is deprecated. Please let us know if you have a valid use case for this field. - * - * @return self - * @deprecated - */ - public function setUpdatedDate($updated_date) - { - - if (is_null($updated_date)) { - throw new \InvalidArgumentException('non-nullable updated_date cannot be null'); - } - - $this->container['updated_date'] = $updated_date; - - return $this; - } - /** * Gets brokerage * @@ -610,6 +579,37 @@ public function setMeta($meta) return $this; } + + /** + * Gets updated_date + * + * @return \DateTime|null + * @deprecated + */ + public function getUpdatedDate() + { + return $this->container['updated_date']; + } + + /** + * Sets updated_date + * + * @param \DateTime|null $updated_date Timestamp of when the connection was last updated in SnapTrade. This field is deprecated. Please let us know if you have a valid use case for this field. + * + * @return self + * @deprecated + */ + public function setUpdatedDate($updated_date) + { + + if (is_null($updated_date)) { + throw new \InvalidArgumentException('non-nullable updated_date cannot be null'); + } + + $this->container['updated_date'] = $updated_date; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/ManualTradeSymbol.php b/lib/Model/ManualTradeSymbol.php index a24a97e..b65f5f7 100644 --- a/lib/Model/ManualTradeSymbol.php +++ b/lib/Model/ManualTradeSymbol.php @@ -51,12 +51,12 @@ class ManualTradeSymbol implements ModelInterface, ArrayAccess, \JsonSerializabl * @var string[] */ protected static $openAPITypes = [ - 'brokerage_symbol_id' => 'string', 'universal_symbol_id' => 'string', 'currency' => '\SnapTrade\Model\Currency', 'local_id' => 'string', 'description' => 'string', - 'symbol' => 'string' + 'symbol' => 'string', + 'brokerage_symbol_id' => 'string' ]; /** @@ -67,12 +67,12 @@ class ManualTradeSymbol implements ModelInterface, ArrayAccess, \JsonSerializabl * @psalm-var array */ protected static $openAPIFormats = [ - 'brokerage_symbol_id' => 'uuid', 'universal_symbol_id' => 'uuid', 'currency' => null, 'local_id' => null, 'description' => null, - 'symbol' => null + 'symbol' => null, + 'brokerage_symbol_id' => 'uuid' ]; /** @@ -81,12 +81,12 @@ class ManualTradeSymbol implements ModelInterface, ArrayAccess, \JsonSerializabl * @var boolean[] */ protected static array $openAPINullables = [ - 'brokerage_symbol_id' => false, - 'universal_symbol_id' => false, + 'universal_symbol_id' => false, 'currency' => false, 'local_id' => false, 'description' => true, - 'symbol' => false + 'symbol' => false, + 'brokerage_symbol_id' => false ]; /** @@ -175,12 +175,12 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'brokerage_symbol_id' => 'brokerage_symbol_id', 'universal_symbol_id' => 'universal_symbol_id', 'currency' => 'currency', 'local_id' => 'local_id', 'description' => 'description', - 'symbol' => 'symbol' + 'symbol' => 'symbol', + 'brokerage_symbol_id' => 'brokerage_symbol_id' ]; /** @@ -189,12 +189,12 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'brokerage_symbol_id' => 'setBrokerageSymbolId', 'universal_symbol_id' => 'setUniversalSymbolId', 'currency' => 'setCurrency', 'local_id' => 'setLocalId', 'description' => 'setDescription', - 'symbol' => 'setSymbol' + 'symbol' => 'setSymbol', + 'brokerage_symbol_id' => 'setBrokerageSymbolId' ]; /** @@ -203,12 +203,12 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'brokerage_symbol_id' => 'getBrokerageSymbolId', 'universal_symbol_id' => 'getUniversalSymbolId', 'currency' => 'getCurrency', 'local_id' => 'getLocalId', 'description' => 'getDescription', - 'symbol' => 'getSymbol' + 'symbol' => 'getSymbol', + 'brokerage_symbol_id' => 'getBrokerageSymbolId' ]; /** @@ -268,12 +268,12 @@ public function getModelName() */ public function __construct(array $data = null) { - $this->setIfExists('brokerage_symbol_id', $data ?? [], null); $this->setIfExists('universal_symbol_id', $data ?? [], null); $this->setIfExists('currency', $data ?? [], null); $this->setIfExists('local_id', $data ?? [], null); $this->setIfExists('description', $data ?? [], null); $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('brokerage_symbol_id', $data ?? [], null); } /** @@ -318,37 +318,6 @@ public function valid() } - /** - * Gets brokerage_symbol_id - * - * @return string|null - * @deprecated - */ - public function getBrokerageSymbolId() - { - return $this->container['brokerage_symbol_id']; - } - - /** - * Sets brokerage_symbol_id - * - * @param string|null $brokerage_symbol_id A unique ID for the security within SnapTrade, scoped to the brokerage account that the security belongs to. This is a legacy field and should not be used. Do not rely on this being a stable ID as it can change. - * - * @return self - * @deprecated - */ - public function setBrokerageSymbolId($brokerage_symbol_id) - { - - if (is_null($brokerage_symbol_id)) { - throw new \InvalidArgumentException('non-nullable brokerage_symbol_id cannot be null'); - } - - $this->container['brokerage_symbol_id'] = $brokerage_symbol_id; - - return $this; - } - /** * Gets universal_symbol_id * @@ -506,6 +475,37 @@ public function setSymbol($symbol) return $this; } + + /** + * Gets brokerage_symbol_id + * + * @return string|null + * @deprecated + */ + public function getBrokerageSymbolId() + { + return $this->container['brokerage_symbol_id']; + } + + /** + * Sets brokerage_symbol_id + * + * @param string|null $brokerage_symbol_id A unique ID for the security within SnapTrade, scoped to the brokerage account that the security belongs to. This is a legacy field and should not be used. Do not rely on this being a stable ID as it can change. + * + * @return self + * @deprecated + */ + public function setBrokerageSymbolId($brokerage_symbol_id) + { + + if (is_null($brokerage_symbol_id)) { + throw new \InvalidArgumentException('non-nullable brokerage_symbol_id cannot be null'); + } + + $this->container['brokerage_symbol_id'] = $brokerage_symbol_id; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/OptionBrokerageSymbol.php b/lib/Model/OptionBrokerageSymbol.php index 088b2c5..f67813e 100644 --- a/lib/Model/OptionBrokerageSymbol.php +++ b/lib/Model/OptionBrokerageSymbol.php @@ -51,9 +51,9 @@ class OptionBrokerageSymbol implements ModelInterface, ArrayAccess, \JsonSeriali * @var string[] */ protected static $openAPITypes = [ + 'option_symbol' => '\SnapTrade\Model\OptionsSymbol', 'id' => 'string', - 'description' => 'string', - 'option_symbol' => '\SnapTrade\Model\OptionsSymbol' + 'description' => 'string' ]; /** @@ -64,9 +64,9 @@ class OptionBrokerageSymbol implements ModelInterface, ArrayAccess, \JsonSeriali * @psalm-var array */ protected static $openAPIFormats = [ + 'option_symbol' => null, 'id' => 'uuid', - 'description' => null, - 'option_symbol' => null + 'description' => null ]; /** @@ -75,9 +75,9 @@ class OptionBrokerageSymbol implements ModelInterface, ArrayAccess, \JsonSeriali * @var boolean[] */ protected static array $openAPINullables = [ - 'id' => false, - 'description' => false, - 'option_symbol' => false + 'option_symbol' => false, + 'id' => false, + 'description' => false ]; /** @@ -166,9 +166,9 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ + 'option_symbol' => 'option_symbol', 'id' => 'id', - 'description' => 'description', - 'option_symbol' => 'option_symbol' + 'description' => 'description' ]; /** @@ -177,9 +177,9 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ + 'option_symbol' => 'setOptionSymbol', 'id' => 'setId', - 'description' => 'setDescription', - 'option_symbol' => 'setOptionSymbol' + 'description' => 'setDescription' ]; /** @@ -188,9 +188,9 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ + 'option_symbol' => 'getOptionSymbol', 'id' => 'getId', - 'description' => 'getDescription', - 'option_symbol' => 'getOptionSymbol' + 'description' => 'getDescription' ]; /** @@ -250,9 +250,9 @@ public function getModelName() */ public function __construct(array $data = null) { + $this->setIfExists('option_symbol', $data ?? [], null); $this->setIfExists('id', $data ?? [], null); $this->setIfExists('description', $data ?? [], null); - $this->setIfExists('option_symbol', $data ?? [], null); } /** @@ -297,6 +297,35 @@ public function valid() } + /** + * Gets option_symbol + * + * @return \SnapTrade\Model\OptionsSymbol|null + */ + public function getOptionSymbol() + { + return $this->container['option_symbol']; + } + + /** + * Sets option_symbol + * + * @param \SnapTrade\Model\OptionsSymbol|null $option_symbol option_symbol + * + * @return self + */ + public function setOptionSymbol($option_symbol) + { + + if (is_null($option_symbol)) { + throw new \InvalidArgumentException('non-nullable option_symbol cannot be null'); + } + + $this->container['option_symbol'] = $option_symbol; + + return $this; + } + /** * Gets id * @@ -358,35 +387,6 @@ public function setDescription($description) return $this; } - - /** - * Gets option_symbol - * - * @return \SnapTrade\Model\OptionsSymbol|null - */ - public function getOptionSymbol() - { - return $this->container['option_symbol']; - } - - /** - * Sets option_symbol - * - * @param \SnapTrade\Model\OptionsSymbol|null $option_symbol option_symbol - * - * @return self - */ - public function setOptionSymbol($option_symbol) - { - - if (is_null($option_symbol)) { - throw new \InvalidArgumentException('non-nullable option_symbol cannot be null'); - } - - $this->container['option_symbol'] = $option_symbol; - - return $this; - } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/OptionsPosition.php b/lib/Model/OptionsPosition.php index 2c426e2..a3dc7d3 100644 --- a/lib/Model/OptionsPosition.php +++ b/lib/Model/OptionsPosition.php @@ -54,8 +54,8 @@ class OptionsPosition implements ModelInterface, ArrayAccess, \JsonSerializable 'symbol' => '\SnapTrade\Model\OptionBrokerageSymbol', 'price' => 'float', 'units' => 'float', - 'currency' => '\SnapTrade\Model\OptionsPositionCurrency', - 'average_purchase_price' => 'float' + 'average_purchase_price' => 'float', + 'currency' => '\SnapTrade\Model\OptionsPositionCurrency' ]; /** @@ -69,8 +69,8 @@ class OptionsPosition implements ModelInterface, ArrayAccess, \JsonSerializable 'symbol' => null, 'price' => null, 'units' => null, - 'currency' => null, - 'average_purchase_price' => null + 'average_purchase_price' => null, + 'currency' => null ]; /** @@ -82,8 +82,8 @@ class OptionsPosition implements ModelInterface, ArrayAccess, \JsonSerializable 'symbol' => false, 'price' => true, 'units' => false, - 'currency' => true, - 'average_purchase_price' => true + 'average_purchase_price' => true, + 'currency' => true ]; /** @@ -175,8 +175,8 @@ public function isNullableSetToNull(string $property): bool 'symbol' => 'symbol', 'price' => 'price', 'units' => 'units', - 'currency' => 'currency', - 'average_purchase_price' => 'average_purchase_price' + 'average_purchase_price' => 'average_purchase_price', + 'currency' => 'currency' ]; /** @@ -188,8 +188,8 @@ public function isNullableSetToNull(string $property): bool 'symbol' => 'setSymbol', 'price' => 'setPrice', 'units' => 'setUnits', - 'currency' => 'setCurrency', - 'average_purchase_price' => 'setAveragePurchasePrice' + 'average_purchase_price' => 'setAveragePurchasePrice', + 'currency' => 'setCurrency' ]; /** @@ -201,8 +201,8 @@ public function isNullableSetToNull(string $property): bool 'symbol' => 'getSymbol', 'price' => 'getPrice', 'units' => 'getUnits', - 'currency' => 'getCurrency', - 'average_purchase_price' => 'getAveragePurchasePrice' + 'average_purchase_price' => 'getAveragePurchasePrice', + 'currency' => 'getCurrency' ]; /** @@ -265,8 +265,8 @@ public function __construct(array $data = null) $this->setIfExists('symbol', $data ?? [], null); $this->setIfExists('price', $data ?? [], null); $this->setIfExists('units', $data ?? [], null); - $this->setIfExists('currency', $data ?? [], null); $this->setIfExists('average_purchase_price', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); } /** @@ -406,75 +406,75 @@ public function setUnits($units) } /** - * Gets currency + * Gets average_purchase_price * - * @return \SnapTrade\Model\OptionsPositionCurrency|null - * @deprecated + * @return float|null */ - public function getCurrency() + public function getAveragePurchasePrice() { - return $this->container['currency']; + return $this->container['average_purchase_price']; } /** - * Sets currency + * Sets average_purchase_price * - * @param \SnapTrade\Model\OptionsPositionCurrency|null $currency currency + * @param float|null $average_purchase_price Cost basis _per contract_ of this option position. To get the cost basis _per share_, divide this value by the number of shares per contract (usually 100). * * @return self - * @deprecated */ - public function setCurrency($currency) + public function setAveragePurchasePrice($average_purchase_price) { - if (is_null($currency)) { - array_push($this->openAPINullablesSetToNull, 'currency'); + if (is_null($average_purchase_price)) { + array_push($this->openAPINullablesSetToNull, 'average_purchase_price'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('currency', $nullablesSetToNull); + $index = array_search('average_purchase_price', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } - $this->container['currency'] = $currency; + $this->container['average_purchase_price'] = $average_purchase_price; return $this; } /** - * Gets average_purchase_price + * Gets currency * - * @return float|null + * @return \SnapTrade\Model\OptionsPositionCurrency|null + * @deprecated */ - public function getAveragePurchasePrice() + public function getCurrency() { - return $this->container['average_purchase_price']; + return $this->container['currency']; } /** - * Sets average_purchase_price + * Sets currency * - * @param float|null $average_purchase_price Cost basis _per contract_ of this option position. To get the cost basis _per share_, divide this value by the number of shares per contract (usually 100). + * @param \SnapTrade\Model\OptionsPositionCurrency|null $currency currency * * @return self + * @deprecated */ - public function setAveragePurchasePrice($average_purchase_price) + public function setCurrency($currency) { - if (is_null($average_purchase_price)) { - array_push($this->openAPINullablesSetToNull, 'average_purchase_price'); + if (is_null($currency)) { + array_push($this->openAPINullablesSetToNull, 'currency'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('average_purchase_price', $nullablesSetToNull); + $index = array_search('currency', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } - $this->container['average_purchase_price'] = $average_purchase_price; + $this->container['currency'] = $currency; return $this; } diff --git a/lib/Model/Position.php b/lib/Model/Position.php index 8cad4a2..b7363c5 100644 --- a/lib/Model/Position.php +++ b/lib/Model/Position.php @@ -55,8 +55,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'units' => 'float', 'price' => 'float', 'open_pnl' => 'float', - 'fractional_units' => 'float', - 'average_purchase_price' => 'float' + 'average_purchase_price' => 'float', + 'fractional_units' => 'float' ]; /** @@ -71,8 +71,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'units' => null, 'price' => null, 'open_pnl' => null, - 'fractional_units' => null, - 'average_purchase_price' => null + 'average_purchase_price' => null, + 'fractional_units' => null ]; /** @@ -85,8 +85,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'units' => true, 'price' => true, 'open_pnl' => true, - 'fractional_units' => true, - 'average_purchase_price' => true + 'average_purchase_price' => true, + 'fractional_units' => true ]; /** @@ -179,8 +179,8 @@ public function isNullableSetToNull(string $property): bool 'units' => 'units', 'price' => 'price', 'open_pnl' => 'open_pnl', - 'fractional_units' => 'fractional_units', - 'average_purchase_price' => 'average_purchase_price' + 'average_purchase_price' => 'average_purchase_price', + 'fractional_units' => 'fractional_units' ]; /** @@ -193,8 +193,8 @@ public function isNullableSetToNull(string $property): bool 'units' => 'setUnits', 'price' => 'setPrice', 'open_pnl' => 'setOpenPnl', - 'fractional_units' => 'setFractionalUnits', - 'average_purchase_price' => 'setAveragePurchasePrice' + 'average_purchase_price' => 'setAveragePurchasePrice', + 'fractional_units' => 'setFractionalUnits' ]; /** @@ -207,8 +207,8 @@ public function isNullableSetToNull(string $property): bool 'units' => 'getUnits', 'price' => 'getPrice', 'open_pnl' => 'getOpenPnl', - 'fractional_units' => 'getFractionalUnits', - 'average_purchase_price' => 'getAveragePurchasePrice' + 'average_purchase_price' => 'getAveragePurchasePrice', + 'fractional_units' => 'getFractionalUnits' ]; /** @@ -272,8 +272,8 @@ public function __construct(array $data = null) $this->setIfExists('units', $data ?? [], null); $this->setIfExists('price', $data ?? [], null); $this->setIfExists('open_pnl', $data ?? [], null); - $this->setIfExists('fractional_units', $data ?? [], null); $this->setIfExists('average_purchase_price', $data ?? [], null); + $this->setIfExists('fractional_units', $data ?? [], null); } /** @@ -456,75 +456,75 @@ public function setOpenPnl($open_pnl) } /** - * Gets fractional_units + * Gets average_purchase_price * * @return float|null - * @deprecated */ - public function getFractionalUnits() + public function getAveragePurchasePrice() { - return $this->container['fractional_units']; + return $this->container['average_purchase_price']; } /** - * Sets fractional_units + * Sets average_purchase_price * - * @param float|null $fractional_units Deprecated, use the `units` field for both fractional and integer units going forward + * @param float|null $average_purchase_price Cost basis _per share_ of this position. * * @return self - * @deprecated */ - public function setFractionalUnits($fractional_units) + public function setAveragePurchasePrice($average_purchase_price) { - if (is_null($fractional_units)) { - array_push($this->openAPINullablesSetToNull, 'fractional_units'); + if (is_null($average_purchase_price)) { + array_push($this->openAPINullablesSetToNull, 'average_purchase_price'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('fractional_units', $nullablesSetToNull); + $index = array_search('average_purchase_price', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } - $this->container['fractional_units'] = $fractional_units; + $this->container['average_purchase_price'] = $average_purchase_price; return $this; } /** - * Gets average_purchase_price + * Gets fractional_units * * @return float|null + * @deprecated */ - public function getAveragePurchasePrice() + public function getFractionalUnits() { - return $this->container['average_purchase_price']; + return $this->container['fractional_units']; } /** - * Sets average_purchase_price + * Sets fractional_units * - * @param float|null $average_purchase_price Cost basis _per share_ of this position. + * @param float|null $fractional_units Deprecated, use the `units` field for both fractional and integer units going forward * * @return self + * @deprecated */ - public function setAveragePurchasePrice($average_purchase_price) + public function setFractionalUnits($fractional_units) { - if (is_null($average_purchase_price)) { - array_push($this->openAPINullablesSetToNull, 'average_purchase_price'); + if (is_null($fractional_units)) { + array_push($this->openAPINullablesSetToNull, 'fractional_units'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('average_purchase_price', $nullablesSetToNull); + $index = array_search('fractional_units', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } - $this->container['average_purchase_price'] = $average_purchase_price; + $this->container['fractional_units'] = $fractional_units; return $this; } diff --git a/lib/Model/PositionSymbol.php b/lib/Model/PositionSymbol.php index 489266f..d442d95 100644 --- a/lib/Model/PositionSymbol.php +++ b/lib/Model/PositionSymbol.php @@ -51,9 +51,9 @@ class PositionSymbol implements ModelInterface, ArrayAccess, \JsonSerializable * @var string[] */ protected static $openAPITypes = [ + 'symbol' => '\SnapTrade\Model\UniversalSymbol', 'id' => 'string', 'description' => 'string', - 'symbol' => '\SnapTrade\Model\UniversalSymbol', 'local_id' => 'string', 'is_quotable' => 'bool', 'is_tradable' => 'bool' @@ -67,9 +67,9 @@ class PositionSymbol implements ModelInterface, ArrayAccess, \JsonSerializable * @psalm-var array */ protected static $openAPIFormats = [ + 'symbol' => null, 'id' => 'uuid', 'description' => null, - 'symbol' => null, 'local_id' => null, 'is_quotable' => null, 'is_tradable' => null @@ -81,9 +81,9 @@ class PositionSymbol implements ModelInterface, ArrayAccess, \JsonSerializable * @var boolean[] */ protected static array $openAPINullables = [ - 'id' => false, + 'symbol' => false, + 'id' => false, 'description' => false, - 'symbol' => false, 'local_id' => true, 'is_quotable' => false, 'is_tradable' => false @@ -175,9 +175,9 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ + 'symbol' => 'symbol', 'id' => 'id', 'description' => 'description', - 'symbol' => 'symbol', 'local_id' => 'local_id', 'is_quotable' => 'is_quotable', 'is_tradable' => 'is_tradable' @@ -189,9 +189,9 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ + 'symbol' => 'setSymbol', 'id' => 'setId', 'description' => 'setDescription', - 'symbol' => 'setSymbol', 'local_id' => 'setLocalId', 'is_quotable' => 'setIsQuotable', 'is_tradable' => 'setIsTradable' @@ -203,9 +203,9 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ + 'symbol' => 'getSymbol', 'id' => 'getId', 'description' => 'getDescription', - 'symbol' => 'getSymbol', 'local_id' => 'getLocalId', 'is_quotable' => 'getIsQuotable', 'is_tradable' => 'getIsTradable' @@ -268,9 +268,9 @@ public function getModelName() */ public function __construct(array $data = null) { + $this->setIfExists('symbol', $data ?? [], null); $this->setIfExists('id', $data ?? [], null); $this->setIfExists('description', $data ?? [], null); - $this->setIfExists('symbol', $data ?? [], null); $this->setIfExists('local_id', $data ?? [], null); $this->setIfExists('is_quotable', $data ?? [], null); $this->setIfExists('is_tradable', $data ?? [], null); @@ -318,6 +318,35 @@ public function valid() } + /** + * Gets symbol + * + * @return \SnapTrade\Model\UniversalSymbol|null + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param \SnapTrade\Model\UniversalSymbol|null $symbol symbol + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + /** * Gets id * @@ -380,35 +409,6 @@ public function setDescription($description) return $this; } - /** - * Gets symbol - * - * @return \SnapTrade\Model\UniversalSymbol|null - */ - public function getSymbol() - { - return $this->container['symbol']; - } - - /** - * Sets symbol - * - * @param \SnapTrade\Model\UniversalSymbol|null $symbol symbol - * - * @return self - */ - public function setSymbol($symbol) - { - - if (is_null($symbol)) { - throw new \InvalidArgumentException('non-nullable symbol cannot be null'); - } - - $this->container['symbol'] = $symbol; - - return $this; - } - /** * Gets local_id * diff --git a/lib/Model/UnderlyingSymbol.php b/lib/Model/UnderlyingSymbol.php index 837857a..76a8fae 100644 --- a/lib/Model/UnderlyingSymbol.php +++ b/lib/Model/UnderlyingSymbol.php @@ -58,9 +58,9 @@ class UnderlyingSymbol implements ModelInterface, ArrayAccess, \JsonSerializable 'currency' => '\SnapTrade\Model\SymbolCurrency', 'exchange' => '\SnapTrade\Model\UnderlyingSymbolExchange', 'type' => '\SnapTrade\Model\UnderlyingSymbolType', - 'currencies' => '\SnapTrade\Model\Currency[]', 'figi_code' => 'string', - 'figi_instrument' => '\SnapTrade\Model\SymbolFigiInstrument' + 'figi_instrument' => '\SnapTrade\Model\SymbolFigiInstrument', + 'currencies' => '\SnapTrade\Model\Currency[]' ]; /** @@ -78,9 +78,9 @@ class UnderlyingSymbol implements ModelInterface, ArrayAccess, \JsonSerializable 'currency' => null, 'exchange' => null, 'type' => null, - 'currencies' => null, 'figi_code' => null, - 'figi_instrument' => null + 'figi_instrument' => null, + 'currencies' => null ]; /** @@ -96,9 +96,9 @@ class UnderlyingSymbol implements ModelInterface, ArrayAccess, \JsonSerializable 'currency' => false, 'exchange' => false, 'type' => false, - 'currencies' => false, 'figi_code' => true, - 'figi_instrument' => true + 'figi_instrument' => true, + 'currencies' => false ]; /** @@ -194,9 +194,9 @@ public function isNullableSetToNull(string $property): bool 'currency' => 'currency', 'exchange' => 'exchange', 'type' => 'type', - 'currencies' => 'currencies', 'figi_code' => 'figi_code', - 'figi_instrument' => 'figi_instrument' + 'figi_instrument' => 'figi_instrument', + 'currencies' => 'currencies' ]; /** @@ -212,9 +212,9 @@ public function isNullableSetToNull(string $property): bool 'currency' => 'setCurrency', 'exchange' => 'setExchange', 'type' => 'setType', - 'currencies' => 'setCurrencies', 'figi_code' => 'setFigiCode', - 'figi_instrument' => 'setFigiInstrument' + 'figi_instrument' => 'setFigiInstrument', + 'currencies' => 'setCurrencies' ]; /** @@ -230,9 +230,9 @@ public function isNullableSetToNull(string $property): bool 'currency' => 'getCurrency', 'exchange' => 'getExchange', 'type' => 'getType', - 'currencies' => 'getCurrencies', 'figi_code' => 'getFigiCode', - 'figi_instrument' => 'getFigiInstrument' + 'figi_instrument' => 'getFigiInstrument', + 'currencies' => 'getCurrencies' ]; /** @@ -299,9 +299,9 @@ public function __construct(array $data = null) $this->setIfExists('currency', $data ?? [], null); $this->setIfExists('exchange', $data ?? [], null); $this->setIfExists('type', $data ?? [], null); - $this->setIfExists('currencies', $data ?? [], null); $this->setIfExists('figi_code', $data ?? [], null); $this->setIfExists('figi_instrument', $data ?? [], null); + $this->setIfExists('currencies', $data ?? [], null); } /** @@ -556,37 +556,6 @@ public function setType($type) return $this; } - /** - * Gets currencies - * - * @return \SnapTrade\Model\Currency[]|null - * @deprecated - */ - public function getCurrencies() - { - return $this->container['currencies']; - } - - /** - * Sets currencies - * - * @param \SnapTrade\Model\Currency[]|null $currencies This field is deprecated and should not be used. Please reach out to SnapTrade support if you have a valid usecase for this. - * - * @return self - * @deprecated - */ - public function setCurrencies($currencies) - { - - if (is_null($currencies)) { - throw new \InvalidArgumentException('non-nullable currencies cannot be null'); - } - - $this->container['currencies'] = $currencies; - - return $this; - } - /** * Gets figi_code * @@ -658,6 +627,37 @@ public function setFigiInstrument($figi_instrument) return $this; } + + /** + * Gets currencies + * + * @return \SnapTrade\Model\Currency[]|null + * @deprecated + */ + public function getCurrencies() + { + return $this->container['currencies']; + } + + /** + * Sets currencies + * + * @param \SnapTrade\Model\Currency[]|null $currencies This field is deprecated and should not be used. Please reach out to SnapTrade support if you have a valid usecase for this. + * + * @return self + * @deprecated + */ + public function setCurrencies($currencies) + { + + if (is_null($currencies)) { + throw new \InvalidArgumentException('non-nullable currencies cannot be null'); + } + + $this->container['currencies'] = $currencies; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/UniversalActivity.php b/lib/Model/UniversalActivity.php index e19b4ae..66d1993 100644 --- a/lib/Model/UniversalActivity.php +++ b/lib/Model/UniversalActivity.php @@ -661,7 +661,7 @@ public function getType() /** * Sets type * - * @param string|null $type A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. + * @param string|null $type A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. `option_symbol` contains the related option contract info. - `OPTIONASSIGNMENT` - Option assignment event. `option_symbol` contains the related option contract info. - `OPTIONEXERCISE` - Option exercise event. `option_symbol` contains the related option contract info. * * @return self */ diff --git a/lib/Model/UniversalSymbol.php b/lib/Model/UniversalSymbol.php index bc3059f..c6acdcd 100644 --- a/lib/Model/UniversalSymbol.php +++ b/lib/Model/UniversalSymbol.php @@ -58,9 +58,9 @@ class UniversalSymbol implements ModelInterface, ArrayAccess, \JsonSerializable 'currency' => '\SnapTrade\Model\SymbolCurrency', 'exchange' => '\SnapTrade\Model\SymbolExchange', 'type' => '\SnapTrade\Model\SecurityType', - 'currencies' => '\SnapTrade\Model\Currency[]', 'figi_code' => 'string', - 'figi_instrument' => '\SnapTrade\Model\SymbolFigiInstrument' + 'figi_instrument' => '\SnapTrade\Model\SymbolFigiInstrument', + 'currencies' => '\SnapTrade\Model\Currency[]' ]; /** @@ -78,9 +78,9 @@ class UniversalSymbol implements ModelInterface, ArrayAccess, \JsonSerializable 'currency' => null, 'exchange' => null, 'type' => null, - 'currencies' => null, 'figi_code' => null, - 'figi_instrument' => null + 'figi_instrument' => null, + 'currencies' => null ]; /** @@ -96,9 +96,9 @@ class UniversalSymbol implements ModelInterface, ArrayAccess, \JsonSerializable 'currency' => false, 'exchange' => false, 'type' => false, - 'currencies' => false, 'figi_code' => true, - 'figi_instrument' => true + 'figi_instrument' => true, + 'currencies' => false ]; /** @@ -194,9 +194,9 @@ public function isNullableSetToNull(string $property): bool 'currency' => 'currency', 'exchange' => 'exchange', 'type' => 'type', - 'currencies' => 'currencies', 'figi_code' => 'figi_code', - 'figi_instrument' => 'figi_instrument' + 'figi_instrument' => 'figi_instrument', + 'currencies' => 'currencies' ]; /** @@ -212,9 +212,9 @@ public function isNullableSetToNull(string $property): bool 'currency' => 'setCurrency', 'exchange' => 'setExchange', 'type' => 'setType', - 'currencies' => 'setCurrencies', 'figi_code' => 'setFigiCode', - 'figi_instrument' => 'setFigiInstrument' + 'figi_instrument' => 'setFigiInstrument', + 'currencies' => 'setCurrencies' ]; /** @@ -230,9 +230,9 @@ public function isNullableSetToNull(string $property): bool 'currency' => 'getCurrency', 'exchange' => 'getExchange', 'type' => 'getType', - 'currencies' => 'getCurrencies', 'figi_code' => 'getFigiCode', - 'figi_instrument' => 'getFigiInstrument' + 'figi_instrument' => 'getFigiInstrument', + 'currencies' => 'getCurrencies' ]; /** @@ -299,9 +299,9 @@ public function __construct(array $data = null) $this->setIfExists('currency', $data ?? [], null); $this->setIfExists('exchange', $data ?? [], null); $this->setIfExists('type', $data ?? [], null); - $this->setIfExists('currencies', $data ?? [], null); $this->setIfExists('figi_code', $data ?? [], null); $this->setIfExists('figi_instrument', $data ?? [], null); + $this->setIfExists('currencies', $data ?? [], null); } /** @@ -574,37 +574,6 @@ public function setType($type) return $this; } - /** - * Gets currencies - * - * @return \SnapTrade\Model\Currency[] - * @deprecated - */ - public function getCurrencies() - { - return $this->container['currencies']; - } - - /** - * Sets currencies - * - * @param \SnapTrade\Model\Currency[] $currencies This field is deprecated and should not be used. Please reach out to SnapTrade support if you have a valid usecase for this. - * - * @return self - * @deprecated - */ - public function setCurrencies($currencies) - { - - if (is_null($currencies)) { - throw new \InvalidArgumentException('non-nullable currencies cannot be null'); - } - - $this->container['currencies'] = $currencies; - - return $this; - } - /** * Gets figi_code * @@ -676,6 +645,37 @@ public function setFigiInstrument($figi_instrument) return $this; } + + /** + * Gets currencies + * + * @return \SnapTrade\Model\Currency[] + * @deprecated + */ + public function getCurrencies() + { + return $this->container['currencies']; + } + + /** + * Sets currencies + * + * @param \SnapTrade\Model\Currency[] $currencies This field is deprecated and should not be used. Please reach out to SnapTrade support if you have a valid usecase for this. + * + * @return self + * @deprecated + */ + public function setCurrencies($currencies) + { + + if (is_null($currencies)) { + throw new \InvalidArgumentException('non-nullable currencies cannot be null'); + } + + $this->container['currencies'] = $currencies; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/test/Model/AccountOrderRecordTest.php b/test/Model/AccountOrderRecordTest.php index 4ac726e..a4ee46e 100644 --- a/test/Model/AccountOrderRecordTest.php +++ b/test/Model/AccountOrderRecordTest.php @@ -90,15 +90,6 @@ public function testPropertyStatus() $this->markTestIncomplete('Not implemented'); } - /** - * Test attribute "symbol" - */ - public function testPropertySymbol() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test attribute "universal_symbol" */ @@ -242,4 +233,13 @@ public function testPropertyExpiryDate() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } diff --git a/test/Model/AccountOrderRecordUniversalSymbolTest.php b/test/Model/AccountOrderRecordUniversalSymbolTest.php index 6c4439a..1b306ba 100644 --- a/test/Model/AccountOrderRecordUniversalSymbolTest.php +++ b/test/Model/AccountOrderRecordUniversalSymbolTest.php @@ -136,27 +136,27 @@ public function testPropertyType() } /** - * Test attribute "currencies" + * Test attribute "figi_code" */ - public function testPropertyCurrencies() + public function testPropertyFigiCode() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "figi_code" + * Test attribute "figi_instrument" */ - public function testPropertyFigiCode() + public function testPropertyFigiInstrument() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "figi_instrument" + * Test attribute "currencies" */ - public function testPropertyFigiInstrument() + public function testPropertyCurrencies() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/BrokerageAuthorizationTest.php b/test/Model/BrokerageAuthorizationTest.php index d54de0a..e89150e 100644 --- a/test/Model/BrokerageAuthorizationTest.php +++ b/test/Model/BrokerageAuthorizationTest.php @@ -90,15 +90,6 @@ public function testPropertyCreatedDate() $this->markTestIncomplete('Not implemented'); } - /** - * Test attribute "updated_date" - */ - public function testPropertyUpdatedDate() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test attribute "brokerage" */ @@ -152,4 +143,13 @@ public function testPropertyMeta() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "updated_date" + */ + public function testPropertyUpdatedDate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } diff --git a/test/Model/BrokerageTest.php b/test/Model/BrokerageTest.php index 662e69f..9673909 100644 --- a/test/Model/BrokerageTest.php +++ b/test/Model/BrokerageTest.php @@ -135,15 +135,6 @@ public function testPropertyAwsS3SquareLogoUrl() $this->markTestIncomplete('Not implemented'); } - /** - * Test attribute "open_url" - */ - public function testPropertyOpenUrl() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test attribute "url" */ @@ -172,18 +163,18 @@ public function testPropertyMaintenanceMode() } /** - * Test attribute "allows_fractional_units" + * Test attribute "allows_trading" */ - public function testPropertyAllowsFractionalUnits() + public function testPropertyAllowsTrading() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "allows_trading" + * Test attribute "allows_fractional_units" */ - public function testPropertyAllowsTrading() + public function testPropertyAllowsFractionalUnits() { // TODO: implement $this->markTestIncomplete('Not implemented'); @@ -224,4 +215,13 @@ public function testPropertyExchanges() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "open_url" + */ + public function testPropertyOpenUrl() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } diff --git a/test/Model/ManualTradeSymbolTest.php b/test/Model/ManualTradeSymbolTest.php index a79811a..f3dff82 100644 --- a/test/Model/ManualTradeSymbolTest.php +++ b/test/Model/ManualTradeSymbolTest.php @@ -72,15 +72,6 @@ public function testManualTradeSymbol() $this->markTestIncomplete('Not implemented'); } - /** - * Test attribute "brokerage_symbol_id" - */ - public function testPropertyBrokerageSymbolId() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test attribute "universal_symbol_id" */ @@ -125,4 +116,13 @@ public function testPropertySymbol() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "brokerage_symbol_id" + */ + public function testPropertyBrokerageSymbolId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } diff --git a/test/Model/OptionBrokerageSymbolTest.php b/test/Model/OptionBrokerageSymbolTest.php index 21f94dc..9ee6515 100644 --- a/test/Model/OptionBrokerageSymbolTest.php +++ b/test/Model/OptionBrokerageSymbolTest.php @@ -73,27 +73,27 @@ public function testOptionBrokerageSymbol() } /** - * Test attribute "id" + * Test attribute "option_symbol" */ - public function testPropertyId() + public function testPropertyOptionSymbol() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "description" + * Test attribute "id" */ - public function testPropertyDescription() + public function testPropertyId() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "option_symbol" + * Test attribute "description" */ - public function testPropertyOptionSymbol() + public function testPropertyDescription() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/OptionsPositionTest.php b/test/Model/OptionsPositionTest.php index 2dc874e..76123bc 100644 --- a/test/Model/OptionsPositionTest.php +++ b/test/Model/OptionsPositionTest.php @@ -100,18 +100,18 @@ public function testPropertyUnits() } /** - * Test attribute "currency" + * Test attribute "average_purchase_price" */ - public function testPropertyCurrency() + public function testPropertyAveragePurchasePrice() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "average_purchase_price" + * Test attribute "currency" */ - public function testPropertyAveragePurchasePrice() + public function testPropertyCurrency() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/PositionSymbolTest.php b/test/Model/PositionSymbolTest.php index 1a07d95..cda6e76 100644 --- a/test/Model/PositionSymbolTest.php +++ b/test/Model/PositionSymbolTest.php @@ -73,27 +73,27 @@ public function testPositionSymbol() } /** - * Test attribute "id" + * Test attribute "symbol" */ - public function testPropertyId() + public function testPropertySymbol() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "description" + * Test attribute "id" */ - public function testPropertyDescription() + public function testPropertyId() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "symbol" + * Test attribute "description" */ - public function testPropertySymbol() + public function testPropertyDescription() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/PositionTest.php b/test/Model/PositionTest.php index fad4e7f..535a56f 100644 --- a/test/Model/PositionTest.php +++ b/test/Model/PositionTest.php @@ -109,18 +109,18 @@ public function testPropertyOpenPnl() } /** - * Test attribute "fractional_units" + * Test attribute "average_purchase_price" */ - public function testPropertyFractionalUnits() + public function testPropertyAveragePurchasePrice() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "average_purchase_price" + * Test attribute "fractional_units" */ - public function testPropertyAveragePurchasePrice() + public function testPropertyFractionalUnits() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/UnderlyingSymbolTest.php b/test/Model/UnderlyingSymbolTest.php index 1e18600..eb63c9f 100644 --- a/test/Model/UnderlyingSymbolTest.php +++ b/test/Model/UnderlyingSymbolTest.php @@ -136,27 +136,27 @@ public function testPropertyType() } /** - * Test attribute "currencies" + * Test attribute "figi_code" */ - public function testPropertyCurrencies() + public function testPropertyFigiCode() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "figi_code" + * Test attribute "figi_instrument" */ - public function testPropertyFigiCode() + public function testPropertyFigiInstrument() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "figi_instrument" + * Test attribute "currencies" */ - public function testPropertyFigiInstrument() + public function testPropertyCurrencies() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/UniversalSymbolTest.php b/test/Model/UniversalSymbolTest.php index f8b424f..052756f 100644 --- a/test/Model/UniversalSymbolTest.php +++ b/test/Model/UniversalSymbolTest.php @@ -136,27 +136,27 @@ public function testPropertyType() } /** - * Test attribute "currencies" + * Test attribute "figi_code" */ - public function testPropertyCurrencies() + public function testPropertyFigiCode() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "figi_code" + * Test attribute "figi_instrument" */ - public function testPropertyFigiCode() + public function testPropertyFigiInstrument() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "figi_instrument" + * Test attribute "currencies" */ - public function testPropertyFigiInstrument() + public function testPropertyCurrencies() { // TODO: implement $this->markTestIncomplete('Not implemented'); From a23bcd7faff1a05f494cb432c39acd127de274ec Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:49:42 +0000 Subject: [PATCH 022/252] Version Bump SDKs (#34) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b816d4c..9ba9864 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -6642171d-955a-4c0d-b6c9-327622a62fde \ No newline at end of file +d3527dc1-6737-4025-ae6a-140887818d7f \ No newline at end of file diff --git a/README.md b/README.md index 4fc4ad4..a363d8e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.46-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.47-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.46" + "konfig/snaptrade-php-sdk": "2.0.47" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index b0d3315..a4cb03f 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.46/PHP'; + protected $userAgent = 'Konfig/2.0.47/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.46' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.47' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 96a6a0ce0ca5970a1830892cdcf040349cb82805 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:07:39 +0000 Subject: [PATCH 023/252] Regenerate SDKs (#35) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Model/SnapTradeLoginUserRequestBody.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 9ba9864..0a7b94d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d3527dc1-6737-4025-ae6a-140887818d7f \ No newline at end of file +ac25c38f-f51b-452b-940d-79d2954cfcbc \ No newline at end of file diff --git a/README.md b/README.md index a363d8e..5fa57e8 100644 --- a/README.md +++ b/README.md @@ -582,7 +582,7 @@ The UUID of the brokerage connection to be reconnected. This parameter should be ##### connectionType: `string` -Sets whether the connection should be read-only or trade-enabled. +Sets whether the connection should be read-only or trade-enabled. Defaults to read-only if not specified. ##### connectionPortalVersion: `string` diff --git a/lib/Model/SnapTradeLoginUserRequestBody.php b/lib/Model/SnapTradeLoginUserRequestBody.php index ff5099f..c3bc55c 100644 --- a/lib/Model/SnapTradeLoginUserRequestBody.php +++ b/lib/Model/SnapTradeLoginUserRequestBody.php @@ -497,7 +497,7 @@ public function getConnectionType() /** * Sets connection_type * - * @param string|null $connection_type Sets whether the connection should be read-only or trade-enabled. + * @param string|null $connection_type Sets whether the connection should be read-only or trade-enabled. Defaults to read-only if not specified. * * @return self */ From 9ad5688bef99175b4e4aeed9c4bb106adb3d733e Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:11:12 +0000 Subject: [PATCH 024/252] Version Bump SDKs (#36) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0a7b94d..444e6df 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ac25c38f-f51b-452b-940d-79d2954cfcbc \ No newline at end of file +4a341084-83f7-4854-a5c4-e7dda9f61d74 \ No newline at end of file diff --git a/README.md b/README.md index 5fa57e8..1f18837 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.47-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.48-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.47" + "konfig/snaptrade-php-sdk": "2.0.48" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index a4cb03f..1981978 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.47/PHP'; + protected $userAgent = 'Konfig/2.0.48/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.47' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.48' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 99fa4408d1aeee86ffd95a7fe69ed47eebb27caf Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:34:17 +0000 Subject: [PATCH 025/252] Regenerate SDKs (#37) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- lib/Model/TransactionsStatus.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 444e6df..6bc44c2 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -4a341084-83f7-4854-a5c4-e7dda9f61d74 \ No newline at end of file +041a8f87-caa8-47ab-a98d-960ef4490927 \ No newline at end of file diff --git a/lib/Model/TransactionsStatus.php b/lib/Model/TransactionsStatus.php index 3452dc5..f63019d 100644 --- a/lib/Model/TransactionsStatus.php +++ b/lib/Model/TransactionsStatus.php @@ -77,7 +77,7 @@ class TransactionsStatus implements ModelInterface, ArrayAccess, \JsonSerializab protected static array $openAPINullables = [ 'initial_sync_completed' => false, 'last_successful_sync' => true, - 'first_transaction_date' => false + 'first_transaction_date' => true ]; /** @@ -383,7 +383,14 @@ public function setFirstTransactionDate($first_transaction_date) { if (is_null($first_transaction_date)) { - throw new \InvalidArgumentException('non-nullable first_transaction_date cannot be null'); + array_push($this->openAPINullablesSetToNull, 'first_transaction_date'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('first_transaction_date', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } } $this->container['first_transaction_date'] = $first_transaction_date; From 9b8de53024536dbecfde6c1b54f9c80090a4ced6 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:38:06 +0000 Subject: [PATCH 026/252] Version Bump SDKs (#38) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 6bc44c2..2bfba48 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -041a8f87-caa8-47ab-a98d-960ef4490927 \ No newline at end of file +e43bfb3c-3dc6-4b4c-b811-9fdc17f3b7cb \ No newline at end of file diff --git a/README.md b/README.md index 1f18837..9d3e43c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.48-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.49-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.48" + "konfig/snaptrade-php-sdk": "2.0.49" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 1981978..cf63942 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.48/PHP'; + protected $userAgent = 'Konfig/2.0.49/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.48' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.49' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 12fb123a7d00efb4fe02a0c84a747de86a33f563 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 01:16:59 +0000 Subject: [PATCH 027/252] Regenerate SDKs (#39) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Api/AuthenticationApi.php | 4 ++-- lib/Model/SnapTradeLoginUserRequestBody.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 2bfba48..eab2ad2 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -e43bfb3c-3dc6-4b4c-b811-9fdc17f3b7cb \ No newline at end of file +2e9d1349-545a-4fa9-857b-2881fdd356eb \ No newline at end of file diff --git a/README.md b/README.md index 9d3e43c..0846052 100644 --- a/README.md +++ b/README.md @@ -554,7 +554,7 @@ $result = $snaptrade->authentication->loginSnapTradeUser( custom_redirect: "https://snaptrade.com", reconnect: "8b5f262d-4bb9-365d-888a-202bd3b15fa1", connection_type: "read", - connection_portal_version: "v3" + connection_portal_version: "v4" ); ``` @@ -586,7 +586,7 @@ Sets whether the connection should be read-only or trade-enabled. Defaults to re ##### connectionPortalVersion: `string` -Sets the version of the connection portal to render. +Sets the connection portal version to render. Currently only v4 is supported and is the default. All other versions are deprecated and will automatically be set to v4. #### πŸ”„ Return diff --git a/lib/Api/AuthenticationApi.php b/lib/Api/AuthenticationApi.php index 2690d7a..fe6017d 100644 --- a/lib/Api/AuthenticationApi.php +++ b/lib/Api/AuthenticationApi.php @@ -976,7 +976,7 @@ public function loginSnapTradeUser( $custom_redirect = SENTINEL_VALUE, $reconnect = SENTINEL_VALUE, $connection_type = 'read', - $connection_portal_version = 'v3', + $connection_portal_version = 'v4', string $contentType = self::contentTypes['loginSnapTradeUser'][0] ) @@ -1207,7 +1207,7 @@ public function loginSnapTradeUserAsync( $custom_redirect = SENTINEL_VALUE, $reconnect = SENTINEL_VALUE, $connection_type = 'read', - $connection_portal_version = 'v3', + $connection_portal_version = 'v4', string $contentType = self::contentTypes['loginSnapTradeUser'][0] ) diff --git a/lib/Model/SnapTradeLoginUserRequestBody.php b/lib/Model/SnapTradeLoginUserRequestBody.php index c3bc55c..2d856dd 100644 --- a/lib/Model/SnapTradeLoginUserRequestBody.php +++ b/lib/Model/SnapTradeLoginUserRequestBody.php @@ -305,7 +305,7 @@ public function __construct(array $data = null) $this->setIfExists('custom_redirect', $data ?? [], null); $this->setIfExists('reconnect', $data ?? [], null); $this->setIfExists('connection_type', $data ?? [], 'read'); - $this->setIfExists('connection_portal_version', $data ?? [], 'v3'); + $this->setIfExists('connection_portal_version', $data ?? [], 'v4'); } /** @@ -536,7 +536,7 @@ public function getConnectionPortalVersion() /** * Sets connection_portal_version * - * @param string|null $connection_portal_version Sets the version of the connection portal to render. + * @param string|null $connection_portal_version Sets the connection portal version to render. Currently only v4 is supported and is the default. All other versions are deprecated and will automatically be set to v4. * * @return self */ From 579b48dcb5be050b94280ee23521c97d3bc1af4e Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 01:20:28 +0000 Subject: [PATCH 028/252] Version Bump SDKs (#40) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index eab2ad2..e08ad6e 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2e9d1349-545a-4fa9-857b-2881fdd356eb \ No newline at end of file +2841e2b5-649f-4790-bdb0-d737222f5ff7 \ No newline at end of file diff --git a/README.md b/README.md index 0846052..d49d388 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.49-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.50-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.49" + "konfig/snaptrade-php-sdk": "2.0.50" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index cf63942..1be5263 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.49/PHP'; + protected $userAgent = 'Konfig/2.0.50/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.49' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.50' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From dac5edcf2f553a6b2796bc5ced4da12da922fba2 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:07:21 +0000 Subject: [PATCH 029/252] Regenerate SDKs (#41) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- lib/Api/AccountInformationApi.php | 54 ++- lib/Model/Model425FailedRequestResponse.php | 455 ++++++++++++++++++ .../Model425FailedRequestResponseTest.php | 92 ++++ 4 files changed, 598 insertions(+), 5 deletions(-) create mode 100644 lib/Model/Model425FailedRequestResponse.php create mode 100644 test/Model/Model425FailedRequestResponseTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index e08ad6e..563c82d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2841e2b5-649f-4790-bdb0-d737222f5ff7 \ No newline at end of file +af4c36fb-e4d8-4394-aa4e-a93c897666aa \ No newline at end of file diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 745aaa7..81b1258 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -170,7 +170,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountHoldings[]|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\AccountHoldings[]|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse|\SnapTrade\Model\Model425FailedRequestResponse * @deprecated */ public function getAllUserHoldings( @@ -200,7 +200,7 @@ public function getAllUserHoldings( * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountHoldings[]|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountHoldings[]|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse|\SnapTrade\Model\Model425FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) * @deprecated */ public function getAllUserHoldingsWithHttpInfo($user_id, $user_secret, $brokerage_authorizations = null, string $contentType = self::contentTypes['getAllUserHoldings'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) @@ -305,6 +305,21 @@ public function getAllUserHoldingsWithHttpInfo($user_id, $user_secret, $brokerag $response->getStatusCode(), $response->getHeaders() ]; + case 425: + if ('\SnapTrade\Model\Model425FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model425FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model425FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } $returnType = '\SnapTrade\Model\AccountHoldings[]'; @@ -349,6 +364,14 @@ public function getAllUserHoldingsWithHttpInfo($user_id, $user_secret, $brokerag ); $e->setResponseObject($data); break; + case 425: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model425FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } @@ -2296,7 +2319,7 @@ public function getUserAccountPositionsRequest($user_id, $user_secret, $account_ * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountHoldingsAccount|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\AccountHoldingsAccount|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse|\SnapTrade\Model\Model425FailedRequestResponse */ public function getUserHoldings( $account_id, @@ -2325,7 +2348,7 @@ public function getUserHoldings( * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountHoldingsAccount|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountHoldingsAccount|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse|\SnapTrade\Model\Model425FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ public function getUserHoldingsWithHttpInfo($account_id, $user_id, $user_secret, string $contentType = self::contentTypes['getUserHoldings'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { @@ -2429,6 +2452,21 @@ public function getUserHoldingsWithHttpInfo($account_id, $user_id, $user_secret, $response->getStatusCode(), $response->getHeaders() ]; + case 425: + if ('\SnapTrade\Model\Model425FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model425FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model425FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } $returnType = '\SnapTrade\Model\AccountHoldingsAccount'; @@ -2473,6 +2511,14 @@ public function getUserHoldingsWithHttpInfo($account_id, $user_id, $user_secret, ); $e->setResponseObject($data); break; + case 425: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model425FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } diff --git a/lib/Model/Model425FailedRequestResponse.php b/lib/Model/Model425FailedRequestResponse.php new file mode 100644 index 0000000..0f43719 --- /dev/null +++ b/lib/Model/Model425FailedRequestResponse.php @@ -0,0 +1,455 @@ + + */ +class Model425FailedRequestResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = '425FailedRequestResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'detail' => 'mixed', + 'code' => 'mixed' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'detail' => null, + 'code' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'detail' => true, + 'code' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'detail' => 'detail', + 'code' => 'code' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'detail' => 'setDetail', + 'code' => 'setCode' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'detail' => 'getDetail', + 'code' => 'getCode' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('detail', $data ?? [], null); + $this->setIfExists('code', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets detail + * + * @return mixed|null + */ + public function getDetail() + { + return $this->container['detail']; + } + + /** + * Sets detail + * + * @param mixed|null $detail detail + * + * @return self + */ + public function setDetail($detail) + { + + if (is_null($detail)) { + array_push($this->openAPINullablesSetToNull, 'detail'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('detail', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['detail'] = $detail; + + return $this; + } + + /** + * Gets code + * + * @return mixed|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param mixed|null $code code + * + * @return self + */ + public function setCode($code) + { + + if (is_null($code)) { + array_push($this->openAPINullablesSetToNull, 'code'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('code', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['code'] = $code; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Model/Model425FailedRequestResponseTest.php b/test/Model/Model425FailedRequestResponseTest.php new file mode 100644 index 0000000..bfe9ab2 --- /dev/null +++ b/test/Model/Model425FailedRequestResponseTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "detail" + */ + public function testPropertyDetail() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "code" + */ + public function testPropertyCode() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From bd85e22e61cd163a7f8a2ca17576246be9084ed3 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:11:10 +0000 Subject: [PATCH 030/252] Version Bump SDKs (#42) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 563c82d..b45a367 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -af4c36fb-e4d8-4394-aa4e-a93c897666aa \ No newline at end of file +cbcf17c6-e95d-457f-8456-f077ac5cfc0a \ No newline at end of file diff --git a/README.md b/README.md index d49d388..0f10978 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.50-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.51-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.50" + "konfig/snaptrade-php-sdk": "2.0.51" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 1be5263..a8f2303 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.50/PHP'; + protected $userAgent = 'Konfig/2.0.51/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.50' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.51' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 2d9137a2e1e4b910cf0f02d5690019e0a986a427 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 23:11:34 +0000 Subject: [PATCH 031/252] Regenerate SDKs (#43) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- lib/Model/AccountHoldings.php | 2 ++ lib/Model/AccountHoldingsAccount.php | 2 ++ lib/Model/SnapTradeHoldingsTotalValue.php | 2 +- test/Model/SnapTradeHoldingsTotalValueTest.php | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b45a367..27a9e00 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -cbcf17c6-e95d-457f-8456-f077ac5cfc0a \ No newline at end of file +e0e75d8c-50ae-4950-84e2-364f664cda44 \ No newline at end of file diff --git a/lib/Model/AccountHoldings.php b/lib/Model/AccountHoldings.php index 151b99e..dbe4070 100644 --- a/lib/Model/AccountHoldings.php +++ b/lib/Model/AccountHoldings.php @@ -409,6 +409,7 @@ public function setPositions($positions) * Gets total_value * * @return \SnapTrade\Model\SnapTradeHoldingsTotalValue|null + * @deprecated */ public function getTotalValue() { @@ -421,6 +422,7 @@ public function getTotalValue() * @param \SnapTrade\Model\SnapTradeHoldingsTotalValue|null $total_value total_value * * @return self + * @deprecated */ public function setTotalValue($total_value) { diff --git a/lib/Model/AccountHoldingsAccount.php b/lib/Model/AccountHoldingsAccount.php index 0779629..55969e0 100644 --- a/lib/Model/AccountHoldingsAccount.php +++ b/lib/Model/AccountHoldingsAccount.php @@ -495,6 +495,7 @@ public function setOrders($orders) * Gets total_value * * @return \SnapTrade\Model\SnapTradeHoldingsTotalValue|null + * @deprecated */ public function getTotalValue() { @@ -507,6 +508,7 @@ public function getTotalValue() * @param \SnapTrade\Model\SnapTradeHoldingsTotalValue|null $total_value total_value * * @return self + * @deprecated */ public function setTotalValue($total_value) { diff --git a/lib/Model/SnapTradeHoldingsTotalValue.php b/lib/Model/SnapTradeHoldingsTotalValue.php index c6beb86..30c9f84 100644 --- a/lib/Model/SnapTradeHoldingsTotalValue.php +++ b/lib/Model/SnapTradeHoldingsTotalValue.php @@ -30,7 +30,7 @@ * SnapTradeHoldingsTotalValue Class Doc Comment * * @category Class - * @description The total market value of the account. Note that this field is calculated based on the sum of the values of account positions and cash balances known to SnapTrade. It may not be accurate if the brokerage account has holdings that SnapTrade is not aware of. For example, if the brokerage account holds assets that SnapTrade does not support, the total value may be underreported. To get the brokerage reported total market value of the account, refer to `account.balance.total`. + * @description This field is deprecated. To get the brokerage reported total market value of the account, please refer to `account.balance.total`. The total market value of the account. Note that this field is calculated based on the sum of the values of account positions and cash balances known to SnapTrade. It may not be accurate if the brokerage account has holdings that SnapTrade is not aware of. For example, if the brokerage account holds assets that SnapTrade does not support, the total value may be underreported. In certain cases, this value may also be double-counting cash-equivalent assets if those assets are represented as both cash and positions in the account. * @package SnapTrade * @implements \ArrayAccess */ diff --git a/test/Model/SnapTradeHoldingsTotalValueTest.php b/test/Model/SnapTradeHoldingsTotalValueTest.php index e6f5962..3e28ce9 100644 --- a/test/Model/SnapTradeHoldingsTotalValueTest.php +++ b/test/Model/SnapTradeHoldingsTotalValueTest.php @@ -29,7 +29,7 @@ * SnapTradeHoldingsTotalValueTest Class Doc Comment * * @category Class - * @description The total market value of the account. Note that this field is calculated based on the sum of the values of account positions and cash balances known to SnapTrade. It may not be accurate if the brokerage account has holdings that SnapTrade is not aware of. For example, if the brokerage account holds assets that SnapTrade does not support, the total value may be underreported. To get the brokerage reported total market value of the account, refer to `account.balance.total`. + * @description This field is deprecated. To get the brokerage reported total market value of the account, please refer to `account.balance.total`. The total market value of the account. Note that this field is calculated based on the sum of the values of account positions and cash balances known to SnapTrade. It may not be accurate if the brokerage account has holdings that SnapTrade is not aware of. For example, if the brokerage account holds assets that SnapTrade does not support, the total value may be underreported. In certain cases, this value may also be double-counting cash-equivalent assets if those assets are represented as both cash and positions in the account. * @package SnapTrade */ class SnapTradeHoldingsTotalValueTest extends TestCase From a5e46090e63836ff3469b335219c7d9fbafe6c2b Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 23:15:06 +0000 Subject: [PATCH 032/252] Version Bump SDKs (#44) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 27a9e00..672024c 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -e0e75d8c-50ae-4950-84e2-364f664cda44 \ No newline at end of file +d501acee-d00e-48c9-bca5-cbf72724d089 \ No newline at end of file diff --git a/README.md b/README.md index 0f10978..70099d4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.51-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.52-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -86,7 +86,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.51" + "konfig/snaptrade-php-sdk": "2.0.52" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index a8f2303..891a4e4 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.51/PHP'; + protected $userAgent = 'Konfig/2.0.52/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.51' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.52' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 5c18f6ce674a1eaad48c03af7c77b750b5838b98 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 21:28:36 +0000 Subject: [PATCH 033/252] Version Bump SDKs (#45) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 672024c..76e48df 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d501acee-d00e-48c9-bca5-cbf72724d089 \ No newline at end of file +bdb300e7-05e3-47da-b6cc-6388ea430d02 \ No newline at end of file From 78edeb27b963ae9b83605b6328c21ecf72c8a228 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:35:59 +0000 Subject: [PATCH 034/252] Regenerate SDKs (#46) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 42 +++ lib/Api/AccountInformationApi.php | 451 ++++++++++++++++++++++++ lib/Model/RecentOrdersResponse.php | 405 +++++++++++++++++++++ test/Api/AccountInformationApiTest.php | 12 + test/Model/RecentOrdersResponseTest.php | 83 +++++ 6 files changed, 994 insertions(+), 1 deletion(-) create mode 100644 lib/Model/RecentOrdersResponse.php create mode 100644 test/Model/RecentOrdersResponseTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 76e48df..bb0d96e 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -bdb300e7-05e3-47da-b6cc-6388ea430d02 \ No newline at end of file +d47db422-267e-4aba-8216-692b8d60dca8 \ No newline at end of file diff --git a/README.md b/README.md index 70099d4..3749f9a 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.accountInformation.getUserAccountDetails`](#snaptradeaccountinformationgetuseraccountdetails) * [`snaptrade.accountInformation.getUserAccountOrders`](#snaptradeaccountinformationgetuseraccountorders) * [`snaptrade.accountInformation.getUserAccountPositions`](#snaptradeaccountinformationgetuseraccountpositions) + * [`snaptrade.accountInformation.getUserAccountRecentOrders`](#snaptradeaccountinformationgetuseraccountrecentorders) * [`snaptrade.accountInformation.getUserHoldings`](#snaptradeaccountinformationgetuserholdings) * [`snaptrade.accountInformation.listUserAccounts`](#snaptradeaccountinformationlistuseraccounts) * [`snaptrade.accountInformation.updateUserAccount`](#snaptradeaccountinformationupdateuseraccount) @@ -338,6 +339,47 @@ $result = $snaptrade->accountInformation->getUserAccountPositions( --- +### `snaptrade.accountInformation.getUserAccountRecentOrders` + +Returns a list of orders executed in the last 24 hours in the specified account. +This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution +Differs from /orders in that it only returns orders that have been *executed* in the last 24 hours as opposed to pending or cancelled orders up to 30 days old +*Please contact support for access as this endpoint is not enabled by default.* + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->accountInformation->getUserAccountRecentOrders( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + + +#### πŸ”„ Return + +[**RecentOrdersResponse**](./lib/Model/RecentOrdersResponse.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/recentOrders` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.accountInformation.getUserHoldings` Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 81b1258..a97734b 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -77,6 +77,9 @@ class AccountInformationApi extends \SnapTrade\CustomApi 'getUserAccountPositions' => [ 'application/json', ], + 'getUserAccountRecentOrders' => [ + 'application/json', + ], 'getUserHoldings' => [ 'application/json', ], @@ -2305,6 +2308,454 @@ public function getUserAccountPositionsRequest($user_id, $user_secret, $account_ ]; } + /** + * Operation getUserAccountRecentOrders + * + * List account recent executed orders + * + * Returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution Differs from /orders in that it only returns orders that have been *executed* in the last 24 hours as opposed to pending or cancelled orders up to 30 days old *Please contact support for access as this endpoint is not enabled by default.* + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrders'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\RecentOrdersResponse|\SnapTrade\Model\Model403FeatureNotEnabledResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse + */ + public function getUserAccountRecentOrders( + $user_id, + $user_secret, + $account_id, + + string $contentType = self::contentTypes['getUserAccountRecentOrders'][0] + ) + { + + list($response) = $this->getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $account_id, $contentType); + return $response; + } + + /** + * Operation getUserAccountRecentOrdersWithHttpInfo + * + * List account recent executed orders + * + * Returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution Differs from /orders in that it only returns orders that have been *executed* in the last 24 hours as opposed to pending or cancelled orders up to 30 days old *Please contact support for access as this endpoint is not enabled by default.* + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrders'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\RecentOrdersResponse|\SnapTrade\Model\Model403FeatureNotEnabledResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountRecentOrdersRequest($user_id, $user_secret, $account_id, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->getUserAccountRecentOrdersWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\RecentOrdersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\RecentOrdersResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\RecentOrdersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FeatureNotEnabledResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FeatureNotEnabledResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FeatureNotEnabledResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\RecentOrdersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\RecentOrdersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FeatureNotEnabledResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getUserAccountRecentOrdersAsync + * + * List account recent executed orders + * + * Returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution Differs from /orders in that it only returns orders that have been *executed* in the last 24 hours as opposed to pending or cancelled orders up to 30 days old *Please contact support for access as this endpoint is not enabled by default.* + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrders'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountRecentOrdersAsync( + $user_id, + $user_secret, + $account_id, + + string $contentType = self::contentTypes['getUserAccountRecentOrders'][0] + ) + { + + return $this->getUserAccountRecentOrdersAsyncWithHttpInfo($user_id, $user_secret, $account_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getUserAccountRecentOrdersAsyncWithHttpInfo + * + * List account recent executed orders + * + * Returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution Differs from /orders in that it only returns orders that have been *executed* in the last 24 hours as opposed to pending or cancelled orders up to 30 days old *Please contact support for access as this endpoint is not enabled by default.* + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrders'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountRecentOrdersAsyncWithHttpInfo($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\RecentOrdersResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountRecentOrdersRequest($user_id, $user_secret, $account_id, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getUserAccountRecentOrders' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrders'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getUserAccountRecentOrdersRequest($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getUserAccountRecentOrders' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getUserAccountRecentOrders' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getUserAccountRecentOrders' + ); + } + + + $resourcePath = '/accounts/{accountId}/recentOrders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + /** * Operation getUserHoldings * diff --git a/lib/Model/RecentOrdersResponse.php b/lib/Model/RecentOrdersResponse.php new file mode 100644 index 0000000..1ff1a49 --- /dev/null +++ b/lib/Model/RecentOrdersResponse.php @@ -0,0 +1,405 @@ + + */ +class RecentOrdersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'RecentOrdersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'orders' => '\SnapTrade\Model\AccountOrderRecord[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'orders' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'orders' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'orders' => 'orders' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'orders' => 'setOrders' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'orders' => 'getOrders' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('orders', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets orders + * + * @return \SnapTrade\Model\AccountOrderRecord[]|null + */ + public function getOrders() + { + return $this->container['orders']; + } + + /** + * Sets orders + * + * @param \SnapTrade\Model\AccountOrderRecord[]|null $orders List of orders executed in the last 24 hours + * + * @return self + */ + public function setOrders($orders) + { + + if (is_null($orders)) { + throw new \InvalidArgumentException('non-nullable orders cannot be null'); + } + + $this->container['orders'] = $orders; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/AccountInformationApiTest.php b/test/Api/AccountInformationApiTest.php index 1297707..b1d614e 100644 --- a/test/Api/AccountInformationApiTest.php +++ b/test/Api/AccountInformationApiTest.php @@ -118,6 +118,18 @@ public function testGetUserAccountPositions() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for getUserAccountRecentOrders + * + * List account recent executed orders. + * + */ + public function testGetUserAccountRecentOrders() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for getUserHoldings * diff --git a/test/Model/RecentOrdersResponseTest.php b/test/Model/RecentOrdersResponseTest.php new file mode 100644 index 0000000..00f764d --- /dev/null +++ b/test/Model/RecentOrdersResponseTest.php @@ -0,0 +1,83 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "orders" + */ + public function testPropertyOrders() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From df5762af185c47fcd9394a58a9cf7566866debf3 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:40:02 +0000 Subject: [PATCH 035/252] Version Bump SDKs (#47) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index bb0d96e..e88a175 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d47db422-267e-4aba-8216-692b8d60dca8 \ No newline at end of file +fd126c0f-318c-435c-ac91-b86a0fcd52aa \ No newline at end of file diff --git a/README.md b/README.md index 3749f9a..8eafc2e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.52-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.53-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -87,7 +87,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.52" + "konfig/snaptrade-php-sdk": "2.0.53" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 891a4e4..4513d2c 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.52/PHP'; + protected $userAgent = 'Konfig/2.0.53/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.52' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.53' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 8795308b35f730c0da9416214fefd9f828a01ce9 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 02:00:21 +0000 Subject: [PATCH 036/252] Regenerate SDKs (#48) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 78 ++++ lib/Api/AccountInformationApi.php | 451 +++++++++++++++++++++ lib/Api/ConnectionsApi.php | 451 +++++++++++++++++++++ lib/Model/RateOfReturnObject.php | 517 ++++++++++++++++++++++++ lib/Model/RateOfReturnResponse.php | 405 +++++++++++++++++++ test/Api/AccountInformationApiTest.php | 12 + test/Api/ConnectionsApiTest.php | 12 + test/Model/RateOfReturnObjectTest.php | 101 +++++ test/Model/RateOfReturnResponseTest.php | 83 ++++ 10 files changed, 2111 insertions(+), 1 deletion(-) create mode 100644 lib/Model/RateOfReturnObject.php create mode 100644 lib/Model/RateOfReturnResponse.php create mode 100644 test/Model/RateOfReturnObjectTest.php create mode 100644 test/Model/RateOfReturnResponseTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index e88a175..7ce89cf 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -fd126c0f-318c-435c-ac91-b86a0fcd52aa \ No newline at end of file +74488690-6e78-4535-9b71-fb7be00bbaa2 \ No newline at end of file diff --git a/README.md b/README.md index 8eafc2e..ab5fc65 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.accountInformation.getUserAccountOrders`](#snaptradeaccountinformationgetuseraccountorders) * [`snaptrade.accountInformation.getUserAccountPositions`](#snaptradeaccountinformationgetuseraccountpositions) * [`snaptrade.accountInformation.getUserAccountRecentOrders`](#snaptradeaccountinformationgetuseraccountrecentorders) + * [`snaptrade.accountInformation.getUserAccountReturnRates`](#snaptradeaccountinformationgetuseraccountreturnrates) * [`snaptrade.accountInformation.getUserHoldings`](#snaptradeaccountinformationgetuserholdings) * [`snaptrade.accountInformation.listUserAccounts`](#snaptradeaccountinformationlistuseraccounts) * [`snaptrade.accountInformation.updateUserAccount`](#snaptradeaccountinformationupdateuseraccount) @@ -41,6 +42,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.connections.listBrokerageAuthorizations`](#snaptradeconnectionslistbrokerageauthorizations) * [`snaptrade.connections.refreshBrokerageAuthorization`](#snaptradeconnectionsrefreshbrokerageauthorization) * [`snaptrade.connections.removeBrokerageAuthorization`](#snaptradeconnectionsremovebrokerageauthorization) + * [`snaptrade.connections.returnRates`](#snaptradeconnectionsreturnrates) * [`snaptrade.connections.sessionEvents`](#snaptradeconnectionssessionevents) * [`snaptrade.options.getOptionStrategy`](#snaptradeoptionsgetoptionstrategy) * [`snaptrade.options.getOptionsChain`](#snaptradeoptionsgetoptionschain) @@ -380,6 +382,44 @@ $result = $snaptrade->accountInformation->getUserAccountRecentOrders( --- +### `snaptrade.accountInformation.getUserAccountReturnRates` + +Returns a list of rate of return percents for a given account. Will include timeframes available from the brokerage, for example "ALL", "1Y", "6M", "3M", "1M" + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->accountInformation->getUserAccountReturnRates( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + + +#### πŸ”„ Return + +[**RateOfReturnResponse**](./lib/Model/RateOfReturnResponse.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/returnRates` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.accountInformation.getUserHoldings` Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ @@ -912,6 +952,44 @@ void (empty response body) --- +### `snaptrade.connections.returnRates` + +Returns a list of rate of return percents for a given connection. Will include timeframes available from the brokerage, for example "ALL", "1Y", "6M", "3M", "1M" + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->connections->returnRates( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### authorization_id: `string` + + +#### πŸ”„ Return + +[**RateOfReturnResponse**](./lib/Model/RateOfReturnResponse.php) + +#### 🌐 Endpoint + +`/authorizations/{authorizationId}/returnRates` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.connections.sessionEvents` Returns a list of session events associated with a user. diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index a97734b..388bdb4 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -80,6 +80,9 @@ class AccountInformationApi extends \SnapTrade\CustomApi 'getUserAccountRecentOrders' => [ 'application/json', ], + 'getUserAccountReturnRates' => [ + 'application/json', + ], 'getUserHoldings' => [ 'application/json', ], @@ -2756,6 +2759,454 @@ public function getUserAccountRecentOrdersRequest($user_id, $user_secret, $accou ]; } + /** + * Operation getUserAccountReturnRates + * + * List account rate of returns + * + * Returns a list of rate of return percents for a given account. Will include timeframes available from the brokerage, for example \"ALL\", \"1Y\", \"6M\", \"3M\", \"1M\" + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountReturnRates'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\RateOfReturnResponse|\SnapTrade\Model\Model403FeatureNotEnabledResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse + */ + public function getUserAccountReturnRates( + $user_id, + $user_secret, + $account_id, + + string $contentType = self::contentTypes['getUserAccountReturnRates'][0] + ) + { + + list($response) = $this->getUserAccountReturnRatesWithHttpInfo($user_id, $user_secret, $account_id, $contentType); + return $response; + } + + /** + * Operation getUserAccountReturnRatesWithHttpInfo + * + * List account rate of returns + * + * Returns a list of rate of return percents for a given account. Will include timeframes available from the brokerage, for example \"ALL\", \"1Y\", \"6M\", \"3M\", \"1M\" + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountReturnRates'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\RateOfReturnResponse|\SnapTrade\Model\Model403FeatureNotEnabledResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getUserAccountReturnRatesWithHttpInfo($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['getUserAccountReturnRates'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountReturnRatesRequest($user_id, $user_secret, $account_id, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->getUserAccountReturnRatesWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\RateOfReturnResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\RateOfReturnResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\RateOfReturnResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FeatureNotEnabledResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FeatureNotEnabledResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FeatureNotEnabledResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\RateOfReturnResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\RateOfReturnResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FeatureNotEnabledResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getUserAccountReturnRatesAsync + * + * List account rate of returns + * + * Returns a list of rate of return percents for a given account. Will include timeframes available from the brokerage, for example \"ALL\", \"1Y\", \"6M\", \"3M\", \"1M\" + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountReturnRates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountReturnRatesAsync( + $user_id, + $user_secret, + $account_id, + + string $contentType = self::contentTypes['getUserAccountReturnRates'][0] + ) + { + + return $this->getUserAccountReturnRatesAsyncWithHttpInfo($user_id, $user_secret, $account_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getUserAccountReturnRatesAsyncWithHttpInfo + * + * List account rate of returns + * + * Returns a list of rate of return percents for a given account. Will include timeframes available from the brokerage, for example \"ALL\", \"1Y\", \"6M\", \"3M\", \"1M\" + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountReturnRates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountReturnRatesAsyncWithHttpInfo($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['getUserAccountReturnRates'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\RateOfReturnResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountReturnRatesRequest($user_id, $user_secret, $account_id, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getUserAccountReturnRates' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountReturnRates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getUserAccountReturnRatesRequest($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['getUserAccountReturnRates'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getUserAccountReturnRates' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getUserAccountReturnRates' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getUserAccountReturnRates' + ); + } + + + $resourcePath = '/accounts/{accountId}/returnRates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + /** * Operation getUserHoldings * diff --git a/lib/Api/ConnectionsApi.php b/lib/Api/ConnectionsApi.php index ec06743..03a745c 100644 --- a/lib/Api/ConnectionsApi.php +++ b/lib/Api/ConnectionsApi.php @@ -77,6 +77,9 @@ class ConnectionsApi extends \SnapTrade\CustomApi 'removeBrokerageAuthorization' => [ 'application/json', ], + 'returnRates' => [ + 'application/json', + ], 'sessionEvents' => [ 'application/json', ], @@ -2264,6 +2267,454 @@ public function removeBrokerageAuthorizationRequest($authorization_id, $user_id, ]; } + /** + * Operation returnRates + * + * List connection rate of returns + * + * Returns a list of rate of return percents for a given connection. Will include timeframes available from the brokerage, for example \"ALL\", \"1Y\", \"6M\", \"3M\", \"1M\" + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $authorization_id authorization_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['returnRates'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\RateOfReturnResponse|\SnapTrade\Model\Model403FeatureNotEnabledResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse + */ + public function returnRates( + $user_id, + $user_secret, + $authorization_id, + + string $contentType = self::contentTypes['returnRates'][0] + ) + { + + list($response) = $this->returnRatesWithHttpInfo($user_id, $user_secret, $authorization_id, $contentType); + return $response; + } + + /** + * Operation returnRatesWithHttpInfo + * + * List connection rate of returns + * + * Returns a list of rate of return percents for a given connection. Will include timeframes available from the brokerage, for example \"ALL\", \"1Y\", \"6M\", \"3M\", \"1M\" + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $authorization_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['returnRates'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\RateOfReturnResponse|\SnapTrade\Model\Model403FeatureNotEnabledResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function returnRatesWithHttpInfo($user_id, $user_secret, $authorization_id, string $contentType = self::contentTypes['returnRates'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->returnRatesRequest($user_id, $user_secret, $authorization_id, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->returnRatesWithHttpInfo( + $user_id, + $user_secret, + $authorization_id, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\RateOfReturnResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\RateOfReturnResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\RateOfReturnResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FeatureNotEnabledResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FeatureNotEnabledResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FeatureNotEnabledResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\RateOfReturnResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\RateOfReturnResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FeatureNotEnabledResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation returnRatesAsync + * + * List connection rate of returns + * + * Returns a list of rate of return percents for a given connection. Will include timeframes available from the brokerage, for example \"ALL\", \"1Y\", \"6M\", \"3M\", \"1M\" + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $authorization_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['returnRates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function returnRatesAsync( + $user_id, + $user_secret, + $authorization_id, + + string $contentType = self::contentTypes['returnRates'][0] + ) + { + + return $this->returnRatesAsyncWithHttpInfo($user_id, $user_secret, $authorization_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation returnRatesAsyncWithHttpInfo + * + * List connection rate of returns + * + * Returns a list of rate of return percents for a given connection. Will include timeframes available from the brokerage, for example \"ALL\", \"1Y\", \"6M\", \"3M\", \"1M\" + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $authorization_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['returnRates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function returnRatesAsyncWithHttpInfo($user_id, $user_secret, $authorization_id, string $contentType = self::contentTypes['returnRates'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\RateOfReturnResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->returnRatesRequest($user_id, $user_secret, $authorization_id, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'returnRates' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $authorization_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['returnRates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function returnRatesRequest($user_id, $user_secret, $authorization_id, string $contentType = self::contentTypes['returnRates'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling returnRates' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling returnRates' + ); + } + // Check if $authorization_id is a string + if ($authorization_id !== SENTINEL_VALUE && !is_string($authorization_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($authorization_id, true), gettype($authorization_id))); + } + // verify the required parameter 'authorization_id' is set + if ($authorization_id === SENTINEL_VALUE || (is_array($authorization_id) && count($authorization_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter authorization_id when calling returnRates' + ); + } + + + $resourcePath = '/authorizations/{authorizationId}/returnRates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($authorization_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'authorizationId' . '}', + ObjectSerializer::toPathValue($authorization_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + /** * Operation sessionEvents * diff --git a/lib/Model/RateOfReturnObject.php b/lib/Model/RateOfReturnObject.php new file mode 100644 index 0000000..6843c47 --- /dev/null +++ b/lib/Model/RateOfReturnObject.php @@ -0,0 +1,517 @@ + + */ +class RateOfReturnObject implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'RateOfReturnObject'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'timeframe' => 'string', + 'return_percent' => 'float', + 'created_date' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'timeframe' => null, + 'return_percent' => null, + 'created_date' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'timeframe' => false, + 'return_percent' => false, + 'created_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'timeframe' => 'timeframe', + 'return_percent' => 'return_percent', + 'created_date' => 'created_date' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'timeframe' => 'setTimeframe', + 'return_percent' => 'setReturnPercent', + 'created_date' => 'setCreatedDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'timeframe' => 'getTimeframe', + 'return_percent' => 'getReturnPercent', + 'created_date' => 'getCreatedDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TIMEFRAME_ALL = 'ALL'; + public const TIMEFRAME__1_Y = '1Y'; + public const TIMEFRAME__6_M = '6M'; + public const TIMEFRAME__3_M = '3M'; + public const TIMEFRAME__1_M = '1M'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTimeframeAllowableValues() + { + return [ + self::TIMEFRAME_ALL, + self::TIMEFRAME__1_Y, + self::TIMEFRAME__6_M, + self::TIMEFRAME__3_M, + self::TIMEFRAME__1_M, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('timeframe', $data ?? [], null); + $this->setIfExists('return_percent', $data ?? [], null); + $this->setIfExists('created_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTimeframeAllowableValues(); + if (!is_null($this->container['timeframe']) && !in_array($this->container['timeframe'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'timeframe', must be one of '%s'", + $this->container['timeframe'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets timeframe + * + * @return string|null + */ + public function getTimeframe() + { + return $this->container['timeframe']; + } + + /** + * Sets timeframe + * + * @param string|null $timeframe The timeframe this return percent is reflecting + * + * @return self + */ + public function setTimeframe($timeframe) + { + $allowedValues = $this->getTimeframeAllowableValues(); + if (!is_null($timeframe) && !in_array($timeframe, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'timeframe', must be one of '%s'", + $timeframe, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($timeframe)) { + throw new \InvalidArgumentException('non-nullable timeframe cannot be null'); + } + + $this->container['timeframe'] = $timeframe; + + return $this; + } + + /** + * Gets return_percent + * + * @return float|null + */ + public function getReturnPercent() + { + return $this->container['return_percent']; + } + + /** + * Sets return_percent + * + * @param float|null $return_percent The percent return of the portfolio, directly from the brokerage. 5.97 indicates a 5.97% return over the timeframe + * + * @return self + */ + public function setReturnPercent($return_percent) + { + + if (is_null($return_percent)) { + throw new \InvalidArgumentException('non-nullable return_percent cannot be null'); + } + + $this->container['return_percent'] = $return_percent; + + return $this; + } + + /** + * Gets created_date + * + * @return \DateTime|null + */ + public function getCreatedDate() + { + return $this->container['created_date']; + } + + /** + * Sets created_date + * + * @param \DateTime|null $created_date The date this was fetched + * + * @return self + */ + public function setCreatedDate($created_date) + { + + if (is_null($created_date)) { + throw new \InvalidArgumentException('non-nullable created_date cannot be null'); + } + + $this->container['created_date'] = $created_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/RateOfReturnResponse.php b/lib/Model/RateOfReturnResponse.php new file mode 100644 index 0000000..963660c --- /dev/null +++ b/lib/Model/RateOfReturnResponse.php @@ -0,0 +1,405 @@ + + */ +class RateOfReturnResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'RateOfReturnResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'data' => '\SnapTrade\Model\RateOfReturnObject[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'data' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'data' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'data' => 'data' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'data' => 'setData' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'data' => 'getData' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('data', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets data + * + * @return \SnapTrade\Model\RateOfReturnObject[]|null + */ + public function getData() + { + return $this->container['data']; + } + + /** + * Sets data + * + * @param \SnapTrade\Model\RateOfReturnObject[]|null $data List of return percentages + * + * @return self + */ + public function setData($data) + { + + if (is_null($data)) { + throw new \InvalidArgumentException('non-nullable data cannot be null'); + } + + $this->container['data'] = $data; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/AccountInformationApiTest.php b/test/Api/AccountInformationApiTest.php index b1d614e..fd1a035 100644 --- a/test/Api/AccountInformationApiTest.php +++ b/test/Api/AccountInformationApiTest.php @@ -130,6 +130,18 @@ public function testGetUserAccountRecentOrders() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for getUserAccountReturnRates + * + * List account rate of returns. + * + */ + public function testGetUserAccountReturnRates() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for getUserHoldings * diff --git a/test/Api/ConnectionsApiTest.php b/test/Api/ConnectionsApiTest.php index bfa7d66..d4d21e0 100644 --- a/test/Api/ConnectionsApiTest.php +++ b/test/Api/ConnectionsApiTest.php @@ -118,6 +118,18 @@ public function testRemoveBrokerageAuthorization() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for returnRates + * + * List connection rate of returns. + * + */ + public function testReturnRates() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for sessionEvents * diff --git a/test/Model/RateOfReturnObjectTest.php b/test/Model/RateOfReturnObjectTest.php new file mode 100644 index 0000000..d7dea25 --- /dev/null +++ b/test/Model/RateOfReturnObjectTest.php @@ -0,0 +1,101 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "timeframe" + */ + public function testPropertyTimeframe() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "return_percent" + */ + public function testPropertyReturnPercent() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "created_date" + */ + public function testPropertyCreatedDate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/RateOfReturnResponseTest.php b/test/Model/RateOfReturnResponseTest.php new file mode 100644 index 0000000..4772839 --- /dev/null +++ b/test/Model/RateOfReturnResponseTest.php @@ -0,0 +1,83 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "data" + */ + public function testPropertyData() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From e15944c980ba2d72b84f29078131b2ac7ae03834 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 02:04:08 +0000 Subject: [PATCH 037/252] Version Bump SDKs (#49) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 7ce89cf..773ee61 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -74488690-6e78-4535-9b71-fb7be00bbaa2 \ No newline at end of file +31caff9f-676b-45ac-9bce-861501b96633 \ No newline at end of file diff --git a/README.md b/README.md index ab5fc65..3723fac 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.53-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.54-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.53" + "konfig/snaptrade-php-sdk": "2.0.54" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 4513d2c..12cb51b 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.53/PHP'; + protected $userAgent = 'Konfig/2.0.54/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.53' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.54' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 7652334fef22d842e396e2dfa0a13f9f61531af1 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 21:16:21 +0000 Subject: [PATCH 038/252] Regenerate SDKs (#50) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- lib/Model/SecurityType.php | 2 +- lib/Model/UnderlyingSymbolType.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 773ee61..a381bf2 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -31caff9f-676b-45ac-9bce-861501b96633 \ No newline at end of file +b547f4fc-b86a-43eb-bb35-68549b943066 \ No newline at end of file diff --git a/lib/Model/SecurityType.php b/lib/Model/SecurityType.php index c56b89a..10a6eab 100644 --- a/lib/Model/SecurityType.php +++ b/lib/Model/SecurityType.php @@ -346,7 +346,7 @@ public function getCode() /** * Sets code * - * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: ad - ADR bnd - Bond cs - Common Stock cef - Closed End Fund et - ETF oef - Open Ended Fund ps - Preferred Stock rt - Right struct - Structured Product ut - Unit wi - When Issued wt - Warrant + * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: - `ad` - ADR - `bnd` - Bond - `cs` - Common Stock - `cef` - Closed End Fund - `et` - ETF - `oef` - Open Ended Fund - `ps` - Preferred Stock - `rt` - Right - `struct` - Structured Product - `ut` - Unit - `wi` - When Issued - `wt` - Warrant * * @return self */ diff --git a/lib/Model/UnderlyingSymbolType.php b/lib/Model/UnderlyingSymbolType.php index cbd1a0c..bb57cac 100644 --- a/lib/Model/UnderlyingSymbolType.php +++ b/lib/Model/UnderlyingSymbolType.php @@ -346,7 +346,7 @@ public function getCode() /** * Sets code * - * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: ad - ADR bnd - Bond cs - Common Stock cef - Closed End Fund et - ETF oef - Open Ended Fund ps - Preferred Stock rt - Right struct - Structured Product ut - Unit wi - When Issued wt - Warrant + * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: - `ad` - ADR - `bnd` - Bond - `cs` - Common Stock - `cef` - Closed End Fund - `et` - ETF - `oef` - Open Ended Fund - `ps` - Preferred Stock - `rt` - Right - `struct` - Structured Product - `ut` - Unit - `wi` - When Issued - `wt` - Warrant * * @return self */ From c97474c86ad5b08738ec86e9261cc49d45a8e82b Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 21:20:10 +0000 Subject: [PATCH 039/252] Version Bump SDKs (#51) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a381bf2..820963c 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -b547f4fc-b86a-43eb-bb35-68549b943066 \ No newline at end of file +2051f815-1af6-414e-a632-def22d8d26fe \ No newline at end of file diff --git a/README.md b/README.md index 3723fac..abb3375 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.54-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.55-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.54" + "konfig/snaptrade-php-sdk": "2.0.55" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 12cb51b..7a4856d 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.54/PHP'; + protected $userAgent = 'Konfig/2.0.55/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.54' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.55' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From acce3d1b03a10d1538818dae95a7a6be9460e25d Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:46:51 +0000 Subject: [PATCH 040/252] Regenerate SDKs (#52) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 9 +++++++-- lib/Api/AccountInformationApi.php | 33 ++++++++++++++++++++++++------- lib/Api/TradingApi.php | 10 +++++----- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 820963c..3fe42ab 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2051f815-1af6-414e-a632-def22d8d26fe \ No newline at end of file +456bbe60-430b-4b93-a448-575ffd8eda31 \ No newline at end of file diff --git a/README.md b/README.md index abb3375..ae755e4 100644 --- a/README.md +++ b/README.md @@ -356,7 +356,8 @@ Differs from /orders in that it only returns orders that have been *executed* in $result = $snaptrade->accountInformation->getUserAccountRecentOrders( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + only_executed: True ); ``` @@ -368,6 +369,10 @@ $result = $snaptrade->accountInformation->getUserAccountRecentOrders( ##### account_id: `string` +##### only_executed: `bool` + +Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well + #### πŸ”„ Return @@ -1736,7 +1741,7 @@ $result = $snaptrade->trading->getUserAccountQuotes( ##### symbols: `string` -List of Universal Symbol IDs or tickers to get quotes for. +List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator ##### account_id: `string` diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 388bdb4..128e605 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -2321,6 +2321,7 @@ public function getUserAccountPositionsRequest($user_id, $user_secret, $account_ * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) + * @param bool $only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrders'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -2331,12 +2332,13 @@ public function getUserAccountRecentOrders( $user_id, $user_secret, $account_id, + $only_executed = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0] ) { - list($response) = $this->getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $account_id, $contentType); + list($response) = $this->getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $account_id, $only_executed, $contentType); return $response; } @@ -2350,15 +2352,16 @@ public function getUserAccountRecentOrders( * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) + * @param bool $only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrders'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\RecentOrdersResponse|\SnapTrade\Model\Model403FeatureNotEnabledResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $account_id, $only_executed = null, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountRecentOrdersRequest($user_id, $user_secret, $account_id, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountRecentOrdersRequest($user_id, $user_secret, $account_id, $only_executed, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config); @@ -2377,6 +2380,7 @@ public function getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $ $user_id, $user_secret, $account_id, + $only_executed, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -2517,6 +2521,7 @@ public function getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $ * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) + * @param bool $only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrders'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -2526,12 +2531,13 @@ public function getUserAccountRecentOrdersAsync( $user_id, $user_secret, $account_id, + $only_executed = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0] ) { - return $this->getUserAccountRecentOrdersAsyncWithHttpInfo($user_id, $user_secret, $account_id, $contentType) + return $this->getUserAccountRecentOrdersAsyncWithHttpInfo($user_id, $user_secret, $account_id, $only_executed, $contentType) ->then( function ($response) { return $response[0]; @@ -2549,15 +2555,16 @@ function ($response) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) + * @param bool $only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrders'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getUserAccountRecentOrdersAsyncWithHttpInfo($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getUserAccountRecentOrdersAsyncWithHttpInfo($user_id, $user_secret, $account_id, $only_executed = null, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\RecentOrdersResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountRecentOrdersRequest($user_id, $user_secret, $account_id, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountRecentOrdersRequest($user_id, $user_secret, $account_id, $only_executed, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config); @@ -2604,12 +2611,13 @@ function ($exception) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) + * @param bool $only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrders'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getUserAccountRecentOrdersRequest($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0]) + public function getUserAccountRecentOrdersRequest($user_id, $user_secret, $account_id, $only_executed = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountRecentOrders'][0]) { // Check if $user_id is a string @@ -2673,6 +2681,17 @@ public function getUserAccountRecentOrdersRequest($user_id, $user_secret, $accou true // required ) ?? []); } + if ($only_executed !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_executed, + 'only_executed', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } // path params diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index cbd553f..b631246 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -1128,7 +1128,7 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) * @param string $account_id account_id (required) * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation @@ -1161,7 +1161,7 @@ public function getUserAccountQuotes( * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) * @param string $account_id (required) * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation @@ -1309,7 +1309,7 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) * @param string $account_id (required) * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation @@ -1345,7 +1345,7 @@ function ($response) { * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) * @param string $account_id (required) * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation @@ -1402,7 +1402,7 @@ function ($exception) { * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) * @param string $account_id (required) * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation From 2bf0303fe902b1f2a281f21885d4f35e735e7fe0 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:50:54 +0000 Subject: [PATCH 041/252] Version Bump SDKs (#53) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 3fe42ab..f07ac07 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -456bbe60-430b-4b93-a448-575ffd8eda31 \ No newline at end of file +8e1d6f87-d85e-43c4-b73e-df00194a23bd \ No newline at end of file diff --git a/README.md b/README.md index ae755e4..ef8aab5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.55-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.56-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.55" + "konfig/snaptrade-php-sdk": "2.0.56" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 7a4856d..2ebf384 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.55/PHP'; + protected $userAgent = 'Konfig/2.0.56/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.55' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.56' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 5a791a1733df8639a429fe8ac3d4fb459d4fee52 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 21:17:24 +0000 Subject: [PATCH 042/252] Regenerate SDKs (#54) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/TransactionsAndReportingApi.php | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f07ac07..a960a82 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -8e1d6f87-d85e-43c4-b73e-df00194a23bd \ No newline at end of file +90d684ea-94b3-4173-a16b-f2473df80f25 \ No newline at end of file diff --git a/README.md b/README.md index ef8aab5..3cef5e9 100644 --- a/README.md +++ b/README.md @@ -1939,7 +1939,7 @@ Optional comma separated list of SnapTrade Connection (Brokerage Authorization) ##### type: `string` -Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. +Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another #### πŸ”„ Return diff --git a/lib/Api/TransactionsAndReportingApi.php b/lib/Api/TransactionsAndReportingApi.php index c11db2a..fda66bc 100644 --- a/lib/Api/TransactionsAndReportingApi.php +++ b/lib/Api/TransactionsAndReportingApi.php @@ -151,7 +151,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -188,7 +188,7 @@ public function getActivities( * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -317,7 +317,7 @@ public function getActivitiesWithHttpInfo($user_id, $user_secret, $start_date = * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -357,7 +357,7 @@ function ($response) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -416,7 +416,7 @@ function ($exception) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param string $accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional) * @param string $brokerage_authorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException From e0f316611af0d1e0f7e747e37228559aa8983835 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 21:22:48 +0000 Subject: [PATCH 043/252] Version Bump SDKs (#55) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a960a82..b9d14c0 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -90d684ea-94b3-4173-a16b-f2473df80f25 \ No newline at end of file +8a393b3b-9e3d-4f4b-bbc3-bffefea63ff4 \ No newline at end of file diff --git a/README.md b/README.md index 3cef5e9..4d29b97 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.56-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.57-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.56" + "konfig/snaptrade-php-sdk": "2.0.57" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 2ebf384..c63d040 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.56/PHP'; + protected $userAgent = 'Konfig/2.0.57/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.56' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.57' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 24e2faa125aaf894cdc205c7b3b7f4ea869708b2 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 23:18:15 +0000 Subject: [PATCH 044/252] Regenerate SDKs (#56) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- lib/Model/SnapTradeHoldingsTotalValue.php | 2 +- test/Model/SnapTradeHoldingsTotalValueTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b9d14c0..fa942a7 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -8a393b3b-9e3d-4f4b-bbc3-bffefea63ff4 \ No newline at end of file +c28e6f11-03d6-4be8-be84-fa7df0143005 \ No newline at end of file diff --git a/lib/Model/SnapTradeHoldingsTotalValue.php b/lib/Model/SnapTradeHoldingsTotalValue.php index 30c9f84..16fd430 100644 --- a/lib/Model/SnapTradeHoldingsTotalValue.php +++ b/lib/Model/SnapTradeHoldingsTotalValue.php @@ -30,7 +30,7 @@ * SnapTradeHoldingsTotalValue Class Doc Comment * * @category Class - * @description This field is deprecated. To get the brokerage reported total market value of the account, please refer to `account.balance.total`. The total market value of the account. Note that this field is calculated based on the sum of the values of account positions and cash balances known to SnapTrade. It may not be accurate if the brokerage account has holdings that SnapTrade is not aware of. For example, if the brokerage account holds assets that SnapTrade does not support, the total value may be underreported. In certain cases, this value may also be double-counting cash-equivalent assets if those assets are represented as both cash and positions in the account. + * @description This field is deprecated. To get the brokerage reported total market value of the account, please refer to `account.balance.total`. The total market value of the account. Note that this field is calculated based on the sum of the values of account positions and cash balances known to SnapTrade. It may not be accurate if the brokerage account has holdings that SnapTrade is not aware of. For example, if the brokerage account holds assets that SnapTrade does not support, the total value may be underreported. In certain cases, this value may also be double-counting cash-equivalent assets if those assets are represented as both cash and positions in the account. * @package SnapTrade * @implements \ArrayAccess */ diff --git a/test/Model/SnapTradeHoldingsTotalValueTest.php b/test/Model/SnapTradeHoldingsTotalValueTest.php index 3e28ce9..ce9dd13 100644 --- a/test/Model/SnapTradeHoldingsTotalValueTest.php +++ b/test/Model/SnapTradeHoldingsTotalValueTest.php @@ -29,7 +29,7 @@ * SnapTradeHoldingsTotalValueTest Class Doc Comment * * @category Class - * @description This field is deprecated. To get the brokerage reported total market value of the account, please refer to `account.balance.total`. The total market value of the account. Note that this field is calculated based on the sum of the values of account positions and cash balances known to SnapTrade. It may not be accurate if the brokerage account has holdings that SnapTrade is not aware of. For example, if the brokerage account holds assets that SnapTrade does not support, the total value may be underreported. In certain cases, this value may also be double-counting cash-equivalent assets if those assets are represented as both cash and positions in the account. + * @description This field is deprecated. To get the brokerage reported total market value of the account, please refer to `account.balance.total`. The total market value of the account. Note that this field is calculated based on the sum of the values of account positions and cash balances known to SnapTrade. It may not be accurate if the brokerage account has holdings that SnapTrade is not aware of. For example, if the brokerage account holds assets that SnapTrade does not support, the total value may be underreported. In certain cases, this value may also be double-counting cash-equivalent assets if those assets are represented as both cash and positions in the account. * @package SnapTrade */ class SnapTradeHoldingsTotalValueTest extends TestCase From 997fc93639b4da0255e7394418eb4243b345f0f2 Mon Sep 17 00:00:00 2001 From: "konfig-bot[bot]" <121480725+konfig-bot[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 23:21:50 +0000 Subject: [PATCH 045/252] Version Bump SDKs (#57) Co-authored-by: konfig-publisher --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index fa942a7..c68c90b 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -c28e6f11-03d6-4be8-be84-fa7df0143005 \ No newline at end of file +d7e2c380-fd30-4295-8ccc-934dd724dab6 \ No newline at end of file diff --git a/README.md b/README.md index 4d29b97..aed0cbb 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.57-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.58-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.57" + "konfig/snaptrade-php-sdk": "2.0.58" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index c63d040..fe890b7 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.57/PHP'; + protected $userAgent = 'Konfig/2.0.58/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.57' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.58' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 42d836c0b959927ac9546a430b688b3a4aee5641 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:59:33 +0000 Subject: [PATCH 046/252] Regenerate SDKs (#62) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index c68c90b..e958225 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d7e2c380-fd30-4295-8ccc-934dd724dab6 \ No newline at end of file +ae569fb7-ec97-4dfd-b915-8930ef1defe0 \ No newline at end of file From 9c881e0d37786906596fe1eb21f663cf14877416 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:12:33 +0000 Subject: [PATCH 047/252] Version Bump SDKs (#63) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index e958225..2d0e7d7 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ae569fb7-ec97-4dfd-b915-8930ef1defe0 \ No newline at end of file +a36a2239-0327-4a9b-af1c-1e6eb3fc7317 \ No newline at end of file diff --git a/README.md b/README.md index aed0cbb..ed836d1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.58-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.59-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.58" + "konfig/snaptrade-php-sdk": "2.0.59" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index fe890b7..42d7049 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.58/PHP'; + protected $userAgent = 'Konfig/2.0.59/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.58' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.59' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From e89efab7d8dec520c6e7730074f90bdb65ee31a8 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:28:23 +0000 Subject: [PATCH 048/252] Regenerate SDKs (#64) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 2d0e7d7..499c343 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -a36a2239-0327-4a9b-af1c-1e6eb3fc7317 \ No newline at end of file +74122184-c436-4da5-8b14-75e124231fa8 \ No newline at end of file From 2f2bad24fd84dd2e329aa3698163581ce147617d Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:32:14 +0000 Subject: [PATCH 049/252] Version Bump SDKs (#65) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 499c343..67aa708 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -74122184-c436-4da5-8b14-75e124231fa8 \ No newline at end of file +676871cf-94e8-4456-8280-3e2d6728c55a \ No newline at end of file diff --git a/README.md b/README.md index ed836d1..c69fd88 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.59-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.60-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.59" + "konfig/snaptrade-php-sdk": "2.0.60" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 42d7049..ddb9e16 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.59/PHP'; + protected $userAgent = 'Konfig/2.0.60/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.59' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.60' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 4d7b3048e818402d62521e4ddbf9d7de08932f26 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:55:57 +0000 Subject: [PATCH 050/252] Regenerate SDKs (#66) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 67aa708..a133b46 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -676871cf-94e8-4456-8280-3e2d6728c55a \ No newline at end of file +ef396d61-c7fe-4880-b8d1-1cf14f459c38 \ No newline at end of file From bd06479cfb9df1da5ac6b0c3aa9665ad01f5e0ac Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:59:36 +0000 Subject: [PATCH 051/252] Version Bump SDKs (#67) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a133b46..4849c66 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ef396d61-c7fe-4880-b8d1-1cf14f459c38 \ No newline at end of file +07f8d645-0c39-4817-961f-35cda7e8cec9 \ No newline at end of file diff --git a/README.md b/README.md index c69fd88..f078661 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.60-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.61-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.60" + "konfig/snaptrade-php-sdk": "2.0.61" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index ddb9e16..d46b525 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.60/PHP'; + protected $userAgent = 'Konfig/2.0.61/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.60' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.61' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 90f99ddf16e764c4b7d452d8f6fde473925d0941 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:34:35 +0000 Subject: [PATCH 052/252] Regenerate SDKs (#68) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 4849c66..ce92887 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -07f8d645-0c39-4817-961f-35cda7e8cec9 \ No newline at end of file +1307cb70-6db2-483b-904f-4f2bf6a2e2b7 \ No newline at end of file From b96ccad5d7ff0f24a80a384a37201522acf0accf Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:38:23 +0000 Subject: [PATCH 053/252] Version Bump SDKs (#69) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index ce92887..cbfa082 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -1307cb70-6db2-483b-904f-4f2bf6a2e2b7 \ No newline at end of file +5c7d5743-8ef2-4ed1-80ae-2534e3721dfe \ No newline at end of file diff --git a/README.md b/README.md index f078661..0e01596 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.61-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.62-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.61" + "konfig/snaptrade-php-sdk": "2.0.62" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index d46b525..903fc3a 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.61/PHP'; + protected $userAgent = 'Konfig/2.0.62/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.61' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.62' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 3a4f0445ca962274752ed6982a56953ce732271e Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:53:06 +0000 Subject: [PATCH 054/252] Regenerate SDKs (#70) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index cbfa082..3c45b36 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -5c7d5743-8ef2-4ed1-80ae-2534e3721dfe \ No newline at end of file +0b28c3e5-35dc-4811-b217-d876575c88ef \ No newline at end of file From 60cbf8022fbc01a9d736c5c306e0f5198576ece3 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:56:49 +0000 Subject: [PATCH 055/252] Version Bump SDKs (#71) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 3c45b36..3865d8a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -0b28c3e5-35dc-4811-b217-d876575c88ef \ No newline at end of file +671b7712-e7d7-44e7-9a3e-d842f3b204c8 \ No newline at end of file diff --git a/README.md b/README.md index 0e01596..86f428d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.62-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.63-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.62" + "konfig/snaptrade-php-sdk": "2.0.63" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 903fc3a..9407dff 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.62/PHP'; + protected $userAgent = 'Konfig/2.0.63/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.62' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.63' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 556ec8160f638e9a59b74584c1da401596acffcc Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 22:00:05 +0000 Subject: [PATCH 056/252] Version Bump SDKs (#72) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 3865d8a..09e498a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -671b7712-e7d7-44e7-9a3e-d842f3b204c8 \ No newline at end of file +20587bb8-46e5-4d37-b9b4-751925cdaa53 \ No newline at end of file diff --git a/README.md b/README.md index 86f428d..b0f6f02 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.63-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.64-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.63" + "konfig/snaptrade-php-sdk": "2.0.64" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 9407dff..3b634fd 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.63/PHP'; + protected $userAgent = 'Konfig/2.0.64/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.63' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.64' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 28d8cc39678d302c6914aa9e491abd5f6f10501f Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 22:12:33 +0000 Subject: [PATCH 057/252] Version Bump SDKs (#73) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 09e498a..eccd589 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -20587bb8-46e5-4d37-b9b4-751925cdaa53 \ No newline at end of file +73a4a2fb-9e7e-4289-a322-1c025396b148 \ No newline at end of file diff --git a/README.md b/README.md index b0f6f02..ef4907e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.64-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.65-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.64" + "konfig/snaptrade-php-sdk": "2.0.65" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 3b634fd..43756da 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.64/PHP'; + protected $userAgent = 'Konfig/2.0.65/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.64' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.65' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 7134dca6b581e0459a374ad3c2174e8df3cfe0ef Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 01:03:39 +0000 Subject: [PATCH 058/252] Version Bump SDKs (#74) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index eccd589..11e07ec 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -73a4a2fb-9e7e-4289-a322-1c025396b148 \ No newline at end of file +760921b9-f1e0-41ea-bea5-0a9edf36733f \ No newline at end of file From 60e477040919f6f00139ecae9a6d8fbd9cf1b068 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 01:21:52 +0000 Subject: [PATCH 059/252] Version Bump SDKs (#75) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 11e07ec..05c9059 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -760921b9-f1e0-41ea-bea5-0a9edf36733f \ No newline at end of file +14790884-217b-4c9b-9d71-c962d1034849 \ No newline at end of file diff --git a/README.md b/README.md index ef4907e..b936598 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.65-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.66-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.65" + "konfig/snaptrade-php-sdk": "2.0.66" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 43756da..befc0c6 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.65/PHP'; + protected $userAgent = 'Konfig/2.0.66/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.65' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.66' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From c9a6dbcf357161041db1fbf395339cbaf5142af4 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 02:01:54 +0000 Subject: [PATCH 060/252] Version Bump SDKs (#76) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 05c9059..a311ec5 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -14790884-217b-4c9b-9d71-c962d1034849 \ No newline at end of file +2f907844-8708-4805-b492-bd0d05223744 \ No newline at end of file From 1f9e2c43d05d21daa29ba7339f0a73dcfadd2424 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:35:49 +0000 Subject: [PATCH 061/252] Version Bump SDKs (#77) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a311ec5..e3d08b6 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2f907844-8708-4805-b492-bd0d05223744 \ No newline at end of file +6d472a3d-77ec-4ff3-83d3-fd4243203f0c \ No newline at end of file From c5abcb0962bce24a7d6d377f6f2832dea4d38516 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 14:57:14 +0000 Subject: [PATCH 062/252] Regenerate SDKs (#78) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 9 +++++---- lib/Api/AccountInformationApi.php | 16 ++++++++-------- test/Api/AccountInformationApiTest.php | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index e3d08b6..52764e6 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -6d472a3d-77ec-4ff3-83d3-fd4243203f0c \ No newline at end of file +5a1a0230-5fb6-4d8d-863d-5bb2b115a5e7 \ No newline at end of file diff --git a/README.md b/README.md index b936598..c349e7e 100644 --- a/README.md +++ b/README.md @@ -343,10 +343,11 @@ $result = $snaptrade->accountInformation->getUserAccountPositions( ### `snaptrade.accountInformation.getUserAccountRecentOrders` -Returns a list of orders executed in the last 24 hours in the specified account. -This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution -Differs from /orders in that it only returns orders that have been *executed* in the last 24 hours as opposed to pending or cancelled orders up to 30 days old -*Please contact support for access as this endpoint is not enabled by default.* +A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. +This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders +Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days +By default only returns executed orders, but that can be changed by setting *only_executed* to false +**Please contact support for access as this endpoint is not enabled by default.** diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 128e605..158dfe5 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -2314,9 +2314,9 @@ public function getUserAccountPositionsRequest($user_id, $user_secret, $account_ /** * Operation getUserAccountRecentOrders * - * List account recent executed orders + * List account recent orders (last 24 hours only) * - * Returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution Differs from /orders in that it only returns orders that have been *executed* in the last 24 hours as opposed to pending or cancelled orders up to 30 days old *Please contact support for access as this endpoint is not enabled by default.* + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Please contact support for access as this endpoint is not enabled by default.** * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -2345,9 +2345,9 @@ public function getUserAccountRecentOrders( /** * Operation getUserAccountRecentOrdersWithHttpInfo * - * List account recent executed orders + * List account recent orders (last 24 hours only) * - * Returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution Differs from /orders in that it only returns orders that have been *executed* in the last 24 hours as opposed to pending or cancelled orders up to 30 days old *Please contact support for access as this endpoint is not enabled by default.* + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Please contact support for access as this endpoint is not enabled by default.** * * @param string $user_id (required) * @param string $user_secret (required) @@ -2514,9 +2514,9 @@ public function getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $ /** * Operation getUserAccountRecentOrdersAsync * - * List account recent executed orders + * List account recent orders (last 24 hours only) * - * Returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution Differs from /orders in that it only returns orders that have been *executed* in the last 24 hours as opposed to pending or cancelled orders up to 30 days old *Please contact support for access as this endpoint is not enabled by default.* + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Please contact support for access as this endpoint is not enabled by default.** * * @param string $user_id (required) * @param string $user_secret (required) @@ -2548,9 +2548,9 @@ function ($response) { /** * Operation getUserAccountRecentOrdersAsyncWithHttpInfo * - * List account recent executed orders + * List account recent orders (last 24 hours only) * - * Returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution Differs from /orders in that it only returns orders that have been *executed* in the last 24 hours as opposed to pending or cancelled orders up to 30 days old *Please contact support for access as this endpoint is not enabled by default.* + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Please contact support for access as this endpoint is not enabled by default.** * * @param string $user_id (required) * @param string $user_secret (required) diff --git a/test/Api/AccountInformationApiTest.php b/test/Api/AccountInformationApiTest.php index fd1a035..59095da 100644 --- a/test/Api/AccountInformationApiTest.php +++ b/test/Api/AccountInformationApiTest.php @@ -121,7 +121,7 @@ public function testGetUserAccountPositions() /** * Test case for getUserAccountRecentOrders * - * List account recent executed orders. + * List account recent orders (last 24 hours only). * */ public function testGetUserAccountRecentOrders() From 42e3650bef8dc71439564d90e1b6d4ffe6bf66df Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:01:11 +0000 Subject: [PATCH 063/252] Version Bump SDKs (#79) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 52764e6..25629ce 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -5a1a0230-5fb6-4d8d-863d-5bb2b115a5e7 \ No newline at end of file +2a40001d-1f28-4c73-89de-35f455a51ce2 \ No newline at end of file diff --git a/README.md b/README.md index c349e7e..119c18d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.66-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.67-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.66" + "konfig/snaptrade-php-sdk": "2.0.67" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index befc0c6..8f34d79 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.66/PHP'; + protected $userAgent = 'Konfig/2.0.67/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.66' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.67' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From ead7acb821519d0c6dcc7b954bc8c066a2bbd1aa Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 14:10:00 +0000 Subject: [PATCH 064/252] Regenerate SDKs (#80) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/Account.php | 55 +++++++++++++++++++++++++++++++++----- test/Model/AccountTest.php | 9 +++++++ 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 25629ce..771cce5 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2a40001d-1f28-4c73-89de-35f455a51ce2 \ No newline at end of file +3111ef54-b392-4b37-830c-a851237b4042 \ No newline at end of file diff --git a/lib/Model/Account.php b/lib/Model/Account.php index ebd5609..c68bb49 100644 --- a/lib/Model/Account.php +++ b/lib/Model/Account.php @@ -61,7 +61,8 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'balance' => '\SnapTrade\Model\AccountBalance', 'meta' => 'array', 'portfolio_group' => 'string', - 'cash_restrictions' => 'string[]' + 'cash_restrictions' => 'string[]', + 'raw_type' => 'string' ]; /** @@ -82,7 +83,8 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'balance' => null, 'meta' => null, 'portfolio_group' => 'uuid', - 'cash_restrictions' => null + 'cash_restrictions' => null, + 'raw_type' => null ]; /** @@ -101,7 +103,8 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'balance' => false, 'meta' => false, 'portfolio_group' => false, - 'cash_restrictions' => false + 'cash_restrictions' => false, + 'raw_type' => true ]; /** @@ -200,7 +203,8 @@ public function isNullableSetToNull(string $property): bool 'balance' => 'balance', 'meta' => 'meta', 'portfolio_group' => 'portfolio_group', - 'cash_restrictions' => 'cash_restrictions' + 'cash_restrictions' => 'cash_restrictions', + 'raw_type' => 'raw_type' ]; /** @@ -219,7 +223,8 @@ public function isNullableSetToNull(string $property): bool 'balance' => 'setBalance', 'meta' => 'setMeta', 'portfolio_group' => 'setPortfolioGroup', - 'cash_restrictions' => 'setCashRestrictions' + 'cash_restrictions' => 'setCashRestrictions', + 'raw_type' => 'setRawType' ]; /** @@ -238,7 +243,8 @@ public function isNullableSetToNull(string $property): bool 'balance' => 'getBalance', 'meta' => 'getMeta', 'portfolio_group' => 'getPortfolioGroup', - 'cash_restrictions' => 'getCashRestrictions' + 'cash_restrictions' => 'getCashRestrictions', + 'raw_type' => 'getRawType' ]; /** @@ -309,6 +315,7 @@ public function __construct(array $data = null) $this->setIfExists('meta', $data ?? [], null); $this->setIfExists('portfolio_group', $data ?? [], null); $this->setIfExists('cash_restrictions', $data ?? [], null); + $this->setIfExists('raw_type', $data ?? [], null); } /** @@ -708,6 +715,42 @@ public function setCashRestrictions($cash_restrictions) return $this; } + + /** + * Gets raw_type + * + * @return string|null + */ + public function getRawType() + { + return $this->container['raw_type']; + } + + /** + * Sets raw_type + * + * @param string|null $raw_type The account type as provided by the brokerage + * + * @return self + */ + public function setRawType($raw_type) + { + + if (is_null($raw_type)) { + array_push($this->openAPINullablesSetToNull, 'raw_type'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('raw_type', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['raw_type'] = $raw_type; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/test/Model/AccountTest.php b/test/Model/AccountTest.php index 3e1937e..2fab6d0 100644 --- a/test/Model/AccountTest.php +++ b/test/Model/AccountTest.php @@ -170,4 +170,13 @@ public function testPropertyCashRestrictions() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "raw_type" + */ + public function testPropertyRawType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } From f6861c78ff531884fd1b348a0c4c4b3076a9308e Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 14:13:50 +0000 Subject: [PATCH 065/252] Version Bump SDKs (#81) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 771cce5..d8766a1 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -3111ef54-b392-4b37-830c-a851237b4042 \ No newline at end of file +c37dd08f-1bfa-4516-9d6a-64a28cb2a11f \ No newline at end of file diff --git a/README.md b/README.md index 119c18d..6e9a9bc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.67-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.68-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.67" + "konfig/snaptrade-php-sdk": "2.0.68" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 8f34d79..2fe46dd 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.67/PHP'; + protected $userAgent = 'Konfig/2.0.68/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.67' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.68' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From d8cc565afc7f4922dafadb25eba71b785b801223 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 18:52:32 +0000 Subject: [PATCH 066/252] Regenerate SDKs (#82) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 18 +- lib/Api/TradingApi.php | 12 + lib/Model/ManualTradeFormWithOptions.php | 175 ++++++- .../ManualTradeFormWithOptionsStopLoss.php | 447 +++++++++++++++++ .../ManualTradeFormWithOptionsTakeProfit.php | 404 ++++++++++++++++ lib/Model/StopLoss.php | 448 ++++++++++++++++++ lib/Model/TakeProfit.php | 405 ++++++++++++++++ ...ManualTradeFormWithOptionsStopLossTest.php | 92 ++++ ...nualTradeFormWithOptionsTakeProfitTest.php | 83 ++++ test/Model/ManualTradeFormWithOptionsTest.php | 27 ++ test/Model/StopLossTest.php | 92 ++++ test/Model/TakeProfitTest.php | 83 ++++ 13 files changed, 2280 insertions(+), 8 deletions(-) create mode 100644 lib/Model/ManualTradeFormWithOptionsStopLoss.php create mode 100644 lib/Model/ManualTradeFormWithOptionsTakeProfit.php create mode 100644 lib/Model/StopLoss.php create mode 100644 lib/Model/TakeProfit.php create mode 100644 test/Model/ManualTradeFormWithOptionsStopLossTest.php create mode 100644 test/Model/ManualTradeFormWithOptionsTakeProfitTest.php create mode 100644 test/Model/StopLossTest.php create mode 100644 test/Model/TakeProfitTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index d8766a1..0e7e83d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -c37dd08f-1bfa-4516-9d6a-64a28cb2a11f \ No newline at end of file +e5c9d30e-caca-42e1-8b4f-e92e45b7062a \ No newline at end of file diff --git a/README.md b/README.md index 6e9a9bc..f8fae32 100644 --- a/README.md +++ b/README.md @@ -1789,7 +1789,15 @@ $result = $snaptrade->trading->placeForceOrder( price: 31.33, stop: 31.33, units: 10.5, - notional_value: None + notional_value: None, + order_class: "BRACKET", + stop_loss: [ + "stop_price" => "48.55", + "limit_price" => "48.50", + ], + take_profit: [ + "limit_price" => "49.95", + ] ); ``` @@ -1831,6 +1839,14 @@ For Equity orders, this represents the number of shares for the order. This can ##### notional_value: [`ManualTradeFormNotionalValue`](./lib/Model/ManualTradeFormNotionalValue.php) +##### order_class: `string` + +The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details + +##### stop_loss: [`ManualTradeFormWithOptionsStopLoss`](./lib/Model/ManualTradeFormWithOptionsStopLoss.php) + +##### take_profit: [`ManualTradeFormWithOptionsTakeProfit`](./lib/Model/ManualTradeFormWithOptionsTakeProfit.php) + #### πŸ”„ Return diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index b631246..0db3abf 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -1622,6 +1622,9 @@ public function placeForceOrder( $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, $notional_value = SENTINEL_VALUE, + $order_class = SENTINEL_VALUE, + $stop_loss = SENTINEL_VALUE, + $take_profit = SENTINEL_VALUE, string $contentType = self::contentTypes['placeForceOrder'][0] ) { @@ -1636,6 +1639,9 @@ public function placeForceOrder( $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $this->setRequestBodyProperty($_body, "order_class", $order_class); + $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); + $this->setRequestBodyProperty($_body, "take_profit", $take_profit); $manual_trade_form_with_options = $_body; list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); @@ -1838,6 +1844,9 @@ public function placeForceOrderAsync( $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, $notional_value = SENTINEL_VALUE, + $order_class = SENTINEL_VALUE, + $stop_loss = SENTINEL_VALUE, + $take_profit = SENTINEL_VALUE, string $contentType = self::contentTypes['placeForceOrder'][0] ) { @@ -1852,6 +1861,9 @@ public function placeForceOrderAsync( $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $this->setRequestBodyProperty($_body, "order_class", $order_class); + $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); + $this->setRequestBodyProperty($_body, "take_profit", $take_profit); $manual_trade_form_with_options = $_body; return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) diff --git a/lib/Model/ManualTradeFormWithOptions.php b/lib/Model/ManualTradeFormWithOptions.php index 079ba2a..45840a9 100644 --- a/lib/Model/ManualTradeFormWithOptions.php +++ b/lib/Model/ManualTradeFormWithOptions.php @@ -60,7 +60,10 @@ class ManualTradeFormWithOptions implements ModelInterface, ArrayAccess, \JsonSe 'price' => 'float', 'stop' => 'float', 'units' => 'float', - 'notional_value' => '\SnapTrade\Model\ManualTradeFormNotionalValue' + 'notional_value' => '\SnapTrade\Model\ManualTradeFormNotionalValue', + 'order_class' => 'string', + 'stop_loss' => '\SnapTrade\Model\ManualTradeFormWithOptionsStopLoss', + 'take_profit' => '\SnapTrade\Model\ManualTradeFormWithOptionsTakeProfit' ]; /** @@ -80,7 +83,10 @@ class ManualTradeFormWithOptions implements ModelInterface, ArrayAccess, \JsonSe 'price' => null, 'stop' => null, 'units' => null, - 'notional_value' => null + 'notional_value' => null, + 'order_class' => null, + 'stop_loss' => null, + 'take_profit' => null ]; /** @@ -98,7 +104,10 @@ class ManualTradeFormWithOptions implements ModelInterface, ArrayAccess, \JsonSe 'price' => true, 'stop' => true, 'units' => true, - 'notional_value' => true + 'notional_value' => true, + 'order_class' => true, + 'stop_loss' => true, + 'take_profit' => true ]; /** @@ -196,7 +205,10 @@ public function isNullableSetToNull(string $property): bool 'price' => 'price', 'stop' => 'stop', 'units' => 'units', - 'notional_value' => 'notional_value' + 'notional_value' => 'notional_value', + 'order_class' => 'order_class', + 'stop_loss' => 'stop_loss', + 'take_profit' => 'take_profit' ]; /** @@ -214,7 +226,10 @@ public function isNullableSetToNull(string $property): bool 'price' => 'setPrice', 'stop' => 'setStop', 'units' => 'setUnits', - 'notional_value' => 'setNotionalValue' + 'notional_value' => 'setNotionalValue', + 'order_class' => 'setOrderClass', + 'stop_loss' => 'setStopLoss', + 'take_profit' => 'setTakeProfit' ]; /** @@ -232,7 +247,10 @@ public function isNullableSetToNull(string $property): bool 'price' => 'getPrice', 'stop' => 'getStop', 'units' => 'getUnits', - 'notional_value' => 'getNotionalValue' + 'notional_value' => 'getNotionalValue', + 'order_class' => 'getOrderClass', + 'stop_loss' => 'getStopLoss', + 'take_profit' => 'getTakeProfit' ]; /** @@ -276,6 +294,21 @@ public function getModelName() return self::$openAPIModelName; } + public const ORDER_CLASS_SIMPLE = 'SIMPLE'; + public const ORDER_CLASS_BRACKET = 'BRACKET'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getOrderClassAllowableValues() + { + return [ + self::ORDER_CLASS_SIMPLE, + self::ORDER_CLASS_BRACKET, + ]; + } /** * Associative array for storing property values @@ -302,6 +335,9 @@ public function __construct(array $data = null) $this->setIfExists('stop', $data ?? [], null); $this->setIfExists('units', $data ?? [], null); $this->setIfExists('notional_value', $data ?? [], null); + $this->setIfExists('order_class', $data ?? [], null); + $this->setIfExists('stop_loss', $data ?? [], null); + $this->setIfExists('take_profit', $data ?? [], null); } /** @@ -343,6 +379,15 @@ public function listInvalidProperties() if ($this->container['time_in_force'] === null) { $invalidProperties[] = "'time_in_force' can't be null"; } + $allowedValues = $this->getOrderClassAllowableValues(); + if (!is_null($this->container['order_class']) && !in_array($this->container['order_class'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'order_class', must be one of '%s'", + $this->container['order_class'], + implode("', '", $allowedValues) + ); + } + return $invalidProperties; } @@ -689,6 +734,124 @@ public function setNotionalValue($notional_value) return $this; } + + /** + * Gets order_class + * + * @return string|null + */ + public function getOrderClass() + { + return $this->container['order_class']; + } + + /** + * Sets order_class + * + * @param string|null $order_class The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details + * + * @return self + */ + public function setOrderClass($order_class) + { + $allowedValues = $this->getOrderClassAllowableValues(); + if (!is_null($order_class) && !in_array($order_class, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'order_class', must be one of '%s'", + $order_class, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($order_class)) { + array_push($this->openAPINullablesSetToNull, 'order_class'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('order_class', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['order_class'] = $order_class; + + return $this; + } + + /** + * Gets stop_loss + * + * @return \SnapTrade\Model\ManualTradeFormWithOptionsStopLoss|null + */ + public function getStopLoss() + { + return $this->container['stop_loss']; + } + + /** + * Sets stop_loss + * + * @param \SnapTrade\Model\ManualTradeFormWithOptionsStopLoss|null $stop_loss stop_loss + * + * @return self + */ + public function setStopLoss($stop_loss) + { + + if (is_null($stop_loss)) { + array_push($this->openAPINullablesSetToNull, 'stop_loss'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('stop_loss', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['stop_loss'] = $stop_loss; + + return $this; + } + + /** + * Gets take_profit + * + * @return \SnapTrade\Model\ManualTradeFormWithOptionsTakeProfit|null + */ + public function getTakeProfit() + { + return $this->container['take_profit']; + } + + /** + * Sets take_profit + * + * @param \SnapTrade\Model\ManualTradeFormWithOptionsTakeProfit|null $take_profit take_profit + * + * @return self + */ + public function setTakeProfit($take_profit) + { + + if (is_null($take_profit)) { + array_push($this->openAPINullablesSetToNull, 'take_profit'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('take_profit', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['take_profit'] = $take_profit; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/ManualTradeFormWithOptionsStopLoss.php b/lib/Model/ManualTradeFormWithOptionsStopLoss.php new file mode 100644 index 0000000..12cd1e8 --- /dev/null +++ b/lib/Model/ManualTradeFormWithOptionsStopLoss.php @@ -0,0 +1,447 @@ + + */ +class ManualTradeFormWithOptionsStopLoss implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ManualTradeFormWithOptions_stop_loss'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'stop_price' => 'string', + 'limit_price' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'stop_price' => null, + 'limit_price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'stop_price' => false, + 'limit_price' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'stop_price' => 'stop_price', + 'limit_price' => 'limit_price' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'stop_price' => 'setStopPrice', + 'limit_price' => 'setLimitPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'stop_price' => 'getStopPrice', + 'limit_price' => 'getLimitPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('stop_price', $data ?? [], null); + $this->setIfExists('limit_price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets stop_price + * + * @return string|null + */ + public function getStopPrice() + { + return $this->container['stop_price']; + } + + /** + * Sets stop_price + * + * @param string|null $stop_price stop_price + * + * @return self + */ + public function setStopPrice($stop_price) + { + + if (is_null($stop_price)) { + throw new \InvalidArgumentException('non-nullable stop_price cannot be null'); + } + + $this->container['stop_price'] = $stop_price; + + return $this; + } + + /** + * Gets limit_price + * + * @return string|null + */ + public function getLimitPrice() + { + return $this->container['limit_price']; + } + + /** + * Sets limit_price + * + * @param string|null $limit_price limit_price + * + * @return self + */ + public function setLimitPrice($limit_price) + { + + if (is_null($limit_price)) { + array_push($this->openAPINullablesSetToNull, 'limit_price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('limit_price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['limit_price'] = $limit_price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/ManualTradeFormWithOptionsTakeProfit.php b/lib/Model/ManualTradeFormWithOptionsTakeProfit.php new file mode 100644 index 0000000..3a4df8c --- /dev/null +++ b/lib/Model/ManualTradeFormWithOptionsTakeProfit.php @@ -0,0 +1,404 @@ + + */ +class ManualTradeFormWithOptionsTakeProfit implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ManualTradeFormWithOptions_take_profit'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'limit_price' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'limit_price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'limit_price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'limit_price' => 'limit_price' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'limit_price' => 'setLimitPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'limit_price' => 'getLimitPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('limit_price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets limit_price + * + * @return string|null + */ + public function getLimitPrice() + { + return $this->container['limit_price']; + } + + /** + * Sets limit_price + * + * @param string|null $limit_price limit_price + * + * @return self + */ + public function setLimitPrice($limit_price) + { + + if (is_null($limit_price)) { + throw new \InvalidArgumentException('non-nullable limit_price cannot be null'); + } + + $this->container['limit_price'] = $limit_price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/StopLoss.php b/lib/Model/StopLoss.php new file mode 100644 index 0000000..18ff94f --- /dev/null +++ b/lib/Model/StopLoss.php @@ -0,0 +1,448 @@ + + */ +class StopLoss implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'StopLoss'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'stop_price' => 'string', + 'limit_price' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'stop_price' => null, + 'limit_price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'stop_price' => false, + 'limit_price' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'stop_price' => 'stop_price', + 'limit_price' => 'limit_price' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'stop_price' => 'setStopPrice', + 'limit_price' => 'setLimitPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'stop_price' => 'getStopPrice', + 'limit_price' => 'getLimitPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('stop_price', $data ?? [], null); + $this->setIfExists('limit_price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets stop_price + * + * @return string|null + */ + public function getStopPrice() + { + return $this->container['stop_price']; + } + + /** + * Sets stop_price + * + * @param string|null $stop_price stop_price + * + * @return self + */ + public function setStopPrice($stop_price) + { + + if (is_null($stop_price)) { + throw new \InvalidArgumentException('non-nullable stop_price cannot be null'); + } + + $this->container['stop_price'] = $stop_price; + + return $this; + } + + /** + * Gets limit_price + * + * @return string|null + */ + public function getLimitPrice() + { + return $this->container['limit_price']; + } + + /** + * Sets limit_price + * + * @param string|null $limit_price limit_price + * + * @return self + */ + public function setLimitPrice($limit_price) + { + + if (is_null($limit_price)) { + array_push($this->openAPINullablesSetToNull, 'limit_price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('limit_price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['limit_price'] = $limit_price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/TakeProfit.php b/lib/Model/TakeProfit.php new file mode 100644 index 0000000..749dfd6 --- /dev/null +++ b/lib/Model/TakeProfit.php @@ -0,0 +1,405 @@ + + */ +class TakeProfit implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TakeProfit'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'limit_price' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'limit_price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'limit_price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'limit_price' => 'limit_price' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'limit_price' => 'setLimitPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'limit_price' => 'getLimitPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('limit_price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets limit_price + * + * @return string|null + */ + public function getLimitPrice() + { + return $this->container['limit_price']; + } + + /** + * Sets limit_price + * + * @param string|null $limit_price limit_price + * + * @return self + */ + public function setLimitPrice($limit_price) + { + + if (is_null($limit_price)) { + throw new \InvalidArgumentException('non-nullable limit_price cannot be null'); + } + + $this->container['limit_price'] = $limit_price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Model/ManualTradeFormWithOptionsStopLossTest.php b/test/Model/ManualTradeFormWithOptionsStopLossTest.php new file mode 100644 index 0000000..29742d3 --- /dev/null +++ b/test/Model/ManualTradeFormWithOptionsStopLossTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop_price" + */ + public function testPropertyStopPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "limit_price" + */ + public function testPropertyLimitPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/ManualTradeFormWithOptionsTakeProfitTest.php b/test/Model/ManualTradeFormWithOptionsTakeProfitTest.php new file mode 100644 index 0000000..e1c5868 --- /dev/null +++ b/test/Model/ManualTradeFormWithOptionsTakeProfitTest.php @@ -0,0 +1,83 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "limit_price" + */ + public function testPropertyLimitPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/ManualTradeFormWithOptionsTest.php b/test/Model/ManualTradeFormWithOptionsTest.php index 7aa386f..ff87240 100644 --- a/test/Model/ManualTradeFormWithOptionsTest.php +++ b/test/Model/ManualTradeFormWithOptionsTest.php @@ -161,4 +161,31 @@ public function testPropertyNotionalValue() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "order_class" + */ + public function testPropertyOrderClass() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop_loss" + */ + public function testPropertyStopLoss() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "take_profit" + */ + public function testPropertyTakeProfit() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } diff --git a/test/Model/StopLossTest.php b/test/Model/StopLossTest.php new file mode 100644 index 0000000..c1523a9 --- /dev/null +++ b/test/Model/StopLossTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop_price" + */ + public function testPropertyStopPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "limit_price" + */ + public function testPropertyLimitPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/TakeProfitTest.php b/test/Model/TakeProfitTest.php new file mode 100644 index 0000000..00ff289 --- /dev/null +++ b/test/Model/TakeProfitTest.php @@ -0,0 +1,83 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "limit_price" + */ + public function testPropertyLimitPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From 871bd5a72cfb9bf8d1044a29a75291a373a0aab1 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 18:56:21 +0000 Subject: [PATCH 067/252] Version Bump SDKs (#83) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0e7e83d..6713820 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -e5c9d30e-caca-42e1-8b4f-e92e45b7062a \ No newline at end of file +18a2ff8b-efe3-4c9f-98d8-3a4955dd3d5f \ No newline at end of file diff --git a/README.md b/README.md index f8fae32..eb21597 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.68-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.69-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -89,7 +89,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.68" + "konfig/snaptrade-php-sdk": "2.0.69" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 2fe46dd..83aca7f 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.68/PHP'; + protected $userAgent = 'Konfig/2.0.69/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.68' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.69' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From b23c69933cc521e5e1089357f39362ab5172da13 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:24:57 +0000 Subject: [PATCH 068/252] Regenerate SDKs (#84) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 67 +++- lib/Api/AccountInformationApi.php | 466 ++++++++++++++++++++++++ lib/Api/TransactionsAndReportingApi.php | 8 +- test/Api/AccountInformationApiTest.php | 12 + 5 files changed, 547 insertions(+), 8 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 6713820..540773a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -18a2ff8b-efe3-4c9f-98d8-3a4955dd3d5f \ No newline at end of file +f6aa3676-5057-4421-ad77-92bc76abefa1 \ No newline at end of file diff --git a/README.md b/README.md index eb21597..174ffe6 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Connect brokerage accounts to your app for live positions and trading * [Manual Installation](#manual-installation) - [Getting Started](#getting-started) - [Reference](#reference) + * [`snaptrade.accountInformation.getAccountActivities`](#snaptradeaccountinformationgetaccountactivities) * [`snaptrade.accountInformation.getAllUserHoldings`](#snaptradeaccountinformationgetalluserholdings) * [`snaptrade.accountInformation.getUserAccountBalance`](#snaptradeaccountinformationgetuseraccountbalance) * [`snaptrade.accountInformation.getUserAccountDetails`](#snaptradeaccountinformationgetuseraccountdetails) @@ -118,15 +119,75 @@ $snaptrade = new \SnapTrade\Client( consumerKey: getenv("SNAPTRADE_CONSUMER_KEY") ); -$result = $snaptrade->accountInformation->getAllUserHoldings( +$result = $snaptrade->accountInformation->getAccountActivities( + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631" + start_date: "2022-01-24", + end_date: "2022-01-24", + type: "BUY,SELL,DIVIDEND" ); ``` ## Reference +### `snaptrade.accountInformation.getAccountActivities` + +Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. + +There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. + +The data returned here is always cached and refreshed once a day. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->accountInformation->getAccountActivities( + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + start_date: "2022-01-24", + end_date: "2022-01-24", + type: "BUY,SELL,DIVIDEND" +); +``` + +#### βš™οΈ Parameters + +##### account_id: `string` + +##### user_id: `string` + +##### user_secret: `string` + +##### start_date: `\DateTime` + +The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. + +##### end_date: `\DateTime` + +The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. + +##### type: `string` + +Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another + + +#### πŸ”„ Return + +[**UniversalActivity**](./lib/Model/UniversalActivity.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/activities` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.accountInformation.getAllUserHoldings` ![Deprecated](https://img.shields.io/badge/deprecated-yellow) @@ -1914,7 +1975,7 @@ Returns all historical transactions for the specified user and filtering criteri There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. -The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +The data returned here is always cached and refreshed once a day. diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 158dfe5..9c47d74 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -62,6 +62,9 @@ class AccountInformationApi extends \SnapTrade\CustomApi /** @var string[] $contentTypes **/ public const contentTypes = [ + 'getAccountActivities' => [ + 'application/json', + ], 'getAllUserHoldings' => [ 'application/json', ], @@ -162,6 +165,469 @@ private function setRequestBodyProperty(&$body, $property, $value) { $body[$property] = $value; } + /** + * Operation getAccountActivities + * + * List account activities + * + * Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * + * @param string $account_id account_id (required) + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) + * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\UniversalActivity[] + */ + public function getAccountActivities( + $account_id, + $user_id, + $user_secret, + $start_date = SENTINEL_VALUE, + $end_date = SENTINEL_VALUE, + $type = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getAccountActivities'][0] + ) + { + + list($response) = $this->getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_secret, $start_date, $end_date, $type, $contentType); + return $response; + } + + /** + * Operation getAccountActivitiesWithHttpInfo + * + * List account activities + * + * Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * + * @param string $account_id (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) + * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\UniversalActivity[], HTTP status code, HTTP response headers (array of strings) + */ + public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_secret, $start_date = null, $end_date = null, $type = null, string $contentType = self::contentTypes['getAccountActivities'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->getAccountActivitiesRequest($account_id, $user_id, $user_secret, $start_date, $end_date, $type, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->getAccountActivitiesWithHttpInfo( + $account_id, + $user_id, + $user_secret, + $start_date, + $end_date, + $type, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\UniversalActivity[]' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\UniversalActivity[]' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\UniversalActivity[]', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\UniversalActivity[]'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\UniversalActivity[]', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getAccountActivitiesAsync + * + * List account activities + * + * Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * + * @param string $account_id (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) + * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getAccountActivitiesAsync( + $account_id, + $user_id, + $user_secret, + $start_date = SENTINEL_VALUE, + $end_date = SENTINEL_VALUE, + $type = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getAccountActivities'][0] + ) + { + + return $this->getAccountActivitiesAsyncWithHttpInfo($account_id, $user_id, $user_secret, $start_date, $end_date, $type, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getAccountActivitiesAsyncWithHttpInfo + * + * List account activities + * + * Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * + * @param string $account_id (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) + * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getAccountActivitiesAsyncWithHttpInfo($account_id, $user_id, $user_secret, $start_date = null, $end_date = null, $type = null, string $contentType = self::contentTypes['getAccountActivities'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\UniversalActivity[]'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getAccountActivitiesRequest($account_id, $user_id, $user_secret, $start_date, $end_date, $type, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getAccountActivities' + * + * @param string $account_id (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) + * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getAccountActivitiesRequest($account_id, $user_id, $user_secret, $start_date = SENTINEL_VALUE, $end_date = SENTINEL_VALUE, $type = SENTINEL_VALUE, string $contentType = self::contentTypes['getAccountActivities'][0]) + { + + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getAccountActivities' + ); + } + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getAccountActivities' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getAccountActivities' + ); + } + // Check if $type is a string + if ($type !== SENTINEL_VALUE && !is_string($type)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($type, true), gettype($type))); + } + + + $resourcePath = '/accounts/{accountId}/activities'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($start_date !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $start_date, + 'startDate', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($end_date !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $end_date, + 'endDate', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($type !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $type, + 'type', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + /** * Operation getAllUserHoldings * diff --git a/lib/Api/TransactionsAndReportingApi.php b/lib/Api/TransactionsAndReportingApi.php index fda66bc..ff88e35 100644 --- a/lib/Api/TransactionsAndReportingApi.php +++ b/lib/Api/TransactionsAndReportingApi.php @@ -143,7 +143,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * Get transaction history for a user * - * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -180,7 +180,7 @@ public function getActivities( * * Get transaction history for a user * - * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. * * @param string $user_id (required) * @param string $user_secret (required) @@ -309,7 +309,7 @@ public function getActivitiesWithHttpInfo($user_id, $user_secret, $start_date = * * Get transaction history for a user * - * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. * * @param string $user_id (required) * @param string $user_secret (required) @@ -349,7 +349,7 @@ function ($response) { * * Get transaction history for a user * - * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. * * @param string $user_id (required) * @param string $user_secret (required) diff --git a/test/Api/AccountInformationApiTest.php b/test/Api/AccountInformationApiTest.php index 59095da..6aef9a8 100644 --- a/test/Api/AccountInformationApiTest.php +++ b/test/Api/AccountInformationApiTest.php @@ -58,6 +58,18 @@ public static function tearDownAfterClass(): void { } + /** + * Test case for getAccountActivities + * + * List account activities. + * + */ + public function testGetAccountActivities() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for getAllUserHoldings * From 49ef983abd0b045cf1a486db4f3e35a76f03c7b0 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:29:02 +0000 Subject: [PATCH 069/252] Version Bump SDKs (#85) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 540773a..34bab66 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f6aa3676-5057-4421-ad77-92bc76abefa1 \ No newline at end of file +638acc1c-7d62-46d4-9879-9594e477e977 \ No newline at end of file diff --git a/README.md b/README.md index 174ffe6..4d36daf 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.69-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.70-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.69" + "konfig/snaptrade-php-sdk": "2.0.70" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 83aca7f..0fe81bd 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.69/PHP'; + protected $userAgent = 'Konfig/2.0.70/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.69' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.70' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 007ca39b3804e0b3a584c5e98e109bab96359c86 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 19:33:05 +0000 Subject: [PATCH 070/252] Regenerate SDKs (#86) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 1 + lib/Api/ConnectionsApi.php | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 34bab66..cd95401 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -638acc1c-7d62-46d4-9879-9594e477e977 \ No newline at end of file +ef8ce378-11a2-4e4d-98af-4affe8c8c848 \ No newline at end of file diff --git a/README.md b/README.md index 4d36daf..fb927c4 100644 --- a/README.md +++ b/README.md @@ -945,6 +945,7 @@ $result = $snaptrade->connections->listBrokerageAuthorizations( ### `snaptrade.connections.refreshBrokerageAuthorization` Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. +This endpoint will also trigger a transaction sync for the past day if one has not yet occured. *Please contact support for access as this endpoint is not enabled by default.* diff --git a/lib/Api/ConnectionsApi.php b/lib/Api/ConnectionsApi.php index 03a745c..49504f0 100644 --- a/lib/Api/ConnectionsApi.php +++ b/lib/Api/ConnectionsApi.php @@ -1430,7 +1430,7 @@ public function listBrokerageAuthorizationsRequest($user_id, $user_secret, strin * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occured. *Please contact support for access as this endpoint is not enabled by default.* * * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) @@ -1459,7 +1459,7 @@ public function refreshBrokerageAuthorization( * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occured. *Please contact support for access as this endpoint is not enabled by default.* * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1672,7 +1672,7 @@ public function refreshBrokerageAuthorizationWithHttpInfo($authorization_id, $us * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occured. *Please contact support for access as this endpoint is not enabled by default.* * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1704,7 +1704,7 @@ function ($response) { * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occured. *Please contact support for access as this endpoint is not enabled by default.* * * @param string $authorization_id (required) * @param string $user_id (required) From a71d57e577b623e4a152ae32bb84c5d3f51a3161 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 19:38:03 +0000 Subject: [PATCH 071/252] Version Bump SDKs (#87) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index cd95401..898058e 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ef8ce378-11a2-4e4d-98af-4affe8c8c848 \ No newline at end of file +e84a79c1-51d6-4fde-9cc6-fa8c16ecef10 \ No newline at end of file diff --git a/README.md b/README.md index fb927c4..f7c1901 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.70-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.71-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.70" + "konfig/snaptrade-php-sdk": "2.0.71" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 0fe81bd..c674766 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.70/PHP'; + protected $userAgent = 'Konfig/2.0.71/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.70' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.71' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 9dad63c3e702af0e0e32200a339b1c87307f09ba Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 01:43:11 +0000 Subject: [PATCH 072/252] Regenerate SDKs (#88) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/SecurityType.php | 2 +- lib/Model/UnderlyingSymbolType.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 898058e..3a83eaa 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -e84a79c1-51d6-4fde-9cc6-fa8c16ecef10 \ No newline at end of file +c05d0685-14f6-4663-8460-4f9795415214 \ No newline at end of file diff --git a/lib/Model/SecurityType.php b/lib/Model/SecurityType.php index 10a6eab..d6c69b4 100644 --- a/lib/Model/SecurityType.php +++ b/lib/Model/SecurityType.php @@ -346,7 +346,7 @@ public function getCode() /** * Sets code * - * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: - `ad` - ADR - `bnd` - Bond - `cs` - Common Stock - `cef` - Closed End Fund - `et` - ETF - `oef` - Open Ended Fund - `ps` - Preferred Stock - `rt` - Right - `struct` - Structured Product - `ut` - Unit - `wi` - When Issued - `wt` - Warrant + * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: - `ad` - ADR - `bnd` - Bond - `cs` - Common Stock - `cef` - Closed End Fund - `crypto` - Cryptocurrency - `et` - ETF - `oef` - Open Ended Fund - `ps` - Preferred Stock - `rt` - Right - `struct` - Structured Product - `ut` - Unit - `wi` - When Issued - `wt` - Warrant * * @return self */ diff --git a/lib/Model/UnderlyingSymbolType.php b/lib/Model/UnderlyingSymbolType.php index bb57cac..4b22b9d 100644 --- a/lib/Model/UnderlyingSymbolType.php +++ b/lib/Model/UnderlyingSymbolType.php @@ -346,7 +346,7 @@ public function getCode() /** * Sets code * - * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: - `ad` - ADR - `bnd` - Bond - `cs` - Common Stock - `cef` - Closed End Fund - `et` - ETF - `oef` - Open Ended Fund - `ps` - Preferred Stock - `rt` - Right - `struct` - Structured Product - `ut` - Unit - `wi` - When Issued - `wt` - Warrant + * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: - `ad` - ADR - `bnd` - Bond - `cs` - Common Stock - `cef` - Closed End Fund - `crypto` - Cryptocurrency - `et` - ETF - `oef` - Open Ended Fund - `ps` - Preferred Stock - `rt` - Right - `struct` - Structured Product - `ut` - Unit - `wi` - When Issued - `wt` - Warrant * * @return self */ From 1449012191f04743560fadbbe2538722c6268143 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 01:47:02 +0000 Subject: [PATCH 073/252] Version Bump SDKs (#89) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 3a83eaa..4703c5c 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -c05d0685-14f6-4663-8460-4f9795415214 \ No newline at end of file +7b7d7a01-55d3-4b97-aff0-7fa5884d0f04 \ No newline at end of file diff --git a/README.md b/README.md index f7c1901..f0a5f5a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.71-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.72-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.71" + "konfig/snaptrade-php-sdk": "2.0.72" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index c674766..ed264c5 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.71/PHP'; + protected $userAgent = 'Konfig/2.0.72/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.71' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.72' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 4b17e4dcac9ae60a7e5ba07995ee170857e3854f Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 13:44:21 +0000 Subject: [PATCH 074/252] Regenerate SDKs (#90) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 20 +- lib/Api/AccountInformationApi.php | 84 +- lib/Model/AccountUniversalActivity.php | 987 ++++++++++++++++++ ...p => AccountUniversalActivityCurrency.php} | 8 +- ... AccountUniversalActivityOptionSymbol.php} | 8 +- ...php => AccountUniversalActivitySymbol.php} | 8 +- lib/Model/PaginatedUniversalActivity.php | 441 ++++++++ lib/Model/PaginationDetails.php | 441 ++++++++ lib/Model/UniversalActivity.php | 18 +- ... AccountUniversalActivityCurrencyTest.php} | 10 +- ...ountUniversalActivityOptionSymbolTest.php} | 10 +- ...=> AccountUniversalActivitySymbolTest.php} | 10 +- test/Model/AccountUniversalActivityTest.php | 218 ++++ test/Model/PaginatedUniversalActivityTest.php | 92 ++ test/Model/PaginationDetailsTest.php | 92 ++ 16 files changed, 2389 insertions(+), 60 deletions(-) create mode 100644 lib/Model/AccountUniversalActivity.php rename lib/Model/{UniversalActivityCurrency.php => AccountUniversalActivityCurrency.php} (97%) rename lib/Model/{UniversalActivityOptionSymbol.php => AccountUniversalActivityOptionSymbol.php} (98%) rename lib/Model/{UniversalActivitySymbol.php => AccountUniversalActivitySymbol.php} (98%) create mode 100644 lib/Model/PaginatedUniversalActivity.php create mode 100644 lib/Model/PaginationDetails.php rename test/Model/{UniversalActivityCurrencyTest.php => AccountUniversalActivityCurrencyTest.php} (86%) rename test/Model/{UniversalActivityOptionSymbolTest.php => AccountUniversalActivityOptionSymbolTest.php} (90%) rename test/Model/{UniversalActivitySymbolTest.php => AccountUniversalActivitySymbolTest.php} (92%) create mode 100644 test/Model/AccountUniversalActivityTest.php create mode 100644 test/Model/PaginatedUniversalActivityTest.php create mode 100644 test/Model/PaginationDetailsTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 4703c5c..b935fa2 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -7b7d7a01-55d3-4b97-aff0-7fa5884d0f04 \ No newline at end of file +c62a2b40-9846-438f-a033-b6a853d7f349 \ No newline at end of file diff --git a/README.md b/README.md index f0a5f5a..fa6fa7a 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,8 @@ $result = $snaptrade->accountInformation->getAccountActivities( user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", start_date: "2022-01-24", end_date: "2022-01-24", + offset: 0, + limit: 1, type: "BUY,SELL,DIVIDEND" ); ``` @@ -133,9 +135,11 @@ $result = $snaptrade->accountInformation->getAccountActivities( ### `snaptrade.accountInformation.getAccountActivities` -Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. +Returns all historical transactions for the specified account. -There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. +This endpoint is paginated and will return a maximum of 1000 transactions per request. See the query parameters for pagination options. + +Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. @@ -150,6 +154,8 @@ $result = $snaptrade->accountInformation->getAccountActivities( user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", start_date: "2022-01-24", end_date: "2022-01-24", + offset: 0, + limit: 1, type: "BUY,SELL,DIVIDEND" ); ``` @@ -170,6 +176,14 @@ The start date (inclusive) of the transaction history to retrieve. If not provid The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. +##### offset: `int` + +An integer that specifies the starting point of the paginated results. Default is 0. + +##### limit: `int` + +An integer that specifies the maximum number of transactions to return. Default of 1000. + ##### type: `string` Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another @@ -177,7 +191,7 @@ Optional comma separated list of transaction types to filter by. SnapTrade does #### πŸ”„ Return -[**UniversalActivity**](./lib/Model/UniversalActivity.php) +[**PaginatedUniversalActivity**](./lib/Model/PaginatedUniversalActivity.php) #### 🌐 Endpoint diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 9c47d74..aa6d2ca 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -170,19 +170,21 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * List account activities * - * Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated and will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id account_id (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) + * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\UniversalActivity[] + * @return \SnapTrade\Model\PaginatedUniversalActivity[] */ public function getAccountActivities( $account_id, @@ -190,13 +192,15 @@ public function getAccountActivities( $user_secret, $start_date = SENTINEL_VALUE, $end_date = SENTINEL_VALUE, + $offset = SENTINEL_VALUE, + $limit = SENTINEL_VALUE, $type = SENTINEL_VALUE, string $contentType = self::contentTypes['getAccountActivities'][0] ) { - list($response) = $this->getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_secret, $start_date, $end_date, $type, $contentType); + list($response) = $this->getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_secret, $start_date, $end_date, $offset, $limit, $type, $contentType); return $response; } @@ -205,23 +209,25 @@ public function getAccountActivities( * * List account activities * - * Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated and will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) + * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\UniversalActivity[], HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\PaginatedUniversalActivity[], HTTP status code, HTTP response headers (array of strings) */ - public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_secret, $start_date = null, $end_date = null, $type = null, string $contentType = self::contentTypes['getAccountActivities'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_secret, $start_date = null, $end_date = null, $offset = null, $limit = null, $type = null, string $contentType = self::contentTypes['getAccountActivities'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getAccountActivitiesRequest($account_id, $user_id, $user_secret, $start_date, $end_date, $type, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getAccountActivitiesRequest($account_id, $user_id, $user_secret, $start_date, $end_date, $offset, $limit, $type, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config); @@ -242,6 +248,8 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se $user_secret, $start_date, $end_date, + $offset, + $limit, $type, $contentType, $requestOptions->setRetryOAuth(false) @@ -280,23 +288,23 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se switch($statusCode) { case 200: - if ('\SnapTrade\Model\UniversalActivity[]' === '\SplFileObject') { + if ('\SnapTrade\Model\PaginatedUniversalActivity[]' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\UniversalActivity[]' !== 'string') { + if ('\SnapTrade\Model\PaginatedUniversalActivity[]' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\UniversalActivity[]', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\PaginatedUniversalActivity[]', []), $response->getStatusCode(), $response->getHeaders() ]; } - $returnType = '\SnapTrade\Model\UniversalActivity[]'; + $returnType = '\SnapTrade\Model\PaginatedUniversalActivity[]'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -317,7 +325,7 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\UniversalActivity[]', + '\SnapTrade\Model\PaginatedUniversalActivity[]', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -332,13 +340,15 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se * * List account activities * - * Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated and will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) + * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * @@ -351,13 +361,15 @@ public function getAccountActivitiesAsync( $user_secret, $start_date = SENTINEL_VALUE, $end_date = SENTINEL_VALUE, + $offset = SENTINEL_VALUE, + $limit = SENTINEL_VALUE, $type = SENTINEL_VALUE, string $contentType = self::contentTypes['getAccountActivities'][0] ) { - return $this->getAccountActivitiesAsyncWithHttpInfo($account_id, $user_id, $user_secret, $start_date, $end_date, $type, $contentType) + return $this->getAccountActivitiesAsyncWithHttpInfo($account_id, $user_id, $user_secret, $start_date, $end_date, $offset, $limit, $type, $contentType) ->then( function ($response) { return $response[0]; @@ -370,23 +382,25 @@ function ($response) { * * List account activities * - * Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated and will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) + * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getAccountActivitiesAsyncWithHttpInfo($account_id, $user_id, $user_secret, $start_date = null, $end_date = null, $type = null, string $contentType = self::contentTypes['getAccountActivities'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getAccountActivitiesAsyncWithHttpInfo($account_id, $user_id, $user_secret, $start_date = null, $end_date = null, $offset = null, $limit = null, $type = null, string $contentType = self::contentTypes['getAccountActivities'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\UniversalActivity[]'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getAccountActivitiesRequest($account_id, $user_id, $user_secret, $start_date, $end_date, $type, $contentType); + $returnType = '\SnapTrade\Model\PaginatedUniversalActivity[]'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getAccountActivitiesRequest($account_id, $user_id, $user_secret, $start_date, $end_date, $offset, $limit, $type, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config); @@ -435,13 +449,15 @@ function ($exception) { * @param string $user_secret (required) * @param \DateTime $start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional) * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) + * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) + * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getAccountActivitiesRequest($account_id, $user_id, $user_secret, $start_date = SENTINEL_VALUE, $end_date = SENTINEL_VALUE, $type = SENTINEL_VALUE, string $contentType = self::contentTypes['getAccountActivities'][0]) + public function getAccountActivitiesRequest($account_id, $user_id, $user_secret, $start_date = SENTINEL_VALUE, $end_date = SENTINEL_VALUE, $offset = SENTINEL_VALUE, $limit = SENTINEL_VALUE, $type = SENTINEL_VALUE, string $contentType = self::contentTypes['getAccountActivities'][0]) { // Check if $account_id is a string @@ -474,7 +490,13 @@ public function getAccountActivitiesRequest($account_id, $user_id, $user_secret, 'Missing the required parameter user_secret when calling getAccountActivities' ); } - // Check if $type is a string + if ($offset !== SENTINEL_VALUE && $offset < 0) { + throw new \InvalidArgumentException('invalid value for "offset" when calling AccountInformationApi.getAccountActivities, must be bigger than or equal to 0.'); + } + if ($limit !== SENTINEL_VALUE && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "limit" when calling AccountInformationApi.getAccountActivities, must be bigger than or equal to 1.'); + } + // Check if $type is a string if ($type !== SENTINEL_VALUE && !is_string($type)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($type, true), gettype($type))); } @@ -509,6 +531,28 @@ public function getAccountActivitiesRequest($account_id, $user_id, $user_secret, false // required ) ?? []); } + if ($offset !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offset, + 'offset', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($limit !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } if ($type !== SENTINEL_VALUE) { // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( diff --git a/lib/Model/AccountUniversalActivity.php b/lib/Model/AccountUniversalActivity.php new file mode 100644 index 0000000..b6519e7 --- /dev/null +++ b/lib/Model/AccountUniversalActivity.php @@ -0,0 +1,987 @@ + + */ +class AccountUniversalActivity implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AccountUniversalActivity'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'symbol' => '\SnapTrade\Model\AccountUniversalActivitySymbol', + 'option_symbol' => '\SnapTrade\Model\AccountUniversalActivityOptionSymbol', + 'price' => 'float', + 'units' => 'float', + 'amount' => 'float', + 'currency' => '\SnapTrade\Model\AccountUniversalActivityCurrency', + 'type' => 'string', + 'option_type' => 'string', + 'description' => 'string', + 'trade_date' => '\DateTime', + 'settlement_date' => '\DateTime', + 'fee' => 'float', + 'fx_rate' => 'float', + 'institution' => 'string', + 'external_reference_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'symbol' => null, + 'option_symbol' => null, + 'price' => null, + 'units' => null, + 'amount' => null, + 'currency' => null, + 'type' => null, + 'option_type' => null, + 'description' => null, + 'trade_date' => 'date-time', + 'settlement_date' => 'date-time', + 'fee' => null, + 'fx_rate' => null, + 'institution' => null, + 'external_reference_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'symbol' => true, + 'option_symbol' => true, + 'price' => false, + 'units' => false, + 'amount' => true, + 'currency' => false, + 'type' => false, + 'option_type' => false, + 'description' => false, + 'trade_date' => true, + 'settlement_date' => false, + 'fee' => false, + 'fx_rate' => true, + 'institution' => false, + 'external_reference_id' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'symbol' => 'symbol', + 'option_symbol' => 'option_symbol', + 'price' => 'price', + 'units' => 'units', + 'amount' => 'amount', + 'currency' => 'currency', + 'type' => 'type', + 'option_type' => 'option_type', + 'description' => 'description', + 'trade_date' => 'trade_date', + 'settlement_date' => 'settlement_date', + 'fee' => 'fee', + 'fx_rate' => 'fx_rate', + 'institution' => 'institution', + 'external_reference_id' => 'external_reference_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'symbol' => 'setSymbol', + 'option_symbol' => 'setOptionSymbol', + 'price' => 'setPrice', + 'units' => 'setUnits', + 'amount' => 'setAmount', + 'currency' => 'setCurrency', + 'type' => 'setType', + 'option_type' => 'setOptionType', + 'description' => 'setDescription', + 'trade_date' => 'setTradeDate', + 'settlement_date' => 'setSettlementDate', + 'fee' => 'setFee', + 'fx_rate' => 'setFxRate', + 'institution' => 'setInstitution', + 'external_reference_id' => 'setExternalReferenceId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'symbol' => 'getSymbol', + 'option_symbol' => 'getOptionSymbol', + 'price' => 'getPrice', + 'units' => 'getUnits', + 'amount' => 'getAmount', + 'currency' => 'getCurrency', + 'type' => 'getType', + 'option_type' => 'getOptionType', + 'description' => 'getDescription', + 'trade_date' => 'getTradeDate', + 'settlement_date' => 'getSettlementDate', + 'fee' => 'getFee', + 'fx_rate' => 'getFxRate', + 'institution' => 'getInstitution', + 'external_reference_id' => 'getExternalReferenceId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('option_symbol', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('units', $data ?? [], null); + $this->setIfExists('amount', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('option_type', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('trade_date', $data ?? [], null); + $this->setIfExists('settlement_date', $data ?? [], null); + $this->setIfExists('fee', $data ?? [], null); + $this->setIfExists('fx_rate', $data ?? [], null); + $this->setIfExists('institution', $data ?? [], null); + $this->setIfExists('external_reference_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for the transaction. This is the ID used to reference the transaction in SnapTrade. Please note that this ID _can_ change if the transaction is deleted and re-added. Under normal circumstances, SnapTrade does not delete transactions. The only time this would happen is if SnapTrade re-fetches and reprocesses the data from the brokerage, which is rare. If you require a stable ID, please let us know and we can work with you to provide one. + * + * @return self + */ + public function setId($id) + { + + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets symbol + * + * @return \SnapTrade\Model\AccountUniversalActivitySymbol|null + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param \SnapTrade\Model\AccountUniversalActivitySymbol|null $symbol symbol + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + array_push($this->openAPINullablesSetToNull, 'symbol'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('symbol', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets option_symbol + * + * @return \SnapTrade\Model\AccountUniversalActivityOptionSymbol|null + */ + public function getOptionSymbol() + { + return $this->container['option_symbol']; + } + + /** + * Sets option_symbol + * + * @param \SnapTrade\Model\AccountUniversalActivityOptionSymbol|null $option_symbol option_symbol + * + * @return self + */ + public function setOptionSymbol($option_symbol) + { + + if (is_null($option_symbol)) { + array_push($this->openAPINullablesSetToNull, 'option_symbol'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('option_symbol', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['option_symbol'] = $option_symbol; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price The price of the security for the transaction. This is mostly applicable to `BUY`, `SELL`, and `DIVIDEND` transactions. + * + * @return self + */ + public function setPrice($price) + { + + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets units + * + * @return float|null + */ + public function getUnits() + { + return $this->container['units']; + } + + /** + * Sets units + * + * @param float|null $units The number of units of the security for the transaction. This is mostly applicable to `BUY`, `SELL`, and `DIVIDEND` transactions. + * + * @return self + */ + public function setUnits($units) + { + + if (is_null($units)) { + throw new \InvalidArgumentException('non-nullable units cannot be null'); + } + + $this->container['units'] = $units; + + return $this; + } + + /** + * Gets amount + * + * @return float|null + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param float|null $amount The amount of the transaction denominated in `currency`. This can be positive or negative. In general, transactions that positively affect the account balance (like sell, deposits, dividends, etc) will have a positive amount, while transactions that negatively affect the account balance (like buy, withdrawals, fees, etc) will have a negative amount. + * + * @return self + */ + public function setAmount($amount) + { + + if (is_null($amount)) { + array_push($this->openAPINullablesSetToNull, 'amount'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('amount', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets currency + * + * @return \SnapTrade\Model\AccountUniversalActivityCurrency|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \SnapTrade\Model\AccountUniversalActivityCurrency|null $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. `option_symbol` contains the related option contract info. - `OPTIONASSIGNMENT` - Option assignment event. `option_symbol` contains the related option contract info. - `OPTIONEXERCISE` - Option exercise event. `option_symbol` contains the related option contract info. + * + * @return self + */ + public function setType($type) + { + + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets option_type + * + * @return string|null + */ + public function getOptionType() + { + return $this->container['option_type']; + } + + /** + * Sets option_type + * + * @param string|null $option_type If an option `BUY` or `SELL` transaction, this further specifies the type of action. The possible values are: - BUY_TO_OPEN - BUY_TO_CLOSE - SELL_TO_OPEN - SELL_TO_CLOSE + * + * @return self + */ + public function setOptionType($option_type) + { + + if (is_null($option_type)) { + throw new \InvalidArgumentException('non-nullable option_type cannot be null'); + } + + $this->container['option_type'] = $option_type; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description A human-readable description of the transaction. This is usually the brokerage's description of the transaction. + * + * @return self + */ + public function setDescription($description) + { + + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets trade_date + * + * @return \DateTime|null + */ + public function getTradeDate() + { + return $this->container['trade_date']; + } + + /** + * Sets trade_date + * + * @param \DateTime|null $trade_date The recorded time for the transaction. The granularity of this timestamp depends on the brokerage. Some brokerages provide the exact time of the transaction, while others provide only the date. Please check the [integrations page](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=6fab8012ade6441fa0c6d9af9c55ce3a) for the specific brokerage to see the granularity of the timestamps. Note that even though the field is named `trade_date`, it can represent any type of transaction, not just trades. + * + * @return self + */ + public function setTradeDate($trade_date) + { + + if (is_null($trade_date)) { + array_push($this->openAPINullablesSetToNull, 'trade_date'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('trade_date', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['trade_date'] = $trade_date; + + return $this; + } + + /** + * Gets settlement_date + * + * @return \DateTime|null + */ + public function getSettlementDate() + { + return $this->container['settlement_date']; + } + + /** + * Sets settlement_date + * + * @param \DateTime|null $settlement_date The date on which the transaction is settled. + * + * @return self + */ + public function setSettlementDate($settlement_date) + { + + if (is_null($settlement_date)) { + throw new \InvalidArgumentException('non-nullable settlement_date cannot be null'); + } + + $this->container['settlement_date'] = $settlement_date; + + return $this; + } + + /** + * Gets fee + * + * @return float|null + */ + public function getFee() + { + return $this->container['fee']; + } + + /** + * Sets fee + * + * @param float|null $fee Any fee associated with the transaction if provided by the brokerage. + * + * @return self + */ + public function setFee($fee) + { + + if (is_null($fee)) { + throw new \InvalidArgumentException('non-nullable fee cannot be null'); + } + + $this->container['fee'] = $fee; + + return $this; + } + + /** + * Gets fx_rate + * + * @return float|null + */ + public function getFxRate() + { + return $this->container['fx_rate']; + } + + /** + * Sets fx_rate + * + * @param float|null $fx_rate The forex conversion rate involved in the transaction if provided by the brokerage. Used in cases where securities of one currency are purchased in a different currency, and the forex conversion is automatic. In those cases, price, amount and fee will be in the top level currency (activity -> currency) + * + * @return self + */ + public function setFxRate($fx_rate) + { + + if (is_null($fx_rate)) { + array_push($this->openAPINullablesSetToNull, 'fx_rate'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('fx_rate', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['fx_rate'] = $fx_rate; + + return $this; + } + + /** + * Gets institution + * + * @return string|null + */ + public function getInstitution() + { + return $this->container['institution']; + } + + /** + * Sets institution + * + * @param string|null $institution The institution that the transaction is associated with. This is usually the brokerage name. + * + * @return self + */ + public function setInstitution($institution) + { + + if (is_null($institution)) { + throw new \InvalidArgumentException('non-nullable institution cannot be null'); + } + + $this->container['institution'] = $institution; + + return $this; + } + + /** + * Gets external_reference_id + * + * @return string|null + */ + public function getExternalReferenceId() + { + return $this->container['external_reference_id']; + } + + /** + * Sets external_reference_id + * + * @param string|null $external_reference_id Reference ID from brokerage used to identify related transactions. For example if an order comprises of several transactions (buy, fee, fx), they can be grouped if they share the same `external_reference_id` + * + * @return self + */ + public function setExternalReferenceId($external_reference_id) + { + + if (is_null($external_reference_id)) { + array_push($this->openAPINullablesSetToNull, 'external_reference_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('external_reference_id', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['external_reference_id'] = $external_reference_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/UniversalActivityCurrency.php b/lib/Model/AccountUniversalActivityCurrency.php similarity index 97% rename from lib/Model/UniversalActivityCurrency.php rename to lib/Model/AccountUniversalActivityCurrency.php index 3a55a27..87d9ebc 100644 --- a/lib/Model/UniversalActivityCurrency.php +++ b/lib/Model/AccountUniversalActivityCurrency.php @@ -1,6 +1,6 @@ */ -class UniversalActivityCurrency implements ModelInterface, ArrayAccess, \JsonSerializable +class AccountUniversalActivityCurrency implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -43,7 +43,7 @@ class UniversalActivityCurrency implements ModelInterface, ArrayAccess, \JsonSer * * @var string */ - protected static $openAPIModelName = 'UniversalActivity_currency'; + protected static $openAPIModelName = 'AccountUniversalActivity_currency'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/lib/Model/UniversalActivityOptionSymbol.php b/lib/Model/AccountUniversalActivityOptionSymbol.php similarity index 98% rename from lib/Model/UniversalActivityOptionSymbol.php rename to lib/Model/AccountUniversalActivityOptionSymbol.php index 40e4e58..acd5871 100644 --- a/lib/Model/UniversalActivityOptionSymbol.php +++ b/lib/Model/AccountUniversalActivityOptionSymbol.php @@ -1,6 +1,6 @@ */ -class UniversalActivityOptionSymbol implements ModelInterface, ArrayAccess, \JsonSerializable +class AccountUniversalActivityOptionSymbol implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -43,7 +43,7 @@ class UniversalActivityOptionSymbol implements ModelInterface, ArrayAccess, \Jso * * @var string */ - protected static $openAPIModelName = 'UniversalActivity_option_symbol'; + protected static $openAPIModelName = 'AccountUniversalActivity_option_symbol'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/lib/Model/UniversalActivitySymbol.php b/lib/Model/AccountUniversalActivitySymbol.php similarity index 98% rename from lib/Model/UniversalActivitySymbol.php rename to lib/Model/AccountUniversalActivitySymbol.php index 088b65e..e1d539b 100644 --- a/lib/Model/UniversalActivitySymbol.php +++ b/lib/Model/AccountUniversalActivitySymbol.php @@ -1,6 +1,6 @@ */ -class UniversalActivitySymbol implements ModelInterface, ArrayAccess, \JsonSerializable +class AccountUniversalActivitySymbol implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -43,7 +43,7 @@ class UniversalActivitySymbol implements ModelInterface, ArrayAccess, \JsonSeria * * @var string */ - protected static $openAPIModelName = 'UniversalActivity_symbol'; + protected static $openAPIModelName = 'AccountUniversalActivity_symbol'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/lib/Model/PaginatedUniversalActivity.php b/lib/Model/PaginatedUniversalActivity.php new file mode 100644 index 0000000..3fe7006 --- /dev/null +++ b/lib/Model/PaginatedUniversalActivity.php @@ -0,0 +1,441 @@ + + */ +class PaginatedUniversalActivity implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaginatedUniversalActivity'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'data' => '\SnapTrade\Model\AccountUniversalActivity[]', + 'pagination' => '\SnapTrade\Model\PaginationDetails' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'data' => null, + 'pagination' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'data' => false, + 'pagination' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'data' => 'data', + 'pagination' => 'pagination' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'data' => 'setData', + 'pagination' => 'setPagination' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'data' => 'getData', + 'pagination' => 'getPagination' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('data', $data ?? [], null); + $this->setIfExists('pagination', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets data + * + * @return \SnapTrade\Model\AccountUniversalActivity[]|null + */ + public function getData() + { + return $this->container['data']; + } + + /** + * Sets data + * + * @param \SnapTrade\Model\AccountUniversalActivity[]|null $data data + * + * @return self + */ + public function setData($data) + { + + if (is_null($data)) { + throw new \InvalidArgumentException('non-nullable data cannot be null'); + } + + $this->container['data'] = $data; + + return $this; + } + + /** + * Gets pagination + * + * @return \SnapTrade\Model\PaginationDetails|null + */ + public function getPagination() + { + return $this->container['pagination']; + } + + /** + * Sets pagination + * + * @param \SnapTrade\Model\PaginationDetails|null $pagination pagination + * + * @return self + */ + public function setPagination($pagination) + { + + if (is_null($pagination)) { + throw new \InvalidArgumentException('non-nullable pagination cannot be null'); + } + + $this->container['pagination'] = $pagination; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/PaginationDetails.php b/lib/Model/PaginationDetails.php new file mode 100644 index 0000000..c6fd9e0 --- /dev/null +++ b/lib/Model/PaginationDetails.php @@ -0,0 +1,441 @@ + + */ +class PaginationDetails implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaginationDetails'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offset' => 'int', + 'limit' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offset' => null, + 'limit' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offset' => false, + 'limit' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offset' => 'offset', + 'limit' => 'limit' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offset' => 'setOffset', + 'limit' => 'setLimit' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offset' => 'getOffset', + 'limit' => 'getLimit' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offset', $data ?? [], null); + $this->setIfExists('limit', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offset + * + * @return int|null + */ + public function getOffset() + { + return $this->container['offset']; + } + + /** + * Sets offset + * + * @param int|null $offset The starting point of the paginated results. + * + * @return self + */ + public function setOffset($offset) + { + + if (is_null($offset)) { + throw new \InvalidArgumentException('non-nullable offset cannot be null'); + } + + $this->container['offset'] = $offset; + + return $this; + } + + /** + * Gets limit + * + * @return int|null + */ + public function getLimit() + { + return $this->container['limit']; + } + + /** + * Sets limit + * + * @param int|null $limit The maximum number of items to return in the response. + * + * @return self + */ + public function setLimit($limit) + { + + if (is_null($limit)) { + throw new \InvalidArgumentException('non-nullable limit cannot be null'); + } + + $this->container['limit'] = $limit; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/UniversalActivity.php b/lib/Model/UniversalActivity.php index 66d1993..eba83b4 100644 --- a/lib/Model/UniversalActivity.php +++ b/lib/Model/UniversalActivity.php @@ -53,12 +53,12 @@ class UniversalActivity implements ModelInterface, ArrayAccess, \JsonSerializabl protected static $openAPITypes = [ 'id' => 'string', 'account' => '\SnapTrade\Model\AccountSimple', - 'symbol' => '\SnapTrade\Model\UniversalActivitySymbol', - 'option_symbol' => '\SnapTrade\Model\UniversalActivityOptionSymbol', + 'symbol' => '\SnapTrade\Model\AccountUniversalActivitySymbol', + 'option_symbol' => '\SnapTrade\Model\AccountUniversalActivityOptionSymbol', 'price' => 'float', 'units' => 'float', 'amount' => 'float', - 'currency' => '\SnapTrade\Model\UniversalActivityCurrency', + 'currency' => '\SnapTrade\Model\AccountUniversalActivityCurrency', 'type' => 'string', 'option_type' => 'string', 'description' => 'string', @@ -456,7 +456,7 @@ public function setAccount($account) /** * Gets symbol * - * @return \SnapTrade\Model\UniversalActivitySymbol|null + * @return \SnapTrade\Model\AccountUniversalActivitySymbol|null */ public function getSymbol() { @@ -466,7 +466,7 @@ public function getSymbol() /** * Sets symbol * - * @param \SnapTrade\Model\UniversalActivitySymbol|null $symbol symbol + * @param \SnapTrade\Model\AccountUniversalActivitySymbol|null $symbol symbol * * @return self */ @@ -492,7 +492,7 @@ public function setSymbol($symbol) /** * Gets option_symbol * - * @return \SnapTrade\Model\UniversalActivityOptionSymbol|null + * @return \SnapTrade\Model\AccountUniversalActivityOptionSymbol|null */ public function getOptionSymbol() { @@ -502,7 +502,7 @@ public function getOptionSymbol() /** * Sets option_symbol * - * @param \SnapTrade\Model\UniversalActivityOptionSymbol|null $option_symbol option_symbol + * @param \SnapTrade\Model\AccountUniversalActivityOptionSymbol|null $option_symbol option_symbol * * @return self */ @@ -622,7 +622,7 @@ public function setAmount($amount) /** * Gets currency * - * @return \SnapTrade\Model\UniversalActivityCurrency|null + * @return \SnapTrade\Model\AccountUniversalActivityCurrency|null */ public function getCurrency() { @@ -632,7 +632,7 @@ public function getCurrency() /** * Sets currency * - * @param \SnapTrade\Model\UniversalActivityCurrency|null $currency currency + * @param \SnapTrade\Model\AccountUniversalActivityCurrency|null $currency currency * * @return self */ diff --git a/test/Model/UniversalActivityCurrencyTest.php b/test/Model/AccountUniversalActivityCurrencyTest.php similarity index 86% rename from test/Model/UniversalActivityCurrencyTest.php rename to test/Model/AccountUniversalActivityCurrencyTest.php index 1eb799f..b0ebe52 100644 --- a/test/Model/UniversalActivityCurrencyTest.php +++ b/test/Model/AccountUniversalActivityCurrencyTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); diff --git a/test/Model/UniversalActivityOptionSymbolTest.php b/test/Model/AccountUniversalActivityOptionSymbolTest.php similarity index 90% rename from test/Model/UniversalActivityOptionSymbolTest.php rename to test/Model/AccountUniversalActivityOptionSymbolTest.php index bf151e6..aea44d1 100644 --- a/test/Model/UniversalActivityOptionSymbolTest.php +++ b/test/Model/AccountUniversalActivityOptionSymbolTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); diff --git a/test/Model/UniversalActivitySymbolTest.php b/test/Model/AccountUniversalActivitySymbolTest.php similarity index 92% rename from test/Model/UniversalActivitySymbolTest.php rename to test/Model/AccountUniversalActivitySymbolTest.php index 428a8df..e590ba1 100644 --- a/test/Model/UniversalActivitySymbolTest.php +++ b/test/Model/AccountUniversalActivitySymbolTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); diff --git a/test/Model/AccountUniversalActivityTest.php b/test/Model/AccountUniversalActivityTest.php new file mode 100644 index 0000000..d904a35 --- /dev/null +++ b/test/Model/AccountUniversalActivityTest.php @@ -0,0 +1,218 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "id" + */ + public function testPropertyId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "option_symbol" + */ + public function testPropertyOptionSymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "price" + */ + public function testPropertyPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "units" + */ + public function testPropertyUnits() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "amount" + */ + public function testPropertyAmount() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "currency" + */ + public function testPropertyCurrency() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "option_type" + */ + public function testPropertyOptionType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "description" + */ + public function testPropertyDescription() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "trade_date" + */ + public function testPropertyTradeDate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "settlement_date" + */ + public function testPropertySettlementDate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "fee" + */ + public function testPropertyFee() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "fx_rate" + */ + public function testPropertyFxRate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "institution" + */ + public function testPropertyInstitution() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "external_reference_id" + */ + public function testPropertyExternalReferenceId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/PaginatedUniversalActivityTest.php b/test/Model/PaginatedUniversalActivityTest.php new file mode 100644 index 0000000..7c42c0b --- /dev/null +++ b/test/Model/PaginatedUniversalActivityTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "data" + */ + public function testPropertyData() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "pagination" + */ + public function testPropertyPagination() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/PaginationDetailsTest.php b/test/Model/PaginationDetailsTest.php new file mode 100644 index 0000000..f4e916f --- /dev/null +++ b/test/Model/PaginationDetailsTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "offset" + */ + public function testPropertyOffset() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "limit" + */ + public function testPropertyLimit() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From 638a5734da580396f547e4f404d3ef7cab2e1d8e Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 13:48:28 +0000 Subject: [PATCH 075/252] Version Bump SDKs (#91) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b935fa2..45a20ff 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -c62a2b40-9846-438f-a033-b6a853d7f349 \ No newline at end of file +cea59c0e-6c04-40d4-a11e-320371aab375 \ No newline at end of file diff --git a/README.md b/README.md index fa6fa7a..0ddb8b1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.72-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.73-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.72" + "konfig/snaptrade-php-sdk": "2.0.73" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index ed264c5..d22ce2e 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.72/PHP'; + protected $userAgent = 'Konfig/2.0.73/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.72' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.73' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 92878a8297badfe2ea00ba65dd5706c71996bed3 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 21:44:08 +0000 Subject: [PATCH 076/252] Regenerate SDKs (#92) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Api/AccountInformationApi.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 45a20ff..ad96c75 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -cea59c0e-6c04-40d4-a11e-320371aab375 \ No newline at end of file +143e2eb0-0b48-4cfc-92dd-9596e3805f02 \ No newline at end of file diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index aa6d2ca..7086eaf 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -184,7 +184,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\PaginatedUniversalActivity[] + * @return \SnapTrade\Model\PaginatedUniversalActivity */ public function getAccountActivities( $account_id, @@ -223,7 +223,7 @@ public function getAccountActivities( * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\PaginatedUniversalActivity[], HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\PaginatedUniversalActivity, HTTP status code, HTTP response headers (array of strings) */ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_secret, $start_date = null, $end_date = null, $offset = null, $limit = null, $type = null, string $contentType = self::contentTypes['getAccountActivities'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { @@ -288,23 +288,23 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se switch($statusCode) { case 200: - if ('\SnapTrade\Model\PaginatedUniversalActivity[]' === '\SplFileObject') { + if ('\SnapTrade\Model\PaginatedUniversalActivity' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\PaginatedUniversalActivity[]' !== 'string') { + if ('\SnapTrade\Model\PaginatedUniversalActivity' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\PaginatedUniversalActivity[]', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\PaginatedUniversalActivity', []), $response->getStatusCode(), $response->getHeaders() ]; } - $returnType = '\SnapTrade\Model\PaginatedUniversalActivity[]'; + $returnType = '\SnapTrade\Model\PaginatedUniversalActivity'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -325,7 +325,7 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\PaginatedUniversalActivity[]', + '\SnapTrade\Model\PaginatedUniversalActivity', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -399,7 +399,7 @@ function ($response) { */ public function getAccountActivitiesAsyncWithHttpInfo($account_id, $user_id, $user_secret, $start_date = null, $end_date = null, $offset = null, $limit = null, $type = null, string $contentType = self::contentTypes['getAccountActivities'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\PaginatedUniversalActivity[]'; + $returnType = '\SnapTrade\Model\PaginatedUniversalActivity'; ["request" => $request, "serializedBody" => $serializedBody] = $this->getAccountActivitiesRequest($account_id, $user_id, $user_secret, $start_date, $end_date, $offset, $limit, $type, $contentType); // Customization hook From d1717b60ad41652df6c4594974c7d78ce61be18e Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 21:48:37 +0000 Subject: [PATCH 077/252] Version Bump SDKs (#93) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index ad96c75..25c63c1 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -143e2eb0-0b48-4cfc-92dd-9596e3805f02 \ No newline at end of file +10de0043-d260-4f6d-99d8-61f62ff0d951 \ No newline at end of file diff --git a/README.md b/README.md index 0ddb8b1..41124df 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.73-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.74-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.73" + "konfig/snaptrade-php-sdk": "2.0.74" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index d22ce2e..ef8675b 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.73/PHP'; + protected $userAgent = 'Konfig/2.0.74/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.73' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.74' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From b7bc68d5597f65d40a03d28e949f483c3a73a5f1 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:24:57 +0000 Subject: [PATCH 078/252] Regenerate SDKs (#94) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/AccountInformationApi.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 25c63c1..9652fbc 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -10de0043-d260-4f6d-99d8-61f62ff0d951 \ No newline at end of file +ca70ef5c-a841-4311-9130-ca61c868a87e \ No newline at end of file diff --git a/README.md b/README.md index 41124df..f324e4c 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ $result = $snaptrade->accountInformation->getAccountActivities( Returns all historical transactions for the specified account. -This endpoint is paginated and will return a maximum of 1000 transactions per request. See the query parameters for pagination options. +This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 7086eaf..ee61730 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -170,7 +170,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated and will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id account_id (required) * @param string $user_id user_id (required) @@ -209,7 +209,7 @@ public function getAccountActivities( * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated and will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) @@ -340,7 +340,7 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated and will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) @@ -382,7 +382,7 @@ function ($response) { * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated and will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) From ae44f6264503616c6e6e144a238dfd262ddb0999 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:29:12 +0000 Subject: [PATCH 079/252] Version Bump SDKs (#95) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 9652fbc..ebdc9c0 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ca70ef5c-a841-4311-9130-ca61c868a87e \ No newline at end of file +cde66e04-5f6a-4774-8750-a8dab157f05b \ No newline at end of file diff --git a/README.md b/README.md index f324e4c..881cf27 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.74-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.75-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.74" + "konfig/snaptrade-php-sdk": "2.0.75" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index ef8675b..b9a8fcc 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.74/PHP'; + protected $userAgent = 'Konfig/2.0.75/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.74' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.75' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From f8cac40393e7d2504ff657121b74102b4ae53ade Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 02:23:18 +0000 Subject: [PATCH 080/252] Regenerate SDKs (#96) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/AccountInformationApi.php | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index ebdc9c0..059e946 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -cde66e04-5f6a-4774-8750-a8dab157f05b \ No newline at end of file +164d0f2e-7ffd-428c-8763-9c6c7aba4096 \ No newline at end of file diff --git a/README.md b/README.md index 881cf27..1ab401d 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,7 @@ An integer that specifies the maximum number of transactions to return. Default ##### type: `string` -Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another +Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another #### πŸ”„ Return diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index ee61730..07f8f14 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -179,7 +179,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -218,7 +218,7 @@ public function getAccountActivities( * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -349,7 +349,7 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -391,7 +391,7 @@ function ($response) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -451,7 +451,7 @@ function ($exception) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException From 8283819c4997c105fb20d06a9d30526c28c0efce Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 02:27:13 +0000 Subject: [PATCH 081/252] Version Bump SDKs (#97) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 059e946..7ce3ef8 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -164d0f2e-7ffd-428c-8763-9c6c7aba4096 \ No newline at end of file +393c3db9-0c96-487d-9110-0adb5708efd4 \ No newline at end of file diff --git a/README.md b/README.md index 1ab401d..0434c1c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.75-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.76-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.75" + "konfig/snaptrade-php-sdk": "2.0.76" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index b9a8fcc..3ea8bbc 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.75/PHP'; + protected $userAgent = 'Konfig/2.0.76/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.75' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.76' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From b80ebb54efb552aacdeef23e237a409bf8dff8a7 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 03:51:17 +0000 Subject: [PATCH 082/252] Regenerate SDKs (#98) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 1 + lib/Api/TransactionsAndReportingApi.php | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 7ce3ef8..81087f1 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -393c3db9-0c96-487d-9110-0adb5708efd4 \ No newline at end of file +d8c5aaa5-0753-4d04-b935-4ec69cf4ea50 \ No newline at end of file diff --git a/README.md b/README.md index 0434c1c..7d9105c 100644 --- a/README.md +++ b/README.md @@ -1985,6 +1985,7 @@ Optional, defaults to true. Determines if a wait is performed to check on order ### `snaptrade.transactionsAndReporting.getActivities` +![Deprecated](https://img.shields.io/badge/deprecated-yellow) Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. diff --git a/lib/Api/TransactionsAndReportingApi.php b/lib/Api/TransactionsAndReportingApi.php index ff88e35..0e2a9f2 100644 --- a/lib/Api/TransactionsAndReportingApi.php +++ b/lib/Api/TransactionsAndReportingApi.php @@ -157,6 +157,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \SnapTrade\Model\UniversalActivity[] + * @deprecated */ public function getActivities( $user_id, @@ -194,6 +195,7 @@ public function getActivities( * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\UniversalActivity[], HTTP status code, HTTP response headers (array of strings) + * @deprecated */ public function getActivitiesWithHttpInfo($user_id, $user_secret, $start_date = null, $end_date = null, $accounts = null, $brokerage_authorizations = null, $type = null, string $contentType = self::contentTypes['getActivities'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { @@ -322,6 +324,7 @@ public function getActivitiesWithHttpInfo($user_id, $user_secret, $start_date = * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated */ public function getActivitiesAsync( $user_id, @@ -362,6 +365,7 @@ function ($response) { * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated */ public function getActivitiesAsyncWithHttpInfo($user_id, $user_secret, $start_date = null, $end_date = null, $accounts = null, $brokerage_authorizations = null, $type = null, string $contentType = self::contentTypes['getActivities'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { @@ -421,6 +425,7 @@ function ($exception) { * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request + * @deprecated */ public function getActivitiesRequest($user_id, $user_secret, $start_date = SENTINEL_VALUE, $end_date = SENTINEL_VALUE, $accounts = SENTINEL_VALUE, $brokerage_authorizations = SENTINEL_VALUE, $type = SENTINEL_VALUE, string $contentType = self::contentTypes['getActivities'][0]) { From d4fc912210d4e6a75e56fb398eb9a5e9ae6fcdb8 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 03:55:09 +0000 Subject: [PATCH 083/252] Version Bump SDKs (#99) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 81087f1..8590193 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d8c5aaa5-0753-4d04-b935-4ec69cf4ea50 \ No newline at end of file +96a3e3d9-444e-4674-acb0-74938541af7e \ No newline at end of file diff --git a/README.md b/README.md index 7d9105c..1abc3d3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.76-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.77-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.76" + "konfig/snaptrade-php-sdk": "2.0.77" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 3ea8bbc..c560753 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.76/PHP'; + protected $userAgent = 'Konfig/2.0.77/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.76' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.77' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From a9902312aee0449106c0d8583ec2705610772a70 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 00:44:10 +0000 Subject: [PATCH 084/252] Regenerate SDKs (#102) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 8590193..7a8dff7 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -96a3e3d9-444e-4674-acb0-74938541af7e \ No newline at end of file +97c4e212-9803-444e-beed-49aae9e72cab \ No newline at end of file From 7f56ad704adbe52e810995ecc941f9a2544863f2 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 00:47:56 +0000 Subject: [PATCH 085/252] Version Bump SDKs (#103) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 7a8dff7..555acc9 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -97c4e212-9803-444e-beed-49aae9e72cab \ No newline at end of file +d56c6c26-3c6d-42ea-8cc2-22d591ea135a \ No newline at end of file diff --git a/README.md b/README.md index 1abc3d3..0e82bf1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.77-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.78-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.77" + "konfig/snaptrade-php-sdk": "2.0.78" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index c560753..1d194bf 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.77/PHP'; + protected $userAgent = 'Konfig/2.0.78/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.77' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.78' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 3eab3a1a844fd797eefe77f5c82db5c3af351b22 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 02:35:05 +0000 Subject: [PATCH 086/252] Regenerate SDKs (#104) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 555acc9..b385285 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d56c6c26-3c6d-42ea-8cc2-22d591ea135a \ No newline at end of file +9ede37b8-daa1-444a-8948-5f9c23588142 \ No newline at end of file From 3de44228921d5df40f911a58d4ac307d703bed5b Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 02:38:55 +0000 Subject: [PATCH 087/252] Version Bump SDKs (#105) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b385285..4c3d6ac 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -9ede37b8-daa1-444a-8948-5f9c23588142 \ No newline at end of file +d2fc53b4-5826-4278-a511-05bdf4020a50 \ No newline at end of file diff --git a/README.md b/README.md index 0e82bf1..db0244d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.78-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.79-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.78" + "konfig/snaptrade-php-sdk": "2.0.79" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 1d194bf..dd11c0a 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.78/PHP'; + protected $userAgent = 'Konfig/2.0.79/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.78' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.79' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 1b4197d8bbdca07c1405ea7e8a30ea5de4de0f81 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 03:14:09 +0000 Subject: [PATCH 088/252] Regenerate SDKs (#106) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 4c3d6ac..f81f2fe 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d2fc53b4-5826-4278-a511-05bdf4020a50 \ No newline at end of file +2abdb158-d639-49f6-8d90-1258258ccf8e \ No newline at end of file From 979fffb547efeaa3a734ce7888318461ac0e0d64 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 03:18:23 +0000 Subject: [PATCH 089/252] Version Bump SDKs (#107) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f81f2fe..c55f8ad 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2abdb158-d639-49f6-8d90-1258258ccf8e \ No newline at end of file +48db29f5-d647-49da-9253-15d3cb692c35 \ No newline at end of file diff --git a/README.md b/README.md index db0244d..d70a095 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.79-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.80-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.79" + "konfig/snaptrade-php-sdk": "2.0.80" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index dd11c0a..607d9f7 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.79/PHP'; + protected $userAgent = 'Konfig/2.0.80/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.79' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.80' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 53bf13e31d440b9969cb51edc06f0d3b969b54ba Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 6 Mar 2025 17:09:51 +0000 Subject: [PATCH 090/252] Regenerate SDKs (#108) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 ++ lib/Api/TransactionsAndReportingApi.php | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index c55f8ad..629f1cd 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -48db29f5-d647-49da-9253-15d3cb692c35 \ No newline at end of file +81f6f000-adb9-4a1a-a812-649883ade9d0 \ No newline at end of file diff --git a/README.md b/README.md index d70a095..e9fce49 100644 --- a/README.md +++ b/README.md @@ -1987,6 +1987,8 @@ Optional, defaults to true. Determines if a wait is performed to check on order ### `snaptrade.transactionsAndReporting.getActivities` ![Deprecated](https://img.shields.io/badge/deprecated-yellow) +This endpoint is being deprecated but will continue to be available for use via SDKs, please use [the account level endpoint](/reference/Account%20Information/AccountInformation_getAccountActivities) if possible + Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. diff --git a/lib/Api/TransactionsAndReportingApi.php b/lib/Api/TransactionsAndReportingApi.php index 0e2a9f2..4f1d179 100644 --- a/lib/Api/TransactionsAndReportingApi.php +++ b/lib/Api/TransactionsAndReportingApi.php @@ -143,7 +143,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * Get transaction history for a user * - * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * This endpoint is being deprecated but will continue to be available for use via SDKs, please use [the account level endpoint](/reference/Account%20Information/AccountInformation_getAccountActivities) if possible Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -181,7 +181,7 @@ public function getActivities( * * Get transaction history for a user * - * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * This endpoint is being deprecated but will continue to be available for use via SDKs, please use [the account level endpoint](/reference/Account%20Information/AccountInformation_getAccountActivities) if possible Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. * * @param string $user_id (required) * @param string $user_secret (required) @@ -311,7 +311,7 @@ public function getActivitiesWithHttpInfo($user_id, $user_secret, $start_date = * * Get transaction history for a user * - * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * This endpoint is being deprecated but will continue to be available for use via SDKs, please use [the account level endpoint](/reference/Account%20Information/AccountInformation_getAccountActivities) if possible Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. * * @param string $user_id (required) * @param string $user_secret (required) @@ -352,7 +352,7 @@ function ($response) { * * Get transaction history for a user * - * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. + * This endpoint is being deprecated but will continue to be available for use via SDKs, please use [the account level endpoint](/reference/Account%20Information/AccountInformation_getAccountActivities) if possible Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. * * @param string $user_id (required) * @param string $user_secret (required) From 4acfd458e1b1bf38a4ef95c6e659b8ac6780ea5f Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 6 Mar 2025 17:14:11 +0000 Subject: [PATCH 091/252] Version Bump SDKs (#109) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 629f1cd..446d471 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -81f6f000-adb9-4a1a-a812-649883ade9d0 \ No newline at end of file +8da58ae8-96e5-4716-8c45-bcf2ae1e76c9 \ No newline at end of file diff --git a/README.md b/README.md index e9fce49..757417f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.80-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.81-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -90,7 +90,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.80" + "konfig/snaptrade-php-sdk": "2.0.81" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 607d9f7..019e773 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.80/PHP'; + protected $userAgent = 'Konfig/2.0.81/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.80' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.81' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From f43cd9f120002e30a3545bbbc2755c238966e716 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 15:46:50 +0000 Subject: [PATCH 092/252] Regenerate SDKs (#111) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 102 ++- lib/Api/TradingApi.php | 508 +++++++++++- lib/Model/AccountOrderRecord.php | 55 +- ...ountOrderRecordChildBrokerageOrderIds.php} | 76 +- ...topLoss.php => ChildBrokerageOrderIDs.php} | 79 +- lib/Model/ManualTradeFormBracket.php | 764 ++++++++++++++++++ lib/Model/ManualTradeFormWithOptions.php | 177 +--- test/Api/TradingApiTest.php | 12 + ...OrderRecordChildBrokerageOrderIdsTest.php} | 25 +- test/Model/AccountOrderRecordTest.php | 9 + ...est.php => ChildBrokerageOrderIDsTest.php} | 20 +- test/Model/ManualTradeFormBracketTest.php | 164 ++++ test/Model/ManualTradeFormWithOptionsTest.php | 27 - 14 files changed, 1705 insertions(+), 315 deletions(-) rename lib/Model/{ManualTradeFormWithOptionsTakeProfit.php => AccountOrderRecordChildBrokerageOrderIds.php} (78%) rename lib/Model/{ManualTradeFormWithOptionsStopLoss.php => ChildBrokerageOrderIDs.php} (81%) create mode 100644 lib/Model/ManualTradeFormBracket.php rename test/Model/{ManualTradeFormWithOptionsTakeProfitTest.php => AccountOrderRecordChildBrokerageOrderIdsTest.php} (63%) rename test/Model/{ManualTradeFormWithOptionsStopLossTest.php => ChildBrokerageOrderIDsTest.php} (72%) create mode 100644 test/Model/ManualTradeFormBracketTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 446d471..2fcd779 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -8da58ae8-96e5-4716-8c45-bcf2ae1e76c9 \ No newline at end of file +edc3964d-4655-4f2d-b1ba-efe30f01c7af \ No newline at end of file diff --git a/README.md b/README.md index 757417f..5990f24 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.trading.cancelUserAccountOrder`](#snaptradetradingcanceluseraccountorder) * [`snaptrade.trading.getOrderImpact`](#snaptradetradinggetorderimpact) * [`snaptrade.trading.getUserAccountQuotes`](#snaptradetradinggetuseraccountquotes) + * [`snaptrade.trading.placeBracketOrder`](#snaptradetradingplacebracketorder) * [`snaptrade.trading.placeForceOrder`](#snaptradetradingplaceforceorder) * [`snaptrade.trading.placeOrder`](#snaptradetradingplaceorder) * [`snaptrade.transactionsAndReporting.getActivities`](#snaptradetransactionsandreportinggetactivities) @@ -1840,6 +1841,87 @@ Should be set to `True` if `symbols` are comprised of tickers. Defaults to `Fals --- +### `snaptrade.trading.placeBracketOrder` + +Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for +use. Only supported on certain brokerages + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->placeBracketOrder( + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + action: "BUY", + symbol: "AAPL", + order_type: "Market", + time_in_force: "FOK", + stop_loss: [ + "stop_price" => "48.55", + "limit_price" => "48.50", + ], + take_profit: [ + "limit_price" => "49.95", + ], + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + price: 31.33, + stop: 31.33, + units: 10.5 +); +``` + +#### βš™οΈ Parameters + +##### account_id: `string` + +Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. + +##### action: + +##### symbol: `string` + +The security's trading ticker symbol. + +##### order_type: + +##### time_in_force: + +##### stop_loss: [`StopLoss`](./lib/Model/StopLoss.php) + +##### take_profit: [`TakeProfit`](./lib/Model/TakeProfit.php) + +##### user_id: `string` + +##### user_secret: `string` + +##### price: `float` + +The limit price for `Limit` and `StopLimit` orders. + +##### stop: `float` + +The price at which a stop order is triggered for `Stop` and `StopLimit` orders. + +##### units: `float` + +Number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. + + +#### πŸ”„ Return + +[**AccountOrderRecord**](./lib/Model/AccountOrderRecord.php) + +#### 🌐 Endpoint + +`/trade/placeBracketOrder` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.trading.placeForceOrder` Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. @@ -1865,15 +1947,7 @@ $result = $snaptrade->trading->placeForceOrder( price: 31.33, stop: 31.33, units: 10.5, - notional_value: None, - order_class: "BRACKET", - stop_loss: [ - "stop_price" => "48.55", - "limit_price" => "48.50", - ], - take_profit: [ - "limit_price" => "49.95", - ] + notional_value: None ); ``` @@ -1899,7 +1973,7 @@ The universal symbol ID of the security to trade. Must be 'null' if `symbol` is ##### symbol: `string` -The security's trading ticker symbol. This currently only support Options symbols in the 21 character OCC format. For example \\\"AAPL 131124C00240000\\\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. +The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example \\\"AAPL 131124C00240000\\\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. ##### price: `float` @@ -1915,14 +1989,6 @@ For Equity orders, this represents the number of shares for the order. This can ##### notional_value: [`ManualTradeFormNotionalValue`](./lib/Model/ManualTradeFormNotionalValue.php) -##### order_class: `string` - -The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details - -##### stop_loss: [`ManualTradeFormWithOptionsStopLoss`](./lib/Model/ManualTradeFormWithOptionsStopLoss.php) - -##### take_profit: [`ManualTradeFormWithOptionsTakeProfit`](./lib/Model/ManualTradeFormWithOptionsTakeProfit.php) - #### πŸ”„ Return diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 0db3abf..f30813b 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -71,6 +71,9 @@ class TradingApi extends \SnapTrade\CustomApi 'getUserAccountQuotes' => [ 'application/json', ], + 'placeBracketOrder' => [ + 'application/json', + ], 'placeForceOrder' => [ 'application/json', ], @@ -1592,6 +1595,499 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a ]; } + /** + * Operation placeBracketOrder + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + */ + public function placeBracketOrder( + + $account_id, + $action, + $symbol, + $order_type, + $time_in_force, + $stop_loss, + $take_profit, + $user_id, + $user_secret, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeBracketOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); + $this->setRequestBodyProperty($_body, "take_profit", $take_profit); + $manual_trade_form_bracket = $_body; + + list($response) = $this->placeBracketOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_bracket, $contentType); + return $response; + } + + /** + * Operation placeBracketOrderWithHttpInfo + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function placeBracketOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($user_id, $user_secret, $manual_trade_form_bracket, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->placeBracketOrderWithHttpInfo( + $user_id, + $user_secret, + $manual_trade_form_bracket, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation placeBracketOrderAsync + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeBracketOrderAsync( + + $account_id, + $action, + $symbol, + $order_type, + $time_in_force, + $stop_loss, + $take_profit, + $user_id, + $user_secret, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeBracketOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); + $this->setRequestBodyProperty($_body, "take_profit", $take_profit); + $manual_trade_form_bracket = $_body; + + return $this->placeBracketOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_bracket, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation placeBracketOrderAsyncWithHttpInfo + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeBracketOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($user_id, $user_secret, $manual_trade_form_bracket, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'placeBracketOrder' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function placeBracketOrderRequest($user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling placeBracketOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling placeBracketOrder' + ); + } + if ($manual_trade_form_bracket !== SENTINEL_VALUE) { + if (!($manual_trade_form_bracket instanceof \SnapTrade\Model\ManualTradeFormBracket)) { + if (!is_array($manual_trade_form_bracket)) + throw new \InvalidArgumentException('"manual_trade_form_bracket" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormBracket TradingApi.placeBracketOrder.'); + else + $manual_trade_form_bracket = new \SnapTrade\Model\ManualTradeFormBracket($manual_trade_form_bracket); + } + } + // verify the required parameter 'manual_trade_form_bracket' is set + if ($manual_trade_form_bracket === SENTINEL_VALUE || (is_array($manual_trade_form_bracket) && count($manual_trade_form_bracket) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter manual_trade_form_bracket when calling placeBracketOrder' + ); + } + + + $resourcePath = '/trade/placeBracketOrder'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($manual_trade_form_bracket)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_bracket)); + } else { + $httpBody = $manual_trade_form_bracket; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + /** * Operation placeForceOrder * @@ -1622,9 +2118,6 @@ public function placeForceOrder( $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, $notional_value = SENTINEL_VALUE, - $order_class = SENTINEL_VALUE, - $stop_loss = SENTINEL_VALUE, - $take_profit = SENTINEL_VALUE, string $contentType = self::contentTypes['placeForceOrder'][0] ) { @@ -1639,9 +2132,6 @@ public function placeForceOrder( $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $this->setRequestBodyProperty($_body, "order_class", $order_class); - $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); - $this->setRequestBodyProperty($_body, "take_profit", $take_profit); $manual_trade_form_with_options = $_body; list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); @@ -1844,9 +2334,6 @@ public function placeForceOrderAsync( $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, $notional_value = SENTINEL_VALUE, - $order_class = SENTINEL_VALUE, - $stop_loss = SENTINEL_VALUE, - $take_profit = SENTINEL_VALUE, string $contentType = self::contentTypes['placeForceOrder'][0] ) { @@ -1861,9 +2348,6 @@ public function placeForceOrderAsync( $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $this->setRequestBodyProperty($_body, "order_class", $order_class); - $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); - $this->setRequestBodyProperty($_body, "take_profit", $take_profit); $manual_trade_form_with_options = $_body; return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) diff --git a/lib/Model/AccountOrderRecord.php b/lib/Model/AccountOrderRecord.php index 4f04f54..9b58416 100644 --- a/lib/Model/AccountOrderRecord.php +++ b/lib/Model/AccountOrderRecord.php @@ -69,7 +69,8 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab 'time_updated' => '\DateTime', 'time_executed' => '\DateTime', 'expiry_date' => '\DateTime', - 'symbol' => 'string' + 'symbol' => 'string', + 'child_brokerage_order_ids' => '\SnapTrade\Model\AccountOrderRecordChildBrokerageOrderIds' ]; /** @@ -98,7 +99,8 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab 'time_updated' => 'date-time', 'time_executed' => 'date-time', 'expiry_date' => 'date-time', - 'symbol' => 'uuid' + 'symbol' => 'uuid', + 'child_brokerage_order_ids' => null ]; /** @@ -125,7 +127,8 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab 'time_updated' => true, 'time_executed' => true, 'expiry_date' => true, - 'symbol' => false + 'symbol' => false, + 'child_brokerage_order_ids' => true ]; /** @@ -232,7 +235,8 @@ public function isNullableSetToNull(string $property): bool 'time_updated' => 'time_updated', 'time_executed' => 'time_executed', 'expiry_date' => 'expiry_date', - 'symbol' => 'symbol' + 'symbol' => 'symbol', + 'child_brokerage_order_ids' => 'child_brokerage_order_ids' ]; /** @@ -259,7 +263,8 @@ public function isNullableSetToNull(string $property): bool 'time_updated' => 'setTimeUpdated', 'time_executed' => 'setTimeExecuted', 'expiry_date' => 'setExpiryDate', - 'symbol' => 'setSymbol' + 'symbol' => 'setSymbol', + 'child_brokerage_order_ids' => 'setChildBrokerageOrderIds' ]; /** @@ -286,7 +291,8 @@ public function isNullableSetToNull(string $property): bool 'time_updated' => 'getTimeUpdated', 'time_executed' => 'getTimeExecuted', 'expiry_date' => 'getExpiryDate', - 'symbol' => 'getSymbol' + 'symbol' => 'getSymbol', + 'child_brokerage_order_ids' => 'getChildBrokerageOrderIds' ]; /** @@ -365,6 +371,7 @@ public function __construct(array $data = null) $this->setIfExists('time_executed', $data ?? [], null); $this->setIfExists('expiry_date', $data ?? [], null); $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('child_brokerage_order_ids', $data ?? [], null); } /** @@ -1038,6 +1045,42 @@ public function setSymbol($symbol) return $this; } + + /** + * Gets child_brokerage_order_ids + * + * @return \SnapTrade\Model\AccountOrderRecordChildBrokerageOrderIds|null + */ + public function getChildBrokerageOrderIds() + { + return $this->container['child_brokerage_order_ids']; + } + + /** + * Sets child_brokerage_order_ids + * + * @param \SnapTrade\Model\AccountOrderRecordChildBrokerageOrderIds|null $child_brokerage_order_ids child_brokerage_order_ids + * + * @return self + */ + public function setChildBrokerageOrderIds($child_brokerage_order_ids) + { + + if (is_null($child_brokerage_order_ids)) { + array_push($this->openAPINullablesSetToNull, 'child_brokerage_order_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('child_brokerage_order_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['child_brokerage_order_ids'] = $child_brokerage_order_ids; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/ManualTradeFormWithOptionsTakeProfit.php b/lib/Model/AccountOrderRecordChildBrokerageOrderIds.php similarity index 78% rename from lib/Model/ManualTradeFormWithOptionsTakeProfit.php rename to lib/Model/AccountOrderRecordChildBrokerageOrderIds.php index 3a4df8c..49ea682 100644 --- a/lib/Model/ManualTradeFormWithOptionsTakeProfit.php +++ b/lib/Model/AccountOrderRecordChildBrokerageOrderIds.php @@ -1,6 +1,6 @@ */ -class ManualTradeFormWithOptionsTakeProfit implements ModelInterface, ArrayAccess, \JsonSerializable +class AccountOrderRecordChildBrokerageOrderIds implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -42,7 +42,7 @@ class ManualTradeFormWithOptionsTakeProfit implements ModelInterface, ArrayAcces * * @var string */ - protected static $openAPIModelName = 'ManualTradeFormWithOptions_take_profit'; + protected static $openAPIModelName = 'AccountOrderRecord_child_brokerage_order_ids'; /** * Array of property to type mappings. Used for (de)serialization @@ -50,7 +50,8 @@ class ManualTradeFormWithOptionsTakeProfit implements ModelInterface, ArrayAcces * @var string[] */ protected static $openAPITypes = [ - 'limit_price' => 'string' + 'take_profit_order_id' => 'string', + 'stop_loss_order_id' => 'string' ]; /** @@ -61,7 +62,8 @@ class ManualTradeFormWithOptionsTakeProfit implements ModelInterface, ArrayAcces * @psalm-var array */ protected static $openAPIFormats = [ - 'limit_price' => null + 'take_profit_order_id' => null, + 'stop_loss_order_id' => null ]; /** @@ -70,7 +72,8 @@ class ManualTradeFormWithOptionsTakeProfit implements ModelInterface, ArrayAcces * @var boolean[] */ protected static array $openAPINullables = [ - 'limit_price' => false + 'take_profit_order_id' => false, + 'stop_loss_order_id' => false ]; /** @@ -159,7 +162,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'limit_price' => 'limit_price' + 'take_profit_order_id' => 'take_profit_order_id', + 'stop_loss_order_id' => 'stop_loss_order_id' ]; /** @@ -168,7 +172,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'limit_price' => 'setLimitPrice' + 'take_profit_order_id' => 'setTakeProfitOrderId', + 'stop_loss_order_id' => 'setStopLossOrderId' ]; /** @@ -177,7 +182,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'limit_price' => 'getLimitPrice' + 'take_profit_order_id' => 'getTakeProfitOrderId', + 'stop_loss_order_id' => 'getStopLossOrderId' ]; /** @@ -237,7 +243,8 @@ public function getModelName() */ public function __construct(array $data = null) { - $this->setIfExists('limit_price', $data ?? [], null); + $this->setIfExists('take_profit_order_id', $data ?? [], null); + $this->setIfExists('stop_loss_order_id', $data ?? [], null); } /** @@ -283,30 +290,59 @@ public function valid() /** - * Gets limit_price + * Gets take_profit_order_id * * @return string|null */ - public function getLimitPrice() + public function getTakeProfitOrderId() { - return $this->container['limit_price']; + return $this->container['take_profit_order_id']; } /** - * Sets limit_price + * Sets take_profit_order_id * - * @param string|null $limit_price limit_price + * @param string|null $take_profit_order_id The brokerage order ID for the take profit leg of the bracket order * * @return self */ - public function setLimitPrice($limit_price) + public function setTakeProfitOrderId($take_profit_order_id) { - if (is_null($limit_price)) { - throw new \InvalidArgumentException('non-nullable limit_price cannot be null'); + if (is_null($take_profit_order_id)) { + throw new \InvalidArgumentException('non-nullable take_profit_order_id cannot be null'); } - $this->container['limit_price'] = $limit_price; + $this->container['take_profit_order_id'] = $take_profit_order_id; + + return $this; + } + + /** + * Gets stop_loss_order_id + * + * @return string|null + */ + public function getStopLossOrderId() + { + return $this->container['stop_loss_order_id']; + } + + /** + * Sets stop_loss_order_id + * + * @param string|null $stop_loss_order_id The brokerage order ID for the stop loss leg of the bracket order + * + * @return self + */ + public function setStopLossOrderId($stop_loss_order_id) + { + + if (is_null($stop_loss_order_id)) { + throw new \InvalidArgumentException('non-nullable stop_loss_order_id cannot be null'); + } + + $this->container['stop_loss_order_id'] = $stop_loss_order_id; return $this; } diff --git a/lib/Model/ManualTradeFormWithOptionsStopLoss.php b/lib/Model/ChildBrokerageOrderIDs.php similarity index 81% rename from lib/Model/ManualTradeFormWithOptionsStopLoss.php rename to lib/Model/ChildBrokerageOrderIDs.php index 12cd1e8..919c7ac 100644 --- a/lib/Model/ManualTradeFormWithOptionsStopLoss.php +++ b/lib/Model/ChildBrokerageOrderIDs.php @@ -1,6 +1,6 @@ */ -class ManualTradeFormWithOptionsStopLoss implements ModelInterface, ArrayAccess, \JsonSerializable +class ChildBrokerageOrderIDs implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -42,7 +42,7 @@ class ManualTradeFormWithOptionsStopLoss implements ModelInterface, ArrayAccess, * * @var string */ - protected static $openAPIModelName = 'ManualTradeFormWithOptions_stop_loss'; + protected static $openAPIModelName = 'ChildBrokerageOrderIDs'; /** * Array of property to type mappings. Used for (de)serialization @@ -50,8 +50,8 @@ class ManualTradeFormWithOptionsStopLoss implements ModelInterface, ArrayAccess, * @var string[] */ protected static $openAPITypes = [ - 'stop_price' => 'string', - 'limit_price' => 'string' + 'take_profit_order_id' => 'string', + 'stop_loss_order_id' => 'string' ]; /** @@ -62,8 +62,8 @@ class ManualTradeFormWithOptionsStopLoss implements ModelInterface, ArrayAccess, * @psalm-var array */ protected static $openAPIFormats = [ - 'stop_price' => null, - 'limit_price' => null + 'take_profit_order_id' => null, + 'stop_loss_order_id' => null ]; /** @@ -72,8 +72,8 @@ class ManualTradeFormWithOptionsStopLoss implements ModelInterface, ArrayAccess, * @var boolean[] */ protected static array $openAPINullables = [ - 'stop_price' => false, - 'limit_price' => true + 'take_profit_order_id' => false, + 'stop_loss_order_id' => false ]; /** @@ -162,8 +162,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'stop_price' => 'stop_price', - 'limit_price' => 'limit_price' + 'take_profit_order_id' => 'take_profit_order_id', + 'stop_loss_order_id' => 'stop_loss_order_id' ]; /** @@ -172,8 +172,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'stop_price' => 'setStopPrice', - 'limit_price' => 'setLimitPrice' + 'take_profit_order_id' => 'setTakeProfitOrderId', + 'stop_loss_order_id' => 'setStopLossOrderId' ]; /** @@ -182,8 +182,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'stop_price' => 'getStopPrice', - 'limit_price' => 'getLimitPrice' + 'take_profit_order_id' => 'getTakeProfitOrderId', + 'stop_loss_order_id' => 'getStopLossOrderId' ]; /** @@ -243,8 +243,8 @@ public function getModelName() */ public function __construct(array $data = null) { - $this->setIfExists('stop_price', $data ?? [], null); - $this->setIfExists('limit_price', $data ?? [], null); + $this->setIfExists('take_profit_order_id', $data ?? [], null); + $this->setIfExists('stop_loss_order_id', $data ?? [], null); } /** @@ -290,66 +290,59 @@ public function valid() /** - * Gets stop_price + * Gets take_profit_order_id * * @return string|null */ - public function getStopPrice() + public function getTakeProfitOrderId() { - return $this->container['stop_price']; + return $this->container['take_profit_order_id']; } /** - * Sets stop_price + * Sets take_profit_order_id * - * @param string|null $stop_price stop_price + * @param string|null $take_profit_order_id The brokerage order ID for the take profit leg of the bracket order * * @return self */ - public function setStopPrice($stop_price) + public function setTakeProfitOrderId($take_profit_order_id) { - if (is_null($stop_price)) { - throw new \InvalidArgumentException('non-nullable stop_price cannot be null'); + if (is_null($take_profit_order_id)) { + throw new \InvalidArgumentException('non-nullable take_profit_order_id cannot be null'); } - $this->container['stop_price'] = $stop_price; + $this->container['take_profit_order_id'] = $take_profit_order_id; return $this; } /** - * Gets limit_price + * Gets stop_loss_order_id * * @return string|null */ - public function getLimitPrice() + public function getStopLossOrderId() { - return $this->container['limit_price']; + return $this->container['stop_loss_order_id']; } /** - * Sets limit_price + * Sets stop_loss_order_id * - * @param string|null $limit_price limit_price + * @param string|null $stop_loss_order_id The brokerage order ID for the stop loss leg of the bracket order * * @return self */ - public function setLimitPrice($limit_price) + public function setStopLossOrderId($stop_loss_order_id) { - if (is_null($limit_price)) { - array_push($this->openAPINullablesSetToNull, 'limit_price'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('limit_price', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } + if (is_null($stop_loss_order_id)) { + throw new \InvalidArgumentException('non-nullable stop_loss_order_id cannot be null'); } - $this->container['limit_price'] = $limit_price; + $this->container['stop_loss_order_id'] = $stop_loss_order_id; return $this; } diff --git a/lib/Model/ManualTradeFormBracket.php b/lib/Model/ManualTradeFormBracket.php new file mode 100644 index 0000000..0dc1677 --- /dev/null +++ b/lib/Model/ManualTradeFormBracket.php @@ -0,0 +1,764 @@ + + */ +class ManualTradeFormBracket implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ManualTradeFormBracket'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'account_id' => 'string', + 'action' => '\SnapTrade\Model\ActionStrictWithOptions', + 'symbol' => 'string', + 'order_type' => '\SnapTrade\Model\OrderTypeStrict', + 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', + 'price' => 'float', + 'stop' => 'float', + 'units' => 'float', + 'stop_loss' => '\SnapTrade\Model\StopLoss', + 'take_profit' => '\SnapTrade\Model\TakeProfit' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'account_id' => 'uuid', + 'action' => null, + 'symbol' => null, + 'order_type' => null, + 'time_in_force' => null, + 'price' => null, + 'stop' => null, + 'units' => null, + 'stop_loss' => null, + 'take_profit' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'account_id' => false, + 'action' => false, + 'symbol' => false, + 'order_type' => false, + 'time_in_force' => false, + 'price' => true, + 'stop' => true, + 'units' => false, + 'stop_loss' => false, + 'take_profit' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'account_id' => 'account_id', + 'action' => 'action', + 'symbol' => 'symbol', + 'order_type' => 'order_type', + 'time_in_force' => 'time_in_force', + 'price' => 'price', + 'stop' => 'stop', + 'units' => 'units', + 'stop_loss' => 'stop_loss', + 'take_profit' => 'take_profit' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'account_id' => 'setAccountId', + 'action' => 'setAction', + 'symbol' => 'setSymbol', + 'order_type' => 'setOrderType', + 'time_in_force' => 'setTimeInForce', + 'price' => 'setPrice', + 'stop' => 'setStop', + 'units' => 'setUnits', + 'stop_loss' => 'setStopLoss', + 'take_profit' => 'setTakeProfit' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'account_id' => 'getAccountId', + 'action' => 'getAction', + 'symbol' => 'getSymbol', + 'order_type' => 'getOrderType', + 'time_in_force' => 'getTimeInForce', + 'price' => 'getPrice', + 'stop' => 'getStop', + 'units' => 'getUnits', + 'stop_loss' => 'getStopLoss', + 'take_profit' => 'getTakeProfit' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('account_id', $data ?? [], null); + $this->setIfExists('action', $data ?? [], null); + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('order_type', $data ?? [], null); + $this->setIfExists('time_in_force', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('stop', $data ?? [], null); + $this->setIfExists('units', $data ?? [], null); + $this->setIfExists('stop_loss', $data ?? [], null); + $this->setIfExists('take_profit', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['account_id'] === null) { + $invalidProperties[] = "'account_id' can't be null"; + } + if ($this->container['action'] === null) { + $invalidProperties[] = "'action' can't be null"; + } + if ($this->container['symbol'] === null) { + $invalidProperties[] = "'symbol' can't be null"; + } + if ($this->container['order_type'] === null) { + $invalidProperties[] = "'order_type' can't be null"; + } + if ($this->container['time_in_force'] === null) { + $invalidProperties[] = "'time_in_force' can't be null"; + } + if ($this->container['stop_loss'] === null) { + $invalidProperties[] = "'stop_loss' can't be null"; + } + if ($this->container['take_profit'] === null) { + $invalidProperties[] = "'take_profit' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets account_id + * + * @return string + */ + public function getAccountId() + { + return $this->container['account_id']; + } + + /** + * Sets account_id + * + * @param string $account_id Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. + * + * @return self + */ + public function setAccountId($account_id) + { + + if (is_null($account_id)) { + throw new \InvalidArgumentException('non-nullable account_id cannot be null'); + } + + $this->container['account_id'] = $account_id; + + return $this; + } + + /** + * Gets action + * + * @return \SnapTrade\Model\ActionStrictWithOptions + */ + public function getAction() + { + return $this->container['action']; + } + + /** + * Sets action + * + * @param \SnapTrade\Model\ActionStrictWithOptions $action action + * + * @return self + */ + public function setAction($action) + { + + if (is_null($action)) { + throw new \InvalidArgumentException('non-nullable action cannot be null'); + } + + $this->container['action'] = $action; + + return $this; + } + + /** + * Gets symbol + * + * @return string + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string $symbol The security's trading ticker symbol. + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets order_type + * + * @return \SnapTrade\Model\OrderTypeStrict + */ + public function getOrderType() + { + return $this->container['order_type']; + } + + /** + * Sets order_type + * + * @param \SnapTrade\Model\OrderTypeStrict $order_type order_type + * + * @return self + */ + public function setOrderType($order_type) + { + + if (is_null($order_type)) { + throw new \InvalidArgumentException('non-nullable order_type cannot be null'); + } + + $this->container['order_type'] = $order_type; + + return $this; + } + + /** + * Gets time_in_force + * + * @return \SnapTrade\Model\TimeInForceStrict + */ + public function getTimeInForce() + { + return $this->container['time_in_force']; + } + + /** + * Sets time_in_force + * + * @param \SnapTrade\Model\TimeInForceStrict $time_in_force time_in_force + * + * @return self + */ + public function setTimeInForce($time_in_force) + { + + if (is_null($time_in_force)) { + throw new \InvalidArgumentException('non-nullable time_in_force cannot be null'); + } + + $this->container['time_in_force'] = $time_in_force; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price The limit price for `Limit` and `StopLimit` orders. + * + * @return self + */ + public function setPrice($price) + { + + if (is_null($price)) { + array_push($this->openAPINullablesSetToNull, 'price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets stop + * + * @return float|null + */ + public function getStop() + { + return $this->container['stop']; + } + + /** + * Sets stop + * + * @param float|null $stop The price at which a stop order is triggered for `Stop` and `StopLimit` orders. + * + * @return self + */ + public function setStop($stop) + { + + if (is_null($stop)) { + array_push($this->openAPINullablesSetToNull, 'stop'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('stop', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['stop'] = $stop; + + return $this; + } + + /** + * Gets units + * + * @return float|null + */ + public function getUnits() + { + return $this->container['units']; + } + + /** + * Sets units + * + * @param float|null $units Number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. + * + * @return self + */ + public function setUnits($units) + { + + if (is_null($units)) { + throw new \InvalidArgumentException('non-nullable units cannot be null'); + } + + $this->container['units'] = $units; + + return $this; + } + + /** + * Gets stop_loss + * + * @return \SnapTrade\Model\StopLoss + */ + public function getStopLoss() + { + return $this->container['stop_loss']; + } + + /** + * Sets stop_loss + * + * @param \SnapTrade\Model\StopLoss $stop_loss stop_loss + * + * @return self + */ + public function setStopLoss($stop_loss) + { + + if (is_null($stop_loss)) { + throw new \InvalidArgumentException('non-nullable stop_loss cannot be null'); + } + + $this->container['stop_loss'] = $stop_loss; + + return $this; + } + + /** + * Gets take_profit + * + * @return \SnapTrade\Model\TakeProfit + */ + public function getTakeProfit() + { + return $this->container['take_profit']; + } + + /** + * Sets take_profit + * + * @param \SnapTrade\Model\TakeProfit $take_profit take_profit + * + * @return self + */ + public function setTakeProfit($take_profit) + { + + if (is_null($take_profit)) { + throw new \InvalidArgumentException('non-nullable take_profit cannot be null'); + } + + $this->container['take_profit'] = $take_profit; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/ManualTradeFormWithOptions.php b/lib/Model/ManualTradeFormWithOptions.php index 45840a9..bdfa014 100644 --- a/lib/Model/ManualTradeFormWithOptions.php +++ b/lib/Model/ManualTradeFormWithOptions.php @@ -60,10 +60,7 @@ class ManualTradeFormWithOptions implements ModelInterface, ArrayAccess, \JsonSe 'price' => 'float', 'stop' => 'float', 'units' => 'float', - 'notional_value' => '\SnapTrade\Model\ManualTradeFormNotionalValue', - 'order_class' => 'string', - 'stop_loss' => '\SnapTrade\Model\ManualTradeFormWithOptionsStopLoss', - 'take_profit' => '\SnapTrade\Model\ManualTradeFormWithOptionsTakeProfit' + 'notional_value' => '\SnapTrade\Model\ManualTradeFormNotionalValue' ]; /** @@ -83,10 +80,7 @@ class ManualTradeFormWithOptions implements ModelInterface, ArrayAccess, \JsonSe 'price' => null, 'stop' => null, 'units' => null, - 'notional_value' => null, - 'order_class' => null, - 'stop_loss' => null, - 'take_profit' => null + 'notional_value' => null ]; /** @@ -104,10 +98,7 @@ class ManualTradeFormWithOptions implements ModelInterface, ArrayAccess, \JsonSe 'price' => true, 'stop' => true, 'units' => true, - 'notional_value' => true, - 'order_class' => true, - 'stop_loss' => true, - 'take_profit' => true + 'notional_value' => true ]; /** @@ -205,10 +196,7 @@ public function isNullableSetToNull(string $property): bool 'price' => 'price', 'stop' => 'stop', 'units' => 'units', - 'notional_value' => 'notional_value', - 'order_class' => 'order_class', - 'stop_loss' => 'stop_loss', - 'take_profit' => 'take_profit' + 'notional_value' => 'notional_value' ]; /** @@ -226,10 +214,7 @@ public function isNullableSetToNull(string $property): bool 'price' => 'setPrice', 'stop' => 'setStop', 'units' => 'setUnits', - 'notional_value' => 'setNotionalValue', - 'order_class' => 'setOrderClass', - 'stop_loss' => 'setStopLoss', - 'take_profit' => 'setTakeProfit' + 'notional_value' => 'setNotionalValue' ]; /** @@ -247,10 +232,7 @@ public function isNullableSetToNull(string $property): bool 'price' => 'getPrice', 'stop' => 'getStop', 'units' => 'getUnits', - 'notional_value' => 'getNotionalValue', - 'order_class' => 'getOrderClass', - 'stop_loss' => 'getStopLoss', - 'take_profit' => 'getTakeProfit' + 'notional_value' => 'getNotionalValue' ]; /** @@ -294,21 +276,6 @@ public function getModelName() return self::$openAPIModelName; } - public const ORDER_CLASS_SIMPLE = 'SIMPLE'; - public const ORDER_CLASS_BRACKET = 'BRACKET'; - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getOrderClassAllowableValues() - { - return [ - self::ORDER_CLASS_SIMPLE, - self::ORDER_CLASS_BRACKET, - ]; - } /** * Associative array for storing property values @@ -335,9 +302,6 @@ public function __construct(array $data = null) $this->setIfExists('stop', $data ?? [], null); $this->setIfExists('units', $data ?? [], null); $this->setIfExists('notional_value', $data ?? [], null); - $this->setIfExists('order_class', $data ?? [], null); - $this->setIfExists('stop_loss', $data ?? [], null); - $this->setIfExists('take_profit', $data ?? [], null); } /** @@ -379,15 +343,6 @@ public function listInvalidProperties() if ($this->container['time_in_force'] === null) { $invalidProperties[] = "'time_in_force' can't be null"; } - $allowedValues = $this->getOrderClassAllowableValues(); - if (!is_null($this->container['order_class']) && !in_array($this->container['order_class'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'order_class', must be one of '%s'", - $this->container['order_class'], - implode("', '", $allowedValues) - ); - } - return $invalidProperties; } @@ -510,7 +465,7 @@ public function getSymbol() /** * Sets symbol * - * @param string|null $symbol The security's trading ticker symbol. This currently only support Options symbols in the 21 character OCC format. For example \"AAPL 131124C00240000\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. + * @param string|null $symbol The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example \"AAPL 131124C00240000\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. * * @return self */ @@ -734,124 +689,6 @@ public function setNotionalValue($notional_value) return $this; } - - /** - * Gets order_class - * - * @return string|null - */ - public function getOrderClass() - { - return $this->container['order_class']; - } - - /** - * Sets order_class - * - * @param string|null $order_class The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details - * - * @return self - */ - public function setOrderClass($order_class) - { - $allowedValues = $this->getOrderClassAllowableValues(); - if (!is_null($order_class) && !in_array($order_class, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'order_class', must be one of '%s'", - $order_class, - implode("', '", $allowedValues) - ) - ); - } - - if (is_null($order_class)) { - array_push($this->openAPINullablesSetToNull, 'order_class'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('order_class', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - - $this->container['order_class'] = $order_class; - - return $this; - } - - /** - * Gets stop_loss - * - * @return \SnapTrade\Model\ManualTradeFormWithOptionsStopLoss|null - */ - public function getStopLoss() - { - return $this->container['stop_loss']; - } - - /** - * Sets stop_loss - * - * @param \SnapTrade\Model\ManualTradeFormWithOptionsStopLoss|null $stop_loss stop_loss - * - * @return self - */ - public function setStopLoss($stop_loss) - { - - if (is_null($stop_loss)) { - array_push($this->openAPINullablesSetToNull, 'stop_loss'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('stop_loss', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - - $this->container['stop_loss'] = $stop_loss; - - return $this; - } - - /** - * Gets take_profit - * - * @return \SnapTrade\Model\ManualTradeFormWithOptionsTakeProfit|null - */ - public function getTakeProfit() - { - return $this->container['take_profit']; - } - - /** - * Sets take_profit - * - * @param \SnapTrade\Model\ManualTradeFormWithOptionsTakeProfit|null $take_profit take_profit - * - * @return self - */ - public function setTakeProfit($take_profit) - { - - if (is_null($take_profit)) { - array_push($this->openAPINullablesSetToNull, 'take_profit'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('take_profit', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - - $this->container['take_profit'] = $take_profit; - - return $this; - } /** * Returns true if offset exists. False otherwise. * diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 6a6ca9b..ba47909 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -94,6 +94,18 @@ public function testGetUserAccountQuotes() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for placeBracketOrder + * + * Place a Bracket Order. + * + */ + public function testPlaceBracketOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for placeForceOrder * diff --git a/test/Model/ManualTradeFormWithOptionsTakeProfitTest.php b/test/Model/AccountOrderRecordChildBrokerageOrderIdsTest.php similarity index 63% rename from test/Model/ManualTradeFormWithOptionsTakeProfitTest.php rename to test/Model/AccountOrderRecordChildBrokerageOrderIdsTest.php index e1c5868..b05e583 100644 --- a/test/Model/ManualTradeFormWithOptionsTakeProfitTest.php +++ b/test/Model/AccountOrderRecordChildBrokerageOrderIdsTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); } /** - * Test attribute "limit_price" + * Test attribute "take_profit_order_id" */ - public function testPropertyLimitPrice() + public function testPropertyTakeProfitOrderId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop_loss_order_id" + */ + public function testPropertyStopLossOrderId() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/AccountOrderRecordTest.php b/test/Model/AccountOrderRecordTest.php index a4ee46e..2a3deaf 100644 --- a/test/Model/AccountOrderRecordTest.php +++ b/test/Model/AccountOrderRecordTest.php @@ -242,4 +242,13 @@ public function testPropertySymbol() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "child_brokerage_order_ids" + */ + public function testPropertyChildBrokerageOrderIds() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } diff --git a/test/Model/ManualTradeFormWithOptionsStopLossTest.php b/test/Model/ChildBrokerageOrderIDsTest.php similarity index 72% rename from test/Model/ManualTradeFormWithOptionsStopLossTest.php rename to test/Model/ChildBrokerageOrderIDsTest.php index 29742d3..0c4c12c 100644 --- a/test/Model/ManualTradeFormWithOptionsStopLossTest.php +++ b/test/Model/ChildBrokerageOrderIDsTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); } /** - * Test attribute "stop_price" + * Test attribute "take_profit_order_id" */ - public function testPropertyStopPrice() + public function testPropertyTakeProfitOrderId() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "limit_price" + * Test attribute "stop_loss_order_id" */ - public function testPropertyLimitPrice() + public function testPropertyStopLossOrderId() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/ManualTradeFormBracketTest.php b/test/Model/ManualTradeFormBracketTest.php new file mode 100644 index 0000000..881daa3 --- /dev/null +++ b/test/Model/ManualTradeFormBracketTest.php @@ -0,0 +1,164 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "account_id" + */ + public function testPropertyAccountId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "action" + */ + public function testPropertyAction() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "order_type" + */ + public function testPropertyOrderType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "time_in_force" + */ + public function testPropertyTimeInForce() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "price" + */ + public function testPropertyPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop" + */ + public function testPropertyStop() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "units" + */ + public function testPropertyUnits() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop_loss" + */ + public function testPropertyStopLoss() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "take_profit" + */ + public function testPropertyTakeProfit() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/ManualTradeFormWithOptionsTest.php b/test/Model/ManualTradeFormWithOptionsTest.php index ff87240..7aa386f 100644 --- a/test/Model/ManualTradeFormWithOptionsTest.php +++ b/test/Model/ManualTradeFormWithOptionsTest.php @@ -161,31 +161,4 @@ public function testPropertyNotionalValue() // TODO: implement $this->markTestIncomplete('Not implemented'); } - - /** - * Test attribute "order_class" - */ - public function testPropertyOrderClass() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "stop_loss" - */ - public function testPropertyStopLoss() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "take_profit" - */ - public function testPropertyTakeProfit() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } } From 32c3260c5986c9eb1c5edaa6d7050022421041a7 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 15:50:52 +0000 Subject: [PATCH 093/252] Version Bump SDKs (#112) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 2fcd779..49f117f 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -edc3964d-4655-4f2d-b1ba-efe30f01c7af \ No newline at end of file +dec02ecb-722b-4453-8d12-48f17f8d1c07 \ No newline at end of file diff --git a/README.md b/README.md index 5990f24..cd9f37d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.81-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.82-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -91,7 +91,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.81" + "konfig/snaptrade-php-sdk": "2.0.82" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 019e773..8a752c5 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.81/PHP'; + protected $userAgent = 'Konfig/2.0.82/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.81' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.82' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 9aed7f8a5da2fbbe9678869376eccf6ed095423f Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 21:27:16 +0000 Subject: [PATCH 094/252] Regenerate SDKs (#113) * Regenerate SDKs * Regenerate SDKs * Regenerate SDKs * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 301 ++ lib/Api/CryptoSpotTradingApi.php | 2566 +++++++++++++++++ lib/Client.php | 3 + lib/Model/CryptoSpotOrderPreview.php | 405 +++ .../CryptoSpotOrderPreviewEstimatedFee.php | 447 +++ lib/Model/CryptoSpotQuote.php | 518 ++++ lib/Model/CryptocurrencyPair.php | 447 +++ .../TradingCryptoSpotCancelOrderRequest.php | 407 +++ .../TradingCryptoSpotPlaceOrderRequest.php | 787 +++++ .../TradingCryptoSpotSymbols200Response.php | 408 +++ test/Api/CryptoSpotTradingApiTest.php | 120 + ...CryptoSpotOrderPreviewEstimatedFeeTest.php | 92 + test/Model/CryptoSpotOrderPreviewTest.php | 83 + test/Model/CryptoSpotQuoteTest.php | 110 + test/Model/CryptocurrencyPairTest.php | 92 + ...radingCryptoSpotCancelOrderRequestTest.php | 83 + ...TradingCryptoSpotPlaceOrderRequestTest.php | 155 + ...radingCryptoSpotSymbols200ResponseTest.php | 83 + 19 files changed, 7108 insertions(+), 1 deletion(-) create mode 100644 lib/Api/CryptoSpotTradingApi.php create mode 100644 lib/Model/CryptoSpotOrderPreview.php create mode 100644 lib/Model/CryptoSpotOrderPreviewEstimatedFee.php create mode 100644 lib/Model/CryptoSpotQuote.php create mode 100644 lib/Model/CryptocurrencyPair.php create mode 100644 lib/Model/TradingCryptoSpotCancelOrderRequest.php create mode 100644 lib/Model/TradingCryptoSpotPlaceOrderRequest.php create mode 100644 lib/Model/TradingCryptoSpotSymbols200Response.php create mode 100644 test/Api/CryptoSpotTradingApiTest.php create mode 100644 test/Model/CryptoSpotOrderPreviewEstimatedFeeTest.php create mode 100644 test/Model/CryptoSpotOrderPreviewTest.php create mode 100644 test/Model/CryptoSpotQuoteTest.php create mode 100644 test/Model/CryptocurrencyPairTest.php create mode 100644 test/Model/TradingCryptoSpotCancelOrderRequestTest.php create mode 100644 test/Model/TradingCryptoSpotPlaceOrderRequestTest.php create mode 100644 test/Model/TradingCryptoSpotSymbols200ResponseTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 49f117f..4f7fa77 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -dec02ecb-722b-4453-8d12-48f17f8d1c07 \ No newline at end of file +dd00215d-37c7-4b22-a4d4-9a4bfc302b6b \ No newline at end of file diff --git a/README.md b/README.md index cd9f37d..7361c35 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,11 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.connections.removeBrokerageAuthorization`](#snaptradeconnectionsremovebrokerageauthorization) * [`snaptrade.connections.returnRates`](#snaptradeconnectionsreturnrates) * [`snaptrade.connections.sessionEvents`](#snaptradeconnectionssessionevents) + * [`snaptrade.cryptoSpotTrading.cryptoSpotCancelOrder`](#snaptradecryptospottradingcryptospotcancelorder) + * [`snaptrade.cryptoSpotTrading.cryptoSpotPlaceOrder`](#snaptradecryptospottradingcryptospotplaceorder) + * [`snaptrade.cryptoSpotTrading.cryptoSpotPreviewOrder`](#snaptradecryptospottradingcryptospotprevieworder) + * [`snaptrade.cryptoSpotTrading.cryptoSpotQuote`](#snaptradecryptospottradingcryptospotquote) + * [`snaptrade.cryptoSpotTrading.cryptoSpotSymbols`](#snaptradecryptospottradingcryptospotsymbols) * [`snaptrade.options.getOptionStrategy`](#snaptradeoptionsgetoptionstrategy) * [`snaptrade.options.getOptionsChain`](#snaptradeoptionsgetoptionschain) * [`snaptrade.options.getOptionsStrategyQuote`](#snaptradeoptionsgetoptionsstrategyquote) @@ -1114,6 +1119,302 @@ Optional comma separated list of session IDs used to filter the request on speci --- +### `snaptrade.cryptoSpotTrading.cryptoSpotCancelOrder` + +Cancels a cryptocurrency spot order in the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->cryptoSpotTrading->cryptoSpotCancelOrder( + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" +); +``` + +#### βš™οΈ Parameters + +##### brokerage_order_id: `string` + +Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + + +#### πŸ”„ Return + +[**AccountOrderRecord**](./lib/Model/AccountOrderRecord.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/crypto/spot/cancelOrder` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + +### `snaptrade.cryptoSpotTrading.cryptoSpotPlaceOrder` + +Places a spot cryptocurrency order in the specified account. +This endpoint does not compute the impact to the account balance from the order before submitting the order to the exchange. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->cryptoSpotTrading->cryptoSpotPlaceOrder( + symbol: [ + "base" => "BTC", + "quote" => "BTC", + ], + side: "BUY", + type: "MARKET", + time_in_force: "GTC", + amount: "123.45", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + limit_price: "123.45", + stop_price: "123.45", + post_only: False, + expiration_date: "2024-01-01T00:00:00Z" +); +``` + +#### βš™οΈ Parameters + +##### symbol: [`CryptocurrencyPair`](./lib/Model/CryptocurrencyPair.php) + +##### side: + +##### type: `string` + +The type of order to place. + +##### time_in_force: `string` + +The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. + +##### amount: `float` + +The amount of the base currency to buy or sell. + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### limit_price: `float` + +The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. + +##### stop_price: `float` + +The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. + +##### post_only: `bool` + +Required for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. + +##### expiration_date: `\DateTime` + +The expiration date of the order. Required if the time_in_force is GTD. + + +#### πŸ”„ Return + +[**AccountOrderRecord**](./lib/Model/AccountOrderRecord.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/crypto/spot/placeOrder` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + +### `snaptrade.cryptoSpotTrading.cryptoSpotPreviewOrder` + +Previews a cryptocurrency spot order using the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->cryptoSpotTrading->cryptoSpotPreviewOrder( + symbol: [ + "base" => "BTC", + "quote" => "BTC", + ], + side: "BUY", + type: "MARKET", + time_in_force: "GTC", + amount: "123.45", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + limit_price: "123.45", + stop_price: "123.45", + post_only: False, + expiration_date: "2024-01-01T00:00:00Z" +); +``` + +#### βš™οΈ Parameters + +##### symbol: [`CryptocurrencyPair`](./lib/Model/CryptocurrencyPair.php) + +##### side: + +##### type: `string` + +The type of order to place. + +##### time_in_force: `string` + +The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. + +##### amount: `float` + +The amount of the base currency to buy or sell. + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### limit_price: `float` + +The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. + +##### stop_price: `float` + +The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. + +##### post_only: `bool` + +Required for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. + +##### expiration_date: `\DateTime` + +The expiration date of the order. Required if the time_in_force is GTD. + + +#### πŸ”„ Return + +[**CryptoSpotOrderPreview**](./lib/Model/CryptoSpotOrderPreview.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/crypto/spot/previewOrder` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + +### `snaptrade.cryptoSpotTrading.cryptoSpotQuote` + +Gets a quote for the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->cryptoSpotTrading->cryptoSpotQuote( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + base: "BTC", + quote: "BTC" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### base: `string` + +##### quote: `string` + + +#### πŸ”„ Return + +[**CryptoSpotQuote**](./lib/Model/CryptoSpotQuote.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/crypto/spot/quote` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + +### `snaptrade.cryptoSpotTrading.cryptoSpotSymbols` + +Searches cryptocurrency spot symbols accessible to the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->cryptoSpotTrading->cryptoSpotSymbols( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + base: "BTC", + quote: "BTC" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### base: `string` + +##### quote: `string` + + +#### πŸ”„ Return + +[**TradingCryptoSpotSymbols200Response**](./lib/Model/TradingCryptoSpotSymbols200Response.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/crypto/spot/symbols` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.options.getOptionStrategy` Creates an option strategy object that will be used to place an option strategy order. diff --git a/lib/Api/CryptoSpotTradingApi.php b/lib/Api/CryptoSpotTradingApi.php new file mode 100644 index 0000000..33aba01 --- /dev/null +++ b/lib/Api/CryptoSpotTradingApi.php @@ -0,0 +1,2566 @@ + [ + 'application/json', + ], + 'cryptoSpotPlaceOrder' => [ + 'application/json', + ], + 'cryptoSpotPreviewOrder' => [ + 'application/json', + ], + 'cryptoSpotQuote' => [ + 'application/json', + ], + 'cryptoSpotSymbols' => [ + 'application/json', + ], + ]; + +/** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + Configuration $config = null, + ClientInterface $client = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $clientOptions = []; + if (!$config->getVerifySsl()) $clientOptions["verify"] = false; + + // Do not truncate error messages + // https://github.com/guzzle/guzzle/issues/2185#issuecomment-800293420 + $stack = new HandlerStack(Utils::chooseHandler()); + $stack->push(Middleware::httpErrors(new BodySummarizer(10000)), 'http_errors'); + $stack->push(Middleware::redirect(), 'allow_redirects'); + $stack->push(Middleware::cookies(), 'cookies'); + $stack->push(Middleware::prepareBody(), 'prepare_body'); + $clientOptions["handler"] = $stack; + + $this->client = $client ?: new Client($clientOptions); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * For initializing request body parameter + */ + private function setRequestBodyProperty(&$body, $property, $value) { + if ($body === null) $body = []; + // user did not pass in a value for this parameter + if ($value === SENTINEL_VALUE) return; + $body[$property] = $value; + } + + /** + * Operation cryptoSpotCancelOrder + * + * Cancel a crypto spot order. + * + * Cancels a cryptocurrency spot order in the specified account. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest $trading_crypto_spot_cancel_order_request trading_crypto_spot_cancel_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotCancelOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function cryptoSpotCancelOrder( + + $brokerage_order_id, + $user_id, + $user_secret, + $account_id, + string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); + $trading_crypto_spot_cancel_order_request = $_body; + + list($response) = $this->cryptoSpotCancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, $contentType); + return $response; + } + + /** + * Operation cryptoSpotCancelOrderWithHttpInfo + * + * Cancel a crypto spot order. + * + * Cancels a cryptocurrency spot order in the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest $trading_crypto_spot_cancel_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotCancelOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function cryptoSpotCancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotCancelOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->cryptoSpotCancelOrderWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $trading_crypto_spot_cancel_order_request, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation cryptoSpotCancelOrderAsync + * + * Cancel a crypto spot order. + * + * Cancels a cryptocurrency spot order in the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest $trading_crypto_spot_cancel_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotCancelOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cryptoSpotCancelOrderAsync( + + $brokerage_order_id, + $user_id, + $user_secret, + $account_id, + string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); + $trading_crypto_spot_cancel_order_request = $_body; + + return $this->cryptoSpotCancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation cryptoSpotCancelOrderAsyncWithHttpInfo + * + * Cancel a crypto spot order. + * + * Cancels a cryptocurrency spot order in the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest $trading_crypto_spot_cancel_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotCancelOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cryptoSpotCancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotCancelOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'cryptoSpotCancelOrder' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest $trading_crypto_spot_cancel_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotCancelOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function cryptoSpotCancelOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling cryptoSpotCancelOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling cryptoSpotCancelOrder' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling cryptoSpotCancelOrder' + ); + } + if ($trading_crypto_spot_cancel_order_request !== SENTINEL_VALUE) { + if (!($trading_crypto_spot_cancel_order_request instanceof \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest)) { + if (!is_array($trading_crypto_spot_cancel_order_request)) + throw new \InvalidArgumentException('"trading_crypto_spot_cancel_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest CryptoSpotTradingApi.cryptoSpotCancelOrder.'); + else + $trading_crypto_spot_cancel_order_request = new \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest($trading_crypto_spot_cancel_order_request); + } + } + // verify the required parameter 'trading_crypto_spot_cancel_order_request' is set + if ($trading_crypto_spot_cancel_order_request === SENTINEL_VALUE || (is_array($trading_crypto_spot_cancel_order_request) && count($trading_crypto_spot_cancel_order_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter trading_crypto_spot_cancel_order_request when calling cryptoSpotCancelOrder' + ); + } + + + $resourcePath = '/accounts/{accountId}/trading/crypto/spot/cancelOrder'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($trading_crypto_spot_cancel_order_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_crypto_spot_cancel_order_request)); + } else { + $httpBody = $trading_crypto_spot_cancel_order_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation cryptoSpotPlaceOrder + * + * Place a spot order on a crypto exchange + * + * Places a spot cryptocurrency order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order to the exchange. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request trading_crypto_spot_place_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPlaceOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function cryptoSpotPlaceOrder( + + $symbol, + $side, + $type, + $time_in_force, + $amount, + $user_id, + $user_secret, + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $trading_crypto_spot_place_order_request = $_body; + + list($response) = $this->cryptoSpotPlaceOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); + return $response; + } + + /** + * Operation cryptoSpotPlaceOrderWithHttpInfo + * + * Place a spot order on a crypto exchange + * + * Places a spot cryptocurrency order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order to the exchange. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPlaceOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function cryptoSpotPlaceOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotPlaceOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->cryptoSpotPlaceOrderWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $trading_crypto_spot_place_order_request, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation cryptoSpotPlaceOrderAsync + * + * Place a spot order on a crypto exchange + * + * Places a spot cryptocurrency order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order to the exchange. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPlaceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cryptoSpotPlaceOrderAsync( + + $symbol, + $side, + $type, + $time_in_force, + $amount, + $user_id, + $user_secret, + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $trading_crypto_spot_place_order_request = $_body; + + return $this->cryptoSpotPlaceOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation cryptoSpotPlaceOrderAsyncWithHttpInfo + * + * Place a spot order on a crypto exchange + * + * Places a spot cryptocurrency order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order to the exchange. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPlaceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cryptoSpotPlaceOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotPlaceOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'cryptoSpotPlaceOrder' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPlaceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function cryptoSpotPlaceOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling cryptoSpotPlaceOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling cryptoSpotPlaceOrder' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling cryptoSpotPlaceOrder' + ); + } + if ($trading_crypto_spot_place_order_request !== SENTINEL_VALUE) { + if (!($trading_crypto_spot_place_order_request instanceof \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest)) { + if (!is_array($trading_crypto_spot_place_order_request)) + throw new \InvalidArgumentException('"trading_crypto_spot_place_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest CryptoSpotTradingApi.cryptoSpotPlaceOrder.'); + else + $trading_crypto_spot_place_order_request = new \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest($trading_crypto_spot_place_order_request); + } + } + // verify the required parameter 'trading_crypto_spot_place_order_request' is set + if ($trading_crypto_spot_place_order_request === SENTINEL_VALUE || (is_array($trading_crypto_spot_place_order_request) && count($trading_crypto_spot_place_order_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter trading_crypto_spot_place_order_request when calling cryptoSpotPlaceOrder' + ); + } + + + $resourcePath = '/accounts/{accountId}/trading/crypto/spot/placeOrder'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($trading_crypto_spot_place_order_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_crypto_spot_place_order_request)); + } else { + $httpBody = $trading_crypto_spot_place_order_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation cryptoSpotPreviewOrder + * + * Place a spot order on a crypto exchange + * + * Previews a cryptocurrency spot order using the specified account. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request trading_crypto_spot_place_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPreviewOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\CryptoSpotOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function cryptoSpotPreviewOrder( + + $symbol, + $side, + $type, + $time_in_force, + $amount, + $user_id, + $user_secret, + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['cryptoSpotPreviewOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $trading_crypto_spot_place_order_request = $_body; + + list($response) = $this->cryptoSpotPreviewOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); + return $response; + } + + /** + * Operation cryptoSpotPreviewOrderWithHttpInfo + * + * Place a spot order on a crypto exchange + * + * Previews a cryptocurrency spot order using the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPreviewOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\CryptoSpotOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function cryptoSpotPreviewOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPreviewOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotPreviewOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->cryptoSpotPreviewOrderWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $trading_crypto_spot_place_order_request, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\CryptoSpotOrderPreview' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\CryptoSpotOrderPreview' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\CryptoSpotOrderPreview', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\CryptoSpotOrderPreview'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\CryptoSpotOrderPreview', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation cryptoSpotPreviewOrderAsync + * + * Place a spot order on a crypto exchange + * + * Previews a cryptocurrency spot order using the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPreviewOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cryptoSpotPreviewOrderAsync( + + $symbol, + $side, + $type, + $time_in_force, + $amount, + $user_id, + $user_secret, + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['cryptoSpotPreviewOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $trading_crypto_spot_place_order_request = $_body; + + return $this->cryptoSpotPreviewOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation cryptoSpotPreviewOrderAsyncWithHttpInfo + * + * Place a spot order on a crypto exchange + * + * Previews a cryptocurrency spot order using the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPreviewOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cryptoSpotPreviewOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPreviewOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\CryptoSpotOrderPreview'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotPreviewOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'cryptoSpotPreviewOrder' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPreviewOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function cryptoSpotPreviewOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPreviewOrder'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling cryptoSpotPreviewOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling cryptoSpotPreviewOrder' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling cryptoSpotPreviewOrder' + ); + } + if ($trading_crypto_spot_place_order_request !== SENTINEL_VALUE) { + if (!($trading_crypto_spot_place_order_request instanceof \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest)) { + if (!is_array($trading_crypto_spot_place_order_request)) + throw new \InvalidArgumentException('"trading_crypto_spot_place_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest CryptoSpotTradingApi.cryptoSpotPreviewOrder.'); + else + $trading_crypto_spot_place_order_request = new \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest($trading_crypto_spot_place_order_request); + } + } + // verify the required parameter 'trading_crypto_spot_place_order_request' is set + if ($trading_crypto_spot_place_order_request === SENTINEL_VALUE || (is_array($trading_crypto_spot_place_order_request) && count($trading_crypto_spot_place_order_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter trading_crypto_spot_place_order_request when calling cryptoSpotPreviewOrder' + ); + } + + + $resourcePath = '/accounts/{accountId}/trading/crypto/spot/previewOrder'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($trading_crypto_spot_place_order_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_crypto_spot_place_order_request)); + } else { + $httpBody = $trading_crypto_spot_place_order_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation cryptoSpotQuote + * + * Get a quote for a cyrptocurrency market + * + * Gets a quote for the specified account. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param string $base base (required) + * @param string $quote quote (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotQuote'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\CryptoSpotQuote|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function cryptoSpotQuote( + $user_id, + $user_secret, + $account_id, + $base, + $quote, + + string $contentType = self::contentTypes['cryptoSpotQuote'][0] + ) + { + + list($response) = $this->cryptoSpotQuoteWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); + return $response; + } + + /** + * Operation cryptoSpotQuoteWithHttpInfo + * + * Get a quote for a cyrptocurrency market + * + * Gets a quote for the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (required) + * @param string $quote (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotQuote'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\CryptoSpotQuote|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function cryptoSpotQuoteWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, string $contentType = self::contentTypes['cryptoSpotQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotQuoteRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->cryptoSpotQuoteWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $base, + $quote, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\CryptoSpotQuote' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\CryptoSpotQuote' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\CryptoSpotQuote', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\CryptoSpotQuote'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\CryptoSpotQuote', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation cryptoSpotQuoteAsync + * + * Get a quote for a cyrptocurrency market + * + * Gets a quote for the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (required) + * @param string $quote (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotQuote'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cryptoSpotQuoteAsync( + $user_id, + $user_secret, + $account_id, + $base, + $quote, + + string $contentType = self::contentTypes['cryptoSpotQuote'][0] + ) + { + + return $this->cryptoSpotQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation cryptoSpotQuoteAsyncWithHttpInfo + * + * Get a quote for a cyrptocurrency market + * + * Gets a quote for the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (required) + * @param string $quote (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotQuote'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cryptoSpotQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, string $contentType = self::contentTypes['cryptoSpotQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\CryptoSpotQuote'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotQuoteRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'cryptoSpotQuote' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (required) + * @param string $quote (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotQuote'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function cryptoSpotQuoteRequest($user_id, $user_secret, $account_id, $base, $quote, string $contentType = self::contentTypes['cryptoSpotQuote'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling cryptoSpotQuote' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling cryptoSpotQuote' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling cryptoSpotQuote' + ); + } + // Check if $base is a string + if ($base !== SENTINEL_VALUE && !is_string($base)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); + } + // verify the required parameter 'base' is set + if ($base === SENTINEL_VALUE || (is_array($base) && count($base) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter base when calling cryptoSpotQuote' + ); + } + // Check if $quote is a string + if ($quote !== SENTINEL_VALUE && !is_string($quote)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); + } + // verify the required parameter 'quote' is set + if ($quote === SENTINEL_VALUE || (is_array($quote) && count($quote) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter quote when calling cryptoSpotQuote' + ); + } + + + $resourcePath = '/accounts/{accountId}/trading/crypto/spot/quote'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($base !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $base, + 'base', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($quote !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $quote, + 'quote', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation cryptoSpotSymbols + * + * Search crypto spot symbols + * + * Searches cryptocurrency spot symbols accessible to the specified account. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param string $base base (optional) + * @param string $quote quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotSymbols'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\TradingCryptoSpotSymbols200Response|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function cryptoSpotSymbols( + $user_id, + $user_secret, + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['cryptoSpotSymbols'][0] + ) + { + + list($response) = $this->cryptoSpotSymbolsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); + return $response; + } + + /** + * Operation cryptoSpotSymbolsWithHttpInfo + * + * Search crypto spot symbols + * + * Searches cryptocurrency spot symbols accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotSymbols'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\TradingCryptoSpotSymbols200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function cryptoSpotSymbolsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['cryptoSpotSymbols'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotSymbolsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->cryptoSpotSymbolsWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $base, + $quote, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\TradingCryptoSpotSymbols200Response' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\TradingCryptoSpotSymbols200Response' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingCryptoSpotSymbols200Response', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\TradingCryptoSpotSymbols200Response'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\TradingCryptoSpotSymbols200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation cryptoSpotSymbolsAsync + * + * Search crypto spot symbols + * + * Searches cryptocurrency spot symbols accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotSymbols'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cryptoSpotSymbolsAsync( + $user_id, + $user_secret, + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['cryptoSpotSymbols'][0] + ) + { + + return $this->cryptoSpotSymbolsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation cryptoSpotSymbolsAsyncWithHttpInfo + * + * Search crypto spot symbols + * + * Searches cryptocurrency spot symbols accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotSymbols'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cryptoSpotSymbolsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['cryptoSpotSymbols'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\TradingCryptoSpotSymbols200Response'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotSymbolsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'cryptoSpotSymbols' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotSymbols'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function cryptoSpotSymbolsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['cryptoSpotSymbols'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling cryptoSpotSymbols' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling cryptoSpotSymbols' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling cryptoSpotSymbols' + ); + } + // Check if $base is a string + if ($base !== SENTINEL_VALUE && !is_string($base)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); + } + // Check if $quote is a string + if ($quote !== SENTINEL_VALUE && !is_string($quote)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); + } + + + $resourcePath = '/accounts/{accountId}/trading/crypto/spot/symbols'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($base !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $base, + 'base', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($quote !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $quote, + 'quote', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/Client.php b/lib/Client.php index b8de060..6cdc634 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -13,6 +13,8 @@ class Client public readonly \SnapTrade\Api\ConnectionsApi $connections; + public readonly \SnapTrade\Api\CryptoSpotTradingApi $cryptoSpotTrading; + public readonly \SnapTrade\Api\OptionsApi $options; public readonly \SnapTrade\Api\ReferenceDataApi $referenceData; @@ -48,6 +50,7 @@ public function __construct( $this->apiStatus = new \SnapTrade\Api\ApiStatusApi($config); $this->authentication = new \SnapTrade\Api\AuthenticationApi($config); $this->connections = new \SnapTrade\Api\ConnectionsApi($config); + $this->cryptoSpotTrading = new \SnapTrade\Api\CryptoSpotTradingApi($config); $this->options = new \SnapTrade\Api\OptionsApi($config); $this->referenceData = new \SnapTrade\Api\ReferenceDataApi($config); $this->trading = new \SnapTrade\Api\TradingApi($config); diff --git a/lib/Model/CryptoSpotOrderPreview.php b/lib/Model/CryptoSpotOrderPreview.php new file mode 100644 index 0000000..1281b7c --- /dev/null +++ b/lib/Model/CryptoSpotOrderPreview.php @@ -0,0 +1,405 @@ + + */ +class CryptoSpotOrderPreview implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CryptoSpotOrderPreview'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'estimated_fee' => '\SnapTrade\Model\CryptoSpotOrderPreviewEstimatedFee' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'estimated_fee' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'estimated_fee' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'estimated_fee' => 'estimated_fee' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'estimated_fee' => 'setEstimatedFee' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'estimated_fee' => 'getEstimatedFee' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('estimated_fee', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets estimated_fee + * + * @return \SnapTrade\Model\CryptoSpotOrderPreviewEstimatedFee|null + */ + public function getEstimatedFee() + { + return $this->container['estimated_fee']; + } + + /** + * Sets estimated_fee + * + * @param \SnapTrade\Model\CryptoSpotOrderPreviewEstimatedFee|null $estimated_fee estimated_fee + * + * @return self + */ + public function setEstimatedFee($estimated_fee) + { + + if (is_null($estimated_fee)) { + throw new \InvalidArgumentException('non-nullable estimated_fee cannot be null'); + } + + $this->container['estimated_fee'] = $estimated_fee; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/CryptoSpotOrderPreviewEstimatedFee.php b/lib/Model/CryptoSpotOrderPreviewEstimatedFee.php new file mode 100644 index 0000000..946982b --- /dev/null +++ b/lib/Model/CryptoSpotOrderPreviewEstimatedFee.php @@ -0,0 +1,447 @@ + + */ +class CryptoSpotOrderPreviewEstimatedFee implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CryptoSpotOrderPreview_estimated_fee'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'currency' => 'string', + 'amount' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'currency' => null, + 'amount' => 'decimal' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'currency' => false, + 'amount' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'currency' => 'currency', + 'amount' => 'amount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'currency' => 'setCurrency', + 'amount' => 'setAmount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'currency' => 'getCurrency', + 'amount' => 'getAmount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('amount', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['amount'] === null) { + $invalidProperties[] = "'amount' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets currency + * + * @return string + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string $currency Symbol to identify a cryptocurrency or fiat currency on a crypto exchange. Fiat currencies symbols are ISO-4217 codes. + * + * @return self + */ + public function setCurrency($currency) + { + + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets amount + * + * @return float + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param float $amount amount + * + * @return self + */ + public function setAmount($amount) + { + + if (is_null($amount)) { + throw new \InvalidArgumentException('non-nullable amount cannot be null'); + } + + $this->container['amount'] = $amount; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/CryptoSpotQuote.php b/lib/Model/CryptoSpotQuote.php new file mode 100644 index 0000000..897c95e --- /dev/null +++ b/lib/Model/CryptoSpotQuote.php @@ -0,0 +1,518 @@ + + */ +class CryptoSpotQuote implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CryptoSpotQuote'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bid' => 'float', + 'ask' => 'float', + 'mid' => 'float', + 'timestamp' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bid' => 'decimal', + 'ask' => 'decimal', + 'mid' => 'decimal', + 'timestamp' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bid' => false, + 'ask' => false, + 'mid' => false, + 'timestamp' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bid' => 'bid', + 'ask' => 'ask', + 'mid' => 'mid', + 'timestamp' => 'timestamp' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bid' => 'setBid', + 'ask' => 'setAsk', + 'mid' => 'setMid', + 'timestamp' => 'setTimestamp' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bid' => 'getBid', + 'ask' => 'getAsk', + 'mid' => 'getMid', + 'timestamp' => 'getTimestamp' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('bid', $data ?? [], null); + $this->setIfExists('ask', $data ?? [], null); + $this->setIfExists('mid', $data ?? [], null); + $this->setIfExists('timestamp', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['bid'] === null) { + $invalidProperties[] = "'bid' can't be null"; + } + if ($this->container['ask'] === null) { + $invalidProperties[] = "'ask' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets bid + * + * @return float + */ + public function getBid() + { + return $this->container['bid']; + } + + /** + * Sets bid + * + * @param float $bid The highest price a buyer is willing to pay. + * + * @return self + */ + public function setBid($bid) + { + + if (is_null($bid)) { + throw new \InvalidArgumentException('non-nullable bid cannot be null'); + } + + $this->container['bid'] = $bid; + + return $this; + } + + /** + * Gets ask + * + * @return float + */ + public function getAsk() + { + return $this->container['ask']; + } + + /** + * Sets ask + * + * @param float $ask The lowest price a seller is willing to accept. + * + * @return self + */ + public function setAsk($ask) + { + + if (is_null($ask)) { + throw new \InvalidArgumentException('non-nullable ask cannot be null'); + } + + $this->container['ask'] = $ask; + + return $this; + } + + /** + * Gets mid + * + * @return float|null + */ + public function getMid() + { + return $this->container['mid']; + } + + /** + * Sets mid + * + * @param float|null $mid The market mid price. + * + * @return self + */ + public function setMid($mid) + { + + if (is_null($mid)) { + throw new \InvalidArgumentException('non-nullable mid cannot be null'); + } + + $this->container['mid'] = $mid; + + return $this; + } + + /** + * Gets timestamp + * + * @return \DateTime|null + */ + public function getTimestamp() + { + return $this->container['timestamp']; + } + + /** + * Sets timestamp + * + * @param \DateTime|null $timestamp The timestamp of the quote. + * + * @return self + */ + public function setTimestamp($timestamp) + { + + if (is_null($timestamp)) { + throw new \InvalidArgumentException('non-nullable timestamp cannot be null'); + } + + $this->container['timestamp'] = $timestamp; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/CryptocurrencyPair.php b/lib/Model/CryptocurrencyPair.php new file mode 100644 index 0000000..1cdfb4e --- /dev/null +++ b/lib/Model/CryptocurrencyPair.php @@ -0,0 +1,447 @@ + + */ +class CryptocurrencyPair implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CryptocurrencyPair'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'base' => 'string', + 'quote' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'base' => null, + 'quote' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'base' => false, + 'quote' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'base' => 'base', + 'quote' => 'quote' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'base' => 'setBase', + 'quote' => 'setQuote' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'base' => 'getBase', + 'quote' => 'getQuote' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('base', $data ?? [], null); + $this->setIfExists('quote', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['base'] === null) { + $invalidProperties[] = "'base' can't be null"; + } + if ($this->container['quote'] === null) { + $invalidProperties[] = "'quote' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets base + * + * @return string + */ + public function getBase() + { + return $this->container['base']; + } + + /** + * Sets base + * + * @param string $base The base currency (e.g., \"BTC\" in BTC/USD). Can be a fiat or crypto code. + * + * @return self + */ + public function setBase($base) + { + + if (is_null($base)) { + throw new \InvalidArgumentException('non-nullable base cannot be null'); + } + + $this->container['base'] = $base; + + return $this; + } + + /** + * Gets quote + * + * @return string + */ + public function getQuote() + { + return $this->container['quote']; + } + + /** + * Sets quote + * + * @param string $quote The quote currency (e.g., \"USD\" in BTC/USD). Can be a fiat or crypto code. + * + * @return self + */ + public function setQuote($quote) + { + + if (is_null($quote)) { + throw new \InvalidArgumentException('non-nullable quote cannot be null'); + } + + $this->container['quote'] = $quote; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/TradingCryptoSpotCancelOrderRequest.php b/lib/Model/TradingCryptoSpotCancelOrderRequest.php new file mode 100644 index 0000000..5c3c6cc --- /dev/null +++ b/lib/Model/TradingCryptoSpotCancelOrderRequest.php @@ -0,0 +1,407 @@ + + */ +class TradingCryptoSpotCancelOrderRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Trading_cryptoSpotCancelOrder_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'brokerage_order_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'brokerage_order_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'brokerage_order_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'brokerage_order_id' => 'brokerage_order_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'brokerage_order_id' => 'setBrokerageOrderId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'brokerage_order_id' => 'getBrokerageOrderId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('brokerage_order_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['brokerage_order_id'] === null) { + $invalidProperties[] = "'brokerage_order_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets brokerage_order_id + * + * @return string + */ + public function getBrokerageOrderId() + { + return $this->container['brokerage_order_id']; + } + + /** + * Sets brokerage_order_id + * + * @param string $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + * + * @return self + */ + public function setBrokerageOrderId($brokerage_order_id) + { + + if (is_null($brokerage_order_id)) { + throw new \InvalidArgumentException('non-nullable brokerage_order_id cannot be null'); + } + + $this->container['brokerage_order_id'] = $brokerage_order_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/TradingCryptoSpotPlaceOrderRequest.php b/lib/Model/TradingCryptoSpotPlaceOrderRequest.php new file mode 100644 index 0000000..63ca6f6 --- /dev/null +++ b/lib/Model/TradingCryptoSpotPlaceOrderRequest.php @@ -0,0 +1,787 @@ + + */ +class TradingCryptoSpotPlaceOrderRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Trading_cryptoSpotPlaceOrder_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'symbol' => '\SnapTrade\Model\CryptocurrencyPair', + 'side' => '\SnapTrade\Model\ActionStrict', + 'type' => 'string', + 'time_in_force' => 'string', + 'amount' => 'float', + 'limit_price' => 'float', + 'stop_price' => 'float', + 'post_only' => 'bool', + 'expiration_date' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'symbol' => null, + 'side' => null, + 'type' => null, + 'time_in_force' => null, + 'amount' => 'decimal', + 'limit_price' => 'decimal', + 'stop_price' => 'decimal', + 'post_only' => null, + 'expiration_date' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'symbol' => false, + 'side' => false, + 'type' => false, + 'time_in_force' => false, + 'amount' => false, + 'limit_price' => false, + 'stop_price' => false, + 'post_only' => false, + 'expiration_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'symbol' => 'symbol', + 'side' => 'side', + 'type' => 'type', + 'time_in_force' => 'time_in_force', + 'amount' => 'amount', + 'limit_price' => 'limit_price', + 'stop_price' => 'stop_price', + 'post_only' => 'post_only', + 'expiration_date' => 'expiration_date' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'symbol' => 'setSymbol', + 'side' => 'setSide', + 'type' => 'setType', + 'time_in_force' => 'setTimeInForce', + 'amount' => 'setAmount', + 'limit_price' => 'setLimitPrice', + 'stop_price' => 'setStopPrice', + 'post_only' => 'setPostOnly', + 'expiration_date' => 'setExpirationDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'symbol' => 'getSymbol', + 'side' => 'getSide', + 'type' => 'getType', + 'time_in_force' => 'getTimeInForce', + 'amount' => 'getAmount', + 'limit_price' => 'getLimitPrice', + 'stop_price' => 'getStopPrice', + 'post_only' => 'getPostOnly', + 'expiration_date' => 'getExpirationDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_MARKET = 'MARKET'; + public const TYPE_LIMIT = 'LIMIT'; + public const TYPE_STOP_LOSS_MARKET = 'STOP_LOSS_MARKET'; + public const TYPE_STOP_LOSS_LIMIT = 'STOP_LOSS_LIMIT'; + public const TYPE_TAKE_PROFIT_MARKET = 'TAKE_PROFIT_MARKET'; + public const TYPE_TAKE_PROFIT_LIMIT = 'TAKE_PROFIT_LIMIT'; + public const TIME_IN_FORCE_GTC = 'GTC'; + public const TIME_IN_FORCE_FOK = 'FOK'; + public const TIME_IN_FORCE_IOC = 'IOC'; + public const TIME_IN_FORCE_GTD = 'GTD'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_MARKET, + self::TYPE_LIMIT, + self::TYPE_STOP_LOSS_MARKET, + self::TYPE_STOP_LOSS_LIMIT, + self::TYPE_TAKE_PROFIT_MARKET, + self::TYPE_TAKE_PROFIT_LIMIT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTimeInForceAllowableValues() + { + return [ + self::TIME_IN_FORCE_GTC, + self::TIME_IN_FORCE_FOK, + self::TIME_IN_FORCE_IOC, + self::TIME_IN_FORCE_GTD, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('side', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('time_in_force', $data ?? [], null); + $this->setIfExists('amount', $data ?? [], null); + $this->setIfExists('limit_price', $data ?? [], null); + $this->setIfExists('stop_price', $data ?? [], null); + $this->setIfExists('post_only', $data ?? [], null); + $this->setIfExists('expiration_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['symbol'] === null) { + $invalidProperties[] = "'symbol' can't be null"; + } + if ($this->container['side'] === null) { + $invalidProperties[] = "'side' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['time_in_force'] === null) { + $invalidProperties[] = "'time_in_force' can't be null"; + } + $allowedValues = $this->getTimeInForceAllowableValues(); + if (!is_null($this->container['time_in_force']) && !in_array($this->container['time_in_force'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'time_in_force', must be one of '%s'", + $this->container['time_in_force'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['amount'] === null) { + $invalidProperties[] = "'amount' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets symbol + * + * @return \SnapTrade\Model\CryptocurrencyPair + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param \SnapTrade\Model\CryptocurrencyPair $symbol symbol + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets side + * + * @return \SnapTrade\Model\ActionStrict + */ + public function getSide() + { + return $this->container['side']; + } + + /** + * Sets side + * + * @param \SnapTrade\Model\ActionStrict $side side + * + * @return self + */ + public function setSide($side) + { + + if (is_null($side)) { + throw new \InvalidArgumentException('non-nullable side cannot be null'); + } + + $this->container['side'] = $side; + + return $this; + } + + /** + * Gets type + * + * @return string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type The type of order to place. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets time_in_force + * + * @return string + */ + public function getTimeInForce() + { + return $this->container['time_in_force']; + } + + /** + * Sets time_in_force + * + * @param string $time_in_force The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. + * + * @return self + */ + public function setTimeInForce($time_in_force) + { + $allowedValues = $this->getTimeInForceAllowableValues(); + if (!in_array($time_in_force, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'time_in_force', must be one of '%s'", + $time_in_force, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($time_in_force)) { + throw new \InvalidArgumentException('non-nullable time_in_force cannot be null'); + } + + $this->container['time_in_force'] = $time_in_force; + + return $this; + } + + /** + * Gets amount + * + * @return float + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param float $amount The amount of the base currency to buy or sell. + * + * @return self + */ + public function setAmount($amount) + { + + if (is_null($amount)) { + throw new \InvalidArgumentException('non-nullable amount cannot be null'); + } + + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets limit_price + * + * @return float|null + */ + public function getLimitPrice() + { + return $this->container['limit_price']; + } + + /** + * Sets limit_price + * + * @param float|null $limit_price The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. + * + * @return self + */ + public function setLimitPrice($limit_price) + { + + if (is_null($limit_price)) { + throw new \InvalidArgumentException('non-nullable limit_price cannot be null'); + } + + $this->container['limit_price'] = $limit_price; + + return $this; + } + + /** + * Gets stop_price + * + * @return float|null + */ + public function getStopPrice() + { + return $this->container['stop_price']; + } + + /** + * Sets stop_price + * + * @param float|null $stop_price The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. + * + * @return self + */ + public function setStopPrice($stop_price) + { + + if (is_null($stop_price)) { + throw new \InvalidArgumentException('non-nullable stop_price cannot be null'); + } + + $this->container['stop_price'] = $stop_price; + + return $this; + } + + /** + * Gets post_only + * + * @return bool|null + */ + public function getPostOnly() + { + return $this->container['post_only']; + } + + /** + * Sets post_only + * + * @param bool|null $post_only Required for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. + * + * @return self + */ + public function setPostOnly($post_only) + { + + if (is_null($post_only)) { + throw new \InvalidArgumentException('non-nullable post_only cannot be null'); + } + + $this->container['post_only'] = $post_only; + + return $this; + } + + /** + * Gets expiration_date + * + * @return \DateTime|null + */ + public function getExpirationDate() + { + return $this->container['expiration_date']; + } + + /** + * Sets expiration_date + * + * @param \DateTime|null $expiration_date The expiration date of the order. Required if the time_in_force is GTD. + * + * @return self + */ + public function setExpirationDate($expiration_date) + { + + if (is_null($expiration_date)) { + throw new \InvalidArgumentException('non-nullable expiration_date cannot be null'); + } + + $this->container['expiration_date'] = $expiration_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/TradingCryptoSpotSymbols200Response.php b/lib/Model/TradingCryptoSpotSymbols200Response.php new file mode 100644 index 0000000..921961c --- /dev/null +++ b/lib/Model/TradingCryptoSpotSymbols200Response.php @@ -0,0 +1,408 @@ + + */ +class TradingCryptoSpotSymbols200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Trading_cryptoSpotSymbols_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\SnapTrade\Model\CryptocurrencyPair[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'items' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('items', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \SnapTrade\Model\CryptocurrencyPair[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \SnapTrade\Model\CryptocurrencyPair[] $items items + * + * @return self + */ + public function setItems($items) + { + + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/CryptoSpotTradingApiTest.php b/test/Api/CryptoSpotTradingApiTest.php new file mode 100644 index 0000000..768b551 --- /dev/null +++ b/test/Api/CryptoSpotTradingApiTest.php @@ -0,0 +1,120 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test case for cryptoSpotPlaceOrder + * + * Place a spot order on a crypto exchange. + * + */ + public function testCryptoSpotPlaceOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test case for cryptoSpotPreviewOrder + * + * Place a spot order on a crypto exchange. + * + */ + public function testCryptoSpotPreviewOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test case for cryptoSpotQuote + * + * Get a quote for a cyrptocurrency market. + * + */ + public function testCryptoSpotQuote() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test case for cryptoSpotSymbols + * + * Search crypto spot symbols. + * + */ + public function testCryptoSpotSymbols() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/CryptoSpotOrderPreviewEstimatedFeeTest.php b/test/Model/CryptoSpotOrderPreviewEstimatedFeeTest.php new file mode 100644 index 0000000..4c370ac --- /dev/null +++ b/test/Model/CryptoSpotOrderPreviewEstimatedFeeTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "currency" + */ + public function testPropertyCurrency() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "amount" + */ + public function testPropertyAmount() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/CryptoSpotOrderPreviewTest.php b/test/Model/CryptoSpotOrderPreviewTest.php new file mode 100644 index 0000000..662b3b7 --- /dev/null +++ b/test/Model/CryptoSpotOrderPreviewTest.php @@ -0,0 +1,83 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "estimated_fee" + */ + public function testPropertyEstimatedFee() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/CryptoSpotQuoteTest.php b/test/Model/CryptoSpotQuoteTest.php new file mode 100644 index 0000000..f169841 --- /dev/null +++ b/test/Model/CryptoSpotQuoteTest.php @@ -0,0 +1,110 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "bid" + */ + public function testPropertyBid() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "ask" + */ + public function testPropertyAsk() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "mid" + */ + public function testPropertyMid() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "timestamp" + */ + public function testPropertyTimestamp() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/CryptocurrencyPairTest.php b/test/Model/CryptocurrencyPairTest.php new file mode 100644 index 0000000..ce870a3 --- /dev/null +++ b/test/Model/CryptocurrencyPairTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "base" + */ + public function testPropertyBase() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "quote" + */ + public function testPropertyQuote() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/TradingCryptoSpotCancelOrderRequestTest.php b/test/Model/TradingCryptoSpotCancelOrderRequestTest.php new file mode 100644 index 0000000..97978ca --- /dev/null +++ b/test/Model/TradingCryptoSpotCancelOrderRequestTest.php @@ -0,0 +1,83 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "brokerage_order_id" + */ + public function testPropertyBrokerageOrderId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/TradingCryptoSpotPlaceOrderRequestTest.php b/test/Model/TradingCryptoSpotPlaceOrderRequestTest.php new file mode 100644 index 0000000..196af2e --- /dev/null +++ b/test/Model/TradingCryptoSpotPlaceOrderRequestTest.php @@ -0,0 +1,155 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "side" + */ + public function testPropertySide() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "time_in_force" + */ + public function testPropertyTimeInForce() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "amount" + */ + public function testPropertyAmount() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "limit_price" + */ + public function testPropertyLimitPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop_price" + */ + public function testPropertyStopPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "post_only" + */ + public function testPropertyPostOnly() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "expiration_date" + */ + public function testPropertyExpirationDate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/TradingCryptoSpotSymbols200ResponseTest.php b/test/Model/TradingCryptoSpotSymbols200ResponseTest.php new file mode 100644 index 0000000..02fc544 --- /dev/null +++ b/test/Model/TradingCryptoSpotSymbols200ResponseTest.php @@ -0,0 +1,83 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "items" + */ + public function testPropertyItems() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From 09654e59e6eb22979a32682477172c415fe7abb1 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 21:31:39 +0000 Subject: [PATCH 095/252] Version Bump SDKs (#114) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 4f7fa77..696e357 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -dd00215d-37c7-4b22-a4d4-9a4bfc302b6b \ No newline at end of file +6b39e14b-12db-41f9-9d62-afd601c2065d \ No newline at end of file diff --git a/README.md b/README.md index 7361c35..adc7351 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.82-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.83-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -96,7 +96,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.82" + "konfig/snaptrade-php-sdk": "2.0.83" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 8a752c5..c9b7c42 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.82/PHP'; + protected $userAgent = 'Konfig/2.0.83/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.82' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.83' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 69466a978de82c313ca6279256c0331c92e6ccbc Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 20:33:19 +0000 Subject: [PATCH 096/252] Regenerate SDKs (#115) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 16 +- lib/Api/CryptoSpotTradingApi.php | 48 +- lib/Model/CryptocurrencyPair.php | 4 +- lib/Model/OrderUpdatedResponse.php | 443 ++++++++++++++++++ .../TradingCryptoSpotPlaceOrderRequest.php | 2 +- test/Api/CryptoSpotTradingApiTest.php | 4 +- test/Model/OrderUpdatedResponseTest.php | 92 ++++ 8 files changed, 573 insertions(+), 38 deletions(-) create mode 100644 lib/Model/OrderUpdatedResponse.php create mode 100644 test/Model/OrderUpdatedResponseTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 696e357..fe127f7 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -6b39e14b-12db-41f9-9d62-afd601c2065d \ No newline at end of file +916e2e5c-4104-41ae-84b6-4035597f0ad4 \ No newline at end of file diff --git a/README.md b/README.md index adc7351..f839486 100644 --- a/README.md +++ b/README.md @@ -1151,7 +1151,7 @@ Order ID returned by brokerage. This is the unique identifier for the order in t #### πŸ”„ Return -[**AccountOrderRecord**](./lib/Model/AccountOrderRecord.php) +[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) #### 🌐 Endpoint @@ -1175,7 +1175,7 @@ This endpoint does not compute the impact to the account balance from the order $result = $snaptrade->cryptoSpotTrading->cryptoSpotPlaceOrder( symbol: [ "base" => "BTC", - "quote" => "BTC", + "quote" => "USD", ], side: "BUY", type: "MARKET", @@ -1225,7 +1225,7 @@ The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, ##### post_only: `bool` -Required for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. +Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. ##### expiration_date: `\DateTime` @@ -1234,7 +1234,7 @@ The expiration date of the order. Required if the time_in_force is GTD. #### πŸ”„ Return -[**AccountOrderRecord**](./lib/Model/AccountOrderRecord.php) +[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) #### 🌐 Endpoint @@ -1257,7 +1257,7 @@ Previews a cryptocurrency spot order using the specified account. $result = $snaptrade->cryptoSpotTrading->cryptoSpotPreviewOrder( symbol: [ "base" => "BTC", - "quote" => "BTC", + "quote" => "USD", ], side: "BUY", type: "MARKET", @@ -1307,7 +1307,7 @@ The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, ##### post_only: `bool` -Required for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. +Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. ##### expiration_date: `\DateTime` @@ -1341,7 +1341,7 @@ $result = $snaptrade->cryptoSpotTrading->cryptoSpotQuote( user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", base: "BTC", - quote: "BTC" + quote: "USD" ); ``` @@ -1385,7 +1385,7 @@ $result = $snaptrade->cryptoSpotTrading->cryptoSpotSymbols( user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", base: "BTC", - quote: "BTC" + quote: "USD" ); ``` diff --git a/lib/Api/CryptoSpotTradingApi.php b/lib/Api/CryptoSpotTradingApi.php index 33aba01..197341a 100644 --- a/lib/Api/CryptoSpotTradingApi.php +++ b/lib/Api/CryptoSpotTradingApi.php @@ -162,7 +162,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse */ public function cryptoSpotCancelOrder( @@ -196,7 +196,7 @@ public function cryptoSpotCancelOrder( * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ public function cryptoSpotCancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { @@ -257,17 +257,17 @@ public function cryptoSpotCancelOrderWithHttpInfo($user_id, $user_secret, $accou switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -288,7 +288,7 @@ public function cryptoSpotCancelOrderWithHttpInfo($user_id, $user_secret, $accou ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -309,7 +309,7 @@ public function cryptoSpotCancelOrderWithHttpInfo($user_id, $user_secret, $accou case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\OrderUpdatedResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -382,7 +382,7 @@ function ($response) { */ public function cryptoSpotCancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotCancelOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, $contentType); // Customization hook @@ -622,7 +622,7 @@ public function cryptoSpotCancelOrderRequest($user_id, $user_secret, $account_id * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse */ public function cryptoSpotPlaceOrder( @@ -672,7 +672,7 @@ public function cryptoSpotPlaceOrder( * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ public function cryptoSpotPlaceOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { @@ -733,17 +733,17 @@ public function cryptoSpotPlaceOrderWithHttpInfo($user_id, $user_secret, $accoun switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -764,7 +764,7 @@ public function cryptoSpotPlaceOrderWithHttpInfo($user_id, $user_secret, $accoun ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -785,7 +785,7 @@ public function cryptoSpotPlaceOrderWithHttpInfo($user_id, $user_secret, $accoun case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\OrderUpdatedResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -874,7 +874,7 @@ function ($response) { */ public function cryptoSpotPlaceOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotPlaceOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); // Customization hook @@ -1102,7 +1102,7 @@ public function cryptoSpotPlaceOrderRequest($user_id, $user_secret, $account_id, /** * Operation cryptoSpotPreviewOrder * - * Place a spot order on a crypto exchange + * Preview a crypto spot order * * Previews a cryptocurrency spot order using the specified account. * @@ -1152,7 +1152,7 @@ public function cryptoSpotPreviewOrder( /** * Operation cryptoSpotPreviewOrderWithHttpInfo * - * Place a spot order on a crypto exchange + * Preview a crypto spot order * * Previews a cryptocurrency spot order using the specified account. * @@ -1298,7 +1298,7 @@ public function cryptoSpotPreviewOrderWithHttpInfo($user_id, $user_secret, $acco /** * Operation cryptoSpotPreviewOrderAsync * - * Place a spot order on a crypto exchange + * Preview a crypto spot order * * Previews a cryptocurrency spot order using the specified account. * @@ -1351,7 +1351,7 @@ function ($response) { /** * Operation cryptoSpotPreviewOrderAsyncWithHttpInfo * - * Place a spot order on a crypto exchange + * Preview a crypto spot order * * Previews a cryptocurrency spot order using the specified account. * @@ -1594,7 +1594,7 @@ public function cryptoSpotPreviewOrderRequest($user_id, $user_secret, $account_i /** * Operation cryptoSpotQuote * - * Get a quote for a cyrptocurrency market + * Get a cryptocurrency spot market quote * * Gets a quote for the specified account. * @@ -1627,7 +1627,7 @@ public function cryptoSpotQuote( /** * Operation cryptoSpotQuoteWithHttpInfo * - * Get a quote for a cyrptocurrency market + * Get a cryptocurrency spot market quote * * Gets a quote for the specified account. * @@ -1775,7 +1775,7 @@ public function cryptoSpotQuoteWithHttpInfo($user_id, $user_secret, $account_id, /** * Operation cryptoSpotQuoteAsync * - * Get a quote for a cyrptocurrency market + * Get a cryptocurrency spot market quote * * Gets a quote for the specified account. * @@ -1811,7 +1811,7 @@ function ($response) { /** * Operation cryptoSpotQuoteAsyncWithHttpInfo * - * Get a quote for a cyrptocurrency market + * Get a cryptocurrency spot market quote * * Gets a quote for the specified account. * diff --git a/lib/Model/CryptocurrencyPair.php b/lib/Model/CryptocurrencyPair.php index 1cdfb4e..67f96af 100644 --- a/lib/Model/CryptocurrencyPair.php +++ b/lib/Model/CryptocurrencyPair.php @@ -309,7 +309,7 @@ public function getBase() /** * Sets base * - * @param string $base The base currency (e.g., \"BTC\" in BTC/USD). Can be a fiat or crypto code. + * @param string $base The base currency of a pair (e.g., \"BTC\" in BTC/USD). Either fiat or cryptocurrency symbol, for fiat use ISO-4217 codes. * * @return self */ @@ -338,7 +338,7 @@ public function getQuote() /** * Sets quote * - * @param string $quote The quote currency (e.g., \"USD\" in BTC/USD). Can be a fiat or crypto code. + * @param string $quote The quote currency of a pair (e.g., \"USD\" in BTC/USD). Either fiat or cryptocurrency symbol, for fiat use ISO-4217 codes. * * @return self */ diff --git a/lib/Model/OrderUpdatedResponse.php b/lib/Model/OrderUpdatedResponse.php new file mode 100644 index 0000000..3fac5da --- /dev/null +++ b/lib/Model/OrderUpdatedResponse.php @@ -0,0 +1,443 @@ + + */ +class OrderUpdatedResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderUpdatedResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'brokerage_order_id' => 'string', + 'order' => '\SnapTrade\Model\AccountOrderRecord' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'brokerage_order_id' => null, + 'order' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'brokerage_order_id' => false, + 'order' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'brokerage_order_id' => 'brokerage_order_id', + 'order' => 'order' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'brokerage_order_id' => 'setBrokerageOrderId', + 'order' => 'setOrder' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'brokerage_order_id' => 'getBrokerageOrderId', + 'order' => 'getOrder' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('brokerage_order_id', $data ?? [], null); + $this->setIfExists('order', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['brokerage_order_id'] === null) { + $invalidProperties[] = "'brokerage_order_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets brokerage_order_id + * + * @return string + */ + public function getBrokerageOrderId() + { + return $this->container['brokerage_order_id']; + } + + /** + * Sets brokerage_order_id + * + * @param string $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + * + * @return self + */ + public function setBrokerageOrderId($brokerage_order_id) + { + + if (is_null($brokerage_order_id)) { + throw new \InvalidArgumentException('non-nullable brokerage_order_id cannot be null'); + } + + $this->container['brokerage_order_id'] = $brokerage_order_id; + + return $this; + } + + /** + * Gets order + * + * @return \SnapTrade\Model\AccountOrderRecord|null + */ + public function getOrder() + { + return $this->container['order']; + } + + /** + * Sets order + * + * @param \SnapTrade\Model\AccountOrderRecord|null $order order + * + * @return self + */ + public function setOrder($order) + { + + if (is_null($order)) { + throw new \InvalidArgumentException('non-nullable order cannot be null'); + } + + $this->container['order'] = $order; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/TradingCryptoSpotPlaceOrderRequest.php b/lib/Model/TradingCryptoSpotPlaceOrderRequest.php index 63ca6f6..3a7b63d 100644 --- a/lib/Model/TradingCryptoSpotPlaceOrderRequest.php +++ b/lib/Model/TradingCryptoSpotPlaceOrderRequest.php @@ -649,7 +649,7 @@ public function getPostOnly() /** * Sets post_only * - * @param bool|null $post_only Required for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. + * @param bool|null $post_only Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. * * @return self */ diff --git a/test/Api/CryptoSpotTradingApiTest.php b/test/Api/CryptoSpotTradingApiTest.php index 768b551..549ecc1 100644 --- a/test/Api/CryptoSpotTradingApiTest.php +++ b/test/Api/CryptoSpotTradingApiTest.php @@ -85,7 +85,7 @@ public function testCryptoSpotPlaceOrder() /** * Test case for cryptoSpotPreviewOrder * - * Place a spot order on a crypto exchange. + * Preview a crypto spot order. * */ public function testCryptoSpotPreviewOrder() @@ -97,7 +97,7 @@ public function testCryptoSpotPreviewOrder() /** * Test case for cryptoSpotQuote * - * Get a quote for a cyrptocurrency market. + * Get a cryptocurrency spot market quote. * */ public function testCryptoSpotQuote() diff --git a/test/Model/OrderUpdatedResponseTest.php b/test/Model/OrderUpdatedResponseTest.php new file mode 100644 index 0000000..a6d7c68 --- /dev/null +++ b/test/Model/OrderUpdatedResponseTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "brokerage_order_id" + */ + public function testPropertyBrokerageOrderId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "order" + */ + public function testPropertyOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From f8deddfa944606b66a7568e347a7acc1b3322bd0 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 20:37:26 +0000 Subject: [PATCH 097/252] Version Bump SDKs (#116) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index fe127f7..f9f4204 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -916e2e5c-4104-41ae-84b6-4035597f0ad4 \ No newline at end of file +766c032c-6f80-4f8d-9f77-46da29d578fb \ No newline at end of file diff --git a/README.md b/README.md index f839486..6551f0b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.83-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.84-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -96,7 +96,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.83" + "konfig/snaptrade-php-sdk": "2.0.84" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index c9b7c42..b5c7d98 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.83/PHP'; + protected $userAgent = 'Konfig/2.0.84/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.83' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.84' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 7814af55431e39eae32ef51b954c5f0d52c6d4f9 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 12:34:18 +0000 Subject: [PATCH 098/252] Regenerate SDKs (#117) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/AccountOrderRecord.php | 72 ++ lib/Model/AccountOrderRecordQuoteCurrency.php | 477 +++++++++++ ...AccountOrderRecordQuoteUniversalSymbol.php | 770 ++++++++++++++++++ .../AccountOrderRecordQuoteCurrencyTest.php | 101 +++ ...untOrderRecordQuoteUniversalSymbolTest.php | 164 ++++ test/Model/AccountOrderRecordTest.php | 18 + 7 files changed, 1603 insertions(+), 1 deletion(-) create mode 100644 lib/Model/AccountOrderRecordQuoteCurrency.php create mode 100644 lib/Model/AccountOrderRecordQuoteUniversalSymbol.php create mode 100644 test/Model/AccountOrderRecordQuoteCurrencyTest.php create mode 100644 test/Model/AccountOrderRecordQuoteUniversalSymbolTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f9f4204..fd97f2b 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -766c032c-6f80-4f8d-9f77-46da29d578fb \ No newline at end of file +6965adfb-84c2-467a-b918-831ae47a00f3 \ No newline at end of file diff --git a/lib/Model/AccountOrderRecord.php b/lib/Model/AccountOrderRecord.php index 9b58416..28f6fef 100644 --- a/lib/Model/AccountOrderRecord.php +++ b/lib/Model/AccountOrderRecord.php @@ -55,6 +55,8 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab 'status' => '\SnapTrade\Model\AccountOrderRecordStatus', 'universal_symbol' => '\SnapTrade\Model\AccountOrderRecordUniversalSymbol', 'option_symbol' => '\SnapTrade\Model\AccountOrderRecordOptionSymbol', + 'quote_universal_symbol' => '\SnapTrade\Model\AccountOrderRecordQuoteUniversalSymbol', + 'quote_currency' => '\SnapTrade\Model\AccountOrderRecordQuoteCurrency', 'action' => 'string', 'total_quantity' => 'float', 'open_quantity' => 'float', @@ -85,6 +87,8 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab 'status' => null, 'universal_symbol' => null, 'option_symbol' => null, + 'quote_universal_symbol' => null, + 'quote_currency' => null, 'action' => null, 'total_quantity' => null, 'open_quantity' => null, @@ -113,6 +117,8 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab 'status' => false, 'universal_symbol' => false, 'option_symbol' => false, + 'quote_universal_symbol' => false, + 'quote_currency' => false, 'action' => false, 'total_quantity' => true, 'open_quantity' => true, @@ -221,6 +227,8 @@ public function isNullableSetToNull(string $property): bool 'status' => 'status', 'universal_symbol' => 'universal_symbol', 'option_symbol' => 'option_symbol', + 'quote_universal_symbol' => 'quote_universal_symbol', + 'quote_currency' => 'quote_currency', 'action' => 'action', 'total_quantity' => 'total_quantity', 'open_quantity' => 'open_quantity', @@ -249,6 +257,8 @@ public function isNullableSetToNull(string $property): bool 'status' => 'setStatus', 'universal_symbol' => 'setUniversalSymbol', 'option_symbol' => 'setOptionSymbol', + 'quote_universal_symbol' => 'setQuoteUniversalSymbol', + 'quote_currency' => 'setQuoteCurrency', 'action' => 'setAction', 'total_quantity' => 'setTotalQuantity', 'open_quantity' => 'setOpenQuantity', @@ -277,6 +287,8 @@ public function isNullableSetToNull(string $property): bool 'status' => 'getStatus', 'universal_symbol' => 'getUniversalSymbol', 'option_symbol' => 'getOptionSymbol', + 'quote_universal_symbol' => 'getQuoteUniversalSymbol', + 'quote_currency' => 'getQuoteCurrency', 'action' => 'getAction', 'total_quantity' => 'getTotalQuantity', 'open_quantity' => 'getOpenQuantity', @@ -356,6 +368,8 @@ public function __construct(array $data = null) $this->setIfExists('status', $data ?? [], null); $this->setIfExists('universal_symbol', $data ?? [], null); $this->setIfExists('option_symbol', $data ?? [], null); + $this->setIfExists('quote_universal_symbol', $data ?? [], null); + $this->setIfExists('quote_currency', $data ?? [], null); $this->setIfExists('action', $data ?? [], null); $this->setIfExists('total_quantity', $data ?? [], null); $this->setIfExists('open_quantity', $data ?? [], null); @@ -532,6 +546,64 @@ public function setOptionSymbol($option_symbol) return $this; } + /** + * Gets quote_universal_symbol + * + * @return \SnapTrade\Model\AccountOrderRecordQuoteUniversalSymbol|null + */ + public function getQuoteUniversalSymbol() + { + return $this->container['quote_universal_symbol']; + } + + /** + * Sets quote_universal_symbol + * + * @param \SnapTrade\Model\AccountOrderRecordQuoteUniversalSymbol|null $quote_universal_symbol quote_universal_symbol + * + * @return self + */ + public function setQuoteUniversalSymbol($quote_universal_symbol) + { + + if (is_null($quote_universal_symbol)) { + throw new \InvalidArgumentException('non-nullable quote_universal_symbol cannot be null'); + } + + $this->container['quote_universal_symbol'] = $quote_universal_symbol; + + return $this; + } + + /** + * Gets quote_currency + * + * @return \SnapTrade\Model\AccountOrderRecordQuoteCurrency|null + */ + public function getQuoteCurrency() + { + return $this->container['quote_currency']; + } + + /** + * Sets quote_currency + * + * @param \SnapTrade\Model\AccountOrderRecordQuoteCurrency|null $quote_currency quote_currency + * + * @return self + */ + public function setQuoteCurrency($quote_currency) + { + + if (is_null($quote_currency)) { + throw new \InvalidArgumentException('non-nullable quote_currency cannot be null'); + } + + $this->container['quote_currency'] = $quote_currency; + + return $this; + } + /** * Gets action * diff --git a/lib/Model/AccountOrderRecordQuoteCurrency.php b/lib/Model/AccountOrderRecordQuoteCurrency.php new file mode 100644 index 0000000..58fe427 --- /dev/null +++ b/lib/Model/AccountOrderRecordQuoteCurrency.php @@ -0,0 +1,477 @@ + + */ +class AccountOrderRecordQuoteCurrency implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AccountOrderRecord_quote_currency'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'code' => 'string', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'uuid', + 'code' => null, + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'code' => false, + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'code' => 'code', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'code' => 'setCode', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'code' => 'getCode', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('code', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for the currency. This is the UUID used to reference the currency in SnapTrade. + * + * @return self + */ + public function setId($id) + { + + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code The ISO-4217 currency code for the currency. + * + * @return self + */ + public function setCode($code) + { + + if (is_null($code)) { + throw new \InvalidArgumentException('non-nullable code cannot be null'); + } + + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name A human-friendly name of the currency. + * + * @return self + */ + public function setName($name) + { + + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/AccountOrderRecordQuoteUniversalSymbol.php b/lib/Model/AccountOrderRecordQuoteUniversalSymbol.php new file mode 100644 index 0000000..0f23d4b --- /dev/null +++ b/lib/Model/AccountOrderRecordQuoteUniversalSymbol.php @@ -0,0 +1,770 @@ + + */ +class AccountOrderRecordQuoteUniversalSymbol implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AccountOrderRecord_quote_universal_symbol'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'symbol' => 'string', + 'raw_symbol' => 'string', + 'description' => 'string', + 'currency' => '\SnapTrade\Model\SymbolCurrency', + 'exchange' => '\SnapTrade\Model\SymbolExchange', + 'type' => '\SnapTrade\Model\SecurityType', + 'figi_code' => 'string', + 'figi_instrument' => '\SnapTrade\Model\SymbolFigiInstrument', + 'currencies' => '\SnapTrade\Model\Currency[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'uuid', + 'symbol' => null, + 'raw_symbol' => null, + 'description' => null, + 'currency' => null, + 'exchange' => null, + 'type' => null, + 'figi_code' => null, + 'figi_instrument' => null, + 'currencies' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'symbol' => false, + 'raw_symbol' => false, + 'description' => true, + 'currency' => false, + 'exchange' => false, + 'type' => false, + 'figi_code' => true, + 'figi_instrument' => true, + 'currencies' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'symbol' => 'symbol', + 'raw_symbol' => 'raw_symbol', + 'description' => 'description', + 'currency' => 'currency', + 'exchange' => 'exchange', + 'type' => 'type', + 'figi_code' => 'figi_code', + 'figi_instrument' => 'figi_instrument', + 'currencies' => 'currencies' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'symbol' => 'setSymbol', + 'raw_symbol' => 'setRawSymbol', + 'description' => 'setDescription', + 'currency' => 'setCurrency', + 'exchange' => 'setExchange', + 'type' => 'setType', + 'figi_code' => 'setFigiCode', + 'figi_instrument' => 'setFigiInstrument', + 'currencies' => 'setCurrencies' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'symbol' => 'getSymbol', + 'raw_symbol' => 'getRawSymbol', + 'description' => 'getDescription', + 'currency' => 'getCurrency', + 'exchange' => 'getExchange', + 'type' => 'getType', + 'figi_code' => 'getFigiCode', + 'figi_instrument' => 'getFigiInstrument', + 'currencies' => 'getCurrencies' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('raw_symbol', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('exchange', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('figi_code', $data ?? [], null); + $this->setIfExists('figi_instrument', $data ?? [], null); + $this->setIfExists('currencies', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['symbol'] === null) { + $invalidProperties[] = "'symbol' can't be null"; + } + if ($this->container['raw_symbol'] === null) { + $invalidProperties[] = "'raw_symbol' can't be null"; + } + if ($this->container['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['currencies'] === null) { + $invalidProperties[] = "'currencies' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls. + * + * @return self + */ + public function setId($id) + { + + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets symbol + * + * @return string + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string $symbol The security's trading ticker symbol. For example \"AAPL\" for Apple Inc. We largely follow the [Yahoo Finance ticker format](https://help.yahoo.com/kb/SLN2310.html)(click on \"Yahoo Finance Market Coverage and Data Delays\"). For example, for securities traded on the Toronto Stock Exchange, the symbol has a '.TO' suffix. For securities traded on NASDAQ or NYSE, the symbol does not have a suffix. + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets raw_symbol + * + * @return string + */ + public function getRawSymbol() + { + return $this->container['raw_symbol']; + } + + /** + * Sets raw_symbol + * + * @param string $raw_symbol The raw symbol is `symbol` with the exchange suffix removed. For example, if `symbol` is \"VAB.TO\", then `raw_symbol` is \"VAB\". + * + * @return self + */ + public function setRawSymbol($raw_symbol) + { + + if (is_null($raw_symbol)) { + throw new \InvalidArgumentException('non-nullable raw_symbol cannot be null'); + } + + $this->container['raw_symbol'] = $raw_symbol; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description A human-readable description of the security. This is usually the company name or ETF name. + * + * @return self + */ + public function setDescription($description) + { + + if (is_null($description)) { + array_push($this->openAPINullablesSetToNull, 'description'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('description', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets currency + * + * @return \SnapTrade\Model\SymbolCurrency + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \SnapTrade\Model\SymbolCurrency $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets exchange + * + * @return \SnapTrade\Model\SymbolExchange|null + */ + public function getExchange() + { + return $this->container['exchange']; + } + + /** + * Sets exchange + * + * @param \SnapTrade\Model\SymbolExchange|null $exchange exchange + * + * @return self + */ + public function setExchange($exchange) + { + + if (is_null($exchange)) { + throw new \InvalidArgumentException('non-nullable exchange cannot be null'); + } + + $this->container['exchange'] = $exchange; + + return $this; + } + + /** + * Gets type + * + * @return \SnapTrade\Model\SecurityType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \SnapTrade\Model\SecurityType $type type + * + * @return self + */ + public function setType($type) + { + + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets figi_code + * + * @return string|null + */ + public function getFigiCode() + { + return $this->container['figi_code']; + } + + /** + * Sets figi_code + * + * @param string|null $figi_code This identifier is unique per security per trading venue. See section 1.4.1 of the [FIGI Standard](https://www.openfigi.com/assets/local/figi-allocation-rules.pdf) for more information. This value should be the same as the `figi_code` in the `figi_instrument` child property. + * + * @return self + */ + public function setFigiCode($figi_code) + { + + if (is_null($figi_code)) { + array_push($this->openAPINullablesSetToNull, 'figi_code'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('figi_code', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['figi_code'] = $figi_code; + + return $this; + } + + /** + * Gets figi_instrument + * + * @return \SnapTrade\Model\SymbolFigiInstrument|null + */ + public function getFigiInstrument() + { + return $this->container['figi_instrument']; + } + + /** + * Sets figi_instrument + * + * @param \SnapTrade\Model\SymbolFigiInstrument|null $figi_instrument figi_instrument + * + * @return self + */ + public function setFigiInstrument($figi_instrument) + { + + if (is_null($figi_instrument)) { + array_push($this->openAPINullablesSetToNull, 'figi_instrument'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('figi_instrument', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['figi_instrument'] = $figi_instrument; + + return $this; + } + + /** + * Gets currencies + * + * @return \SnapTrade\Model\Currency[] + * @deprecated + */ + public function getCurrencies() + { + return $this->container['currencies']; + } + + /** + * Sets currencies + * + * @param \SnapTrade\Model\Currency[] $currencies This field is deprecated and should not be used. Please reach out to SnapTrade support if you have a valid usecase for this. + * + * @return self + * @deprecated + */ + public function setCurrencies($currencies) + { + + if (is_null($currencies)) { + throw new \InvalidArgumentException('non-nullable currencies cannot be null'); + } + + $this->container['currencies'] = $currencies; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Model/AccountOrderRecordQuoteCurrencyTest.php b/test/Model/AccountOrderRecordQuoteCurrencyTest.php new file mode 100644 index 0000000..6c49b7a --- /dev/null +++ b/test/Model/AccountOrderRecordQuoteCurrencyTest.php @@ -0,0 +1,101 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "id" + */ + public function testPropertyId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "code" + */ + public function testPropertyCode() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "name" + */ + public function testPropertyName() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/AccountOrderRecordQuoteUniversalSymbolTest.php b/test/Model/AccountOrderRecordQuoteUniversalSymbolTest.php new file mode 100644 index 0000000..0e4655a --- /dev/null +++ b/test/Model/AccountOrderRecordQuoteUniversalSymbolTest.php @@ -0,0 +1,164 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "id" + */ + public function testPropertyId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "raw_symbol" + */ + public function testPropertyRawSymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "description" + */ + public function testPropertyDescription() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "currency" + */ + public function testPropertyCurrency() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "exchange" + */ + public function testPropertyExchange() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "figi_code" + */ + public function testPropertyFigiCode() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "figi_instrument" + */ + public function testPropertyFigiInstrument() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "currencies" + */ + public function testPropertyCurrencies() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/AccountOrderRecordTest.php b/test/Model/AccountOrderRecordTest.php index 2a3deaf..d747ba3 100644 --- a/test/Model/AccountOrderRecordTest.php +++ b/test/Model/AccountOrderRecordTest.php @@ -108,6 +108,24 @@ public function testPropertyOptionSymbol() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "quote_universal_symbol" + */ + public function testPropertyQuoteUniversalSymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "quote_currency" + */ + public function testPropertyQuoteCurrency() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "action" */ From a17c80f6eb0fd7689fb6de1616b3c3bb4254cd1c Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 12:38:32 +0000 Subject: [PATCH 099/252] Version Bump SDKs (#118) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index fd97f2b..b6082c0 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -6965adfb-84c2-467a-b918-831ae47a00f3 \ No newline at end of file +5fd704fd-442f-4bf9-b3f1-0375c7a7ea37 \ No newline at end of file diff --git a/README.md b/README.md index 6551f0b..09471e2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.84-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.85-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -96,7 +96,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.84" + "konfig/snaptrade-php-sdk": "2.0.85" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index b5c7d98..82972ef 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.84/PHP'; + protected $userAgent = 'Konfig/2.0.85/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.84' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.85' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From eccf150d50334da050f1e13b35e423c9e227c335 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 20:52:59 +0000 Subject: [PATCH 100/252] Regenerate SDKs (#119) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 96 +++- lib/Api/TradingApi.php | 586 ++++++++++++++++++++- lib/Model/ManualTradeFormBracket.php | 83 ++- lib/Model/ManualTradeReplaceForm.php | 615 ++++++++++++++++++++++ lib/Model/TradingInstrument.php | 483 +++++++++++++++++ test/Api/TradingApiTest.php | 12 + test/Model/ManualTradeFormBracketTest.php | 12 +- test/Model/ManualTradeReplaceFormTest.php | 128 +++++ test/Model/TradingInstrumentTest.php | 92 ++++ 10 files changed, 2035 insertions(+), 74 deletions(-) create mode 100644 lib/Model/ManualTradeReplaceForm.php create mode 100644 lib/Model/TradingInstrument.php create mode 100644 test/Model/ManualTradeReplaceFormTest.php create mode 100644 test/Model/TradingInstrumentTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b6082c0..808adee 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -5fd704fd-442f-4bf9-b3f1-0375c7a7ea37 \ No newline at end of file +32a29b59-79bc-4ee1-93ef-5ccd7ec2de44 \ No newline at end of file diff --git a/README.md b/README.md index 09471e2..3471f94 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.trading.placeBracketOrder`](#snaptradetradingplacebracketorder) * [`snaptrade.trading.placeForceOrder`](#snaptradetradingplaceforceorder) * [`snaptrade.trading.placeOrder`](#snaptradetradingplaceorder) + * [`snaptrade.trading.replaceOrder`](#snaptradetradingreplaceorder) * [`snaptrade.transactionsAndReporting.getActivities`](#snaptradetransactionsandreportinggetactivities) * [`snaptrade.transactionsAndReporting.getReportingCustomRange`](#snaptradetransactionsandreportinggetreportingcustomrange) @@ -2153,9 +2154,11 @@ use. Only supported on certain brokerages ```php $result = $snaptrade->trading->placeBracketOrder( - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", action: "BUY", - symbol: "AAPL", + instrument: [ + "symbol" => "AAPL", + "type" => "EQUITY", + ], order_type: "Market", time_in_force: "FOK", stop_loss: [ @@ -2165,8 +2168,10 @@ $result = $snaptrade->trading->placeBracketOrder( take_profit: [ "limit_price" => "49.95", ], + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + symbol: "AAPL", price: 31.33, stop: 31.33, units: 10.5 @@ -2175,15 +2180,9 @@ $result = $snaptrade->trading->placeBracketOrder( #### βš™οΈ Parameters -##### account_id: `string` - -Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. - ##### action: -##### symbol: `string` - -The security's trading ticker symbol. +##### instrument: [`TradingInstrument`](./lib/Model/TradingInstrument.php) ##### order_type: @@ -2193,10 +2192,18 @@ The security's trading ticker symbol. ##### take_profit: [`TakeProfit`](./lib/Model/TakeProfit.php) +##### account_id: `string` + +The ID of the account to execute the trade on. + ##### user_id: `string` ##### user_secret: `string` +##### symbol: `string` + +The security's trading ticker symbol. + ##### price: `float` The limit price for `Limit` and `StopLimit` orders. @@ -2216,7 +2223,7 @@ Number of shares for the order. This can be a decimal for fractional orders. Mus #### 🌐 Endpoint -`/trade/placeBracketOrder` `POST` +`/accounts/{accountId}/trading/bracket` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) @@ -2351,6 +2358,75 @@ Optional, defaults to true. Determines if a wait is performed to check on order --- +### `snaptrade.trading.replaceOrder` + +Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling +the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one +returned in the response going forward. Only supported on some brokerages + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->replaceOrder( + action: "BUY", + order_type: "Market", + time_in_force: "FOK", + account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + price: 31.33, + stop: 31.33, + units: 10.5 +); +``` + +#### βš™οΈ Parameters + +##### action: + +##### order_type: + +##### time_in_force: + +##### account_id: `string` + +The ID of the account to execute the trade on. + +##### brokerage_order_id: `string` + +The Brokerage Order ID of the order to replace. + +##### user_id: `string` + +##### user_secret: `string` + +##### price: `float` + +The limit price for `Limit` and `StopLimit` orders. + +##### stop: `float` + +The price at which a stop order is triggered for `Stop` and `StopLimit` orders. + +##### units: [`float`](./lib/Model/float.php) + + +#### πŸ”„ Return + +[**AccountOrderRecord**](./lib/Model/AccountOrderRecord.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace` `PATCH` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.transactionsAndReporting.getActivities` ![Deprecated](https://img.shields.io/badge/deprecated-yellow) diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index f30813b..95230eb 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -80,6 +80,9 @@ class TradingApi extends \SnapTrade\CustomApi 'placeOrder' => [ 'application/json', ], + 'replaceOrder' => [ + 'application/json', + ], ]; /** @@ -1602,6 +1605,7 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket manual_trade_form_bracket (required) @@ -1613,15 +1617,16 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a */ public function placeBracketOrder( - $account_id, $action, - $symbol, + $instrument, $order_type, $time_in_force, $stop_loss, $take_profit, + $account_id, $user_id, $user_secret, + $symbol = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, @@ -1629,9 +1634,9 @@ public function placeBracketOrder( ) { $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); $this->setRequestBodyProperty($_body, "action", $action); $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "instrument", $instrument); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); @@ -1641,7 +1646,7 @@ public function placeBracketOrder( $this->setRequestBodyProperty($_body, "take_profit", $take_profit); $manual_trade_form_bracket = $_body; - list($response) = $this->placeBracketOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_bracket, $contentType); + list($response) = $this->placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); return $response; } @@ -1652,6 +1657,7 @@ public function placeBracketOrder( * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) @@ -1661,9 +1667,9 @@ public function placeBracketOrder( * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeBracketOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($user_id, $user_secret, $manual_trade_form_bracket, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -1679,6 +1685,7 @@ public function placeBracketOrderWithHttpInfo($user_id, $user_secret, $manual_tr $requestOptions->shouldRetryOAuth() ) { return $this->placeBracketOrderWithHttpInfo( + $account_id, $user_id, $user_secret, $manual_trade_form_bracket, @@ -1819,6 +1826,7 @@ public function placeBracketOrderWithHttpInfo($user_id, $user_secret, $manual_tr * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) @@ -1829,15 +1837,16 @@ public function placeBracketOrderWithHttpInfo($user_id, $user_secret, $manual_tr */ public function placeBracketOrderAsync( - $account_id, $action, - $symbol, + $instrument, $order_type, $time_in_force, $stop_loss, $take_profit, + $account_id, $user_id, $user_secret, + $symbol = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, @@ -1845,9 +1854,9 @@ public function placeBracketOrderAsync( ) { $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); $this->setRequestBodyProperty($_body, "action", $action); $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "instrument", $instrument); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); @@ -1857,7 +1866,7 @@ public function placeBracketOrderAsync( $this->setRequestBodyProperty($_body, "take_profit", $take_profit); $manual_trade_form_bracket = $_body; - return $this->placeBracketOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_bracket, $contentType) + return $this->placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType) ->then( function ($response) { return $response[0]; @@ -1872,6 +1881,7 @@ function ($response) { * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) @@ -1880,10 +1890,10 @@ function ($response) { * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeBracketOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($user_id, $user_secret, $manual_trade_form_bracket, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -1927,6 +1937,7 @@ function ($exception) { /** * Create request for operation 'placeBracketOrder' * + * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) @@ -1935,9 +1946,19 @@ function ($exception) { * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeBracketOrderRequest($user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0]) + public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0]) { + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling placeBracketOrder' + ); + } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -1974,7 +1995,7 @@ public function placeBracketOrderRequest($user_id, $user_secret, $manual_trade_f } - $resourcePath = '/trade/placeBracketOrder'; + $resourcePath = '/accounts/{accountId}/trading/bracket'; $formParams = []; $queryParams = []; $headerParams = []; @@ -2005,6 +2026,14 @@ public function placeBracketOrderRequest($user_id, $user_secret, $manual_trade_f } + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -3035,6 +3064,535 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ ]; } + /** + * Operation replaceOrder + * + * Replaces an order with a new one + * + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + */ + public function replaceOrder( + + $action, + $order_type, + $time_in_force, + $account_id, + $brokerage_order_id, + $user_id, + $user_secret, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['replaceOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $manual_trade_replace_form = $_body; + + list($response) = $this->replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + return $response; + } + + /** + * Operation replaceOrderWithHttpInfo + * + * Replaces an order with a new one + * + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->replaceOrderWithHttpInfo( + $account_id, + $brokerage_order_id, + $user_id, + $user_secret, + $manual_trade_replace_form, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation replaceOrderAsync + * + * Replaces an order with a new one + * + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function replaceOrderAsync( + + $action, + $order_type, + $time_in_force, + $account_id, + $brokerage_order_id, + $user_id, + $user_secret, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['replaceOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $manual_trade_replace_form = $_body; + + return $this->replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation replaceOrderAsyncWithHttpInfo + * + * Replaces an order with a new one + * + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'replaceOrder' + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0]) + { + + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling replaceOrder' + ); + } + // Check if $brokerage_order_id is a string + if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); + } + // verify the required parameter 'brokerage_order_id' is set + if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter brokerage_order_id when calling replaceOrder' + ); + } + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling replaceOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling replaceOrder' + ); + } + if ($manual_trade_replace_form !== SENTINEL_VALUE) { + if (!($manual_trade_replace_form instanceof \SnapTrade\Model\ManualTradeReplaceForm)) { + if (!is_array($manual_trade_replace_form)) + throw new \InvalidArgumentException('"manual_trade_replace_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeReplaceForm TradingApi.replaceOrder.'); + else + $manual_trade_replace_form = new \SnapTrade\Model\ManualTradeReplaceForm($manual_trade_replace_form); + } + } + // verify the required parameter 'manual_trade_replace_form' is set + if ($manual_trade_replace_form === SENTINEL_VALUE || (is_array($manual_trade_replace_form) && count($manual_trade_replace_form) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter manual_trade_replace_form when calling replaceOrder' + ); + } + + + $resourcePath = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($brokerage_order_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'brokerageOrderId' . '}', + ObjectSerializer::toPathValue($brokerage_order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($manual_trade_replace_form)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_replace_form)); + } else { + $httpBody = $manual_trade_replace_form; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'PATCH'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + /** * Create http client option * diff --git a/lib/Model/ManualTradeFormBracket.php b/lib/Model/ManualTradeFormBracket.php index 0dc1677..3a6831d 100644 --- a/lib/Model/ManualTradeFormBracket.php +++ b/lib/Model/ManualTradeFormBracket.php @@ -51,9 +51,9 @@ class ManualTradeFormBracket implements ModelInterface, ArrayAccess, \JsonSerial * @var string[] */ protected static $openAPITypes = [ - 'account_id' => 'string', 'action' => '\SnapTrade\Model\ActionStrictWithOptions', 'symbol' => 'string', + 'instrument' => '\SnapTrade\Model\TradingInstrument', 'order_type' => '\SnapTrade\Model\OrderTypeStrict', 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', 'price' => 'float', @@ -71,9 +71,9 @@ class ManualTradeFormBracket implements ModelInterface, ArrayAccess, \JsonSerial * @psalm-var array */ protected static $openAPIFormats = [ - 'account_id' => 'uuid', 'action' => null, 'symbol' => null, + 'instrument' => null, 'order_type' => null, 'time_in_force' => null, 'price' => null, @@ -89,9 +89,9 @@ class ManualTradeFormBracket implements ModelInterface, ArrayAccess, \JsonSerial * @var boolean[] */ protected static array $openAPINullables = [ - 'account_id' => false, - 'action' => false, + 'action' => false, 'symbol' => false, + 'instrument' => false, 'order_type' => false, 'time_in_force' => false, 'price' => true, @@ -187,9 +187,9 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'account_id' => 'account_id', 'action' => 'action', 'symbol' => 'symbol', + 'instrument' => 'instrument', 'order_type' => 'order_type', 'time_in_force' => 'time_in_force', 'price' => 'price', @@ -205,9 +205,9 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'account_id' => 'setAccountId', 'action' => 'setAction', 'symbol' => 'setSymbol', + 'instrument' => 'setInstrument', 'order_type' => 'setOrderType', 'time_in_force' => 'setTimeInForce', 'price' => 'setPrice', @@ -223,9 +223,9 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'account_id' => 'getAccountId', 'action' => 'getAction', 'symbol' => 'getSymbol', + 'instrument' => 'getInstrument', 'order_type' => 'getOrderType', 'time_in_force' => 'getTimeInForce', 'price' => 'getPrice', @@ -292,9 +292,9 @@ public function getModelName() */ public function __construct(array $data = null) { - $this->setIfExists('account_id', $data ?? [], null); $this->setIfExists('action', $data ?? [], null); $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('instrument', $data ?? [], null); $this->setIfExists('order_type', $data ?? [], null); $this->setIfExists('time_in_force', $data ?? [], null); $this->setIfExists('price', $data ?? [], null); @@ -331,14 +331,11 @@ public function listInvalidProperties() { $invalidProperties = []; - if ($this->container['account_id'] === null) { - $invalidProperties[] = "'account_id' can't be null"; - } if ($this->container['action'] === null) { $invalidProperties[] = "'action' can't be null"; } - if ($this->container['symbol'] === null) { - $invalidProperties[] = "'symbol' can't be null"; + if ($this->container['instrument'] === null) { + $invalidProperties[] = "'instrument' can't be null"; } if ($this->container['order_type'] === null) { $invalidProperties[] = "'order_type' can't be null"; @@ -368,88 +365,88 @@ public function valid() /** - * Gets account_id + * Gets action * - * @return string + * @return \SnapTrade\Model\ActionStrictWithOptions */ - public function getAccountId() + public function getAction() { - return $this->container['account_id']; + return $this->container['action']; } /** - * Sets account_id + * Sets action * - * @param string $account_id Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade. + * @param \SnapTrade\Model\ActionStrictWithOptions $action action * * @return self */ - public function setAccountId($account_id) + public function setAction($action) { - if (is_null($account_id)) { - throw new \InvalidArgumentException('non-nullable account_id cannot be null'); + if (is_null($action)) { + throw new \InvalidArgumentException('non-nullable action cannot be null'); } - $this->container['account_id'] = $account_id; + $this->container['action'] = $action; return $this; } /** - * Gets action + * Gets symbol * - * @return \SnapTrade\Model\ActionStrictWithOptions + * @return string|null */ - public function getAction() + public function getSymbol() { - return $this->container['action']; + return $this->container['symbol']; } /** - * Sets action + * Sets symbol * - * @param \SnapTrade\Model\ActionStrictWithOptions $action action + * @param string|null $symbol The security's trading ticker symbol. * * @return self */ - public function setAction($action) + public function setSymbol($symbol) { - if (is_null($action)) { - throw new \InvalidArgumentException('non-nullable action cannot be null'); + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); } - $this->container['action'] = $action; + $this->container['symbol'] = $symbol; return $this; } /** - * Gets symbol + * Gets instrument * - * @return string + * @return \SnapTrade\Model\TradingInstrument */ - public function getSymbol() + public function getInstrument() { - return $this->container['symbol']; + return $this->container['instrument']; } /** - * Sets symbol + * Sets instrument * - * @param string $symbol The security's trading ticker symbol. + * @param \SnapTrade\Model\TradingInstrument $instrument instrument * * @return self */ - public function setSymbol($symbol) + public function setInstrument($instrument) { - if (is_null($symbol)) { - throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + if (is_null($instrument)) { + throw new \InvalidArgumentException('non-nullable instrument cannot be null'); } - $this->container['symbol'] = $symbol; + $this->container['instrument'] = $instrument; return $this; } diff --git a/lib/Model/ManualTradeReplaceForm.php b/lib/Model/ManualTradeReplaceForm.php new file mode 100644 index 0000000..bdb9ba6 --- /dev/null +++ b/lib/Model/ManualTradeReplaceForm.php @@ -0,0 +1,615 @@ + + */ +class ManualTradeReplaceForm implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ManualTradeReplaceForm'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'action' => '\SnapTrade\Model\ActionStrict', + 'order_type' => '\SnapTrade\Model\OrderTypeStrict', + 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', + 'price' => 'float', + 'stop' => 'float', + 'units' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'action' => null, + 'order_type' => null, + 'time_in_force' => null, + 'price' => null, + 'stop' => null, + 'units' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'action' => false, + 'order_type' => false, + 'time_in_force' => false, + 'price' => true, + 'stop' => true, + 'units' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'action' => 'action', + 'order_type' => 'order_type', + 'time_in_force' => 'time_in_force', + 'price' => 'price', + 'stop' => 'stop', + 'units' => 'units' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'action' => 'setAction', + 'order_type' => 'setOrderType', + 'time_in_force' => 'setTimeInForce', + 'price' => 'setPrice', + 'stop' => 'setStop', + 'units' => 'setUnits' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'action' => 'getAction', + 'order_type' => 'getOrderType', + 'time_in_force' => 'getTimeInForce', + 'price' => 'getPrice', + 'stop' => 'getStop', + 'units' => 'getUnits' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('action', $data ?? [], null); + $this->setIfExists('order_type', $data ?? [], null); + $this->setIfExists('time_in_force', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('stop', $data ?? [], null); + $this->setIfExists('units', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['action'] === null) { + $invalidProperties[] = "'action' can't be null"; + } + if ($this->container['order_type'] === null) { + $invalidProperties[] = "'order_type' can't be null"; + } + if ($this->container['time_in_force'] === null) { + $invalidProperties[] = "'time_in_force' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets action + * + * @return \SnapTrade\Model\ActionStrict + */ + public function getAction() + { + return $this->container['action']; + } + + /** + * Sets action + * + * @param \SnapTrade\Model\ActionStrict $action action + * + * @return self + */ + public function setAction($action) + { + + if (is_null($action)) { + throw new \InvalidArgumentException('non-nullable action cannot be null'); + } + + $this->container['action'] = $action; + + return $this; + } + + /** + * Gets order_type + * + * @return \SnapTrade\Model\OrderTypeStrict + */ + public function getOrderType() + { + return $this->container['order_type']; + } + + /** + * Sets order_type + * + * @param \SnapTrade\Model\OrderTypeStrict $order_type order_type + * + * @return self + */ + public function setOrderType($order_type) + { + + if (is_null($order_type)) { + throw new \InvalidArgumentException('non-nullable order_type cannot be null'); + } + + $this->container['order_type'] = $order_type; + + return $this; + } + + /** + * Gets time_in_force + * + * @return \SnapTrade\Model\TimeInForceStrict + */ + public function getTimeInForce() + { + return $this->container['time_in_force']; + } + + /** + * Sets time_in_force + * + * @param \SnapTrade\Model\TimeInForceStrict $time_in_force time_in_force + * + * @return self + */ + public function setTimeInForce($time_in_force) + { + + if (is_null($time_in_force)) { + throw new \InvalidArgumentException('non-nullable time_in_force cannot be null'); + } + + $this->container['time_in_force'] = $time_in_force; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price The limit price for `Limit` and `StopLimit` orders. + * + * @return self + */ + public function setPrice($price) + { + + if (is_null($price)) { + array_push($this->openAPINullablesSetToNull, 'price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets stop + * + * @return float|null + */ + public function getStop() + { + return $this->container['stop']; + } + + /** + * Sets stop + * + * @param float|null $stop The price at which a stop order is triggered for `Stop` and `StopLimit` orders. + * + * @return self + */ + public function setStop($stop) + { + + if (is_null($stop)) { + array_push($this->openAPINullablesSetToNull, 'stop'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('stop', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['stop'] = $stop; + + return $this; + } + + /** + * Gets units + * + * @return float|null + */ + public function getUnits() + { + return $this->container['units']; + } + + /** + * Sets units + * + * @param float|null $units units + * + * @return self + */ + public function setUnits($units) + { + + if (is_null($units)) { + array_push($this->openAPINullablesSetToNull, 'units'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('units', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['units'] = $units; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/TradingInstrument.php b/lib/Model/TradingInstrument.php new file mode 100644 index 0000000..a0bb9c8 --- /dev/null +++ b/lib/Model/TradingInstrument.php @@ -0,0 +1,483 @@ + + */ +class TradingInstrument implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TradingInstrument'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'symbol' => 'string', + 'type' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'symbol' => null, + 'type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'symbol' => false, + 'type' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'symbol' => 'symbol', + 'type' => 'type' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'symbol' => 'setSymbol', + 'type' => 'setType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'symbol' => 'getSymbol', + 'type' => 'getType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_EQUITY = 'EQUITY'; + public const TYPE_CRYPTOCURRENCY = 'CRYPTOCURRENCY'; + public const TYPE_CRYPTOCURRENCY_PAIR = 'CRYPTOCURRENCY_PAIR'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_EQUITY, + self::TYPE_CRYPTOCURRENCY, + self::TYPE_CRYPTOCURRENCY_PAIR, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets symbol + * + * @return string|null + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string|null $symbol The security's trading ticker symbol + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type type + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($type)) { + array_push($this->openAPINullablesSetToNull, 'type'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('type', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['type'] = $type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index ba47909..a10fbdc 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -129,4 +129,16 @@ public function testPlaceOrder() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test case for replaceOrder + * + * Replaces an order with a new one. + * + */ + public function testReplaceOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } diff --git a/test/Model/ManualTradeFormBracketTest.php b/test/Model/ManualTradeFormBracketTest.php index 881daa3..1c8c52c 100644 --- a/test/Model/ManualTradeFormBracketTest.php +++ b/test/Model/ManualTradeFormBracketTest.php @@ -73,27 +73,27 @@ public function testManualTradeFormBracket() } /** - * Test attribute "account_id" + * Test attribute "action" */ - public function testPropertyAccountId() + public function testPropertyAction() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "action" + * Test attribute "symbol" */ - public function testPropertyAction() + public function testPropertySymbol() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "symbol" + * Test attribute "instrument" */ - public function testPropertySymbol() + public function testPropertyInstrument() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/ManualTradeReplaceFormTest.php b/test/Model/ManualTradeReplaceFormTest.php new file mode 100644 index 0000000..f4f956b --- /dev/null +++ b/test/Model/ManualTradeReplaceFormTest.php @@ -0,0 +1,128 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "action" + */ + public function testPropertyAction() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "order_type" + */ + public function testPropertyOrderType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "time_in_force" + */ + public function testPropertyTimeInForce() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "price" + */ + public function testPropertyPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop" + */ + public function testPropertyStop() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "units" + */ + public function testPropertyUnits() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/TradingInstrumentTest.php b/test/Model/TradingInstrumentTest.php new file mode 100644 index 0000000..aeb8de2 --- /dev/null +++ b/test/Model/TradingInstrumentTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From 2b5f5c099b7349b7869d83d3cb010ba3e2580581 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 20:57:24 +0000 Subject: [PATCH 101/252] Version Bump SDKs (#120) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 808adee..0ed776e 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -32a29b59-79bc-4ee1-93ef-5ccd7ec2de44 \ No newline at end of file +01ef76ef-10c1-4ca4-bcc6-e0c03c2768c3 \ No newline at end of file diff --git a/README.md b/README.md index 3471f94..00e5f36 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.85-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.86-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.85" + "konfig/snaptrade-php-sdk": "2.0.86" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 82972ef..6344841 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.85/PHP'; + protected $userAgent = 'Konfig/2.0.86/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.85' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.86' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 0b3f3730e5b148a31338b33cecef0a8b242dc5b9 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 28 Mar 2025 22:33:31 +0000 Subject: [PATCH 102/252] Regenerate SDKs (#121) * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 657 ++- lib/Api/CryptoSpotTradingApi.php | 2566 ----------- lib/Api/TradingApi.php | 3906 +++++++++++++---- lib/Client.php | 3 - lib/Model/CryptocurrencyPair.php | 40 +- ...tQuote.php => CryptocurrencyPairQuote.php} | 8 +- ...rderPreview.php => SimpleOrderPreview.php} | 16 +- ...php => SimpleOrderPreviewEstimatedFee.php} | 8 +- .../TradingCryptoSpotCancelOrderRequest.php | 407 -- ...php => TradingPlaceSimpleOrderRequest.php} | 46 +- ...ptocurrencyPairInstruments200Response.php} | 8 +- test/Api/CryptoSpotTradingApiTest.php | 120 - test/Api/TradingApiTest.php | 60 + ...st.php => CryptocurrencyPairQuoteTest.php} | 12 +- test/Model/CryptocurrencyPairTest.php | 11 +- ...=> SimpleOrderPreviewEstimatedFeeTest.php} | 10 +- ...iewTest.php => SimpleOrderPreviewTest.php} | 12 +- ...radingCryptoSpotCancelOrderRequestTest.php | 83 - ...=> TradingPlaceSimpleOrderRequestTest.php} | 16 +- ...urrencyPairInstruments200ResponseTest.php} | 10 +- 21 files changed, 3647 insertions(+), 4354 deletions(-) delete mode 100644 lib/Api/CryptoSpotTradingApi.php rename lib/Model/{CryptoSpotQuote.php => CryptocurrencyPairQuote.php} (98%) rename lib/Model/{CryptoSpotOrderPreview.php => SimpleOrderPreview.php} (94%) rename lib/Model/{CryptoSpotOrderPreviewEstimatedFee.php => SimpleOrderPreviewEstimatedFee.php} (97%) delete mode 100644 lib/Model/TradingCryptoSpotCancelOrderRequest.php rename lib/Model/{TradingCryptoSpotPlaceOrderRequest.php => TradingPlaceSimpleOrderRequest.php} (94%) rename lib/Model/{TradingCryptoSpotSymbols200Response.php => TradingSearchCryptocurrencyPairInstruments200Response.php} (96%) delete mode 100644 test/Api/CryptoSpotTradingApiTest.php rename test/Model/{CryptoSpotQuoteTest.php => CryptocurrencyPairQuoteTest.php} (87%) rename test/Model/{CryptoSpotOrderPreviewEstimatedFeeTest.php => SimpleOrderPreviewEstimatedFeeTest.php} (84%) rename test/Model/{CryptoSpotOrderPreviewTest.php => SimpleOrderPreviewTest.php} (82%) delete mode 100644 test/Model/TradingCryptoSpotCancelOrderRequestTest.php rename test/Model/{TradingCryptoSpotPlaceOrderRequestTest.php => TradingPlaceSimpleOrderRequestTest.php} (87%) rename test/Model/{TradingCryptoSpotSymbols200ResponseTest.php => TradingSearchCryptocurrencyPairInstruments200ResponseTest.php} (77%) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0ed776e..ef0c2d4 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -01ef76ef-10c1-4ca4-bcc6-e0c03c2768c3 \ No newline at end of file +2313026f-85c6-4292-b60b-f24e9c2ae6f7 \ No newline at end of file diff --git a/README.md b/README.md index 00e5f36..87cbf37 100644 --- a/README.md +++ b/README.md @@ -45,11 +45,6 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.connections.removeBrokerageAuthorization`](#snaptradeconnectionsremovebrokerageauthorization) * [`snaptrade.connections.returnRates`](#snaptradeconnectionsreturnrates) * [`snaptrade.connections.sessionEvents`](#snaptradeconnectionssessionevents) - * [`snaptrade.cryptoSpotTrading.cryptoSpotCancelOrder`](#snaptradecryptospottradingcryptospotcancelorder) - * [`snaptrade.cryptoSpotTrading.cryptoSpotPlaceOrder`](#snaptradecryptospottradingcryptospotplaceorder) - * [`snaptrade.cryptoSpotTrading.cryptoSpotPreviewOrder`](#snaptradecryptospottradingcryptospotprevieworder) - * [`snaptrade.cryptoSpotTrading.cryptoSpotQuote`](#snaptradecryptospottradingcryptospotquote) - * [`snaptrade.cryptoSpotTrading.cryptoSpotSymbols`](#snaptradecryptospottradingcryptospotsymbols) * [`snaptrade.options.getOptionStrategy`](#snaptradeoptionsgetoptionstrategy) * [`snaptrade.options.getOptionsChain`](#snaptradeoptionsgetoptionschain) * [`snaptrade.options.getOptionsStrategyQuote`](#snaptradeoptionsgetoptionsstrategyquote) @@ -66,13 +61,18 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.referenceData.listAllCurrencies`](#snaptradereferencedatalistallcurrencies) * [`snaptrade.referenceData.listAllCurrenciesRates`](#snaptradereferencedatalistallcurrenciesrates) * [`snaptrade.referenceData.symbolSearchUserAccount`](#snaptradereferencedatasymbolsearchuseraccount) + * [`snaptrade.trading.cancelOrder`](#snaptradetradingcancelorder) * [`snaptrade.trading.cancelUserAccountOrder`](#snaptradetradingcanceluseraccountorder) + * [`snaptrade.trading.getCryptocurrencyPairQuote`](#snaptradetradinggetcryptocurrencypairquote) * [`snaptrade.trading.getOrderImpact`](#snaptradetradinggetorderimpact) * [`snaptrade.trading.getUserAccountQuotes`](#snaptradetradinggetuseraccountquotes) * [`snaptrade.trading.placeBracketOrder`](#snaptradetradingplacebracketorder) * [`snaptrade.trading.placeForceOrder`](#snaptradetradingplaceforceorder) * [`snaptrade.trading.placeOrder`](#snaptradetradingplaceorder) + * [`snaptrade.trading.placeSimpleOrder`](#snaptradetradingplacesimpleorder) + * [`snaptrade.trading.previewSimpleOrder`](#snaptradetradingpreviewsimpleorder) * [`snaptrade.trading.replaceOrder`](#snaptradetradingreplaceorder) + * [`snaptrade.trading.searchCryptocurrencyPairInstruments`](#snaptradetradingsearchcryptocurrencypairinstruments) * [`snaptrade.transactionsAndReporting.getActivities`](#snaptradetransactionsandreportinggetactivities) * [`snaptrade.transactionsAndReporting.getReportingCustomRange`](#snaptradetransactionsandreportinggetreportingcustomrange) @@ -1120,302 +1120,6 @@ Optional comma separated list of session IDs used to filter the request on speci --- -### `snaptrade.cryptoSpotTrading.cryptoSpotCancelOrder` - -Cancels a cryptocurrency spot order in the specified account. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->cryptoSpotTrading->cryptoSpotCancelOrder( - brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" -); -``` - -#### βš™οΈ Parameters - -##### brokerage_order_id: `string` - -Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - - -#### πŸ”„ Return - -[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/crypto/spot/cancelOrder` `POST` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - -### `snaptrade.cryptoSpotTrading.cryptoSpotPlaceOrder` - -Places a spot cryptocurrency order in the specified account. -This endpoint does not compute the impact to the account balance from the order before submitting the order to the exchange. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->cryptoSpotTrading->cryptoSpotPlaceOrder( - symbol: [ - "base" => "BTC", - "quote" => "USD", - ], - side: "BUY", - type: "MARKET", - time_in_force: "GTC", - amount: "123.45", - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - limit_price: "123.45", - stop_price: "123.45", - post_only: False, - expiration_date: "2024-01-01T00:00:00Z" -); -``` - -#### βš™οΈ Parameters - -##### symbol: [`CryptocurrencyPair`](./lib/Model/CryptocurrencyPair.php) - -##### side: - -##### type: `string` - -The type of order to place. - -##### time_in_force: `string` - -The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. - -##### amount: `float` - -The amount of the base currency to buy or sell. - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### limit_price: `float` - -The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. - -##### stop_price: `float` - -The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. - -##### post_only: `bool` - -Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. - -##### expiration_date: `\DateTime` - -The expiration date of the order. Required if the time_in_force is GTD. - - -#### πŸ”„ Return - -[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/crypto/spot/placeOrder` `POST` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - -### `snaptrade.cryptoSpotTrading.cryptoSpotPreviewOrder` - -Previews a cryptocurrency spot order using the specified account. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->cryptoSpotTrading->cryptoSpotPreviewOrder( - symbol: [ - "base" => "BTC", - "quote" => "USD", - ], - side: "BUY", - type: "MARKET", - time_in_force: "GTC", - amount: "123.45", - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - limit_price: "123.45", - stop_price: "123.45", - post_only: False, - expiration_date: "2024-01-01T00:00:00Z" -); -``` - -#### βš™οΈ Parameters - -##### symbol: [`CryptocurrencyPair`](./lib/Model/CryptocurrencyPair.php) - -##### side: - -##### type: `string` - -The type of order to place. - -##### time_in_force: `string` - -The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. - -##### amount: `float` - -The amount of the base currency to buy or sell. - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### limit_price: `float` - -The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. - -##### stop_price: `float` - -The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. - -##### post_only: `bool` - -Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. - -##### expiration_date: `\DateTime` - -The expiration date of the order. Required if the time_in_force is GTD. - - -#### πŸ”„ Return - -[**CryptoSpotOrderPreview**](./lib/Model/CryptoSpotOrderPreview.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/crypto/spot/previewOrder` `POST` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - -### `snaptrade.cryptoSpotTrading.cryptoSpotQuote` - -Gets a quote for the specified account. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->cryptoSpotTrading->cryptoSpotQuote( - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - base: "BTC", - quote: "USD" -); -``` - -#### βš™οΈ Parameters - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### base: `string` - -##### quote: `string` - - -#### πŸ”„ Return - -[**CryptoSpotQuote**](./lib/Model/CryptoSpotQuote.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/crypto/spot/quote` `GET` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - -### `snaptrade.cryptoSpotTrading.cryptoSpotSymbols` - -Searches cryptocurrency spot symbols accessible to the specified account. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->cryptoSpotTrading->cryptoSpotSymbols( - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - base: "BTC", - quote: "USD" -); -``` - -#### βš™οΈ Parameters - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### base: `string` - -##### quote: `string` - - -#### πŸ”„ Return - -[**TradingCryptoSpotSymbols200Response**](./lib/Model/TradingCryptoSpotSymbols200Response.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/crypto/spot/symbols` `GET` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - ### `snaptrade.options.getOptionStrategy` Creates an option strategy object that will be used to place an option strategy order. @@ -1894,67 +1598,151 @@ $result = $snaptrade->referenceData->listAllBrokerages(); Returns a list of all defined Currency objects. -#### πŸ› οΈ Usage +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->referenceData->listAllCurrencies(); +``` + + +#### πŸ”„ Return + +[**Currency**](./lib/Model/Currency.php) + +#### 🌐 Endpoint + +`/currencies` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + +### `snaptrade.referenceData.listAllCurrenciesRates` + +Returns a list of all Exchange Rate Pairs for all supported Currencies. + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->referenceData->listAllCurrenciesRates(); +``` + + +#### πŸ”„ Return + +[**ExchangeRatePairs**](./lib/Model/ExchangeRatePairs.php) + +#### 🌐 Endpoint + +`/currencies/rates` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + +### `snaptrade.referenceData.symbolSearchUserAccount` + +Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. + +The search results are further limited to the symbols supported by the brokerage for which the account is under. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->referenceData->symbolSearchUserAccount( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + substring: "AAPL" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### substring: `string` -```php -$result = $snaptrade->referenceData->listAllCurrencies(); -``` +The search query for symbols. #### πŸ”„ Return -[**Currency**](./lib/Model/Currency.php) +[**UniversalSymbol**](./lib/Model/UniversalSymbol.php) #### 🌐 Endpoint -`/currencies` `GET` +`/accounts/{accountId}/symbols` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- -### `snaptrade.referenceData.listAllCurrenciesRates` +### `snaptrade.trading.cancelOrder` + +Cancels an order in the specified account. -Returns a list of all Exchange Rate Pairs for all supported Currencies. #### πŸ› οΈ Usage ```php -$result = $snaptrade->referenceData->listAllCurrenciesRates(); +$result = $snaptrade->trading->cancelOrder( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e" +); ``` +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### brokerage_order_id: `string` + #### πŸ”„ Return -[**ExchangeRatePairs**](./lib/Model/ExchangeRatePairs.php) +[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) #### 🌐 Endpoint -`/currencies/rates` `GET` +`/accounts/{accountId}/trading/simple/{brokerageOrderId}/cancel` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- -### `snaptrade.referenceData.symbolSearchUserAccount` - -Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. +### `snaptrade.trading.cancelUserAccountOrder` -The search results are further limited to the symbols supported by the brokerage for which the account is under. +Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. #### πŸ› οΈ Usage ```php -$result = $snaptrade->referenceData->symbolSearchUserAccount( +$result = $snaptrade->trading->cancelUserAccountOrder( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - substring: "AAPL" + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e" ); ``` @@ -1966,38 +1754,38 @@ $result = $snaptrade->referenceData->symbolSearchUserAccount( ##### account_id: `string` -##### substring: `string` +##### brokerage_order_id: `string` -The search query for symbols. +Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. #### πŸ”„ Return -[**UniversalSymbol**](./lib/Model/UniversalSymbol.php) +[**AccountOrderRecord**](./lib/Model/AccountOrderRecord.php) #### 🌐 Endpoint -`/accounts/{accountId}/symbols` `POST` +`/accounts/{accountId}/orders/cancel` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- -### `snaptrade.trading.cancelUserAccountOrder` +### `snaptrade.trading.getCryptocurrencyPairQuote` -Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. +Gets a quote for the specified account. #### πŸ› οΈ Usage ```php -$result = $snaptrade->trading->cancelUserAccountOrder( +$result = $snaptrade->trading->getCryptocurrencyPairQuote( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e" + instrument_symbol: "BTC-USD" ); ``` @@ -2009,18 +1797,16 @@ $result = $snaptrade->trading->cancelUserAccountOrder( ##### account_id: `string` -##### brokerage_order_id: `string` - -Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. +##### instrument_symbol: `string` #### πŸ”„ Return -[**AccountOrderRecord**](./lib/Model/AccountOrderRecord.php) +[**CryptocurrencyPairQuote**](./lib/Model/CryptocurrencyPairQuote.php) #### 🌐 Endpoint -`/accounts/{accountId}/orders/cancel` `POST` +`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) @@ -2358,6 +2144,171 @@ Optional, defaults to true. Determines if a wait is performed to check on order --- +### `snaptrade.trading.placeSimpleOrder` + +Places an order in the specified account. +This endpoint does not compute the impact to the account balance from the order before submitting the order. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->placeSimpleOrder( + instrument: [ + "symbol" => "AAPL", + "type" => "EQUITY", + ], + side: "BUY", + type: "MARKET", + time_in_force: "GTC", + amount: "123.45", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + limit_price: "123.45", + stop_price: "123.45", + post_only: False, + expiration_date: "2024-01-01T00:00:00Z" +); +``` + +#### βš™οΈ Parameters + +##### instrument: [`TradingInstrument`](./lib/Model/TradingInstrument.php) + +##### side: + +##### type: `string` + +The type of order to place. + +##### time_in_force: `string` + +The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. + +##### amount: `float` + +The amount of the base currency to buy or sell. + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### limit_price: `float` + +The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. + +##### stop_price: `float` + +The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. + +##### post_only: `bool` + +Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. + +##### expiration_date: `\DateTime` + +The expiration date of the order. Required if the time_in_force is GTD. + + +#### πŸ”„ Return + +[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/simple` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + +### `snaptrade.trading.previewSimpleOrder` + +Previews an order using the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->previewSimpleOrder( + instrument: [ + "symbol" => "AAPL", + "type" => "EQUITY", + ], + side: "BUY", + type: "MARKET", + time_in_force: "GTC", + amount: "123.45", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + limit_price: "123.45", + stop_price: "123.45", + post_only: False, + expiration_date: "2024-01-01T00:00:00Z" +); +``` + +#### βš™οΈ Parameters + +##### instrument: [`TradingInstrument`](./lib/Model/TradingInstrument.php) + +##### side: + +##### type: `string` + +The type of order to place. + +##### time_in_force: `string` + +The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. + +##### amount: `float` + +The amount of the base currency to buy or sell. + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### limit_price: `float` + +The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. + +##### stop_price: `float` + +The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. + +##### post_only: `bool` + +Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. + +##### expiration_date: `\DateTime` + +The expiration date of the order. Required if the time_in_force is GTD. + + +#### πŸ”„ Return + +[**SimpleOrderPreview**](./lib/Model/SimpleOrderPreview.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/simple/preview` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.trading.replaceOrder` Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling @@ -2427,6 +2378,50 @@ The price at which a stop order is triggered for `Stop` and `StopLimit` orders. --- +### `snaptrade.trading.searchCryptocurrencyPairInstruments` + +Searches cryptocurrency pairs instruments accessible to the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->searchCryptocurrencyPairInstruments( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + base: "BTC", + quote: "USD" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### base: `string` + +##### quote: `string` + + +#### πŸ”„ Return + +[**TradingSearchCryptocurrencyPairInstruments200Response**](./lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.transactionsAndReporting.getActivities` ![Deprecated](https://img.shields.io/badge/deprecated-yellow) diff --git a/lib/Api/CryptoSpotTradingApi.php b/lib/Api/CryptoSpotTradingApi.php deleted file mode 100644 index 197341a..0000000 --- a/lib/Api/CryptoSpotTradingApi.php +++ /dev/null @@ -1,2566 +0,0 @@ - [ - 'application/json', - ], - 'cryptoSpotPlaceOrder' => [ - 'application/json', - ], - 'cryptoSpotPreviewOrder' => [ - 'application/json', - ], - 'cryptoSpotQuote' => [ - 'application/json', - ], - 'cryptoSpotSymbols' => [ - 'application/json', - ], - ]; - -/** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - Configuration $config = null, - ClientInterface $client = null, - HeaderSelector $selector = null, - $hostIndex = 0 - ) { - $clientOptions = []; - if (!$config->getVerifySsl()) $clientOptions["verify"] = false; - - // Do not truncate error messages - // https://github.com/guzzle/guzzle/issues/2185#issuecomment-800293420 - $stack = new HandlerStack(Utils::chooseHandler()); - $stack->push(Middleware::httpErrors(new BodySummarizer(10000)), 'http_errors'); - $stack->push(Middleware::redirect(), 'allow_redirects'); - $stack->push(Middleware::cookies(), 'cookies'); - $stack->push(Middleware::prepareBody(), 'prepare_body'); - $clientOptions["handler"] = $stack; - - $this->client = $client ?: new Client($clientOptions); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * For initializing request body parameter - */ - private function setRequestBodyProperty(&$body, $property, $value) { - if ($body === null) $body = []; - // user did not pass in a value for this parameter - if ($value === SENTINEL_VALUE) return; - $body[$property] = $value; - } - - /** - * Operation cryptoSpotCancelOrder - * - * Cancel a crypto spot order. - * - * Cancels a cryptocurrency spot order in the specified account. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest $trading_crypto_spot_cancel_order_request trading_crypto_spot_cancel_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotCancelOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse - */ - public function cryptoSpotCancelOrder( - - $brokerage_order_id, - $user_id, - $user_secret, - $account_id, - string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); - $trading_crypto_spot_cancel_order_request = $_body; - - list($response) = $this->cryptoSpotCancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, $contentType); - return $response; - } - - /** - * Operation cryptoSpotCancelOrderWithHttpInfo - * - * Cancel a crypto spot order. - * - * Cancels a cryptocurrency spot order in the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest $trading_crypto_spot_cancel_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotCancelOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function cryptoSpotCancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotCancelOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->cryptoSpotCancelOrderWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $trading_crypto_spot_cancel_order_request, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\OrderUpdatedResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation cryptoSpotCancelOrderAsync - * - * Cancel a crypto spot order. - * - * Cancels a cryptocurrency spot order in the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest $trading_crypto_spot_cancel_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotCancelOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function cryptoSpotCancelOrderAsync( - - $brokerage_order_id, - $user_id, - $user_secret, - $account_id, - string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); - $trading_crypto_spot_cancel_order_request = $_body; - - return $this->cryptoSpotCancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation cryptoSpotCancelOrderAsyncWithHttpInfo - * - * Cancel a crypto spot order. - * - * Cancels a cryptocurrency spot order in the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest $trading_crypto_spot_cancel_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotCancelOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function cryptoSpotCancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotCancelOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'cryptoSpotCancelOrder' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest $trading_crypto_spot_cancel_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotCancelOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function cryptoSpotCancelOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_cancel_order_request, string $contentType = self::contentTypes['cryptoSpotCancelOrder'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling cryptoSpotCancelOrder' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling cryptoSpotCancelOrder' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling cryptoSpotCancelOrder' - ); - } - if ($trading_crypto_spot_cancel_order_request !== SENTINEL_VALUE) { - if (!($trading_crypto_spot_cancel_order_request instanceof \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest)) { - if (!is_array($trading_crypto_spot_cancel_order_request)) - throw new \InvalidArgumentException('"trading_crypto_spot_cancel_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest CryptoSpotTradingApi.cryptoSpotCancelOrder.'); - else - $trading_crypto_spot_cancel_order_request = new \SnapTrade\Model\TradingCryptoSpotCancelOrderRequest($trading_crypto_spot_cancel_order_request); - } - } - // verify the required parameter 'trading_crypto_spot_cancel_order_request' is set - if ($trading_crypto_spot_cancel_order_request === SENTINEL_VALUE || (is_array($trading_crypto_spot_cancel_order_request) && count($trading_crypto_spot_cancel_order_request) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter trading_crypto_spot_cancel_order_request when calling cryptoSpotCancelOrder' - ); - } - - - $resourcePath = '/accounts/{accountId}/trading/crypto/spot/cancelOrder'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (isset($trading_crypto_spot_cancel_order_request)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_crypto_spot_cancel_order_request)); - } else { - $httpBody = $trading_crypto_spot_cancel_order_request; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'POST'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation cryptoSpotPlaceOrder - * - * Place a spot order on a crypto exchange - * - * Places a spot cryptocurrency order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order to the exchange. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request trading_crypto_spot_place_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPlaceOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse - */ - public function cryptoSpotPlaceOrder( - - $symbol, - $side, - $type, - $time_in_force, - $amount, - $user_id, - $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $trading_crypto_spot_place_order_request = $_body; - - list($response) = $this->cryptoSpotPlaceOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); - return $response; - } - - /** - * Operation cryptoSpotPlaceOrderWithHttpInfo - * - * Place a spot order on a crypto exchange - * - * Places a spot cryptocurrency order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order to the exchange. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPlaceOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function cryptoSpotPlaceOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotPlaceOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->cryptoSpotPlaceOrderWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $trading_crypto_spot_place_order_request, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\OrderUpdatedResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation cryptoSpotPlaceOrderAsync - * - * Place a spot order on a crypto exchange - * - * Places a spot cryptocurrency order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order to the exchange. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPlaceOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function cryptoSpotPlaceOrderAsync( - - $symbol, - $side, - $type, - $time_in_force, - $amount, - $user_id, - $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $trading_crypto_spot_place_order_request = $_body; - - return $this->cryptoSpotPlaceOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation cryptoSpotPlaceOrderAsyncWithHttpInfo - * - * Place a spot order on a crypto exchange - * - * Places a spot cryptocurrency order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order to the exchange. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPlaceOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function cryptoSpotPlaceOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotPlaceOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'cryptoSpotPlaceOrder' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPlaceOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function cryptoSpotPlaceOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPlaceOrder'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling cryptoSpotPlaceOrder' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling cryptoSpotPlaceOrder' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling cryptoSpotPlaceOrder' - ); - } - if ($trading_crypto_spot_place_order_request !== SENTINEL_VALUE) { - if (!($trading_crypto_spot_place_order_request instanceof \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest)) { - if (!is_array($trading_crypto_spot_place_order_request)) - throw new \InvalidArgumentException('"trading_crypto_spot_place_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest CryptoSpotTradingApi.cryptoSpotPlaceOrder.'); - else - $trading_crypto_spot_place_order_request = new \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest($trading_crypto_spot_place_order_request); - } - } - // verify the required parameter 'trading_crypto_spot_place_order_request' is set - if ($trading_crypto_spot_place_order_request === SENTINEL_VALUE || (is_array($trading_crypto_spot_place_order_request) && count($trading_crypto_spot_place_order_request) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter trading_crypto_spot_place_order_request when calling cryptoSpotPlaceOrder' - ); - } - - - $resourcePath = '/accounts/{accountId}/trading/crypto/spot/placeOrder'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (isset($trading_crypto_spot_place_order_request)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_crypto_spot_place_order_request)); - } else { - $httpBody = $trading_crypto_spot_place_order_request; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'POST'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation cryptoSpotPreviewOrder - * - * Preview a crypto spot order - * - * Previews a cryptocurrency spot order using the specified account. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request trading_crypto_spot_place_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPreviewOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\CryptoSpotOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse - */ - public function cryptoSpotPreviewOrder( - - $symbol, - $side, - $type, - $time_in_force, - $amount, - $user_id, - $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['cryptoSpotPreviewOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $trading_crypto_spot_place_order_request = $_body; - - list($response) = $this->cryptoSpotPreviewOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); - return $response; - } - - /** - * Operation cryptoSpotPreviewOrderWithHttpInfo - * - * Preview a crypto spot order - * - * Previews a cryptocurrency spot order using the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPreviewOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\CryptoSpotOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function cryptoSpotPreviewOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPreviewOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotPreviewOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->cryptoSpotPreviewOrderWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $trading_crypto_spot_place_order_request, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\CryptoSpotOrderPreview' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\CryptoSpotOrderPreview' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\CryptoSpotOrderPreview', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\CryptoSpotOrderPreview'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\CryptoSpotOrderPreview', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation cryptoSpotPreviewOrderAsync - * - * Preview a crypto spot order - * - * Previews a cryptocurrency spot order using the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPreviewOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function cryptoSpotPreviewOrderAsync( - - $symbol, - $side, - $type, - $time_in_force, - $amount, - $user_id, - $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['cryptoSpotPreviewOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $trading_crypto_spot_place_order_request = $_body; - - return $this->cryptoSpotPreviewOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation cryptoSpotPreviewOrderAsyncWithHttpInfo - * - * Preview a crypto spot order - * - * Previews a cryptocurrency spot order using the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPreviewOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function cryptoSpotPreviewOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPreviewOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\CryptoSpotOrderPreview'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotPreviewOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'cryptoSpotPreviewOrder' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest $trading_crypto_spot_place_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotPreviewOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function cryptoSpotPreviewOrderRequest($user_id, $user_secret, $account_id, $trading_crypto_spot_place_order_request, string $contentType = self::contentTypes['cryptoSpotPreviewOrder'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling cryptoSpotPreviewOrder' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling cryptoSpotPreviewOrder' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling cryptoSpotPreviewOrder' - ); - } - if ($trading_crypto_spot_place_order_request !== SENTINEL_VALUE) { - if (!($trading_crypto_spot_place_order_request instanceof \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest)) { - if (!is_array($trading_crypto_spot_place_order_request)) - throw new \InvalidArgumentException('"trading_crypto_spot_place_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest CryptoSpotTradingApi.cryptoSpotPreviewOrder.'); - else - $trading_crypto_spot_place_order_request = new \SnapTrade\Model\TradingCryptoSpotPlaceOrderRequest($trading_crypto_spot_place_order_request); - } - } - // verify the required parameter 'trading_crypto_spot_place_order_request' is set - if ($trading_crypto_spot_place_order_request === SENTINEL_VALUE || (is_array($trading_crypto_spot_place_order_request) && count($trading_crypto_spot_place_order_request) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter trading_crypto_spot_place_order_request when calling cryptoSpotPreviewOrder' - ); - } - - - $resourcePath = '/accounts/{accountId}/trading/crypto/spot/previewOrder'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (isset($trading_crypto_spot_place_order_request)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_crypto_spot_place_order_request)); - } else { - $httpBody = $trading_crypto_spot_place_order_request; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'POST'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation cryptoSpotQuote - * - * Get a cryptocurrency spot market quote - * - * Gets a quote for the specified account. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param string $base base (required) - * @param string $quote quote (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotQuote'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\CryptoSpotQuote|\SnapTrade\Model\Model400FailedRequestResponse - */ - public function cryptoSpotQuote( - $user_id, - $user_secret, - $account_id, - $base, - $quote, - - string $contentType = self::contentTypes['cryptoSpotQuote'][0] - ) - { - - list($response) = $this->cryptoSpotQuoteWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); - return $response; - } - - /** - * Operation cryptoSpotQuoteWithHttpInfo - * - * Get a cryptocurrency spot market quote - * - * Gets a quote for the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (required) - * @param string $quote (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotQuote'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\CryptoSpotQuote|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function cryptoSpotQuoteWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, string $contentType = self::contentTypes['cryptoSpotQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotQuoteRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->cryptoSpotQuoteWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $base, - $quote, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\CryptoSpotQuote' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\CryptoSpotQuote' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\CryptoSpotQuote', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\CryptoSpotQuote'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\CryptoSpotQuote', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation cryptoSpotQuoteAsync - * - * Get a cryptocurrency spot market quote - * - * Gets a quote for the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (required) - * @param string $quote (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotQuote'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function cryptoSpotQuoteAsync( - $user_id, - $user_secret, - $account_id, - $base, - $quote, - - string $contentType = self::contentTypes['cryptoSpotQuote'][0] - ) - { - - return $this->cryptoSpotQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation cryptoSpotQuoteAsyncWithHttpInfo - * - * Get a cryptocurrency spot market quote - * - * Gets a quote for the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (required) - * @param string $quote (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotQuote'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function cryptoSpotQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, string $contentType = self::contentTypes['cryptoSpotQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\CryptoSpotQuote'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotQuoteRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'cryptoSpotQuote' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (required) - * @param string $quote (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotQuote'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function cryptoSpotQuoteRequest($user_id, $user_secret, $account_id, $base, $quote, string $contentType = self::contentTypes['cryptoSpotQuote'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling cryptoSpotQuote' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling cryptoSpotQuote' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling cryptoSpotQuote' - ); - } - // Check if $base is a string - if ($base !== SENTINEL_VALUE && !is_string($base)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); - } - // verify the required parameter 'base' is set - if ($base === SENTINEL_VALUE || (is_array($base) && count($base) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter base when calling cryptoSpotQuote' - ); - } - // Check if $quote is a string - if ($quote !== SENTINEL_VALUE && !is_string($quote)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); - } - // verify the required parameter 'quote' is set - if ($quote === SENTINEL_VALUE || (is_array($quote) && count($quote) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter quote when calling cryptoSpotQuote' - ); - } - - - $resourcePath = '/accounts/{accountId}/trading/crypto/spot/quote'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($base !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $base, - 'base', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($quote !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $quote, - 'quote', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'GET'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation cryptoSpotSymbols - * - * Search crypto spot symbols - * - * Searches cryptocurrency spot symbols accessible to the specified account. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param string $base base (optional) - * @param string $quote quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotSymbols'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\TradingCryptoSpotSymbols200Response|\SnapTrade\Model\Model400FailedRequestResponse - */ - public function cryptoSpotSymbols( - $user_id, - $user_secret, - $account_id, - $base = SENTINEL_VALUE, - $quote = SENTINEL_VALUE, - - string $contentType = self::contentTypes['cryptoSpotSymbols'][0] - ) - { - - list($response) = $this->cryptoSpotSymbolsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); - return $response; - } - - /** - * Operation cryptoSpotSymbolsWithHttpInfo - * - * Search crypto spot symbols - * - * Searches cryptocurrency spot symbols accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotSymbols'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\TradingCryptoSpotSymbols200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function cryptoSpotSymbolsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['cryptoSpotSymbols'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotSymbolsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->cryptoSpotSymbolsWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $base, - $quote, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\TradingCryptoSpotSymbols200Response' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\TradingCryptoSpotSymbols200Response' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingCryptoSpotSymbols200Response', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\TradingCryptoSpotSymbols200Response'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\TradingCryptoSpotSymbols200Response', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation cryptoSpotSymbolsAsync - * - * Search crypto spot symbols - * - * Searches cryptocurrency spot symbols accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotSymbols'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function cryptoSpotSymbolsAsync( - $user_id, - $user_secret, - $account_id, - $base = SENTINEL_VALUE, - $quote = SENTINEL_VALUE, - - string $contentType = self::contentTypes['cryptoSpotSymbols'][0] - ) - { - - return $this->cryptoSpotSymbolsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation cryptoSpotSymbolsAsyncWithHttpInfo - * - * Search crypto spot symbols - * - * Searches cryptocurrency spot symbols accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotSymbols'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function cryptoSpotSymbolsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['cryptoSpotSymbols'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\TradingCryptoSpotSymbols200Response'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->cryptoSpotSymbolsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'cryptoSpotSymbols' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cryptoSpotSymbols'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function cryptoSpotSymbolsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['cryptoSpotSymbols'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling cryptoSpotSymbols' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling cryptoSpotSymbols' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling cryptoSpotSymbols' - ); - } - // Check if $base is a string - if ($base !== SENTINEL_VALUE && !is_string($base)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); - } - // Check if $quote is a string - if ($quote !== SENTINEL_VALUE && !is_string($quote)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); - } - - - $resourcePath = '/accounts/{accountId}/trading/crypto/spot/symbols'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($base !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $base, - 'base', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } - if ($quote !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $quote, - 'quote', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'GET'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 95230eb..88cfcbd 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -62,9 +62,15 @@ class TradingApi extends \SnapTrade\CustomApi /** @var string[] $contentTypes **/ public const contentTypes = [ + 'cancelOrder' => [ + 'application/json', + ], 'cancelUserAccountOrder' => [ 'application/json', ], + 'getCryptocurrencyPairQuote' => [ + 'application/json', + ], 'getOrderImpact' => [ 'application/json', ], @@ -80,9 +86,18 @@ class TradingApi extends \SnapTrade\CustomApi 'placeOrder' => [ 'application/json', ], + 'placeSimpleOrder' => [ + 'application/json', + ], + 'previewSimpleOrder' => [ + 'application/json', + ], 'replaceOrder' => [ 'application/json', ], + 'searchCryptocurrencyPairInstruments' => [ + 'application/json', + ], ]; /** @@ -154,62 +169,59 @@ private function setRequestBodyProperty(&$body, $property, $value) { } /** - * Operation cancelUserAccountOrder + * Operation cancelOrder * - * Cancel order + * Cancel an order. * - * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. + * Cancels an order in the specified account. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request trading_cancel_user_account_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation + * @param string $brokerage_order_id brokerage_order_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse + * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse */ - public function cancelUserAccountOrder( - + public function cancelOrder( $user_id, $user_secret, $account_id, - $brokerage_order_id = SENTINEL_VALUE, - string $contentType = self::contentTypes['cancelUserAccountOrder'][0] + $brokerage_order_id, + + string $contentType = self::contentTypes['cancelOrder'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); - $trading_cancel_user_account_order_request = $_body; - list($response) = $this->cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); + list($response) = $this->cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); return $response; } /** - * Operation cancelUserAccountOrderWithHttpInfo + * Operation cancelOrderWithHttpInfo * - * Cancel order + * Cancel an order. * - * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. + * Cancels an order in the specified account. * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation + * @param string $brokerage_order_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['cancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelOrderRequest($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); try { $options = $this->createHttpClientOption(); @@ -221,11 +233,11 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->cancelUserAccountOrderWithHttpInfo( + return $this->cancelOrderWithHttpInfo( $user_id, $user_secret, $account_id, - $trading_cancel_user_account_order_request, + $brokerage_order_id, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -263,17 +275,17 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -292,24 +304,9 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco $response->getStatusCode(), $response->getHeaders() ]; - case 500: - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -330,7 +327,7 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\OrderUpdatedResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -343,49 +340,38 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco ); $e->setResponseObject($data); break; - case 500: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model500UnexpectedExceptionResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; } throw $e; } } /** - * Operation cancelUserAccountOrderAsync + * Operation cancelOrderAsync * - * Cancel order + * Cancel an order. * - * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. + * Cancels an order in the specified account. * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation + * @param string $brokerage_order_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function cancelUserAccountOrderAsync( - + public function cancelOrderAsync( $user_id, $user_secret, $account_id, - $brokerage_order_id = SENTINEL_VALUE, - string $contentType = self::contentTypes['cancelUserAccountOrder'][0] + $brokerage_order_id, + + string $contentType = self::contentTypes['cancelOrder'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); - $trading_cancel_user_account_order_request = $_body; - return $this->cancelUserAccountOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType) + return $this->cancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType) ->then( function ($response) { return $response[0]; @@ -394,28 +380,28 @@ function ($response) { } /** - * Operation cancelUserAccountOrderAsyncWithHttpInfo + * Operation cancelOrderAsyncWithHttpInfo * - * Cancel order + * Cancel an order. * - * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. + * Cancels an order in the specified account. * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation + * @param string $brokerage_order_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function cancelUserAccountOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function cancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['cancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelOrderRequest($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -454,18 +440,18 @@ function ($exception) { } /** - * Create request for operation 'cancelUserAccountOrder' + * Create request for operation 'cancelOrder' * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation + * @param string $brokerage_order_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0]) + public function cancelOrderRequest($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['cancelOrder'][0]) { // Check if $user_id is a string @@ -475,7 +461,7 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling cancelUserAccountOrder' + 'Missing the required parameter user_id when calling cancelOrder' ); } // Check if $user_secret is a string @@ -485,7 +471,7 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling cancelUserAccountOrder' + 'Missing the required parameter user_secret when calling cancelOrder' ); } // Check if $account_id is a string @@ -495,26 +481,22 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i // verify the required parameter 'account_id' is set if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling cancelUserAccountOrder' + 'Missing the required parameter account_id when calling cancelOrder' ); } - if ($trading_cancel_user_account_order_request !== SENTINEL_VALUE) { - if (!($trading_cancel_user_account_order_request instanceof \SnapTrade\Model\TradingCancelUserAccountOrderRequest)) { - if (!is_array($trading_cancel_user_account_order_request)) - throw new \InvalidArgumentException('"trading_cancel_user_account_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCancelUserAccountOrderRequest TradingApi.cancelUserAccountOrder.'); - else - $trading_cancel_user_account_order_request = new \SnapTrade\Model\TradingCancelUserAccountOrderRequest($trading_cancel_user_account_order_request); - } + // Check if $brokerage_order_id is a string + if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); } - // verify the required parameter 'trading_cancel_user_account_order_request' is set - if ($trading_cancel_user_account_order_request === SENTINEL_VALUE || (is_array($trading_cancel_user_account_order_request) && count($trading_cancel_user_account_order_request) === 0)) { + // verify the required parameter 'brokerage_order_id' is set + if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter trading_cancel_user_account_order_request when calling cancelUserAccountOrder' + 'Missing the required parameter brokerage_order_id when calling cancelOrder' ); } - $resourcePath = '/accounts/{accountId}/orders/cancel'; + $resourcePath = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/cancel'; $formParams = []; $queryParams = []; $headerParams = []; @@ -553,6 +535,14 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i $resourcePath ); } + // path params + if ($brokerage_order_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'brokerageOrderId' . '}', + ObjectSerializer::toPathValue($brokerage_order_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -562,14 +552,7 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i ); // for model (json/xml) - if (isset($trading_cancel_user_account_order_request)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_cancel_user_account_order_request)); - } else { - $httpBody = $trading_cancel_user_account_order_request; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -637,72 +620,59 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i } /** - * Operation getOrderImpact + * Operation cancelUserAccountOrder * - * Check order impact + * Cancel order * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request trading_cancel_user_account_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse */ - public function getOrderImpact( + public function cancelUserAccountOrder( - $account_id, - $action, - $universal_symbol_id, - $order_type, - $time_in_force, $user_id, $user_secret, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['getOrderImpact'][0] + $account_id, + $brokerage_order_id = SENTINEL_VALUE, + string $contentType = self::contentTypes['cancelUserAccountOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form = $_body; + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); + $trading_cancel_user_account_order_request = $_body; - list($response) = $this->getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType); + list($response) = $this->cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); return $response; } /** - * Operation getOrderImpactWithHttpInfo + * Operation cancelUserAccountOrderWithHttpInfo * - * Check order impact + * Cancel order * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -717,10 +687,11 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->getOrderImpactWithHttpInfo( + return $this->cancelUserAccountOrderWithHttpInfo( $user_id, $user_secret, - $manual_trade_form, + $account_id, + $trading_cancel_user_account_order_request, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -758,17 +729,17 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade switch($statusCode) { case 200: - if ('\SnapTrade\Model\ManualTradeAndImpact' === '\SplFileObject') { + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\ManualTradeAndImpact' !== 'string') { + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\ManualTradeAndImpact', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -787,24 +758,24 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade $response->getStatusCode(), $response->getHeaders() ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } - $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; + $returnType = '\SnapTrade\Model\AccountOrderRecord'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -825,7 +796,7 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\ManualTradeAndImpact', + '\SnapTrade\Model\AccountOrderRecord', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -838,10 +809,10 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade ); $e->setResponseObject($data); break; - case 403: + case 500: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -852,49 +823,35 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade } /** - * Operation getOrderImpactAsync + * Operation cancelUserAccountOrderAsync * - * Check order impact + * Cancel order * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOrderImpactAsync( + public function cancelUserAccountOrderAsync( - $account_id, - $action, - $universal_symbol_id, - $order_type, - $time_in_force, $user_id, $user_secret, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['getOrderImpact'][0] + $account_id, + $brokerage_order_id = SENTINEL_VALUE, + string $contentType = self::contentTypes['cancelUserAccountOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form = $_body; + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); + $trading_cancel_user_account_order_request = $_body; - return $this->getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType) + return $this->cancelUserAccountOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType) ->then( function ($response) { return $response[0]; @@ -903,24 +860,25 @@ function ($response) { } /** - * Operation getOrderImpactAsyncWithHttpInfo + * Operation cancelUserAccountOrderAsyncWithHttpInfo * - * Check order impact + * Cancel order * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function cancelUserAccountOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -962,17 +920,18 @@ function ($exception) { } /** - * Create request for operation 'getOrderImpact' + * Create request for operation 'cancelUserAccountOrder' * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0]) + public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0]) { // Check if $user_id is a string @@ -982,7 +941,7 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getOrderImpact' + 'Missing the required parameter user_id when calling cancelUserAccountOrder' ); } // Check if $user_secret is a string @@ -992,26 +951,36 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getOrderImpact' + 'Missing the required parameter user_secret when calling cancelUserAccountOrder' ); } - if ($manual_trade_form !== SENTINEL_VALUE) { - if (!($manual_trade_form instanceof \SnapTrade\Model\ManualTradeForm)) { - if (!is_array($manual_trade_form)) - throw new \InvalidArgumentException('"manual_trade_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeForm TradingApi.getOrderImpact.'); + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling cancelUserAccountOrder' + ); + } + if ($trading_cancel_user_account_order_request !== SENTINEL_VALUE) { + if (!($trading_cancel_user_account_order_request instanceof \SnapTrade\Model\TradingCancelUserAccountOrderRequest)) { + if (!is_array($trading_cancel_user_account_order_request)) + throw new \InvalidArgumentException('"trading_cancel_user_account_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCancelUserAccountOrderRequest TradingApi.cancelUserAccountOrder.'); else - $manual_trade_form = new \SnapTrade\Model\ManualTradeForm($manual_trade_form); + $trading_cancel_user_account_order_request = new \SnapTrade\Model\TradingCancelUserAccountOrderRequest($trading_cancel_user_account_order_request); } } - // verify the required parameter 'manual_trade_form' is set - if ($manual_trade_form === SENTINEL_VALUE || (is_array($manual_trade_form) && count($manual_trade_form) === 0)) { + // verify the required parameter 'trading_cancel_user_account_order_request' is set + if ($trading_cancel_user_account_order_request === SENTINEL_VALUE || (is_array($trading_cancel_user_account_order_request) && count($trading_cancel_user_account_order_request) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form when calling getOrderImpact' + 'Missing the required parameter trading_cancel_user_account_order_request when calling cancelUserAccountOrder' ); } - $resourcePath = '/trade/impact'; + $resourcePath = '/accounts/{accountId}/orders/cancel'; $formParams = []; $queryParams = []; $headerParams = []; @@ -1042,6 +1011,14 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form } + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -1051,12 +1028,12 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form ); // for model (json/xml) - if (isset($manual_trade_form)) { + if (isset($trading_cancel_user_account_order_request)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_cancel_user_account_order_request)); } else { - $httpBody = $manual_trade_form; + $httpBody = $trading_cancel_user_account_order_request; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -1126,59 +1103,56 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form } /** - * Operation getUserAccountQuotes + * Operation getCryptocurrencyPairQuote * - * Get symbol quotes + * Get cryptocurrency pair quote * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Gets a quote for the specified account. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) * @param string $account_id account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * @param string $instrument_symbol instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse + * @return \SnapTrade\Model\CryptocurrencyPairQuote|\SnapTrade\Model\Model400FailedRequestResponse */ - public function getUserAccountQuotes( + public function getCryptocurrencyPairQuote( $user_id, $user_secret, - $symbols, $account_id, - $use_ticker = SENTINEL_VALUE, + $instrument_symbol, - string $contentType = self::contentTypes['getUserAccountQuotes'][0] + string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0] ) { - list($response) = $this->getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + list($response) = $this->getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); return $response; } /** - * Operation getUserAccountQuotesWithHttpInfo + * Operation getCryptocurrencyPairQuoteWithHttpInfo * - * Get symbol quotes + * Get cryptocurrency pair quote * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Gets a quote for the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\CryptocurrencyPairQuote|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config); @@ -1193,12 +1167,11 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->getUserAccountQuotesWithHttpInfo( + return $this->getCryptocurrencyPairQuoteWithHttpInfo( $user_id, $user_secret, - $symbols, $account_id, - $use_ticker, + $instrument_symbol, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -1236,38 +1209,38 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol switch($statusCode) { case 200: - if ('\SnapTrade\Model\SymbolsQuotesInner[]' === '\SplFileObject') { + if ('\SnapTrade\Model\CryptocurrencyPairQuote' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\SymbolsQuotesInner[]' !== 'string') { + if ('\SnapTrade\Model\CryptocurrencyPairQuote' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\SymbolsQuotesInner[]', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\CryptocurrencyPairQuote', []), $response->getStatusCode(), $response->getHeaders() ]; - case 500: - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } - $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; + $returnType = '\SnapTrade\Model\CryptocurrencyPairQuote'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -1288,15 +1261,15 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\SymbolsQuotesInner[]', + '\SnapTrade\Model\CryptocurrencyPairQuote', $e->getResponseHeaders() ); $e->setResponseObject($data); break; - case 500: + case 400: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + '\SnapTrade\Model\Model400FailedRequestResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -1307,34 +1280,32 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol } /** - * Operation getUserAccountQuotesAsync + * Operation getCryptocurrencyPairQuoteAsync * - * Get symbol quotes + * Get cryptocurrency pair quote * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Gets a quote for the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getUserAccountQuotesAsync( + public function getCryptocurrencyPairQuoteAsync( $user_id, $user_secret, - $symbols, $account_id, - $use_ticker = SENTINEL_VALUE, + $instrument_symbol, - string $contentType = self::contentTypes['getUserAccountQuotes'][0] + string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0] ) { - return $this->getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType) + return $this->getCryptocurrencyPairQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, $contentType) ->then( function ($response) { return $response[0]; @@ -1343,26 +1314,25 @@ function ($response) { } /** - * Operation getUserAccountQuotesAsyncWithHttpInfo + * Operation getCryptocurrencyPairQuoteAsyncWithHttpInfo * - * Get symbol quotes + * Get cryptocurrency pair quote * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Gets a quote for the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getCryptocurrencyPairQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + $returnType = '\SnapTrade\Model\CryptocurrencyPairQuote'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config); @@ -1404,19 +1374,18 @@ function ($exception) { } /** - * Create request for operation 'getUserAccountQuotes' + * Create request for operation 'getCryptocurrencyPairQuote' * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountQuotes'][0]) + public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0]) { // Check if $user_id is a string @@ -1426,7 +1395,7 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getUserAccountQuotes' + 'Missing the required parameter user_id when calling getCryptocurrencyPairQuote' ); } // Check if $user_secret is a string @@ -1436,17 +1405,7 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getUserAccountQuotes' - ); - } - // Check if $symbols is a string - if ($symbols !== SENTINEL_VALUE && !is_string($symbols)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($symbols, true), gettype($symbols))); - } - // verify the required parameter 'symbols' is set - if ($symbols === SENTINEL_VALUE || (is_array($symbols) && count($symbols) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter symbols when calling getUserAccountQuotes' + 'Missing the required parameter user_secret when calling getCryptocurrencyPairQuote' ); } // Check if $account_id is a string @@ -1456,12 +1415,22 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a // verify the required parameter 'account_id' is set if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling getUserAccountQuotes' + 'Missing the required parameter account_id when calling getCryptocurrencyPairQuote' + ); + } + // Check if $instrument_symbol is a string + if ($instrument_symbol !== SENTINEL_VALUE && !is_string($instrument_symbol)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($instrument_symbol, true), gettype($instrument_symbol))); + } + // verify the required parameter 'instrument_symbol' is set + if ($instrument_symbol === SENTINEL_VALUE || (is_array($instrument_symbol) && count($instrument_symbol) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter instrument_symbol when calling getCryptocurrencyPairQuote' ); } - $resourcePath = '/accounts/{accountId}/quotes'; + $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote'; $formParams = []; $queryParams = []; $headerParams = []; @@ -1490,28 +1459,6 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a true // required ) ?? []); } - if ($symbols !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $symbols, - 'symbols', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($use_ticker !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $use_ticker, - 'use_ticker', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } // path params @@ -1522,6 +1469,14 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a $resourcePath ); } + // path params + if ($instrument_symbol !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'instrumentSymbol' . '}', + ObjectSerializer::toPathValue($instrument_symbol), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -1599,77 +1554,72 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a } /** - * Operation placeBracketOrder + * Operation getOrderImpact * - * Place a Bracket Order + * Check order impact * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * - * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse */ - public function placeBracketOrder( + public function getOrderImpact( + $account_id, $action, - $instrument, + $universal_symbol_id, $order_type, $time_in_force, - $stop_loss, - $take_profit, - $account_id, $user_id, $user_secret, - $symbol = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeBracketOrder'][0] + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['getOrderImpact'][0] ) { $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); - $this->setRequestBodyProperty($_body, "take_profit", $take_profit); - $manual_trade_form_bracket = $_body; + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form = $_body; - list($response) = $this->placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + list($response) = $this->getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType); return $response; } /** - * Operation placeBracketOrderWithHttpInfo + * Operation getOrderImpactWithHttpInfo * - * Place a Bracket Order + * Check order impact * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * - * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -1684,11 +1634,10 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeBracketOrderWithHttpInfo( - $account_id, + return $this->getOrderImpactWithHttpInfo( $user_id, $user_secret, - $manual_trade_form_bracket, + $manual_trade_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -1726,17 +1675,17 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\ManualTradeAndImpact' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\ManualTradeAndImpact' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\ManualTradeAndImpact', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -1772,7 +1721,7 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -1793,7 +1742,7 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\ManualTradeAndImpact', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -1820,53 +1769,2460 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre } /** - * Operation placeBracketOrderAsync + * Operation getOrderImpactAsync * - * Place a Bracket Order + * Check order impact + * + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderImpactAsync( + + $account_id, + $action, + $universal_symbol_id, + $order_type, + $time_in_force, + $user_id, + $user_secret, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['getOrderImpact'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form = $_body; + + return $this->getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderImpactAsyncWithHttpInfo + * + * Check order impact + * + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderImpact' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getOrderImpact' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getOrderImpact' + ); + } + if ($manual_trade_form !== SENTINEL_VALUE) { + if (!($manual_trade_form instanceof \SnapTrade\Model\ManualTradeForm)) { + if (!is_array($manual_trade_form)) + throw new \InvalidArgumentException('"manual_trade_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeForm TradingApi.getOrderImpact.'); + else + $manual_trade_form = new \SnapTrade\Model\ManualTradeForm($manual_trade_form); + } + } + // verify the required parameter 'manual_trade_form' is set + if ($manual_trade_form === SENTINEL_VALUE || (is_array($manual_trade_form) && count($manual_trade_form) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter manual_trade_form when calling getOrderImpact' + ); + } + + + $resourcePath = '/trade/impact'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($manual_trade_form)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form)); + } else { + $httpBody = $manual_trade_form; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation getUserAccountQuotes + * + * Get symbol quotes + * + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse + */ + public function getUserAccountQuotes( + $user_id, + $user_secret, + $symbols, + $account_id, + $use_ticker = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getUserAccountQuotes'][0] + ) + { + + list($response) = $this->getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + return $response; + } + + /** + * Operation getUserAccountQuotesWithHttpInfo + * + * Get symbol quotes + * + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->getUserAccountQuotesWithHttpInfo( + $user_id, + $user_secret, + $symbols, + $account_id, + $use_ticker, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\SymbolsQuotesInner[]' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\SymbolsQuotesInner[]' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\SymbolsQuotesInner[]', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\SymbolsQuotesInner[]', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getUserAccountQuotesAsync + * + * Get symbol quotes + * + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountQuotesAsync( + $user_id, + $user_secret, + $symbols, + $account_id, + $use_ticker = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getUserAccountQuotes'][0] + ) + { + + return $this->getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getUserAccountQuotesAsyncWithHttpInfo + * + * Get symbol quotes + * + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getUserAccountQuotes' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountQuotes'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getUserAccountQuotes' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getUserAccountQuotes' + ); + } + // Check if $symbols is a string + if ($symbols !== SENTINEL_VALUE && !is_string($symbols)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($symbols, true), gettype($symbols))); + } + // verify the required parameter 'symbols' is set + if ($symbols === SENTINEL_VALUE || (is_array($symbols) && count($symbols) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter symbols when calling getUserAccountQuotes' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getUserAccountQuotes' + ); + } + + + $resourcePath = '/accounts/{accountId}/quotes'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($symbols !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $symbols, + 'symbols', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($use_ticker !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $use_ticker, + 'use_ticker', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation placeBracketOrder + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + */ + public function placeBracketOrder( + + $action, + $instrument, + $order_type, + $time_in_force, + $stop_loss, + $take_profit, + $account_id, + $user_id, + $user_secret, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeBracketOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); + $this->setRequestBodyProperty($_body, "take_profit", $take_profit); + $manual_trade_form_bracket = $_body; + + list($response) = $this->placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + return $response; + } + + /** + * Operation placeBracketOrderWithHttpInfo + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->placeBracketOrderWithHttpInfo( + $account_id, + $user_id, + $user_secret, + $manual_trade_form_bracket, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation placeBracketOrderAsync + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeBracketOrderAsync( + + $action, + $instrument, + $order_type, + $time_in_force, + $stop_loss, + $take_profit, + $account_id, + $user_id, + $user_secret, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeBracketOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); + $this->setRequestBodyProperty($_body, "take_profit", $take_profit); + $manual_trade_form_bracket = $_body; + + return $this->placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation placeBracketOrderAsyncWithHttpInfo + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'placeBracketOrder' + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0]) + { + + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling placeBracketOrder' + ); + } + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling placeBracketOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling placeBracketOrder' + ); + } + if ($manual_trade_form_bracket !== SENTINEL_VALUE) { + if (!($manual_trade_form_bracket instanceof \SnapTrade\Model\ManualTradeFormBracket)) { + if (!is_array($manual_trade_form_bracket)) + throw new \InvalidArgumentException('"manual_trade_form_bracket" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormBracket TradingApi.placeBracketOrder.'); + else + $manual_trade_form_bracket = new \SnapTrade\Model\ManualTradeFormBracket($manual_trade_form_bracket); + } + } + // verify the required parameter 'manual_trade_form_bracket' is set + if ($manual_trade_form_bracket === SENTINEL_VALUE || (is_array($manual_trade_form_bracket) && count($manual_trade_form_bracket) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter manual_trade_form_bracket when calling placeBracketOrder' + ); + } + + + $resourcePath = '/accounts/{accountId}/trading/bracket'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($manual_trade_form_bracket)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_bracket)); + } else { + $httpBody = $manual_trade_form_bracket; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation placeForceOrder + * + * Place order + * + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + */ + public function placeForceOrder( + + $account_id, + $action, + $order_type, + $time_in_force, + $user_id, + $user_secret, + $universal_symbol_id = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeForceOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form_with_options = $_body; + + list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + return $response; + } + + /** + * Operation placeForceOrderWithHttpInfo + * + * Place order + * + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->placeForceOrderWithHttpInfo( + $user_id, + $user_secret, + $manual_trade_form_with_options, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation placeForceOrderAsync + * + * Place order + * + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeForceOrderAsync( + + $account_id, + $action, + $order_type, + $time_in_force, + $user_id, + $user_secret, + $universal_symbol_id = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeForceOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form_with_options = $_body; + + return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation placeForceOrderAsyncWithHttpInfo + * + * Place order + * + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'placeForceOrder' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling placeForceOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling placeForceOrder' + ); + } + if ($manual_trade_form_with_options !== SENTINEL_VALUE) { + if (!($manual_trade_form_with_options instanceof \SnapTrade\Model\ManualTradeFormWithOptions)) { + if (!is_array($manual_trade_form_with_options)) + throw new \InvalidArgumentException('"manual_trade_form_with_options" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormWithOptions TradingApi.placeForceOrder.'); + else + $manual_trade_form_with_options = new \SnapTrade\Model\ManualTradeFormWithOptions($manual_trade_form_with_options); + } + } + // verify the required parameter 'manual_trade_form_with_options' is set + if ($manual_trade_form_with_options === SENTINEL_VALUE || (is_array($manual_trade_form_with_options) && count($manual_trade_form_with_options) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter manual_trade_form_with_options when calling placeForceOrder' + ); + } + + + $resourcePath = '/trade/place'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($manual_trade_form_with_options)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_with_options)); + } else { + $httpBody = $manual_trade_form_with_options; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation placeOrder + * + * Place checked order + * + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function placeOrder( + $trade_id, + $user_id, + $user_secret, + $wait_to_confirm = SENTINEL_VALUE, + + string $contentType = self::contentTypes['placeOrder'][0] + ) + { + $_body = null; + $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); + $validated_trade_body = $_body; + + list($response) = $this->placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + return $response; + } + + /** + * Operation placeOrderWithHttpInfo + * + * Place checked order + * + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->placeOrderWithHttpInfo( + $trade_id, + $user_id, + $user_secret, + $validated_trade_body, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation placeOrderAsync + * + * Place checked order + * + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeOrderAsync( + $trade_id, + $user_id, + $user_secret, + $wait_to_confirm = SENTINEL_VALUE, + + string $contentType = self::contentTypes['placeOrder'][0] + ) + { + $_body = null; + $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); + $validated_trade_body = $_body; + + return $this->placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation placeOrderAsyncWithHttpInfo + * + * Place checked order + * + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'placeOrder' + * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body = SENTINEL_VALUE, string $contentType = self::contentTypes['placeOrder'][0]) + { + + // Check if $trade_id is a string + if ($trade_id !== SENTINEL_VALUE && !is_string($trade_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trade_id, true), gettype($trade_id))); + } + // verify the required parameter 'trade_id' is set + if ($trade_id === SENTINEL_VALUE || (is_array($trade_id) && count($trade_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter trade_id when calling placeOrder' + ); + } + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling placeOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling placeOrder' + ); + } + if ($validated_trade_body !== SENTINEL_VALUE) { + if (!($validated_trade_body instanceof \SnapTrade\Model\ValidatedTradeBody)) { + if (!is_array($validated_trade_body)) + throw new \InvalidArgumentException('"validated_trade_body" must be associative array or an instance of \SnapTrade\Model\ValidatedTradeBody TradingApi.placeOrder.'); + else + $validated_trade_body = new \SnapTrade\Model\ValidatedTradeBody($validated_trade_body); + } + } + + + $resourcePath = '/trade/{tradeId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($trade_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'tradeId' . '}', + ObjectSerializer::toPathValue($trade_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($validated_trade_body)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($validated_trade_body)); + } else { + $httpBody = $validated_trade_body; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation placeSimpleOrder + * + * Place order + * + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request trading_place_simple_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function placeSimpleOrder( + + $instrument, + $side, + $type, + $time_in_force, + $amount, + $user_id, + $user_secret, + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeSimpleOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $trading_place_simple_order_request = $_body; + + list($response) = $this->placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); + return $response; + } + + /** + * Operation placeSimpleOrderWithHttpInfo + * + * Place order + * + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->placeSimpleOrderWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $trading_place_simple_order_request, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\OrderUpdatedResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation placeSimpleOrderAsync * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * Place order + * + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * - * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeBracketOrderAsync( + public function placeSimpleOrderAsync( - $action, $instrument, - $order_type, + $side, + $type, $time_in_force, - $stop_loss, - $take_profit, - $account_id, + $amount, $user_id, $user_secret, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeBracketOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeSimpleOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); - $this->setRequestBodyProperty($_body, "take_profit", $take_profit); - $manual_trade_form_bracket = $_body; - - return $this->placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType) + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $trading_place_simple_order_request = $_body; + + return $this->placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType) ->then( function ($response) { return $response[0]; @@ -1875,25 +4231,25 @@ function ($response) { } /** - * Operation placeBracketOrderAsyncWithHttpInfo + * Operation placeSimpleOrderAsyncWithHttpInfo * - * Place a Bracket Order + * Place order * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * - * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -1935,30 +4291,20 @@ function ($exception) { } /** - * Create request for operation 'placeBracketOrder' + * Create request for operation 'placeSimpleOrder' * - * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0]) + public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['placeSimpleOrder'][0]) { - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling placeBracketOrder' - ); - } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -1966,7 +4312,7 @@ public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $m // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeBracketOrder' + 'Missing the required parameter user_id when calling placeSimpleOrder' ); } // Check if $user_secret is a string @@ -1976,26 +4322,36 @@ public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $m // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeBracketOrder' + 'Missing the required parameter user_secret when calling placeSimpleOrder' ); } - if ($manual_trade_form_bracket !== SENTINEL_VALUE) { - if (!($manual_trade_form_bracket instanceof \SnapTrade\Model\ManualTradeFormBracket)) { - if (!is_array($manual_trade_form_bracket)) - throw new \InvalidArgumentException('"manual_trade_form_bracket" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormBracket TradingApi.placeBracketOrder.'); + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling placeSimpleOrder' + ); + } + if ($trading_place_simple_order_request !== SENTINEL_VALUE) { + if (!($trading_place_simple_order_request instanceof \SnapTrade\Model\TradingPlaceSimpleOrderRequest)) { + if (!is_array($trading_place_simple_order_request)) + throw new \InvalidArgumentException('"trading_place_simple_order_request" must be associative array or an instance of \SnapTrade\Model\TradingPlaceSimpleOrderRequest TradingApi.placeSimpleOrder.'); else - $manual_trade_form_bracket = new \SnapTrade\Model\ManualTradeFormBracket($manual_trade_form_bracket); + $trading_place_simple_order_request = new \SnapTrade\Model\TradingPlaceSimpleOrderRequest($trading_place_simple_order_request); } } - // verify the required parameter 'manual_trade_form_bracket' is set - if ($manual_trade_form_bracket === SENTINEL_VALUE || (is_array($manual_trade_form_bracket) && count($manual_trade_form_bracket) === 0)) { + // verify the required parameter 'trading_place_simple_order_request' is set + if ($trading_place_simple_order_request === SENTINEL_VALUE || (is_array($trading_place_simple_order_request) && count($trading_place_simple_order_request) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form_bracket when calling placeBracketOrder' + 'Missing the required parameter trading_place_simple_order_request when calling placeSimpleOrder' ); } - $resourcePath = '/accounts/{accountId}/trading/bracket'; + $resourcePath = '/accounts/{accountId}/trading/simple'; $formParams = []; $queryParams = []; $headerParams = []; @@ -2043,12 +4399,12 @@ public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $m ); // for model (json/xml) - if (isset($manual_trade_form_bracket)) { + if (isset($trading_place_simple_order_request)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_bracket)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_place_simple_order_request)); } else { - $httpBody = $manual_trade_form_bracket; + $httpBody = $trading_place_simple_order_request; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -2118,74 +4474,75 @@ public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $m } /** - * Operation placeForceOrder + * Operation previewSimpleOrder * - * Place order + * Preview order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Previews an order using the specified account. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request trading_place_simple_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse */ - public function placeForceOrder( + public function previewSimpleOrder( - $account_id, - $action, - $order_type, + $instrument, + $side, + $type, $time_in_force, + $amount, $user_id, $user_secret, - $universal_symbol_id = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeForceOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['previewSimpleOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form_with_options = $_body; - - list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $trading_place_simple_order_request = $_body; + + list($response) = $this->previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); return $response; } /** - * Operation placeForceOrderWithHttpInfo + * Operation previewSimpleOrderWithHttpInfo * - * Place order + * Preview order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Previews an order using the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -2200,10 +4557,11 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeForceOrderWithHttpInfo( + return $this->previewSimpleOrderWithHttpInfo( $user_id, $user_secret, - $manual_trade_form_with_options, + $account_id, + $trading_place_simple_order_request, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -2241,17 +4599,17 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\SimpleOrderPreview' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\SimpleOrderPreview' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\SimpleOrderPreview', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -2270,24 +4628,9 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad $response->getStatusCode(), $response->getHeaders() ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\SimpleOrderPreview'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -2308,23 +4651,15 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', + '\SnapTrade\Model\SimpleOrderPreview', $e->getResponseHeaders() ); $e->setResponseObject($data); break; - case 403: + case 400: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', + '\SnapTrade\Model\Model400FailedRequestResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -2335,51 +4670,51 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad } /** - * Operation placeForceOrderAsync + * Operation previewSimpleOrderAsync * - * Place order + * Preview order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Previews an order using the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeForceOrderAsync( + public function previewSimpleOrderAsync( - $account_id, - $action, - $order_type, + $instrument, + $side, + $type, $time_in_force, + $amount, $user_id, $user_secret, - $universal_symbol_id = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeForceOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['previewSimpleOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form_with_options = $_body; - - return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $trading_place_simple_order_request = $_body; + + return $this->previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType) ->then( function ($response) { return $response[0]; @@ -2388,24 +4723,25 @@ function ($response) { } /** - * Operation placeForceOrderAsyncWithHttpInfo + * Operation previewSimpleOrderAsyncWithHttpInfo * - * Place order + * Preview order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Previews an order using the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + $returnType = '\SnapTrade\Model\SimpleOrderPreview'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -2447,17 +4783,18 @@ function ($exception) { } /** - * Create request for operation 'placeForceOrder' + * Create request for operation 'previewSimpleOrder' * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0]) + public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['previewSimpleOrder'][0]) { // Check if $user_id is a string @@ -2467,7 +4804,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeForceOrder' + 'Missing the required parameter user_id when calling previewSimpleOrder' ); } // Check if $user_secret is a string @@ -2477,26 +4814,36 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeForceOrder' + 'Missing the required parameter user_secret when calling previewSimpleOrder' ); } - if ($manual_trade_form_with_options !== SENTINEL_VALUE) { - if (!($manual_trade_form_with_options instanceof \SnapTrade\Model\ManualTradeFormWithOptions)) { - if (!is_array($manual_trade_form_with_options)) - throw new \InvalidArgumentException('"manual_trade_form_with_options" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormWithOptions TradingApi.placeForceOrder.'); + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling previewSimpleOrder' + ); + } + if ($trading_place_simple_order_request !== SENTINEL_VALUE) { + if (!($trading_place_simple_order_request instanceof \SnapTrade\Model\TradingPlaceSimpleOrderRequest)) { + if (!is_array($trading_place_simple_order_request)) + throw new \InvalidArgumentException('"trading_place_simple_order_request" must be associative array or an instance of \SnapTrade\Model\TradingPlaceSimpleOrderRequest TradingApi.previewSimpleOrder.'); else - $manual_trade_form_with_options = new \SnapTrade\Model\ManualTradeFormWithOptions($manual_trade_form_with_options); + $trading_place_simple_order_request = new \SnapTrade\Model\TradingPlaceSimpleOrderRequest($trading_place_simple_order_request); } } - // verify the required parameter 'manual_trade_form_with_options' is set - if ($manual_trade_form_with_options === SENTINEL_VALUE || (is_array($manual_trade_form_with_options) && count($manual_trade_form_with_options) === 0)) { + // verify the required parameter 'trading_place_simple_order_request' is set + if ($trading_place_simple_order_request === SENTINEL_VALUE || (is_array($trading_place_simple_order_request) && count($trading_place_simple_order_request) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form_with_options when calling placeForceOrder' + 'Missing the required parameter trading_place_simple_order_request when calling previewSimpleOrder' ); } - $resourcePath = '/trade/place'; + $resourcePath = '/accounts/{accountId}/trading/simple/preview'; $formParams = []; $queryParams = []; $headerParams = []; @@ -2527,6 +4874,14 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for } + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -2536,12 +4891,12 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for ); // for model (json/xml) - if (isset($manual_trade_form_with_options)) { + if (isset($trading_place_simple_order_request)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_with_options)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_place_simple_order_request)); } else { - $httpBody = $manual_trade_form_with_options; + $httpBody = $trading_place_simple_order_request; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -2611,59 +4966,72 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for } /** - * Operation placeOrder + * Operation replaceOrder * - * Place checked order + * Replaces an order with a new one * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse */ - public function placeOrder( - $trade_id, + public function replaceOrder( + + $action, + $order_type, + $time_in_force, + $account_id, + $brokerage_order_id, $user_id, $user_secret, - $wait_to_confirm = SENTINEL_VALUE, - - string $contentType = self::contentTypes['placeOrder'][0] + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['replaceOrder'][0] ) { - $_body = null; - $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); - $validated_trade_body = $_body; + $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $manual_trade_replace_form = $_body; - list($response) = $this->placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + list($response) = $this->replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); return $response; } /** - * Operation placeOrderWithHttpInfo + * Operation replaceOrderWithHttpInfo * - * Place checked order + * Replaces an order with a new one * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -2678,11 +5046,12 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeOrderWithHttpInfo( - $trade_id, + return $this->replaceOrderWithHttpInfo( + $account_id, + $brokerage_order_id, $user_id, $user_secret, - $validated_trade_body, + $manual_trade_replace_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -2749,6 +5118,21 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid $response->getStatusCode(), $response->getHeaders() ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } $returnType = '\SnapTrade\Model\AccountOrderRecord'; @@ -2785,41 +5169,61 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid ); $e->setResponseObject($data); break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } } /** - * Operation placeOrderAsync + * Operation replaceOrderAsync * - * Place checked order + * Replaces an order with a new one * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeOrderAsync( - $trade_id, + public function replaceOrderAsync( + + $action, + $order_type, + $time_in_force, + $account_id, + $brokerage_order_id, $user_id, $user_secret, - $wait_to_confirm = SENTINEL_VALUE, - - string $contentType = self::contentTypes['placeOrder'][0] + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['replaceOrder'][0] ) { - $_body = null; - $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); - $validated_trade_body = $_body; + $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $manual_trade_replace_form = $_body; - return $this->placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType) + return $this->replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType) ->then( function ($response) { return $response[0]; @@ -2828,25 +5232,26 @@ function ($response) { } /** - * Operation placeOrderAsyncWithHttpInfo + * Operation replaceOrderAsyncWithHttpInfo * - * Place checked order + * Replaces an order with a new one * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -2888,28 +5293,39 @@ function ($exception) { } /** - * Create request for operation 'placeOrder' + * Create request for operation 'replaceOrder' * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body = SENTINEL_VALUE, string $contentType = self::contentTypes['placeOrder'][0]) + public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0]) { - // Check if $trade_id is a string - if ($trade_id !== SENTINEL_VALUE && !is_string($trade_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trade_id, true), gettype($trade_id))); + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling replaceOrder' + ); } - // verify the required parameter 'trade_id' is set - if ($trade_id === SENTINEL_VALUE || (is_array($trade_id) && count($trade_id) === 0)) { + // Check if $brokerage_order_id is a string + if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); + } + // verify the required parameter 'brokerage_order_id' is set + if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter trade_id when calling placeOrder' + 'Missing the required parameter brokerage_order_id when calling replaceOrder' ); } // Check if $user_id is a string @@ -2919,7 +5335,7 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeOrder' + 'Missing the required parameter user_id when calling replaceOrder' ); } // Check if $user_secret is a string @@ -2929,20 +5345,26 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeOrder' + 'Missing the required parameter user_secret when calling replaceOrder' ); } - if ($validated_trade_body !== SENTINEL_VALUE) { - if (!($validated_trade_body instanceof \SnapTrade\Model\ValidatedTradeBody)) { - if (!is_array($validated_trade_body)) - throw new \InvalidArgumentException('"validated_trade_body" must be associative array or an instance of \SnapTrade\Model\ValidatedTradeBody TradingApi.placeOrder.'); + if ($manual_trade_replace_form !== SENTINEL_VALUE) { + if (!($manual_trade_replace_form instanceof \SnapTrade\Model\ManualTradeReplaceForm)) { + if (!is_array($manual_trade_replace_form)) + throw new \InvalidArgumentException('"manual_trade_replace_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeReplaceForm TradingApi.replaceOrder.'); else - $validated_trade_body = new \SnapTrade\Model\ValidatedTradeBody($validated_trade_body); + $manual_trade_replace_form = new \SnapTrade\Model\ManualTradeReplaceForm($manual_trade_replace_form); } } + // verify the required parameter 'manual_trade_replace_form' is set + if ($manual_trade_replace_form === SENTINEL_VALUE || (is_array($manual_trade_replace_form) && count($manual_trade_replace_form) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter manual_trade_replace_form when calling replaceOrder' + ); + } - $resourcePath = '/trade/{tradeId}'; + $resourcePath = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace'; $formParams = []; $queryParams = []; $headerParams = []; @@ -2974,10 +5396,18 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // path params - if ($trade_id !== SENTINEL_VALUE) { + if ($account_id !== SENTINEL_VALUE) { $resourcePath = str_replace( - '{' . 'tradeId' . '}', - ObjectSerializer::toPathValue($trade_id), + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($brokerage_order_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'brokerageOrderId' . '}', + ObjectSerializer::toPathValue($brokerage_order_id), $resourcePath ); } @@ -2990,12 +5420,12 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ ); // for model (json/xml) - if (isset($validated_trade_body)) { + if (isset($manual_trade_replace_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($validated_trade_body)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_replace_form)); } else { - $httpBody = $validated_trade_body; + $httpBody = $manual_trade_replace_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -3048,7 +5478,7 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ $headers ); - $method = 'POST'; + $method = 'PATCH'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); @@ -3065,75 +5495,62 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ } /** - * Operation replaceOrder + * Operation searchCryptocurrencyPairInstruments * - * Replaces an order with a new one + * Search cryptocurrency pairs instruments * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Searches cryptocurrency pairs instruments accessible to the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param string $base base (optional) + * @param string $quote quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse */ - public function replaceOrder( - - $action, - $order_type, - $time_in_force, - $account_id, - $brokerage_order_id, + public function searchCryptocurrencyPairInstruments( $user_id, $user_secret, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['replaceOrder'][0] + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $manual_trade_replace_form = $_body; - list($response) = $this->replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + list($response) = $this->searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); return $response; } /** - * Operation replaceOrderWithHttpInfo + * Operation searchCryptocurrencyPairInstrumentsWithHttpInfo * - * Replaces an order with a new one + * Search cryptocurrency pairs instruments * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Searches cryptocurrency pairs instruments accessible to the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); try { $options = $this->createHttpClientOption(); @@ -3145,12 +5562,12 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->replaceOrderWithHttpInfo( - $account_id, - $brokerage_order_id, + return $this->searchCryptocurrencyPairInstrumentsWithHttpInfo( $user_id, $user_secret, - $manual_trade_replace_form, + $account_id, + $base, + $quote, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -3188,17 +5605,17 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -3217,24 +5634,9 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user $response->getStatusCode(), $response->getHeaders() ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -3255,7 +5657,7 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -3268,61 +5670,40 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user ); $e->setResponseObject($data); break; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; } throw $e; } } /** - * Operation replaceOrderAsync + * Operation searchCryptocurrencyPairInstrumentsAsync * - * Replaces an order with a new one + * Search cryptocurrency pairs instruments * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Searches cryptocurrency pairs instruments accessible to the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function replaceOrderAsync( - - $action, - $order_type, - $time_in_force, - $account_id, - $brokerage_order_id, + public function searchCryptocurrencyPairInstrumentsAsync( $user_id, $user_secret, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['replaceOrder'][0] + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $manual_trade_replace_form = $_body; - return $this->replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType) + return $this->searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) ->then( function ($response) { return $response[0]; @@ -3331,29 +5712,29 @@ function ($response) { } /** - * Operation replaceOrderAsyncWithHttpInfo + * Operation searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo * - * Replaces an order with a new one + * Search cryptocurrency pairs instruments * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Searches cryptocurrency pairs instruments accessible to the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -3392,41 +5773,21 @@ function ($exception) { } /** - * Create request for operation 'replaceOrder' + * Create request for operation 'searchCryptocurrencyPairInstruments' * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0]) + public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0]) { - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling replaceOrder' - ); - } - // Check if $brokerage_order_id is a string - if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); - } - // verify the required parameter 'brokerage_order_id' is set - if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter brokerage_order_id when calling replaceOrder' - ); - } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -3434,7 +5795,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling replaceOrder' + 'Missing the required parameter user_id when calling searchCryptocurrencyPairInstruments' ); } // Check if $user_secret is a string @@ -3444,26 +5805,30 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling replaceOrder' + 'Missing the required parameter user_secret when calling searchCryptocurrencyPairInstruments' ); } - if ($manual_trade_replace_form !== SENTINEL_VALUE) { - if (!($manual_trade_replace_form instanceof \SnapTrade\Model\ManualTradeReplaceForm)) { - if (!is_array($manual_trade_replace_form)) - throw new \InvalidArgumentException('"manual_trade_replace_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeReplaceForm TradingApi.replaceOrder.'); - else - $manual_trade_replace_form = new \SnapTrade\Model\ManualTradeReplaceForm($manual_trade_replace_form); - } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); } - // verify the required parameter 'manual_trade_replace_form' is set - if ($manual_trade_replace_form === SENTINEL_VALUE || (is_array($manual_trade_replace_form) && count($manual_trade_replace_form) === 0)) { + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_replace_form when calling replaceOrder' + 'Missing the required parameter account_id when calling searchCryptocurrencyPairInstruments' ); } + // Check if $base is a string + if ($base !== SENTINEL_VALUE && !is_string($base)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); + } + // Check if $quote is a string + if ($quote !== SENTINEL_VALUE && !is_string($quote)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); + } - $resourcePath = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace'; + $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs'; $formParams = []; $queryParams = []; $headerParams = []; @@ -3492,6 +5857,28 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, true // required ) ?? []); } + if ($base !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $base, + 'base', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($quote !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $quote, + 'quote', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } // path params @@ -3502,14 +5889,6 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $resourcePath ); } - // path params - if ($brokerage_order_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'brokerageOrderId' . '}', - ObjectSerializer::toPathValue($brokerage_order_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -3519,14 +5898,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, ); // for model (json/xml) - if (isset($manual_trade_replace_form)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_replace_form)); - } else { - $httpBody = $manual_trade_replace_form; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -3577,7 +5949,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $headers ); - $method = 'PATCH'; + $method = 'GET'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); diff --git a/lib/Client.php b/lib/Client.php index 6cdc634..b8de060 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -13,8 +13,6 @@ class Client public readonly \SnapTrade\Api\ConnectionsApi $connections; - public readonly \SnapTrade\Api\CryptoSpotTradingApi $cryptoSpotTrading; - public readonly \SnapTrade\Api\OptionsApi $options; public readonly \SnapTrade\Api\ReferenceDataApi $referenceData; @@ -50,7 +48,6 @@ public function __construct( $this->apiStatus = new \SnapTrade\Api\ApiStatusApi($config); $this->authentication = new \SnapTrade\Api\AuthenticationApi($config); $this->connections = new \SnapTrade\Api\ConnectionsApi($config); - $this->cryptoSpotTrading = new \SnapTrade\Api\CryptoSpotTradingApi($config); $this->options = new \SnapTrade\Api\OptionsApi($config); $this->referenceData = new \SnapTrade\Api\ReferenceDataApi($config); $this->trading = new \SnapTrade\Api\TradingApi($config); diff --git a/lib/Model/CryptocurrencyPair.php b/lib/Model/CryptocurrencyPair.php index 67f96af..aa0a8d0 100644 --- a/lib/Model/CryptocurrencyPair.php +++ b/lib/Model/CryptocurrencyPair.php @@ -30,7 +30,7 @@ * CryptocurrencyPair Class Doc Comment * * @category Class - * @description A cryptocurrency symbol. This is a unique identifier for a cryptocurrency. + * @description A cryptocurrency pair instrument. * @package SnapTrade * @implements \ArrayAccess */ @@ -51,6 +51,7 @@ class CryptocurrencyPair implements ModelInterface, ArrayAccess, \JsonSerializab * @var string[] */ protected static $openAPITypes = [ + 'symbol' => 'string', 'base' => 'string', 'quote' => 'string' ]; @@ -63,6 +64,7 @@ class CryptocurrencyPair implements ModelInterface, ArrayAccess, \JsonSerializab * @psalm-var array */ protected static $openAPIFormats = [ + 'symbol' => null, 'base' => null, 'quote' => null ]; @@ -73,7 +75,8 @@ class CryptocurrencyPair implements ModelInterface, ArrayAccess, \JsonSerializab * @var boolean[] */ protected static array $openAPINullables = [ - 'base' => false, + 'symbol' => false, + 'base' => false, 'quote' => false ]; @@ -163,6 +166,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ + 'symbol' => 'symbol', 'base' => 'base', 'quote' => 'quote' ]; @@ -173,6 +177,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ + 'symbol' => 'setSymbol', 'base' => 'setBase', 'quote' => 'setQuote' ]; @@ -183,6 +188,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ + 'symbol' => 'getSymbol', 'base' => 'getBase', 'quote' => 'getQuote' ]; @@ -244,6 +250,7 @@ public function getModelName() */ public function __construct(array $data = null) { + $this->setIfExists('symbol', $data ?? [], null); $this->setIfExists('base', $data ?? [], null); $this->setIfExists('quote', $data ?? [], null); } @@ -296,6 +303,35 @@ public function valid() } + /** + * Gets symbol + * + * @return string|null + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string|null $symbol Cryptocurrency pair instrument instrument symbol + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + /** * Gets base * diff --git a/lib/Model/CryptoSpotQuote.php b/lib/Model/CryptocurrencyPairQuote.php similarity index 98% rename from lib/Model/CryptoSpotQuote.php rename to lib/Model/CryptocurrencyPairQuote.php index 897c95e..fd6c5f3 100644 --- a/lib/Model/CryptoSpotQuote.php +++ b/lib/Model/CryptocurrencyPairQuote.php @@ -1,6 +1,6 @@ */ -class CryptoSpotQuote implements ModelInterface, ArrayAccess, \JsonSerializable +class CryptocurrencyPairQuote implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -42,7 +42,7 @@ class CryptoSpotQuote implements ModelInterface, ArrayAccess, \JsonSerializable * * @var string */ - protected static $openAPIModelName = 'CryptoSpotQuote'; + protected static $openAPIModelName = 'CryptocurrencyPairQuote'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/lib/Model/CryptoSpotOrderPreview.php b/lib/Model/SimpleOrderPreview.php similarity index 94% rename from lib/Model/CryptoSpotOrderPreview.php rename to lib/Model/SimpleOrderPreview.php index 1281b7c..0a43460 100644 --- a/lib/Model/CryptoSpotOrderPreview.php +++ b/lib/Model/SimpleOrderPreview.php @@ -1,6 +1,6 @@ */ -class CryptoSpotOrderPreview implements ModelInterface, ArrayAccess, \JsonSerializable +class SimpleOrderPreview implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -43,7 +43,7 @@ class CryptoSpotOrderPreview implements ModelInterface, ArrayAccess, \JsonSerial * * @var string */ - protected static $openAPIModelName = 'CryptoSpotOrderPreview'; + protected static $openAPIModelName = 'SimpleOrderPreview'; /** * Array of property to type mappings. Used for (de)serialization @@ -51,7 +51,7 @@ class CryptoSpotOrderPreview implements ModelInterface, ArrayAccess, \JsonSerial * @var string[] */ protected static $openAPITypes = [ - 'estimated_fee' => '\SnapTrade\Model\CryptoSpotOrderPreviewEstimatedFee' + 'estimated_fee' => '\SnapTrade\Model\SimpleOrderPreviewEstimatedFee' ]; /** @@ -286,7 +286,7 @@ public function valid() /** * Gets estimated_fee * - * @return \SnapTrade\Model\CryptoSpotOrderPreviewEstimatedFee|null + * @return \SnapTrade\Model\SimpleOrderPreviewEstimatedFee|null */ public function getEstimatedFee() { @@ -296,7 +296,7 @@ public function getEstimatedFee() /** * Sets estimated_fee * - * @param \SnapTrade\Model\CryptoSpotOrderPreviewEstimatedFee|null $estimated_fee estimated_fee + * @param \SnapTrade\Model\SimpleOrderPreviewEstimatedFee|null $estimated_fee estimated_fee * * @return self */ diff --git a/lib/Model/CryptoSpotOrderPreviewEstimatedFee.php b/lib/Model/SimpleOrderPreviewEstimatedFee.php similarity index 97% rename from lib/Model/CryptoSpotOrderPreviewEstimatedFee.php rename to lib/Model/SimpleOrderPreviewEstimatedFee.php index 946982b..a3c8976 100644 --- a/lib/Model/CryptoSpotOrderPreviewEstimatedFee.php +++ b/lib/Model/SimpleOrderPreviewEstimatedFee.php @@ -1,6 +1,6 @@ */ -class CryptoSpotOrderPreviewEstimatedFee implements ModelInterface, ArrayAccess, \JsonSerializable +class SimpleOrderPreviewEstimatedFee implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -43,7 +43,7 @@ class CryptoSpotOrderPreviewEstimatedFee implements ModelInterface, ArrayAccess, * * @var string */ - protected static $openAPIModelName = 'CryptoSpotOrderPreview_estimated_fee'; + protected static $openAPIModelName = 'SimpleOrderPreview_estimated_fee'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/lib/Model/TradingCryptoSpotCancelOrderRequest.php b/lib/Model/TradingCryptoSpotCancelOrderRequest.php deleted file mode 100644 index 5c3c6cc..0000000 --- a/lib/Model/TradingCryptoSpotCancelOrderRequest.php +++ /dev/null @@ -1,407 +0,0 @@ - - */ -class TradingCryptoSpotCancelOrderRequest implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Trading_cryptoSpotCancelOrder_request'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'brokerage_order_id' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'brokerage_order_id' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'brokerage_order_id' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'brokerage_order_id' => 'brokerage_order_id' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'brokerage_order_id' => 'setBrokerageOrderId' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'brokerage_order_id' => 'getBrokerageOrderId' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('brokerage_order_id', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['brokerage_order_id'] === null) { - $invalidProperties[] = "'brokerage_order_id' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets brokerage_order_id - * - * @return string - */ - public function getBrokerageOrderId() - { - return $this->container['brokerage_order_id']; - } - - /** - * Sets brokerage_order_id - * - * @param string $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. - * - * @return self - */ - public function setBrokerageOrderId($brokerage_order_id) - { - - if (is_null($brokerage_order_id)) { - throw new \InvalidArgumentException('non-nullable brokerage_order_id cannot be null'); - } - - $this->container['brokerage_order_id'] = $brokerage_order_id; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/lib/Model/TradingCryptoSpotPlaceOrderRequest.php b/lib/Model/TradingPlaceSimpleOrderRequest.php similarity index 94% rename from lib/Model/TradingCryptoSpotPlaceOrderRequest.php rename to lib/Model/TradingPlaceSimpleOrderRequest.php index 3a7b63d..5ce098e 100644 --- a/lib/Model/TradingCryptoSpotPlaceOrderRequest.php +++ b/lib/Model/TradingPlaceSimpleOrderRequest.php @@ -1,6 +1,6 @@ */ -class TradingCryptoSpotPlaceOrderRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class TradingPlaceSimpleOrderRequest implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -42,7 +42,7 @@ class TradingCryptoSpotPlaceOrderRequest implements ModelInterface, ArrayAccess, * * @var string */ - protected static $openAPIModelName = 'Trading_cryptoSpotPlaceOrder_request'; + protected static $openAPIModelName = 'Trading_placeSimpleOrder_request'; /** * Array of property to type mappings. Used for (de)serialization @@ -50,7 +50,7 @@ class TradingCryptoSpotPlaceOrderRequest implements ModelInterface, ArrayAccess, * @var string[] */ protected static $openAPITypes = [ - 'symbol' => '\SnapTrade\Model\CryptocurrencyPair', + 'instrument' => '\SnapTrade\Model\TradingInstrument', 'side' => '\SnapTrade\Model\ActionStrict', 'type' => 'string', 'time_in_force' => 'string', @@ -69,7 +69,7 @@ class TradingCryptoSpotPlaceOrderRequest implements ModelInterface, ArrayAccess, * @psalm-var array */ protected static $openAPIFormats = [ - 'symbol' => null, + 'instrument' => null, 'side' => null, 'type' => null, 'time_in_force' => null, @@ -86,7 +86,7 @@ class TradingCryptoSpotPlaceOrderRequest implements ModelInterface, ArrayAccess, * @var boolean[] */ protected static array $openAPINullables = [ - 'symbol' => false, + 'instrument' => false, 'side' => false, 'type' => false, 'time_in_force' => false, @@ -183,7 +183,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'symbol' => 'symbol', + 'instrument' => 'instrument', 'side' => 'side', 'type' => 'type', 'time_in_force' => 'time_in_force', @@ -200,7 +200,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'symbol' => 'setSymbol', + 'instrument' => 'setInstrument', 'side' => 'setSide', 'type' => 'setType', 'time_in_force' => 'setTimeInForce', @@ -217,7 +217,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'symbol' => 'getSymbol', + 'instrument' => 'getInstrument', 'side' => 'getSide', 'type' => 'getType', 'time_in_force' => 'getTimeInForce', @@ -327,7 +327,7 @@ public function getTimeInForceAllowableValues() */ public function __construct(array $data = null) { - $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('instrument', $data ?? [], null); $this->setIfExists('side', $data ?? [], null); $this->setIfExists('type', $data ?? [], null); $this->setIfExists('time_in_force', $data ?? [], null); @@ -365,8 +365,8 @@ public function listInvalidProperties() { $invalidProperties = []; - if ($this->container['symbol'] === null) { - $invalidProperties[] = "'symbol' can't be null"; + if ($this->container['instrument'] === null) { + $invalidProperties[] = "'instrument' can't be null"; } if ($this->container['side'] === null) { $invalidProperties[] = "'side' can't be null"; @@ -414,30 +414,30 @@ public function valid() /** - * Gets symbol + * Gets instrument * - * @return \SnapTrade\Model\CryptocurrencyPair + * @return \SnapTrade\Model\TradingInstrument */ - public function getSymbol() + public function getInstrument() { - return $this->container['symbol']; + return $this->container['instrument']; } /** - * Sets symbol + * Sets instrument * - * @param \SnapTrade\Model\CryptocurrencyPair $symbol symbol + * @param \SnapTrade\Model\TradingInstrument $instrument instrument * * @return self */ - public function setSymbol($symbol) + public function setInstrument($instrument) { - if (is_null($symbol)) { - throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + if (is_null($instrument)) { + throw new \InvalidArgumentException('non-nullable instrument cannot be null'); } - $this->container['symbol'] = $symbol; + $this->container['instrument'] = $instrument; return $this; } diff --git a/lib/Model/TradingCryptoSpotSymbols200Response.php b/lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php similarity index 96% rename from lib/Model/TradingCryptoSpotSymbols200Response.php rename to lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php index 921961c..8e76897 100644 --- a/lib/Model/TradingCryptoSpotSymbols200Response.php +++ b/lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php @@ -1,6 +1,6 @@ */ -class TradingCryptoSpotSymbols200Response implements ModelInterface, ArrayAccess, \JsonSerializable +class TradingSearchCryptocurrencyPairInstruments200Response implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -43,7 +43,7 @@ class TradingCryptoSpotSymbols200Response implements ModelInterface, ArrayAccess * * @var string */ - protected static $openAPIModelName = 'Trading_cryptoSpotSymbols_200_response'; + protected static $openAPIModelName = 'Trading_searchCryptocurrencyPairInstruments_200_response'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/test/Api/CryptoSpotTradingApiTest.php b/test/Api/CryptoSpotTradingApiTest.php deleted file mode 100644 index 549ecc1..0000000 --- a/test/Api/CryptoSpotTradingApiTest.php +++ /dev/null @@ -1,120 +0,0 @@ -markTestIncomplete('Not implemented'); - } - - /** - * Test case for cryptoSpotPlaceOrder - * - * Place a spot order on a crypto exchange. - * - */ - public function testCryptoSpotPlaceOrder() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test case for cryptoSpotPreviewOrder - * - * Preview a crypto spot order. - * - */ - public function testCryptoSpotPreviewOrder() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test case for cryptoSpotQuote - * - * Get a cryptocurrency spot market quote. - * - */ - public function testCryptoSpotQuote() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test case for cryptoSpotSymbols - * - * Search crypto spot symbols. - * - */ - public function testCryptoSpotSymbols() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } -} diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index a10fbdc..07394f9 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -58,6 +58,18 @@ public static function tearDownAfterClass(): void { } + /** + * Test case for cancelOrder + * + * Cancel an order.. + * + */ + public function testCancelOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for cancelUserAccountOrder * @@ -70,6 +82,18 @@ public function testCancelUserAccountOrder() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for getCryptocurrencyPairQuote + * + * Get cryptocurrency pair quote. + * + */ + public function testGetCryptocurrencyPairQuote() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for getOrderImpact * @@ -130,6 +154,30 @@ public function testPlaceOrder() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for placeSimpleOrder + * + * Place order. + * + */ + public function testPlaceSimpleOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test case for previewSimpleOrder + * + * Preview order. + * + */ + public function testPreviewSimpleOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for replaceOrder * @@ -141,4 +189,16 @@ public function testReplaceOrder() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test case for searchCryptocurrencyPairInstruments + * + * Search cryptocurrency pairs instruments. + * + */ + public function testSearchCryptocurrencyPairInstruments() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } diff --git a/test/Model/CryptoSpotQuoteTest.php b/test/Model/CryptocurrencyPairQuoteTest.php similarity index 87% rename from test/Model/CryptoSpotQuoteTest.php rename to test/Model/CryptocurrencyPairQuoteTest.php index f169841..778591f 100644 --- a/test/Model/CryptoSpotQuoteTest.php +++ b/test/Model/CryptocurrencyPairQuoteTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); diff --git a/test/Model/CryptocurrencyPairTest.php b/test/Model/CryptocurrencyPairTest.php index ce870a3..ddc9d6c 100644 --- a/test/Model/CryptocurrencyPairTest.php +++ b/test/Model/CryptocurrencyPairTest.php @@ -29,7 +29,7 @@ * CryptocurrencyPairTest Class Doc Comment * * @category Class - * @description A cryptocurrency symbol. This is a unique identifier for a cryptocurrency. + * @description A cryptocurrency pair instrument. * @package SnapTrade */ class CryptocurrencyPairTest extends TestCase @@ -72,6 +72,15 @@ public function testCryptocurrencyPair() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "base" */ diff --git a/test/Model/CryptoSpotOrderPreviewEstimatedFeeTest.php b/test/Model/SimpleOrderPreviewEstimatedFeeTest.php similarity index 84% rename from test/Model/CryptoSpotOrderPreviewEstimatedFeeTest.php rename to test/Model/SimpleOrderPreviewEstimatedFeeTest.php index 4c370ac..e59b41e 100644 --- a/test/Model/CryptoSpotOrderPreviewEstimatedFeeTest.php +++ b/test/Model/SimpleOrderPreviewEstimatedFeeTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); diff --git a/test/Model/CryptoSpotOrderPreviewTest.php b/test/Model/SimpleOrderPreviewTest.php similarity index 82% rename from test/Model/CryptoSpotOrderPreviewTest.php rename to test/Model/SimpleOrderPreviewTest.php index 662b3b7..d31075b 100644 --- a/test/Model/CryptoSpotOrderPreviewTest.php +++ b/test/Model/SimpleOrderPreviewTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); diff --git a/test/Model/TradingCryptoSpotCancelOrderRequestTest.php b/test/Model/TradingCryptoSpotCancelOrderRequestTest.php deleted file mode 100644 index 97978ca..0000000 --- a/test/Model/TradingCryptoSpotCancelOrderRequestTest.php +++ /dev/null @@ -1,83 +0,0 @@ -markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "brokerage_order_id" - */ - public function testPropertyBrokerageOrderId() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } -} diff --git a/test/Model/TradingCryptoSpotPlaceOrderRequestTest.php b/test/Model/TradingPlaceSimpleOrderRequestTest.php similarity index 87% rename from test/Model/TradingCryptoSpotPlaceOrderRequestTest.php rename to test/Model/TradingPlaceSimpleOrderRequestTest.php index 196af2e..5aaba92 100644 --- a/test/Model/TradingCryptoSpotPlaceOrderRequestTest.php +++ b/test/Model/TradingPlaceSimpleOrderRequestTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); } /** - * Test attribute "symbol" + * Test attribute "instrument" */ - public function testPropertySymbol() + public function testPropertyInstrument() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/TradingCryptoSpotSymbols200ResponseTest.php b/test/Model/TradingSearchCryptocurrencyPairInstruments200ResponseTest.php similarity index 77% rename from test/Model/TradingCryptoSpotSymbols200ResponseTest.php rename to test/Model/TradingSearchCryptocurrencyPairInstruments200ResponseTest.php index 02fc544..7009fa2 100644 --- a/test/Model/TradingCryptoSpotSymbols200ResponseTest.php +++ b/test/Model/TradingSearchCryptocurrencyPairInstruments200ResponseTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); From 365b460e04d6f9c367d4e498edc5096c90e50574 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 28 Mar 2025 22:37:59 +0000 Subject: [PATCH 103/252] Version Bump SDKs (#122) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index ef0c2d4..91567fe 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2313026f-85c6-4292-b60b-f24e9c2ae6f7 \ No newline at end of file +e9a513f1-dcbf-4751-a83a-d17faa481ecf \ No newline at end of file diff --git a/README.md b/README.md index 87cbf37..8d86f94 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.86-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.87-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.86" + "konfig/snaptrade-php-sdk": "2.0.87" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 6344841..403a53e 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.86/PHP'; + protected $userAgent = 'Konfig/2.0.87/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.86' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.87' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 5e6f19ccfe96b48bb651cc6e47aeb8b9910d4fbe Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Sat, 29 Mar 2025 23:39:49 +0000 Subject: [PATCH 104/252] Regenerate SDKs (#123) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/CryptocurrencyPair.php | 2 +- lib/Model/TradingInstrument.php | 27 +++++++++---------- ...yptocurrencyPairInstruments200Response.php | 2 +- ...currencyPairInstruments200ResponseTest.php | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 91567fe..3eab97b 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -e9a513f1-dcbf-4751-a83a-d17faa481ecf \ No newline at end of file +1b2380e4-11fc-4b52-a61e-750455eedf64 \ No newline at end of file diff --git a/lib/Model/CryptocurrencyPair.php b/lib/Model/CryptocurrencyPair.php index aa0a8d0..b46986b 100644 --- a/lib/Model/CryptocurrencyPair.php +++ b/lib/Model/CryptocurrencyPair.php @@ -316,7 +316,7 @@ public function getSymbol() /** * Sets symbol * - * @param string|null $symbol Cryptocurrency pair instrument instrument symbol + * @param string|null $symbol Cryptocurrency pair instrument symbol * * @return self */ diff --git a/lib/Model/TradingInstrument.php b/lib/Model/TradingInstrument.php index a0bb9c8..f69dce4 100644 --- a/lib/Model/TradingInstrument.php +++ b/lib/Model/TradingInstrument.php @@ -73,7 +73,7 @@ class TradingInstrument implements ModelInterface, ArrayAccess, \JsonSerializabl */ protected static array $openAPINullables = [ 'symbol' => false, - 'type' => true + 'type' => false ]; /** @@ -291,6 +291,12 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['symbol'] === null) { + $invalidProperties[] = "'symbol' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } $allowedValues = $this->getTypeAllowableValues(); if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { $invalidProperties[] = sprintf( @@ -318,7 +324,7 @@ public function valid() /** * Gets symbol * - * @return string|null + * @return string */ public function getSymbol() { @@ -328,7 +334,7 @@ public function getSymbol() /** * Sets symbol * - * @param string|null $symbol The security's trading ticker symbol + * @param string $symbol The instrument's trading ticker symbol * * @return self */ @@ -347,7 +353,7 @@ public function setSymbol($symbol) /** * Gets type * - * @return string|null + * @return string */ public function getType() { @@ -357,14 +363,14 @@ public function getType() /** * Sets type * - * @param string|null $type type + * @param string $type The type of the instrument * * @return self */ public function setType($type) { $allowedValues = $this->getTypeAllowableValues(); - if (!is_null($type) && !in_array($type, $allowedValues, true)) { + if (!in_array($type, $allowedValues, true)) { throw new \InvalidArgumentException( sprintf( "Invalid value '%s' for 'type', must be one of '%s'", @@ -375,14 +381,7 @@ public function setType($type) } if (is_null($type)) { - array_push($this->openAPINullablesSetToNull, 'type'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('type', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } + throw new \InvalidArgumentException('non-nullable type cannot be null'); } $this->container['type'] = $type; diff --git a/lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php b/lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php index 8e76897..c1cc825 100644 --- a/lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php +++ b/lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php @@ -30,7 +30,7 @@ * TradingSearchCryptocurrencyPairInstruments200Response Class Doc Comment * * @category Class - * @description The symbols + * @description The instruments * @package SnapTrade * @implements \ArrayAccess */ diff --git a/test/Model/TradingSearchCryptocurrencyPairInstruments200ResponseTest.php b/test/Model/TradingSearchCryptocurrencyPairInstruments200ResponseTest.php index 7009fa2..2390927 100644 --- a/test/Model/TradingSearchCryptocurrencyPairInstruments200ResponseTest.php +++ b/test/Model/TradingSearchCryptocurrencyPairInstruments200ResponseTest.php @@ -29,7 +29,7 @@ * TradingSearchCryptocurrencyPairInstruments200ResponseTest Class Doc Comment * * @category Class - * @description The symbols + * @description The instruments * @package SnapTrade */ class TradingSearchCryptocurrencyPairInstruments200ResponseTest extends TestCase From 41d472a203e52ed3b7771cdea82ca9ada27645a4 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Sat, 29 Mar 2025 23:44:14 +0000 Subject: [PATCH 105/252] Version Bump SDKs (#124) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 3eab97b..f194fe7 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -1b2380e4-11fc-4b52-a61e-750455eedf64 \ No newline at end of file +1b551f77-0b74-4e78-86f8-3c4da14e2448 \ No newline at end of file diff --git a/README.md b/README.md index 8d86f94..97ff943 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.87-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.88-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.87" + "konfig/snaptrade-php-sdk": "2.0.88" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 403a53e..d6ff51c 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.87/PHP'; + protected $userAgent = 'Konfig/2.0.88/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.87' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.88' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 57178f71cac02f7aa086609b42383405f0da863a Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 00:51:51 +0000 Subject: [PATCH 106/252] Regenerate SDKs (#125) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/Account.php | 98 +++++++++++++++++++------------------- test/Model/AccountTest.php | 16 +++---- 3 files changed, 58 insertions(+), 58 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f194fe7..5df996c 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -1b551f77-0b74-4e78-86f8-3c4da14e2448 \ No newline at end of file +16d95070-c4ec-44ed-86fb-978a8e237976 \ No newline at end of file diff --git a/lib/Model/Account.php b/lib/Model/Account.php index c68bb49..f529716 100644 --- a/lib/Model/Account.php +++ b/lib/Model/Account.php @@ -59,10 +59,10 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'created_date' => '\DateTime', 'sync_status' => '\SnapTrade\Model\AccountSyncStatus', 'balance' => '\SnapTrade\Model\AccountBalance', + 'raw_type' => 'string', 'meta' => 'array', 'portfolio_group' => 'string', - 'cash_restrictions' => 'string[]', - 'raw_type' => 'string' + 'cash_restrictions' => 'string[]' ]; /** @@ -81,10 +81,10 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'created_date' => 'date-time', 'sync_status' => null, 'balance' => null, + 'raw_type' => null, 'meta' => null, 'portfolio_group' => 'uuid', - 'cash_restrictions' => null, - 'raw_type' => null + 'cash_restrictions' => null ]; /** @@ -101,10 +101,10 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'created_date' => false, 'sync_status' => false, 'balance' => false, + 'raw_type' => true, 'meta' => false, 'portfolio_group' => false, - 'cash_restrictions' => false, - 'raw_type' => true + 'cash_restrictions' => false ]; /** @@ -201,10 +201,10 @@ public function isNullableSetToNull(string $property): bool 'created_date' => 'created_date', 'sync_status' => 'sync_status', 'balance' => 'balance', + 'raw_type' => 'raw_type', 'meta' => 'meta', 'portfolio_group' => 'portfolio_group', - 'cash_restrictions' => 'cash_restrictions', - 'raw_type' => 'raw_type' + 'cash_restrictions' => 'cash_restrictions' ]; /** @@ -221,10 +221,10 @@ public function isNullableSetToNull(string $property): bool 'created_date' => 'setCreatedDate', 'sync_status' => 'setSyncStatus', 'balance' => 'setBalance', + 'raw_type' => 'setRawType', 'meta' => 'setMeta', 'portfolio_group' => 'setPortfolioGroup', - 'cash_restrictions' => 'setCashRestrictions', - 'raw_type' => 'setRawType' + 'cash_restrictions' => 'setCashRestrictions' ]; /** @@ -241,10 +241,10 @@ public function isNullableSetToNull(string $property): bool 'created_date' => 'getCreatedDate', 'sync_status' => 'getSyncStatus', 'balance' => 'getBalance', + 'raw_type' => 'getRawType', 'meta' => 'getMeta', 'portfolio_group' => 'getPortfolioGroup', - 'cash_restrictions' => 'getCashRestrictions', - 'raw_type' => 'getRawType' + 'cash_restrictions' => 'getCashRestrictions' ]; /** @@ -312,10 +312,10 @@ public function __construct(array $data = null) $this->setIfExists('created_date', $data ?? [], null); $this->setIfExists('sync_status', $data ?? [], null); $this->setIfExists('balance', $data ?? [], null); + $this->setIfExists('raw_type', $data ?? [], null); $this->setIfExists('meta', $data ?? [], null); $this->setIfExists('portfolio_group', $data ?? [], null); $this->setIfExists('cash_restrictions', $data ?? [], null); - $this->setIfExists('raw_type', $data ?? [], null); } /** @@ -623,6 +623,42 @@ public function setBalance($balance) return $this; } + /** + * Gets raw_type + * + * @return string|null + */ + public function getRawType() + { + return $this->container['raw_type']; + } + + /** + * Sets raw_type + * + * @param string|null $raw_type The account type as provided by the brokerage + * + * @return self + */ + public function setRawType($raw_type) + { + + if (is_null($raw_type)) { + array_push($this->openAPINullablesSetToNull, 'raw_type'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('raw_type', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['raw_type'] = $raw_type; + + return $this; + } + /** * Gets meta * @@ -715,42 +751,6 @@ public function setCashRestrictions($cash_restrictions) return $this; } - - /** - * Gets raw_type - * - * @return string|null - */ - public function getRawType() - { - return $this->container['raw_type']; - } - - /** - * Sets raw_type - * - * @param string|null $raw_type The account type as provided by the brokerage - * - * @return self - */ - public function setRawType($raw_type) - { - - if (is_null($raw_type)) { - array_push($this->openAPINullablesSetToNull, 'raw_type'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('raw_type', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - - $this->container['raw_type'] = $raw_type; - - return $this; - } /** * Returns true if offset exists. False otherwise. * diff --git a/test/Model/AccountTest.php b/test/Model/AccountTest.php index 2fab6d0..c63d53c 100644 --- a/test/Model/AccountTest.php +++ b/test/Model/AccountTest.php @@ -145,36 +145,36 @@ public function testPropertyBalance() } /** - * Test attribute "meta" + * Test attribute "raw_type" */ - public function testPropertyMeta() + public function testPropertyRawType() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "portfolio_group" + * Test attribute "meta" */ - public function testPropertyPortfolioGroup() + public function testPropertyMeta() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "cash_restrictions" + * Test attribute "portfolio_group" */ - public function testPropertyCashRestrictions() + public function testPropertyPortfolioGroup() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test attribute "raw_type" + * Test attribute "cash_restrictions" */ - public function testPropertyRawType() + public function testPropertyCashRestrictions() { // TODO: implement $this->markTestIncomplete('Not implemented'); From 3a6fe054cd17b61d486541e1e6a59107d764527d Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 00:56:09 +0000 Subject: [PATCH 107/252] Version Bump SDKs (#126) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 5df996c..57b3125 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -16d95070-c4ec-44ed-86fb-978a8e237976 \ No newline at end of file +e114dbf9-b3dc-4747-9274-d28c44af7edd \ No newline at end of file diff --git a/README.md b/README.md index 97ff943..b59b667 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.88-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.89-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.88" + "konfig/snaptrade-php-sdk": "2.0.89" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index d6ff51c..e0e1c64 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.88/PHP'; + protected $userAgent = 'Konfig/2.0.89/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.88' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.89' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From ee4328ee6e8d16003117a360ee6c46fe2afe63d7 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 17:40:31 +0000 Subject: [PATCH 108/252] Regenerate SDKs (#127) * Regenerate SDKs * Regenerate SDKs * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 6 +++--- lib/Api/AccountInformationApi.php | 8 ++++---- lib/Api/AuthenticationApi.php | 4 ++-- lib/Api/ConnectionsApi.php | 16 ++++++++-------- lib/Model/SnapTradeRegisterUserRequestBody.php | 7 +++++-- lib/Model/TradingInstrument.php | 2 +- test/Api/AccountInformationApiTest.php | 2 +- 8 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 57b3125..b3e2a71 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -e114dbf9-b3dc-4747-9274-d28c44af7edd \ No newline at end of file +a03b9b90-e51f-4aa7-a18d-635c386c4021 \ No newline at end of file diff --git a/README.md b/README.md index b59b667..fea2293 100644 --- a/README.md +++ b/README.md @@ -888,7 +888,7 @@ $result = $snaptrade->connections->detailBrokerageAuthorization( Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. -*Please contact us in order to use this endpoint as it is disabled by default.* +This endpoint is available on test keys. If you would like it enabled on production keys as well, please contact support as it is disabled by default. @@ -966,9 +966,9 @@ $result = $snaptrade->connections->listBrokerageAuthorizations( ### `snaptrade.connections.refreshBrokerageAuthorization` Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. -This endpoint will also trigger a transaction sync for the past day if one has not yet occured. +This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. -*Please contact support for access as this endpoint is not enabled by default.* +**Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge of $0.05** diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 07f8f14..ec2084b 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -1952,7 +1952,7 @@ public function getUserAccountDetailsRequest($user_id, $user_secret, $account_id /** * Operation getUserAccountOrders * - * List account recent orders + * List account orders * * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. * @@ -1985,7 +1985,7 @@ public function getUserAccountOrders( /** * Operation getUserAccountOrdersWithHttpInfo * - * List account recent orders + * List account orders * * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. * @@ -2133,7 +2133,7 @@ public function getUserAccountOrdersWithHttpInfo($user_id, $user_secret, $accoun /** * Operation getUserAccountOrdersAsync * - * List account recent orders + * List account orders * * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. * @@ -2169,7 +2169,7 @@ function ($response) { /** * Operation getUserAccountOrdersAsyncWithHttpInfo * - * List account recent orders + * List account orders * * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. * diff --git a/lib/Api/AuthenticationApi.php b/lib/Api/AuthenticationApi.php index fe6017d..0da1226 100644 --- a/lib/Api/AuthenticationApi.php +++ b/lib/Api/AuthenticationApi.php @@ -1462,7 +1462,7 @@ public function loginSnapTradeUserRequest($user_id, $user_secret, $snap_trade_lo */ public function registerSnapTradeUser( - $user_id = SENTINEL_VALUE, + $user_id, string $contentType = self::contentTypes['registerSnapTradeUser'][0] ) { @@ -1675,7 +1675,7 @@ public function registerSnapTradeUserWithHttpInfo($snap_trade_register_user_requ */ public function registerSnapTradeUserAsync( - $user_id = SENTINEL_VALUE, + $user_id, string $contentType = self::contentTypes['registerSnapTradeUser'][0] ) { diff --git a/lib/Api/ConnectionsApi.php b/lib/Api/ConnectionsApi.php index 49504f0..96215be 100644 --- a/lib/Api/ConnectionsApi.php +++ b/lib/Api/ConnectionsApi.php @@ -560,7 +560,7 @@ public function detailBrokerageAuthorizationRequest($authorization_id, $user_id, * * Force disable connection * - * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. This endpoint is available on test keys. If you would like it enabled on production keys as well, please contact support as it is disabled by default. * * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) @@ -589,7 +589,7 @@ public function disableBrokerageAuthorization( * * Force disable connection * - * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. This endpoint is available on test keys. If you would like it enabled on production keys as well, please contact support as it is disabled by default. * * @param string $authorization_id (required) * @param string $user_id (required) @@ -802,7 +802,7 @@ public function disableBrokerageAuthorizationWithHttpInfo($authorization_id, $us * * Force disable connection * - * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. This endpoint is available on test keys. If you would like it enabled on production keys as well, please contact support as it is disabled by default. * * @param string $authorization_id (required) * @param string $user_id (required) @@ -834,7 +834,7 @@ function ($response) { * * Force disable connection * - * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. *Please contact us in order to use this endpoint as it is disabled by default.* + * Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [`CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection. This endpoint is available on test keys. If you would like it enabled on production keys as well, please contact support as it is disabled by default. * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1430,7 +1430,7 @@ public function listBrokerageAuthorizationsRequest($user_id, $user_secret, strin * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occured. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge of $0.05** * * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) @@ -1459,7 +1459,7 @@ public function refreshBrokerageAuthorization( * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occured. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge of $0.05** * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1672,7 +1672,7 @@ public function refreshBrokerageAuthorizationWithHttpInfo($authorization_id, $us * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occured. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge of $0.05** * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1704,7 +1704,7 @@ function ($response) { * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occured. *Please contact support for access as this endpoint is not enabled by default.* + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge of $0.05** * * @param string $authorization_id (required) * @param string $user_id (required) diff --git a/lib/Model/SnapTradeRegisterUserRequestBody.php b/lib/Model/SnapTradeRegisterUserRequestBody.php index bda577d..e46d900 100644 --- a/lib/Model/SnapTradeRegisterUserRequestBody.php +++ b/lib/Model/SnapTradeRegisterUserRequestBody.php @@ -268,6 +268,9 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['user_id'] === null) { + $invalidProperties[] = "'user_id' can't be null"; + } return $invalidProperties; } @@ -286,7 +289,7 @@ public function valid() /** * Gets user_id * - * @return string|null + * @return string */ public function getUserId() { @@ -296,7 +299,7 @@ public function getUserId() /** * Sets user_id * - * @param string|null $user_id SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable. + * @param string $user_id SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable. * * @return self */ diff --git a/lib/Model/TradingInstrument.php b/lib/Model/TradingInstrument.php index f69dce4..2f2c5d1 100644 --- a/lib/Model/TradingInstrument.php +++ b/lib/Model/TradingInstrument.php @@ -363,7 +363,7 @@ public function getType() /** * Sets type * - * @param string $type The type of the instrument + * @param string $type The instrument's type * * @return self */ diff --git a/test/Api/AccountInformationApiTest.php b/test/Api/AccountInformationApiTest.php index 6aef9a8..1e30ea5 100644 --- a/test/Api/AccountInformationApiTest.php +++ b/test/Api/AccountInformationApiTest.php @@ -109,7 +109,7 @@ public function testGetUserAccountDetails() /** * Test case for getUserAccountOrders * - * List account recent orders. + * List account orders. * */ public function testGetUserAccountOrders() From b22c6d7e5272f4f85b9ed5c21bf29165795b10e5 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 17:44:40 +0000 Subject: [PATCH 109/252] Version Bump SDKs (#128) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b3e2a71..939f191 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -a03b9b90-e51f-4aa7-a18d-635c386c4021 \ No newline at end of file +1bc5865a-c216-430f-a3d3-ea9240281b92 \ No newline at end of file diff --git a/README.md b/README.md index fea2293..181eea0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.89-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.90-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.89" + "konfig/snaptrade-php-sdk": "2.0.90" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index e0e1c64..dca6d51 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.89/PHP'; + protected $userAgent = 'Konfig/2.0.90/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.89' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.90' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 2dddee9cf04af879a414d8933ef77ef7e946f519 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 19:16:39 +0000 Subject: [PATCH 110/252] Regenerate SDKs (#129) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 5 ++++ lib/Api/TradingApi.php | 4 +++ lib/Model/ManualTradeReplaceForm.php | 36 +++++++++++++++++++++++ test/Model/ManualTradeReplaceFormTest.php | 9 ++++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 939f191..04b3b7a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -1bc5865a-c216-430f-a3d3-ea9240281b92 \ No newline at end of file +e2b25dfb-9e84-4c3b-b8bb-1c1e99110545 \ No newline at end of file diff --git a/README.md b/README.md index 181eea0..20c4c6e 100644 --- a/README.md +++ b/README.md @@ -2329,6 +2329,7 @@ $result = $snaptrade->trading->replaceOrder( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", price: 31.33, + symbol: "AAPL", stop: 31.33, units: 10.5 ); @@ -2358,6 +2359,10 @@ The Brokerage Order ID of the order to replace. The limit price for `Limit` and `StopLimit` orders. +##### symbol: `string` + +The security's trading ticker symbol + ##### stop: `float` The price at which a stop order is triggered for `Stop` and `StopLimit` orders. diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 88cfcbd..9e0c979 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -4993,6 +4993,7 @@ public function replaceOrder( $user_id, $user_secret, $price = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, string $contentType = self::contentTypes['replaceOrder'][0] @@ -5003,6 +5004,7 @@ public function replaceOrder( $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); $manual_trade_replace_form = $_body; @@ -5209,6 +5211,7 @@ public function replaceOrderAsync( $user_id, $user_secret, $price = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, string $contentType = self::contentTypes['replaceOrder'][0] @@ -5219,6 +5222,7 @@ public function replaceOrderAsync( $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); $manual_trade_replace_form = $_body; diff --git a/lib/Model/ManualTradeReplaceForm.php b/lib/Model/ManualTradeReplaceForm.php index bdb9ba6..4abbd52 100644 --- a/lib/Model/ManualTradeReplaceForm.php +++ b/lib/Model/ManualTradeReplaceForm.php @@ -55,6 +55,7 @@ class ManualTradeReplaceForm implements ModelInterface, ArrayAccess, \JsonSerial 'order_type' => '\SnapTrade\Model\OrderTypeStrict', 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', 'price' => 'float', + 'symbol' => 'string', 'stop' => 'float', 'units' => 'float' ]; @@ -71,6 +72,7 @@ class ManualTradeReplaceForm implements ModelInterface, ArrayAccess, \JsonSerial 'order_type' => null, 'time_in_force' => null, 'price' => null, + 'symbol' => null, 'stop' => null, 'units' => null ]; @@ -85,6 +87,7 @@ class ManualTradeReplaceForm implements ModelInterface, ArrayAccess, \JsonSerial 'order_type' => false, 'time_in_force' => false, 'price' => true, + 'symbol' => false, 'stop' => true, 'units' => true ]; @@ -179,6 +182,7 @@ public function isNullableSetToNull(string $property): bool 'order_type' => 'order_type', 'time_in_force' => 'time_in_force', 'price' => 'price', + 'symbol' => 'symbol', 'stop' => 'stop', 'units' => 'units' ]; @@ -193,6 +197,7 @@ public function isNullableSetToNull(string $property): bool 'order_type' => 'setOrderType', 'time_in_force' => 'setTimeInForce', 'price' => 'setPrice', + 'symbol' => 'setSymbol', 'stop' => 'setStop', 'units' => 'setUnits' ]; @@ -207,6 +212,7 @@ public function isNullableSetToNull(string $property): bool 'order_type' => 'getOrderType', 'time_in_force' => 'getTimeInForce', 'price' => 'getPrice', + 'symbol' => 'getSymbol', 'stop' => 'getStop', 'units' => 'getUnits' ]; @@ -272,6 +278,7 @@ public function __construct(array $data = null) $this->setIfExists('order_type', $data ?? [], null); $this->setIfExists('time_in_force', $data ?? [], null); $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('symbol', $data ?? [], null); $this->setIfExists('stop', $data ?? [], null); $this->setIfExists('units', $data ?? [], null); } @@ -450,6 +457,35 @@ public function setPrice($price) return $this; } + /** + * Gets symbol + * + * @return string|null + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string|null $symbol The security's trading ticker symbol + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + /** * Gets stop * diff --git a/test/Model/ManualTradeReplaceFormTest.php b/test/Model/ManualTradeReplaceFormTest.php index f4f956b..6be5c5c 100644 --- a/test/Model/ManualTradeReplaceFormTest.php +++ b/test/Model/ManualTradeReplaceFormTest.php @@ -108,6 +108,15 @@ public function testPropertyPrice() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "stop" */ From cfb6cb9fdf9b0718a4da5378c3fd7934e5a942e7 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 19:20:49 +0000 Subject: [PATCH 111/252] Version Bump SDKs (#130) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 04b3b7a..a3aed70 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -e2b25dfb-9e84-4c3b-b8bb-1c1e99110545 \ No newline at end of file +3041bf81-9202-4c27-b9ed-9d856bb04018 \ No newline at end of file diff --git a/README.md b/README.md index 20c4c6e..df37818 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.90-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.91-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.90" + "konfig/snaptrade-php-sdk": "2.0.91" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index dca6d51..a834892 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.90/PHP'; + protected $userAgent = 'Konfig/2.0.91/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.90' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.91' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From b139e5e331aeda794dbff029d4e150c1613004fa Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 17:00:27 +0000 Subject: [PATCH 112/252] Regenerate SDKs (#131) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/AccountInformationApi.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a3aed70..a17ecae 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -3041bf81-9202-4c27-b9ed-9d856bb04018 \ No newline at end of file +82d11985-372e-48dc-a796-a17b96c6cb8a \ No newline at end of file diff --git a/README.md b/README.md index df37818..86574ea 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ $result = $snaptrade->accountInformation->getAccountActivities( Returns all historical transactions for the specified account. -This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. +This endpoint is paginated with a default (and maximum) page size of 1000. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index ec2084b..d777332 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -170,7 +170,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default (and maximum) page size of 1000. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id account_id (required) * @param string $user_id user_id (required) @@ -209,7 +209,7 @@ public function getAccountActivities( * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default (and maximum) page size of 1000. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) @@ -340,7 +340,7 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default (and maximum) page size of 1000. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) @@ -382,7 +382,7 @@ function ($response) { * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default (and maximum) page size of 1000. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) From f62af009441c1f66e7b201f1ad1a3c4f0afca2ac Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 17:04:43 +0000 Subject: [PATCH 113/252] Version Bump SDKs (#132) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a17ecae..f2040c1 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -82d11985-372e-48dc-a796-a17b96c6cb8a \ No newline at end of file +4b89348b-8e65-4b14-abdf-f66494609ec7 \ No newline at end of file diff --git a/README.md b/README.md index 86574ea..fc93153 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.91-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.92-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.91" + "konfig/snaptrade-php-sdk": "2.0.92" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index a834892..b7b161a 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.91/PHP'; + protected $userAgent = 'Konfig/2.0.92/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.91' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.92' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 378333a70aae8cd49fe349a20487ec5607075aac Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 18:38:20 +0000 Subject: [PATCH 114/252] Regenerate SDKs (#133) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/AccountInformationApi.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f2040c1..f1aa6dd 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -4b89348b-8e65-4b14-abdf-f66494609ec7 \ No newline at end of file +e09fd9ad-b6a6-4bc3-8652-4c618e396f53 \ No newline at end of file diff --git a/README.md b/README.md index fc93153..01c44e2 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ $result = $snaptrade->accountInformation->getAccountActivities( Returns all historical transactions for the specified account. -This endpoint is paginated with a default (and maximum) page size of 1000. See the query parameters for pagination options. +This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index d777332..ec2084b 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -170,7 +170,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default (and maximum) page size of 1000. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id account_id (required) * @param string $user_id user_id (required) @@ -209,7 +209,7 @@ public function getAccountActivities( * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default (and maximum) page size of 1000. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) @@ -340,7 +340,7 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default (and maximum) page size of 1000. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) @@ -382,7 +382,7 @@ function ($response) { * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default (and maximum) page size of 1000. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. * * @param string $account_id (required) * @param string $user_id (required) From 0ad1524b41ce66252485c4fdda88f10393b97cc9 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 18:42:29 +0000 Subject: [PATCH 115/252] Version Bump SDKs (#134) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f1aa6dd..6625efa 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -e09fd9ad-b6a6-4bc3-8652-4c618e396f53 \ No newline at end of file +42cbc57d-b776-450e-b639-f95cd3775ac5 \ No newline at end of file diff --git a/README.md b/README.md index 01c44e2..1048b7a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.92-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.93-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.92" + "konfig/snaptrade-php-sdk": "2.0.93" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index b7b161a..bd56019 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.92/PHP'; + protected $userAgent = 'Konfig/2.0.93/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.92' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.93' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 021721bfa61e45db038fc9d3ef4099c5aae37a4c Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 14:25:53 +0000 Subject: [PATCH 116/252] Regenerate SDKs (#135) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/PaginationDetails.php | 48 ++++++++++++++++++++++++---- test/Model/PaginationDetailsTest.php | 9 ++++++ 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 6625efa..30a9a31 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -42cbc57d-b776-450e-b639-f95cd3775ac5 \ No newline at end of file +2d605f14-ec9d-43d9-9f46-e09312b266c7 \ No newline at end of file diff --git a/lib/Model/PaginationDetails.php b/lib/Model/PaginationDetails.php index c6fd9e0..885e151 100644 --- a/lib/Model/PaginationDetails.php +++ b/lib/Model/PaginationDetails.php @@ -52,7 +52,8 @@ class PaginationDetails implements ModelInterface, ArrayAccess, \JsonSerializabl */ protected static $openAPITypes = [ 'offset' => 'int', - 'limit' => 'int' + 'limit' => 'int', + 'total' => 'int' ]; /** @@ -64,7 +65,8 @@ class PaginationDetails implements ModelInterface, ArrayAccess, \JsonSerializabl */ protected static $openAPIFormats = [ 'offset' => null, - 'limit' => null + 'limit' => null, + 'total' => null ]; /** @@ -74,7 +76,8 @@ class PaginationDetails implements ModelInterface, ArrayAccess, \JsonSerializabl */ protected static array $openAPINullables = [ 'offset' => false, - 'limit' => false + 'limit' => false, + 'total' => false ]; /** @@ -164,7 +167,8 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'offset' => 'offset', - 'limit' => 'limit' + 'limit' => 'limit', + 'total' => 'total' ]; /** @@ -174,7 +178,8 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'offset' => 'setOffset', - 'limit' => 'setLimit' + 'limit' => 'setLimit', + 'total' => 'setTotal' ]; /** @@ -184,7 +189,8 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'offset' => 'getOffset', - 'limit' => 'getLimit' + 'limit' => 'getLimit', + 'total' => 'getTotal' ]; /** @@ -246,6 +252,7 @@ public function __construct(array $data = null) { $this->setIfExists('offset', $data ?? [], null); $this->setIfExists('limit', $data ?? [], null); + $this->setIfExists('total', $data ?? [], null); } /** @@ -347,6 +354,35 @@ public function setLimit($limit) return $this; } + + /** + * Gets total + * + * @return int|null + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param int|null $total The total number of items available to be returned over the API. + * + * @return self + */ + public function setTotal($total) + { + + if (is_null($total)) { + throw new \InvalidArgumentException('non-nullable total cannot be null'); + } + + $this->container['total'] = $total; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/test/Model/PaginationDetailsTest.php b/test/Model/PaginationDetailsTest.php index f4e916f..ea54f6a 100644 --- a/test/Model/PaginationDetailsTest.php +++ b/test/Model/PaginationDetailsTest.php @@ -89,4 +89,13 @@ public function testPropertyLimit() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "total" + */ + public function testPropertyTotal() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } From 74acdd1729f1b4e56a65a5c19137407516ab589c Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 14:30:15 +0000 Subject: [PATCH 117/252] Version Bump SDKs (#136) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 30a9a31..c7ecfd6 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2d605f14-ec9d-43d9-9f46-e09312b266c7 \ No newline at end of file +8b72df76-d8c1-430c-906f-5166bc539e1b \ No newline at end of file diff --git a/README.md b/README.md index 1048b7a..e3dc7a8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.93-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.94-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.93" + "konfig/snaptrade-php-sdk": "2.0.94" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index bd56019..833d13e 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.93/PHP'; + protected $userAgent = 'Konfig/2.0.94/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.93' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.94' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 7a313900a2d5b307f03e755ceb9a87de6018aa27 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 00:51:32 +0000 Subject: [PATCH 118/252] Regenerate SDKs (#138) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 79 ++- lib/Api/TradingApi.php | 479 ++++++++++++++ lib/Model/MlegActionStrict.php | 68 ++ lib/Model/MlegLeg.php | 485 ++++++++++++++ lib/Model/MlegOrderResponse.php | 446 +++++++++++++ lib/Model/MlegTradingInstrument.php | 480 ++++++++++++++ lib/Model/TimeInForceStrict.php | 7 +- lib/Model/TradingPlaceMlegOrderRequest.php | 609 ++++++++++++++++++ test/Api/TradingApiTest.php | 12 + test/Model/MlegActionStrictTest.php | 74 +++ test/Model/MlegLegTest.php | 101 +++ test/Model/MlegOrderResponseTest.php | 92 +++ test/Model/MlegTradingInstrumentTest.php | 92 +++ test/Model/TimeInForceStrictTest.php | 2 +- .../TradingPlaceMlegOrderRequestTest.php | 119 ++++ 16 files changed, 3138 insertions(+), 9 deletions(-) create mode 100644 lib/Model/MlegActionStrict.php create mode 100644 lib/Model/MlegLeg.php create mode 100644 lib/Model/MlegOrderResponse.php create mode 100644 lib/Model/MlegTradingInstrument.php create mode 100644 lib/Model/TradingPlaceMlegOrderRequest.php create mode 100644 test/Model/MlegActionStrictTest.php create mode 100644 test/Model/MlegLegTest.php create mode 100644 test/Model/MlegOrderResponseTest.php create mode 100644 test/Model/MlegTradingInstrumentTest.php create mode 100644 test/Model/TradingPlaceMlegOrderRequestTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index c7ecfd6..4a6a330 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -8b72df76-d8c1-430c-906f-5166bc539e1b \ No newline at end of file +2b6a3a41-72ef-4269-a487-33fbf6b51c3a \ No newline at end of file diff --git a/README.md b/README.md index e3dc7a8..1102b7f 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.trading.getUserAccountQuotes`](#snaptradetradinggetuseraccountquotes) * [`snaptrade.trading.placeBracketOrder`](#snaptradetradingplacebracketorder) * [`snaptrade.trading.placeForceOrder`](#snaptradetradingplaceforceorder) + * [`snaptrade.trading.placeMlegOrder`](#snaptradetradingplacemlegorder) * [`snaptrade.trading.placeOrder`](#snaptradetradingplaceorder) * [`snaptrade.trading.placeSimpleOrder`](#snaptradetradingplacesimpleorder) * [`snaptrade.trading.previewSimpleOrder`](#snaptradetradingpreviewsimpleorder) @@ -1314,7 +1315,7 @@ Places the option strategy order and returns the order record received from the ```php $result = $snaptrade->options->placeOptionStrategy( order_type: "Market", - time_in_force: "FOK", + time_in_force: "Day", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", @@ -1826,7 +1827,7 @@ $result = $snaptrade->trading->getOrderImpact( action: "BUY", universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", order_type: "Market", - time_in_force: "FOK", + time_in_force: "Day", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", price: 31.33, @@ -1946,7 +1947,7 @@ $result = $snaptrade->trading->placeBracketOrder( "type" => "EQUITY", ], order_type: "Market", - time_in_force: "FOK", + time_in_force: "Day", stop_loss: [ "stop_price" => "48.55", "limit_price" => "48.50", @@ -2033,7 +2034,7 @@ $result = $snaptrade->trading->placeForceOrder( account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", action: "BUY", order_type: "Market", - time_in_force: "FOK", + time_in_force: "Day", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", @@ -2097,6 +2098,74 @@ For Equity orders, this represents the number of shares for the order. This can --- +### `snaptrade.trading.placeMlegOrder` + +Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->placeMlegOrder( + type: "MARKET", + time_in_force: "Day", + legs: [ + [ + "instrument" => [ + "symbol" => "PBI 250718C00006000", + "type" => "OPTION", + ], + "action" => "BUY_TO_OPEN", + "units" => 1, + ] + ], + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + limit_price: "", + stop_price: "" +); +``` + +#### βš™οΈ Parameters + +##### type: `string` + +The type of order to place. + +##### time_in_force: + +##### legs: [`MlegLeg`](./lib/Model/MlegLeg.php)[] + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### limit_price: `float` + +The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT. + +##### stop_price: `float` + +The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT. + + +#### πŸ”„ Return + +[**MlegOrderResponse**](./lib/Model/MlegOrderResponse.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/options` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.trading.placeOrder` Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). @@ -2323,7 +2392,7 @@ returned in the response going forward. Only supported on some brokerages $result = $snaptrade->trading->replaceOrder( action: "BUY", order_type: "Market", - time_in_force: "FOK", + time_in_force: "Day", account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", user_id: "snaptrade-user-123", diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 9e0c979..b54d4f5 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -83,6 +83,9 @@ class TradingApi extends \SnapTrade\CustomApi 'placeForceOrder' => [ 'application/json', ], + 'placeMlegOrder' => [ + 'application/json', + ], 'placeOrder' => [ 'application/json', ], @@ -3527,6 +3530,482 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for ]; } + /** + * Operation placeMlegOrder + * + * Place multi-leg option order + * + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request trading_place_mleg_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function placeMlegOrder( + + $type, + $time_in_force, + $legs, + $user_id, + $user_secret, + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeMlegOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "legs", $legs); + $trading_place_mleg_order_request = $_body; + + list($response) = $this->placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType); + return $response; + } + + /** + * Operation placeMlegOrderWithHttpInfo + * + * Place multi-leg option order + * + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->placeMlegOrderWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $trading_place_mleg_order_request, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\MlegOrderResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\MlegOrderResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\MlegOrderResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\MlegOrderResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\MlegOrderResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation placeMlegOrderAsync + * + * Place multi-leg option order + * + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeMlegOrderAsync( + + $type, + $time_in_force, + $legs, + $user_id, + $user_secret, + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeMlegOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "legs", $legs); + $trading_place_mleg_order_request = $_body; + + return $this->placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation placeMlegOrderAsyncWithHttpInfo + * + * Place multi-leg option order + * + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\MlegOrderResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'placeMlegOrder' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, string $contentType = self::contentTypes['placeMlegOrder'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling placeMlegOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling placeMlegOrder' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling placeMlegOrder' + ); + } + if ($trading_place_mleg_order_request !== SENTINEL_VALUE) { + if (!($trading_place_mleg_order_request instanceof \SnapTrade\Model\TradingPlaceMlegOrderRequest)) { + if (!is_array($trading_place_mleg_order_request)) + throw new \InvalidArgumentException('"trading_place_mleg_order_request" must be associative array or an instance of \SnapTrade\Model\TradingPlaceMlegOrderRequest TradingApi.placeMlegOrder.'); + else + $trading_place_mleg_order_request = new \SnapTrade\Model\TradingPlaceMlegOrderRequest($trading_place_mleg_order_request); + } + } + // verify the required parameter 'trading_place_mleg_order_request' is set + if ($trading_place_mleg_order_request === SENTINEL_VALUE || (is_array($trading_place_mleg_order_request) && count($trading_place_mleg_order_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter trading_place_mleg_order_request when calling placeMlegOrder' + ); + } + + + $resourcePath = '/accounts/{accountId}/trading/options'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($trading_place_mleg_order_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_place_mleg_order_request)); + } else { + $httpBody = $trading_place_mleg_order_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + /** * Operation placeOrder * diff --git a/lib/Model/MlegActionStrict.php b/lib/Model/MlegActionStrict.php new file mode 100644 index 0000000..18137d4 --- /dev/null +++ b/lib/Model/MlegActionStrict.php @@ -0,0 +1,68 @@ + + */ +class MlegLeg implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'MlegLeg'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'instrument' => '\SnapTrade\Model\MlegTradingInstrument', + 'action' => '\SnapTrade\Model\MlegActionStrict', + 'units' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'instrument' => null, + 'action' => null, + 'units' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'instrument' => false, + 'action' => false, + 'units' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'instrument' => 'instrument', + 'action' => 'action', + 'units' => 'units' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'instrument' => 'setInstrument', + 'action' => 'setAction', + 'units' => 'setUnits' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'instrument' => 'getInstrument', + 'action' => 'getAction', + 'units' => 'getUnits' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('instrument', $data ?? [], null); + $this->setIfExists('action', $data ?? [], null); + $this->setIfExists('units', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['instrument'] === null) { + $invalidProperties[] = "'instrument' can't be null"; + } + if ($this->container['action'] === null) { + $invalidProperties[] = "'action' can't be null"; + } + if ($this->container['units'] === null) { + $invalidProperties[] = "'units' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets instrument + * + * @return \SnapTrade\Model\MlegTradingInstrument + */ + public function getInstrument() + { + return $this->container['instrument']; + } + + /** + * Sets instrument + * + * @param \SnapTrade\Model\MlegTradingInstrument $instrument instrument + * + * @return self + */ + public function setInstrument($instrument) + { + + if (is_null($instrument)) { + throw new \InvalidArgumentException('non-nullable instrument cannot be null'); + } + + $this->container['instrument'] = $instrument; + + return $this; + } + + /** + * Gets action + * + * @return \SnapTrade\Model\MlegActionStrict + */ + public function getAction() + { + return $this->container['action']; + } + + /** + * Sets action + * + * @param \SnapTrade\Model\MlegActionStrict $action action + * + * @return self + */ + public function setAction($action) + { + + if (is_null($action)) { + throw new \InvalidArgumentException('non-nullable action cannot be null'); + } + + $this->container['action'] = $action; + + return $this; + } + + /** + * Gets units + * + * @return int + */ + public function getUnits() + { + return $this->container['units']; + } + + /** + * Sets units + * + * @param int $units The quantity to trade. For options this represents the number of contracts. For equity this represents the number of shares. + * + * @return self + */ + public function setUnits($units) + { + + if (is_null($units)) { + throw new \InvalidArgumentException('non-nullable units cannot be null'); + } + + $this->container['units'] = $units; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/MlegOrderResponse.php b/lib/Model/MlegOrderResponse.php new file mode 100644 index 0000000..73f9553 --- /dev/null +++ b/lib/Model/MlegOrderResponse.php @@ -0,0 +1,446 @@ + + */ +class MlegOrderResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'MlegOrderResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'brokerage_order_id' => 'string', + 'orders' => '\SnapTrade\Model\AccountOrderRecord[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'brokerage_order_id' => null, + 'orders' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'brokerage_order_id' => false, + 'orders' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'brokerage_order_id' => 'brokerage_order_id', + 'orders' => 'orders' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'brokerage_order_id' => 'setBrokerageOrderId', + 'orders' => 'setOrders' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'brokerage_order_id' => 'getBrokerageOrderId', + 'orders' => 'getOrders' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('brokerage_order_id', $data ?? [], null); + $this->setIfExists('orders', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['brokerage_order_id'] === null) { + $invalidProperties[] = "'brokerage_order_id' can't be null"; + } + if ($this->container['orders'] === null) { + $invalidProperties[] = "'orders' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets brokerage_order_id + * + * @return string + */ + public function getBrokerageOrderId() + { + return $this->container['brokerage_order_id']; + } + + /** + * Sets brokerage_order_id + * + * @param string $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + * + * @return self + */ + public function setBrokerageOrderId($brokerage_order_id) + { + + if (is_null($brokerage_order_id)) { + throw new \InvalidArgumentException('non-nullable brokerage_order_id cannot be null'); + } + + $this->container['brokerage_order_id'] = $brokerage_order_id; + + return $this; + } + + /** + * Gets orders + * + * @return \SnapTrade\Model\AccountOrderRecord[] + */ + public function getOrders() + { + return $this->container['orders']; + } + + /** + * Sets orders + * + * @param \SnapTrade\Model\AccountOrderRecord[] $orders orders + * + * @return self + */ + public function setOrders($orders) + { + + if (is_null($orders)) { + throw new \InvalidArgumentException('non-nullable orders cannot be null'); + } + + $this->container['orders'] = $orders; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/MlegTradingInstrument.php b/lib/Model/MlegTradingInstrument.php new file mode 100644 index 0000000..897bff9 --- /dev/null +++ b/lib/Model/MlegTradingInstrument.php @@ -0,0 +1,480 @@ + + */ +class MlegTradingInstrument implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'MlegTradingInstrument'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'symbol' => 'string', + 'type' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'symbol' => null, + 'type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'symbol' => false, + 'type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'symbol' => 'symbol', + 'type' => 'type' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'symbol' => 'setSymbol', + 'type' => 'setType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'symbol' => 'getSymbol', + 'type' => 'getType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_OPTION = 'OPTION'; + public const TYPE_EQUITY = 'EQUITY'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_OPTION, + self::TYPE_EQUITY, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['symbol'] === null) { + $invalidProperties[] = "'symbol' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets symbol + * + * @return string + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string $symbol The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example \"AAPL 131124C00240000\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format) + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets type + * + * @return string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type The instrument's type + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + + $this->container['type'] = $type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/TimeInForceStrict.php b/lib/Model/TimeInForceStrict.php index 66ae91c..06f7bb9 100644 --- a/lib/Model/TimeInForceStrict.php +++ b/lib/Model/TimeInForceStrict.php @@ -28,7 +28,7 @@ * TimeInForceStrict Class Doc Comment * * @category Class - * @description The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. + * @description The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. * @package SnapTrade */ class TimeInForceStrict @@ -42,6 +42,8 @@ class TimeInForceStrict public const GTC = 'GTC'; + public const IOC = 'IOC'; + /** * Gets allowable values of the enum * @return string[] @@ -51,7 +53,8 @@ public static function getAllowableEnumValues() return [ self::FOK, self::DAY, - self::GTC + self::GTC, + self::IOC ]; } } diff --git a/lib/Model/TradingPlaceMlegOrderRequest.php b/lib/Model/TradingPlaceMlegOrderRequest.php new file mode 100644 index 0000000..34e9972 --- /dev/null +++ b/lib/Model/TradingPlaceMlegOrderRequest.php @@ -0,0 +1,609 @@ + + */ +class TradingPlaceMlegOrderRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Trading_placeMlegOrder_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', + 'limit_price' => 'float', + 'stop_price' => 'float', + 'legs' => '\SnapTrade\Model\MlegLeg[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'time_in_force' => null, + 'limit_price' => 'decimal', + 'stop_price' => 'decimal', + 'legs' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'time_in_force' => false, + 'limit_price' => true, + 'stop_price' => true, + 'legs' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'time_in_force' => 'time_in_force', + 'limit_price' => 'limit_price', + 'stop_price' => 'stop_price', + 'legs' => 'legs' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'time_in_force' => 'setTimeInForce', + 'limit_price' => 'setLimitPrice', + 'stop_price' => 'setStopPrice', + 'legs' => 'setLegs' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'time_in_force' => 'getTimeInForce', + 'limit_price' => 'getLimitPrice', + 'stop_price' => 'getStopPrice', + 'legs' => 'getLegs' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_MARKET = 'MARKET'; + public const TYPE_LIMIT = 'LIMIT'; + public const TYPE_STOP_LOSS_MARKET = 'STOP_LOSS_MARKET'; + public const TYPE_STOP_LOSS_LIMIT = 'STOP_LOSS_LIMIT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_MARKET, + self::TYPE_LIMIT, + self::TYPE_STOP_LOSS_MARKET, + self::TYPE_STOP_LOSS_LIMIT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('time_in_force', $data ?? [], null); + $this->setIfExists('limit_price', $data ?? [], null); + $this->setIfExists('stop_price', $data ?? [], null); + $this->setIfExists('legs', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['time_in_force'] === null) { + $invalidProperties[] = "'time_in_force' can't be null"; + } + if ($this->container['legs'] === null) { + $invalidProperties[] = "'legs' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type The type of order to place. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets time_in_force + * + * @return \SnapTrade\Model\TimeInForceStrict + */ + public function getTimeInForce() + { + return $this->container['time_in_force']; + } + + /** + * Sets time_in_force + * + * @param \SnapTrade\Model\TimeInForceStrict $time_in_force time_in_force + * + * @return self + */ + public function setTimeInForce($time_in_force) + { + + if (is_null($time_in_force)) { + throw new \InvalidArgumentException('non-nullable time_in_force cannot be null'); + } + + $this->container['time_in_force'] = $time_in_force; + + return $this; + } + + /** + * Gets limit_price + * + * @return float|null + */ + public function getLimitPrice() + { + return $this->container['limit_price']; + } + + /** + * Sets limit_price + * + * @param float|null $limit_price The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT. + * + * @return self + */ + public function setLimitPrice($limit_price) + { + + if (is_null($limit_price)) { + array_push($this->openAPINullablesSetToNull, 'limit_price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('limit_price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['limit_price'] = $limit_price; + + return $this; + } + + /** + * Gets stop_price + * + * @return float|null + */ + public function getStopPrice() + { + return $this->container['stop_price']; + } + + /** + * Sets stop_price + * + * @param float|null $stop_price The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT. + * + * @return self + */ + public function setStopPrice($stop_price) + { + + if (is_null($stop_price)) { + array_push($this->openAPINullablesSetToNull, 'stop_price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('stop_price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['stop_price'] = $stop_price; + + return $this; + } + + /** + * Gets legs + * + * @return \SnapTrade\Model\MlegLeg[] + */ + public function getLegs() + { + return $this->container['legs']; + } + + /** + * Sets legs + * + * @param \SnapTrade\Model\MlegLeg[] $legs legs + * + * @return self + */ + public function setLegs($legs) + { + + if (is_null($legs)) { + throw new \InvalidArgumentException('non-nullable legs cannot be null'); + } + + $this->container['legs'] = $legs; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 07394f9..add1d24 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -142,6 +142,18 @@ public function testPlaceForceOrder() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for placeMlegOrder + * + * Place multi-leg option order. + * + */ + public function testPlaceMlegOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for placeOrder * diff --git a/test/Model/MlegActionStrictTest.php b/test/Model/MlegActionStrictTest.php new file mode 100644 index 0000000..ed89490 --- /dev/null +++ b/test/Model/MlegActionStrictTest.php @@ -0,0 +1,74 @@ +markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/MlegLegTest.php b/test/Model/MlegLegTest.php new file mode 100644 index 0000000..9fb2f12 --- /dev/null +++ b/test/Model/MlegLegTest.php @@ -0,0 +1,101 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "instrument" + */ + public function testPropertyInstrument() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "action" + */ + public function testPropertyAction() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "units" + */ + public function testPropertyUnits() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/MlegOrderResponseTest.php b/test/Model/MlegOrderResponseTest.php new file mode 100644 index 0000000..1c29091 --- /dev/null +++ b/test/Model/MlegOrderResponseTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "brokerage_order_id" + */ + public function testPropertyBrokerageOrderId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "orders" + */ + public function testPropertyOrders() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/MlegTradingInstrumentTest.php b/test/Model/MlegTradingInstrumentTest.php new file mode 100644 index 0000000..27e7cad --- /dev/null +++ b/test/Model/MlegTradingInstrumentTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/TimeInForceStrictTest.php b/test/Model/TimeInForceStrictTest.php index 228e9c8..45d137f 100644 --- a/test/Model/TimeInForceStrictTest.php +++ b/test/Model/TimeInForceStrictTest.php @@ -29,7 +29,7 @@ * TimeInForceStrictTest Class Doc Comment * * @category Class - * @description The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. + * @description The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. * @package SnapTrade */ class TimeInForceStrictTest extends TestCase diff --git a/test/Model/TradingPlaceMlegOrderRequestTest.php b/test/Model/TradingPlaceMlegOrderRequestTest.php new file mode 100644 index 0000000..10cf01e --- /dev/null +++ b/test/Model/TradingPlaceMlegOrderRequestTest.php @@ -0,0 +1,119 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "time_in_force" + */ + public function testPropertyTimeInForce() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "limit_price" + */ + public function testPropertyLimitPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop_price" + */ + public function testPropertyStopPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "legs" + */ + public function testPropertyLegs() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From a0a128aed54feab7f4054b2c095337d91b26c4f2 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 00:55:42 +0000 Subject: [PATCH 119/252] Version Bump SDKs (#139) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 4a6a330..01d0306 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2b6a3a41-72ef-4269-a487-33fbf6b51c3a \ No newline at end of file +b6daa2f4-bdfd-4320-9598-ec7146ce975c \ No newline at end of file diff --git a/README.md b/README.md index 1102b7f..4963bb9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.94-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.95-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.94" + "konfig/snaptrade-php-sdk": "2.0.95" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 833d13e..df70301 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.94/PHP'; + protected $userAgent = 'Konfig/2.0.95/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.94' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.95' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 6f631dea484d229098a3a454b2084bf438a51df8 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 18:25:30 +0000 Subject: [PATCH 120/252] Regenerate SDKs (#140) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 +- lib/Model/MlegOrderTypeStrict.php | 62 ++++++++++++++++++ lib/Model/TradingPlaceMlegOrderRequest.php | 44 +------------ test/Model/MlegOrderTypeStrictTest.php | 74 ++++++++++++++++++++++ 5 files changed, 141 insertions(+), 45 deletions(-) create mode 100644 lib/Model/MlegOrderTypeStrict.php create mode 100644 test/Model/MlegOrderTypeStrictTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 01d0306..a1d5b50 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -b6daa2f4-bdfd-4320-9598-ec7146ce975c \ No newline at end of file +d5b0c310-f9ff-4bc5-8c57-520178daea6a \ No newline at end of file diff --git a/README.md b/README.md index 4963bb9..9a7488c 100644 --- a/README.md +++ b/README.md @@ -2130,9 +2130,7 @@ $result = $snaptrade->trading->placeMlegOrder( #### βš™οΈ Parameters -##### type: `string` - -The type of order to place. +##### type: ##### time_in_force: diff --git a/lib/Model/MlegOrderTypeStrict.php b/lib/Model/MlegOrderTypeStrict.php new file mode 100644 index 0000000..d50c396 --- /dev/null +++ b/lib/Model/MlegOrderTypeStrict.php @@ -0,0 +1,62 @@ + 'string', + 'type' => '\SnapTrade\Model\MlegOrderTypeStrict', 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', 'limit_price' => 'float', 'stop_price' => 'float', @@ -245,25 +245,6 @@ public function getModelName() return self::$openAPIModelName; } - public const TYPE_MARKET = 'MARKET'; - public const TYPE_LIMIT = 'LIMIT'; - public const TYPE_STOP_LOSS_MARKET = 'STOP_LOSS_MARKET'; - public const TYPE_STOP_LOSS_LIMIT = 'STOP_LOSS_LIMIT'; - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getTypeAllowableValues() - { - return [ - self::TYPE_MARKET, - self::TYPE_LIMIT, - self::TYPE_STOP_LOSS_MARKET, - self::TYPE_STOP_LOSS_LIMIT, - ]; - } /** * Associative array for storing property values @@ -317,15 +298,6 @@ public function listInvalidProperties() if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } - $allowedValues = $this->getTypeAllowableValues(); - if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'type', must be one of '%s'", - $this->container['type'], - implode("', '", $allowedValues) - ); - } - if ($this->container['time_in_force'] === null) { $invalidProperties[] = "'time_in_force' can't be null"; } @@ -350,7 +322,7 @@ public function valid() /** * Gets type * - * @return string + * @return \SnapTrade\Model\MlegOrderTypeStrict */ public function getType() { @@ -360,22 +332,12 @@ public function getType() /** * Sets type * - * @param string $type The type of order to place. + * @param \SnapTrade\Model\MlegOrderTypeStrict $type type * * @return self */ public function setType($type) { - $allowedValues = $this->getTypeAllowableValues(); - if (!in_array($type, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'type', must be one of '%s'", - $type, - implode("', '", $allowedValues) - ) - ); - } if (is_null($type)) { throw new \InvalidArgumentException('non-nullable type cannot be null'); diff --git a/test/Model/MlegOrderTypeStrictTest.php b/test/Model/MlegOrderTypeStrictTest.php new file mode 100644 index 0000000..0a4c3a9 --- /dev/null +++ b/test/Model/MlegOrderTypeStrictTest.php @@ -0,0 +1,74 @@ +markTestIncomplete('Not implemented'); + } +} From 244399ea61156e9a3084fbf045a89160f194c04a Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 18:29:44 +0000 Subject: [PATCH 121/252] Version Bump SDKs (#141) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a1d5b50..3f00acb 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d5b0c310-f9ff-4bc5-8c57-520178daea6a \ No newline at end of file +ff0ad65e-17dc-4316-adab-926dd5908fd2 \ No newline at end of file diff --git a/README.md b/README.md index 9a7488c..4fba66c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.95-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.96-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.95" + "konfig/snaptrade-php-sdk": "2.0.96" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index df70301..ee93732 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.95/PHP'; + protected $userAgent = 'Konfig/2.0.96/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.95' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.96' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 27bcc46f0b78286d96d225d8c5ecc59052487c1c Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 19:39:04 +0000 Subject: [PATCH 122/252] Regenerate SDKs (#142) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 6 +- lib/Api/TradingApi.php | 8 +- lib/Model/MlegInstrumentType.php | 56 ++++++++++++++ lib/Model/MlegTradingInstrument.php | 72 +++++------------- lib/Model/TradingPlaceMlegOrderRequest.php | 36 ++++----- test/Model/MlegInstrumentTypeTest.php | 74 +++++++++++++++++++ test/Model/MlegTradingInstrumentTest.php | 4 +- .../TradingPlaceMlegOrderRequestTest.php | 4 +- 9 files changed, 179 insertions(+), 83 deletions(-) create mode 100644 lib/Model/MlegInstrumentType.php create mode 100644 test/Model/MlegInstrumentTypeTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 3f00acb..89cf109 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ff0ad65e-17dc-4316-adab-926dd5908fd2 \ No newline at end of file +79f0821b-0981-404f-8cda-a37c5a601393 \ No newline at end of file diff --git a/README.md b/README.md index 4fba66c..687998a 100644 --- a/README.md +++ b/README.md @@ -2108,13 +2108,13 @@ Places a multi-leg option order. Only supported on certain option trading broker ```php $result = $snaptrade->trading->placeMlegOrder( - type: "MARKET", + order_type: "MARKET", time_in_force: "Day", legs: [ [ "instrument" => [ "symbol" => "PBI 250718C00006000", - "type" => "OPTION", + "instrument_type" => "OPTION", ], "action" => "BUY_TO_OPEN", "units" => 1, @@ -2130,7 +2130,7 @@ $result = $snaptrade->trading->placeMlegOrder( #### βš™οΈ Parameters -##### type: +##### order_type: ##### time_in_force: diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index b54d4f5..bfc219a 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -3549,7 +3549,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for */ public function placeMlegOrder( - $type, + $order_type, $time_in_force, $legs, $user_id, @@ -3561,7 +3561,7 @@ public function placeMlegOrder( ) { $_body = []; - $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "limit_price", $limit_price); $this->setRequestBodyProperty($_body, "stop_price", $stop_price); @@ -3736,7 +3736,7 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, */ public function placeMlegOrderAsync( - $type, + $order_type, $time_in_force, $legs, $user_id, @@ -3748,7 +3748,7 @@ public function placeMlegOrderAsync( ) { $_body = []; - $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "limit_price", $limit_price); $this->setRequestBodyProperty($_body, "stop_price", $stop_price); diff --git a/lib/Model/MlegInstrumentType.php b/lib/Model/MlegInstrumentType.php new file mode 100644 index 0000000..67ebacd --- /dev/null +++ b/lib/Model/MlegInstrumentType.php @@ -0,0 +1,56 @@ + 'string', - 'type' => 'string' + 'instrument_type' => '\SnapTrade\Model\MlegInstrumentType' ]; /** @@ -63,7 +63,7 @@ class MlegTradingInstrument implements ModelInterface, ArrayAccess, \JsonSeriali */ protected static $openAPIFormats = [ 'symbol' => null, - 'type' => null + 'instrument_type' => null ]; /** @@ -73,7 +73,7 @@ class MlegTradingInstrument implements ModelInterface, ArrayAccess, \JsonSeriali */ protected static array $openAPINullables = [ 'symbol' => false, - 'type' => false + 'instrument_type' => false ]; /** @@ -163,7 +163,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'symbol' => 'symbol', - 'type' => 'type' + 'instrument_type' => 'instrument_type' ]; /** @@ -173,7 +173,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'symbol' => 'setSymbol', - 'type' => 'setType' + 'instrument_type' => 'setInstrumentType' ]; /** @@ -183,7 +183,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'symbol' => 'getSymbol', - 'type' => 'getType' + 'instrument_type' => 'getInstrumentType' ]; /** @@ -227,21 +227,6 @@ public function getModelName() return self::$openAPIModelName; } - public const TYPE_OPTION = 'OPTION'; - public const TYPE_EQUITY = 'EQUITY'; - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getTypeAllowableValues() - { - return [ - self::TYPE_OPTION, - self::TYPE_EQUITY, - ]; - } /** * Associative array for storing property values @@ -259,7 +244,7 @@ public function getTypeAllowableValues() public function __construct(array $data = null) { $this->setIfExists('symbol', $data ?? [], null); - $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('instrument_type', $data ?? [], null); } /** @@ -292,18 +277,9 @@ public function listInvalidProperties() if ($this->container['symbol'] === null) { $invalidProperties[] = "'symbol' can't be null"; } - if ($this->container['type'] === null) { - $invalidProperties[] = "'type' can't be null"; - } - $allowedValues = $this->getTypeAllowableValues(); - if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'type', must be one of '%s'", - $this->container['type'], - implode("', '", $allowedValues) - ); + if ($this->container['instrument_type'] === null) { + $invalidProperties[] = "'instrument_type' can't be null"; } - return $invalidProperties; } @@ -349,40 +325,30 @@ public function setSymbol($symbol) } /** - * Gets type + * Gets instrument_type * - * @return string + * @return \SnapTrade\Model\MlegInstrumentType */ - public function getType() + public function getInstrumentType() { - return $this->container['type']; + return $this->container['instrument_type']; } /** - * Sets type + * Sets instrument_type * - * @param string $type The instrument's type + * @param \SnapTrade\Model\MlegInstrumentType $instrument_type instrument_type * * @return self */ - public function setType($type) + public function setInstrumentType($instrument_type) { - $allowedValues = $this->getTypeAllowableValues(); - if (!in_array($type, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'type', must be one of '%s'", - $type, - implode("', '", $allowedValues) - ) - ); - } - if (is_null($type)) { - throw new \InvalidArgumentException('non-nullable type cannot be null'); + if (is_null($instrument_type)) { + throw new \InvalidArgumentException('non-nullable instrument_type cannot be null'); } - $this->container['type'] = $type; + $this->container['instrument_type'] = $instrument_type; return $this; } diff --git a/lib/Model/TradingPlaceMlegOrderRequest.php b/lib/Model/TradingPlaceMlegOrderRequest.php index 42f205c..5ce36f0 100644 --- a/lib/Model/TradingPlaceMlegOrderRequest.php +++ b/lib/Model/TradingPlaceMlegOrderRequest.php @@ -50,7 +50,7 @@ class TradingPlaceMlegOrderRequest implements ModelInterface, ArrayAccess, \Json * @var string[] */ protected static $openAPITypes = [ - 'type' => '\SnapTrade\Model\MlegOrderTypeStrict', + 'order_type' => '\SnapTrade\Model\MlegOrderTypeStrict', 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', 'limit_price' => 'float', 'stop_price' => 'float', @@ -65,7 +65,7 @@ class TradingPlaceMlegOrderRequest implements ModelInterface, ArrayAccess, \Json * @psalm-var array */ protected static $openAPIFormats = [ - 'type' => null, + 'order_type' => null, 'time_in_force' => null, 'limit_price' => 'decimal', 'stop_price' => 'decimal', @@ -78,7 +78,7 @@ class TradingPlaceMlegOrderRequest implements ModelInterface, ArrayAccess, \Json * @var boolean[] */ protected static array $openAPINullables = [ - 'type' => false, + 'order_type' => false, 'time_in_force' => false, 'limit_price' => true, 'stop_price' => true, @@ -171,7 +171,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'type' => 'type', + 'order_type' => 'order_type', 'time_in_force' => 'time_in_force', 'limit_price' => 'limit_price', 'stop_price' => 'stop_price', @@ -184,7 +184,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'type' => 'setType', + 'order_type' => 'setOrderType', 'time_in_force' => 'setTimeInForce', 'limit_price' => 'setLimitPrice', 'stop_price' => 'setStopPrice', @@ -197,7 +197,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'type' => 'getType', + 'order_type' => 'getOrderType', 'time_in_force' => 'getTimeInForce', 'limit_price' => 'getLimitPrice', 'stop_price' => 'getStopPrice', @@ -261,7 +261,7 @@ public function getModelName() */ public function __construct(array $data = null) { - $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('order_type', $data ?? [], null); $this->setIfExists('time_in_force', $data ?? [], null); $this->setIfExists('limit_price', $data ?? [], null); $this->setIfExists('stop_price', $data ?? [], null); @@ -295,8 +295,8 @@ public function listInvalidProperties() { $invalidProperties = []; - if ($this->container['type'] === null) { - $invalidProperties[] = "'type' can't be null"; + if ($this->container['order_type'] === null) { + $invalidProperties[] = "'order_type' can't be null"; } if ($this->container['time_in_force'] === null) { $invalidProperties[] = "'time_in_force' can't be null"; @@ -320,30 +320,30 @@ public function valid() /** - * Gets type + * Gets order_type * * @return \SnapTrade\Model\MlegOrderTypeStrict */ - public function getType() + public function getOrderType() { - return $this->container['type']; + return $this->container['order_type']; } /** - * Sets type + * Sets order_type * - * @param \SnapTrade\Model\MlegOrderTypeStrict $type type + * @param \SnapTrade\Model\MlegOrderTypeStrict $order_type order_type * * @return self */ - public function setType($type) + public function setOrderType($order_type) { - if (is_null($type)) { - throw new \InvalidArgumentException('non-nullable type cannot be null'); + if (is_null($order_type)) { + throw new \InvalidArgumentException('non-nullable order_type cannot be null'); } - $this->container['type'] = $type; + $this->container['order_type'] = $order_type; return $this; } diff --git a/test/Model/MlegInstrumentTypeTest.php b/test/Model/MlegInstrumentTypeTest.php new file mode 100644 index 0000000..faae046 --- /dev/null +++ b/test/Model/MlegInstrumentTypeTest.php @@ -0,0 +1,74 @@ +markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/MlegTradingInstrumentTest.php b/test/Model/MlegTradingInstrumentTest.php index 27e7cad..9e5e159 100644 --- a/test/Model/MlegTradingInstrumentTest.php +++ b/test/Model/MlegTradingInstrumentTest.php @@ -82,9 +82,9 @@ public function testPropertySymbol() } /** - * Test attribute "type" + * Test attribute "instrument_type" */ - public function testPropertyType() + public function testPropertyInstrumentType() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/TradingPlaceMlegOrderRequestTest.php b/test/Model/TradingPlaceMlegOrderRequestTest.php index 10cf01e..32aa7cf 100644 --- a/test/Model/TradingPlaceMlegOrderRequestTest.php +++ b/test/Model/TradingPlaceMlegOrderRequestTest.php @@ -73,9 +73,9 @@ public function testTradingPlaceMlegOrderRequest() } /** - * Test attribute "type" + * Test attribute "order_type" */ - public function testPropertyType() + public function testPropertyOrderType() { // TODO: implement $this->markTestIncomplete('Not implemented'); From 7077387fd8521114e017980d6024a38f43cf0add Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 19:43:16 +0000 Subject: [PATCH 123/252] Version Bump SDKs (#143) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 89cf109..505b1f2 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -79f0821b-0981-404f-8cda-a37c5a601393 \ No newline at end of file +a727d8dd-0a9d-456c-a224-e2dedc1d0d21 \ No newline at end of file diff --git a/README.md b/README.md index 687998a..04889d3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.96-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.97-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.96" + "konfig/snaptrade-php-sdk": "2.0.97" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index ee93732..a2d1fb1 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.96/PHP'; + protected $userAgent = 'Konfig/2.0.97/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.96' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.97' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 638f1b9cf357fcedb94d69129332d15671dc2192 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 21:09:59 +0000 Subject: [PATCH 124/252] Regenerate SDKs (#144) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Api/TradingApi.php | 52 +++++++++---------- ...MlegOrderRequest.php => MlegTradeForm.php} | 9 ++-- ...rRequestTest.php => MlegTradeFormTest.php} | 12 ++--- 4 files changed, 38 insertions(+), 37 deletions(-) rename lib/Model/{TradingPlaceMlegOrderRequest.php => MlegTradeForm.php} (98%) rename test/Model/{TradingPlaceMlegOrderRequestTest.php => MlegTradeFormTest.php} (87%) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 505b1f2..da20b7c 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -a727d8dd-0a9d-456c-a224-e2dedc1d0d21 \ No newline at end of file +514ceb20-7929-4fe8-8e83-c17bdfe15c8e \ No newline at end of file diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index bfc219a..6a49007 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -3540,7 +3540,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) - * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request trading_place_mleg_order_request (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form mleg_trade_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -3566,9 +3566,9 @@ public function placeMlegOrder( $this->setRequestBodyProperty($_body, "limit_price", $limit_price); $this->setRequestBodyProperty($_body, "stop_price", $stop_price); $this->setRequestBodyProperty($_body, "legs", $legs); - $trading_place_mleg_order_request = $_body; + $mleg_trade_form = $_body; - list($response) = $this->placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType); + list($response) = $this->placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); return $response; } @@ -3582,16 +3582,16 @@ public function placeMlegOrder( * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3610,7 +3610,7 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $user_id, $user_secret, $account_id, - $trading_place_mleg_order_request, + $mleg_trade_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -3728,7 +3728,7 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -3753,9 +3753,9 @@ public function placeMlegOrderAsync( $this->setRequestBodyProperty($_body, "limit_price", $limit_price); $this->setRequestBodyProperty($_body, "stop_price", $stop_price); $this->setRequestBodyProperty($_body, "legs", $legs); - $trading_place_mleg_order_request = $_body; + $mleg_trade_form = $_body; - return $this->placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType) + return $this->placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType) ->then( function ($response) { return $response[0]; @@ -3773,16 +3773,16 @@ function ($response) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\MlegOrderResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3829,13 +3829,13 @@ function ($exception) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, string $contentType = self::contentTypes['placeMlegOrder'][0]) + public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0]) { // Check if $user_id is a string @@ -3868,18 +3868,18 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $trad 'Missing the required parameter account_id when calling placeMlegOrder' ); } - if ($trading_place_mleg_order_request !== SENTINEL_VALUE) { - if (!($trading_place_mleg_order_request instanceof \SnapTrade\Model\TradingPlaceMlegOrderRequest)) { - if (!is_array($trading_place_mleg_order_request)) - throw new \InvalidArgumentException('"trading_place_mleg_order_request" must be associative array or an instance of \SnapTrade\Model\TradingPlaceMlegOrderRequest TradingApi.placeMlegOrder.'); + if ($mleg_trade_form !== SENTINEL_VALUE) { + if (!($mleg_trade_form instanceof \SnapTrade\Model\MlegTradeForm)) { + if (!is_array($mleg_trade_form)) + throw new \InvalidArgumentException('"mleg_trade_form" must be associative array or an instance of \SnapTrade\Model\MlegTradeForm TradingApi.placeMlegOrder.'); else - $trading_place_mleg_order_request = new \SnapTrade\Model\TradingPlaceMlegOrderRequest($trading_place_mleg_order_request); + $mleg_trade_form = new \SnapTrade\Model\MlegTradeForm($mleg_trade_form); } } - // verify the required parameter 'trading_place_mleg_order_request' is set - if ($trading_place_mleg_order_request === SENTINEL_VALUE || (is_array($trading_place_mleg_order_request) && count($trading_place_mleg_order_request) === 0)) { + // verify the required parameter 'mleg_trade_form' is set + if ($mleg_trade_form === SENTINEL_VALUE || (is_array($mleg_trade_form) && count($mleg_trade_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter trading_place_mleg_order_request when calling placeMlegOrder' + 'Missing the required parameter mleg_trade_form when calling placeMlegOrder' ); } @@ -3932,12 +3932,12 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $trad ); // for model (json/xml) - if (isset($trading_place_mleg_order_request)) { + if (isset($mleg_trade_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_place_mleg_order_request)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($mleg_trade_form)); } else { - $httpBody = $trading_place_mleg_order_request; + $httpBody = $mleg_trade_form; } } elseif (count($formParams) > 0) { if ($multipart) { diff --git a/lib/Model/TradingPlaceMlegOrderRequest.php b/lib/Model/MlegTradeForm.php similarity index 98% rename from lib/Model/TradingPlaceMlegOrderRequest.php rename to lib/Model/MlegTradeForm.php index 5ce36f0..3e209ce 100644 --- a/lib/Model/TradingPlaceMlegOrderRequest.php +++ b/lib/Model/MlegTradeForm.php @@ -1,6 +1,6 @@ */ -class TradingPlaceMlegOrderRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class MlegTradeForm implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -42,7 +43,7 @@ class TradingPlaceMlegOrderRequest implements ModelInterface, ArrayAccess, \Json * * @var string */ - protected static $openAPIModelName = 'Trading_placeMlegOrder_request'; + protected static $openAPIModelName = 'MlegTradeForm'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/test/Model/TradingPlaceMlegOrderRequestTest.php b/test/Model/MlegTradeFormTest.php similarity index 87% rename from test/Model/TradingPlaceMlegOrderRequestTest.php rename to test/Model/MlegTradeFormTest.php index 32aa7cf..2ea3866 100644 --- a/test/Model/TradingPlaceMlegOrderRequestTest.php +++ b/test/Model/MlegTradeFormTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); From 125b409c64ea417584499c2b41cedbaa013557f5 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 21:13:57 +0000 Subject: [PATCH 125/252] Version Bump SDKs (#145) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index da20b7c..0255c9b 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -514ceb20-7929-4fe8-8e83-c17bdfe15c8e \ No newline at end of file +616e51f6-73aa-41eb-8d68-237632e749c6 \ No newline at end of file diff --git a/README.md b/README.md index 04889d3..cd2dc9d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.97-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.98-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.97" + "konfig/snaptrade-php-sdk": "2.0.98" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index a2d1fb1..b439d61 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.97/PHP'; + protected $userAgent = 'Konfig/2.0.98/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.97' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.98' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 20a412476b44600c7450a4cb831716bcb791e7ca Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 22:29:57 +0000 Subject: [PATCH 126/252] Regenerate SDKs (#147) * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/TradingApi.php | 104 +++++++++--------- lib/Model/ManualTradeFormWithOptions.php | 2 +- lib/Model/MlegTradingInstrument.php | 2 +- ...leOrderRequest.php => SimpleOrderForm.php} | 8 +- ...equestTest.php => SimpleOrderFormTest.php} | 12 +- 7 files changed, 66 insertions(+), 66 deletions(-) rename lib/Model/{TradingPlaceSimpleOrderRequest.php => SimpleOrderForm.php} (98%) rename test/Model/{TradingPlaceSimpleOrderRequestTest.php => SimpleOrderFormTest.php} (90%) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0255c9b..b0c1bfe 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -616e51f6-73aa-41eb-8d68-237632e749c6 \ No newline at end of file +cdd2319c-ebca-490b-8ca8-aee808609fd7 \ No newline at end of file diff --git a/README.md b/README.md index cd2dc9d..6a42ed0 100644 --- a/README.md +++ b/README.md @@ -2068,7 +2068,7 @@ The universal symbol ID of the security to trade. Must be 'null' if `symbol` is ##### symbol: `string` -The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example \\\"AAPL 131124C00240000\\\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. +The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example `AAPL 131124C00240000` represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. ##### price: `float` diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 6a49007..cb08fdc 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -4470,7 +4470,7 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) - * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request trading_place_simple_order_request (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -4504,9 +4504,9 @@ public function placeSimpleOrder( $this->setRequestBodyProperty($_body, "stop_price", $stop_price); $this->setRequestBodyProperty($_body, "post_only", $post_only); $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $trading_place_simple_order_request = $_body; + $simple_order_form = $_body; - list($response) = $this->placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); + list($response) = $this->placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); return $response; } @@ -4520,16 +4520,16 @@ public function placeSimpleOrder( * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4548,7 +4548,7 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id $user_id, $user_secret, $account_id, - $trading_place_simple_order_request, + $simple_order_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -4666,7 +4666,7 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -4699,9 +4699,9 @@ public function placeSimpleOrderAsync( $this->setRequestBodyProperty($_body, "stop_price", $stop_price); $this->setRequestBodyProperty($_body, "post_only", $post_only); $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $trading_place_simple_order_request = $_body; + $simple_order_form = $_body; - return $this->placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType) + return $this->placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) ->then( function ($response) { return $response[0]; @@ -4719,16 +4719,16 @@ function ($response) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4775,13 +4775,13 @@ function ($exception) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['placeSimpleOrder'][0]) + public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0]) { // Check if $user_id is a string @@ -4814,18 +4814,18 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $tr 'Missing the required parameter account_id when calling placeSimpleOrder' ); } - if ($trading_place_simple_order_request !== SENTINEL_VALUE) { - if (!($trading_place_simple_order_request instanceof \SnapTrade\Model\TradingPlaceSimpleOrderRequest)) { - if (!is_array($trading_place_simple_order_request)) - throw new \InvalidArgumentException('"trading_place_simple_order_request" must be associative array or an instance of \SnapTrade\Model\TradingPlaceSimpleOrderRequest TradingApi.placeSimpleOrder.'); + if ($simple_order_form !== SENTINEL_VALUE) { + if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { + if (!is_array($simple_order_form)) + throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm TradingApi.placeSimpleOrder.'); else - $trading_place_simple_order_request = new \SnapTrade\Model\TradingPlaceSimpleOrderRequest($trading_place_simple_order_request); + $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); } } - // verify the required parameter 'trading_place_simple_order_request' is set - if ($trading_place_simple_order_request === SENTINEL_VALUE || (is_array($trading_place_simple_order_request) && count($trading_place_simple_order_request) === 0)) { + // verify the required parameter 'simple_order_form' is set + if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter trading_place_simple_order_request when calling placeSimpleOrder' + 'Missing the required parameter simple_order_form when calling placeSimpleOrder' ); } @@ -4878,12 +4878,12 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $tr ); // for model (json/xml) - if (isset($trading_place_simple_order_request)) { + if (isset($simple_order_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_place_simple_order_request)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); } else { - $httpBody = $trading_place_simple_order_request; + $httpBody = $simple_order_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -4962,7 +4962,7 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $tr * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) - * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request trading_place_simple_order_request (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -4996,9 +4996,9 @@ public function previewSimpleOrder( $this->setRequestBodyProperty($_body, "stop_price", $stop_price); $this->setRequestBodyProperty($_body, "post_only", $post_only); $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $trading_place_simple_order_request = $_body; + $simple_order_form = $_body; - list($response) = $this->previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); + list($response) = $this->previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); return $response; } @@ -5012,16 +5012,16 @@ public function previewSimpleOrder( * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -5040,7 +5040,7 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ $user_id, $user_secret, $account_id, - $trading_place_simple_order_request, + $simple_order_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -5158,7 +5158,7 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -5191,9 +5191,9 @@ public function previewSimpleOrderAsync( $this->setRequestBodyProperty($_body, "stop_price", $stop_price); $this->setRequestBodyProperty($_body, "post_only", $post_only); $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $trading_place_simple_order_request = $_body; + $simple_order_form = $_body; - return $this->previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType) + return $this->previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) ->then( function ($response) { return $response[0]; @@ -5211,16 +5211,16 @@ function ($response) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\SimpleOrderPreview'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -5267,13 +5267,13 @@ function ($exception) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingPlaceSimpleOrderRequest $trading_place_simple_order_request (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $trading_place_simple_order_request, string $contentType = self::contentTypes['previewSimpleOrder'][0]) + public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0]) { // Check if $user_id is a string @@ -5306,18 +5306,18 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ 'Missing the required parameter account_id when calling previewSimpleOrder' ); } - if ($trading_place_simple_order_request !== SENTINEL_VALUE) { - if (!($trading_place_simple_order_request instanceof \SnapTrade\Model\TradingPlaceSimpleOrderRequest)) { - if (!is_array($trading_place_simple_order_request)) - throw new \InvalidArgumentException('"trading_place_simple_order_request" must be associative array or an instance of \SnapTrade\Model\TradingPlaceSimpleOrderRequest TradingApi.previewSimpleOrder.'); + if ($simple_order_form !== SENTINEL_VALUE) { + if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { + if (!is_array($simple_order_form)) + throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm TradingApi.previewSimpleOrder.'); else - $trading_place_simple_order_request = new \SnapTrade\Model\TradingPlaceSimpleOrderRequest($trading_place_simple_order_request); + $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); } } - // verify the required parameter 'trading_place_simple_order_request' is set - if ($trading_place_simple_order_request === SENTINEL_VALUE || (is_array($trading_place_simple_order_request) && count($trading_place_simple_order_request) === 0)) { + // verify the required parameter 'simple_order_form' is set + if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter trading_place_simple_order_request when calling previewSimpleOrder' + 'Missing the required parameter simple_order_form when calling previewSimpleOrder' ); } @@ -5370,12 +5370,12 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ ); // for model (json/xml) - if (isset($trading_place_simple_order_request)) { + if (isset($simple_order_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_place_simple_order_request)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); } else { - $httpBody = $trading_place_simple_order_request; + $httpBody = $simple_order_form; } } elseif (count($formParams) > 0) { if ($multipart) { diff --git a/lib/Model/ManualTradeFormWithOptions.php b/lib/Model/ManualTradeFormWithOptions.php index bdfa014..24a4b5e 100644 --- a/lib/Model/ManualTradeFormWithOptions.php +++ b/lib/Model/ManualTradeFormWithOptions.php @@ -465,7 +465,7 @@ public function getSymbol() /** * Sets symbol * - * @param string|null $symbol The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example \"AAPL 131124C00240000\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. + * @param string|null $symbol The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example `AAPL 131124C00240000` represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. * * @return self */ diff --git a/lib/Model/MlegTradingInstrument.php b/lib/Model/MlegTradingInstrument.php index 1e169b5..6b553a1 100644 --- a/lib/Model/MlegTradingInstrument.php +++ b/lib/Model/MlegTradingInstrument.php @@ -308,7 +308,7 @@ public function getSymbol() /** * Sets symbol * - * @param string $symbol The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example \"AAPL 131124C00240000\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format) + * @param string $symbol The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example `AAPL 131124C00240000` represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format) * * @return self */ diff --git a/lib/Model/TradingPlaceSimpleOrderRequest.php b/lib/Model/SimpleOrderForm.php similarity index 98% rename from lib/Model/TradingPlaceSimpleOrderRequest.php rename to lib/Model/SimpleOrderForm.php index 5ce098e..ff62728 100644 --- a/lib/Model/TradingPlaceSimpleOrderRequest.php +++ b/lib/Model/SimpleOrderForm.php @@ -1,6 +1,6 @@ */ -class TradingPlaceSimpleOrderRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class SimpleOrderForm implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -42,7 +42,7 @@ class TradingPlaceSimpleOrderRequest implements ModelInterface, ArrayAccess, \Js * * @var string */ - protected static $openAPIModelName = 'Trading_placeSimpleOrder_request'; + protected static $openAPIModelName = 'SimpleOrderForm'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/test/Model/TradingPlaceSimpleOrderRequestTest.php b/test/Model/SimpleOrderFormTest.php similarity index 90% rename from test/Model/TradingPlaceSimpleOrderRequestTest.php rename to test/Model/SimpleOrderFormTest.php index 5aaba92..465e72f 100644 --- a/test/Model/TradingPlaceSimpleOrderRequestTest.php +++ b/test/Model/SimpleOrderFormTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); From 343be74b625ae07c53bd51b38e9ee12e8fcd254c Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Sat, 10 May 2025 06:18:25 +0000 Subject: [PATCH 127/252] Regenerate SDKs (#149) Co-authored-by: Passiv Ops Co-authored-by: Alessio Galdy --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b0c1bfe..38d30a2 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -cdd2319c-ebca-490b-8ca8-aee808609fd7 \ No newline at end of file +f7a6de37-c1e9-4887-8eae-827d02f9cc31 From 523f191e6418bcf5d3a2e3c5f5d90a4cbb18cffa Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Sat, 10 May 2025 06:22:24 +0000 Subject: [PATCH 128/252] Version Bump SDKs (#150) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 38d30a2..9b7b98c 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f7a6de37-c1e9-4887-8eae-827d02f9cc31 +6883db3c-d58d-40c1-ac65-ff91db925667 \ No newline at end of file diff --git a/README.md b/README.md index 6a42ed0..f09f49a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.98-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.99-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.98" + "konfig/snaptrade-php-sdk": "2.0.99" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index b439d61..d0fcc29 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.98/PHP'; + protected $userAgent = 'Konfig/2.0.99/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.98' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.99' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 62d41e5a98b805f4fe272c52d477a83d5bc8f517 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 14 May 2025 21:41:42 +0000 Subject: [PATCH 129/252] Regenerate SDKs (#151) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 9b7b98c..c0928f9 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -6883db3c-d58d-40c1-ac65-ff91db925667 \ No newline at end of file +b6a5ea87-45f1-4857-a251-675a5c29d733 \ No newline at end of file From 2d9dac1d0943eda5ddeced8730100c22cadb6b9a Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 14 May 2025 21:46:22 +0000 Subject: [PATCH 130/252] Version Bump SDKs (#152) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index c0928f9..01431c9 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -b6a5ea87-45f1-4857-a251-675a5c29d733 \ No newline at end of file +ec11710a-aa03-442d-8fa8-c75bd80da86a \ No newline at end of file diff --git a/README.md b/README.md index f09f49a..aec86fb 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.99-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.100-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.99" + "konfig/snaptrade-php-sdk": "2.0.100" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index d0fcc29..62f2022 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.99/PHP'; + protected $userAgent = 'Konfig/2.0.100/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.99' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.100' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From d238e10a759ed185d26749cab8cfefe68a4f6ed9 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 15:47:49 +0000 Subject: [PATCH 131/252] Regenerate SDKs (#153) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 01431c9..9803a92 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ec11710a-aa03-442d-8fa8-c75bd80da86a \ No newline at end of file +0315d507-5133-4244-9d6d-3311039c5d60 \ No newline at end of file From c4b8729d86e04686f63e5dbe381126f8bf0d401b Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 15:52:01 +0000 Subject: [PATCH 132/252] Version Bump SDKs (#154) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 9803a92..17d73ab 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -0315d507-5133-4244-9d6d-3311039c5d60 \ No newline at end of file +923abf88-e1bc-414a-bca0-dca1cbb80fa1 \ No newline at end of file diff --git a/README.md b/README.md index aec86fb..3913491 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.100-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.101-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.100" + "konfig/snaptrade-php-sdk": "2.0.101" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 62f2022..e22c07c 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.100/PHP'; + protected $userAgent = 'Konfig/2.0.101/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.100' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.101' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 227669e865b93c8dcf1002b3b68f27e8878480cd Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 18:58:48 +0000 Subject: [PATCH 133/252] Regenerate SDKs (#155) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/BrokerageAuthorization.php | 48 ++++++++++++++++++++--- test/Model/BrokerageAuthorizationTest.php | 9 +++++ 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 17d73ab..70bb5c8 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -923abf88-e1bc-414a-bca0-dca1cbb80fa1 \ No newline at end of file +0047ffe6-189b-46f1-a01a-fa948a3b5b6a \ No newline at end of file diff --git a/lib/Model/BrokerageAuthorization.php b/lib/Model/BrokerageAuthorization.php index 8affc92..4886669 100644 --- a/lib/Model/BrokerageAuthorization.php +++ b/lib/Model/BrokerageAuthorization.php @@ -59,7 +59,8 @@ class BrokerageAuthorization implements ModelInterface, ArrayAccess, \JsonSerial 'disabled' => 'bool', 'disabled_date' => '\DateTime', 'meta' => 'array', - 'updated_date' => '\DateTime' + 'updated_date' => '\DateTime', + 'is_eligible_for_payout' => 'bool' ]; /** @@ -78,7 +79,8 @@ class BrokerageAuthorization implements ModelInterface, ArrayAccess, \JsonSerial 'disabled' => null, 'disabled_date' => 'date-time', 'meta' => null, - 'updated_date' => 'date-time' + 'updated_date' => 'date-time', + 'is_eligible_for_payout' => null ]; /** @@ -95,7 +97,8 @@ class BrokerageAuthorization implements ModelInterface, ArrayAccess, \JsonSerial 'disabled' => false, 'disabled_date' => true, 'meta' => false, - 'updated_date' => false + 'updated_date' => false, + 'is_eligible_for_payout' => false ]; /** @@ -192,7 +195,8 @@ public function isNullableSetToNull(string $property): bool 'disabled' => 'disabled', 'disabled_date' => 'disabled_date', 'meta' => 'meta', - 'updated_date' => 'updated_date' + 'updated_date' => 'updated_date', + 'is_eligible_for_payout' => 'is_eligible_for_payout' ]; /** @@ -209,7 +213,8 @@ public function isNullableSetToNull(string $property): bool 'disabled' => 'setDisabled', 'disabled_date' => 'setDisabledDate', 'meta' => 'setMeta', - 'updated_date' => 'setUpdatedDate' + 'updated_date' => 'setUpdatedDate', + 'is_eligible_for_payout' => 'setIsEligibleForPayout' ]; /** @@ -226,7 +231,8 @@ public function isNullableSetToNull(string $property): bool 'disabled' => 'getDisabled', 'disabled_date' => 'getDisabledDate', 'meta' => 'getMeta', - 'updated_date' => 'getUpdatedDate' + 'updated_date' => 'getUpdatedDate', + 'is_eligible_for_payout' => 'getIsEligibleForPayout' ]; /** @@ -295,6 +301,7 @@ public function __construct(array $data = null) $this->setIfExists('disabled_date', $data ?? [], null); $this->setIfExists('meta', $data ?? [], null); $this->setIfExists('updated_date', $data ?? [], null); + $this->setIfExists('is_eligible_for_payout', $data ?? [], null); } /** @@ -610,6 +617,35 @@ public function setUpdatedDate($updated_date) return $this; } + + /** + * Gets is_eligible_for_payout + * + * @return bool|null + */ + public function getIsEligibleForPayout() + { + return $this->container['is_eligible_for_payout']; + } + + /** + * Sets is_eligible_for_payout + * + * @param bool|null $is_eligible_for_payout Whether the connection is eligible for a payout. + * + * @return self + */ + public function setIsEligibleForPayout($is_eligible_for_payout) + { + + if (is_null($is_eligible_for_payout)) { + throw new \InvalidArgumentException('non-nullable is_eligible_for_payout cannot be null'); + } + + $this->container['is_eligible_for_payout'] = $is_eligible_for_payout; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/test/Model/BrokerageAuthorizationTest.php b/test/Model/BrokerageAuthorizationTest.php index e89150e..3f08757 100644 --- a/test/Model/BrokerageAuthorizationTest.php +++ b/test/Model/BrokerageAuthorizationTest.php @@ -152,4 +152,13 @@ public function testPropertyUpdatedDate() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "is_eligible_for_payout" + */ + public function testPropertyIsEligibleForPayout() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } From 78b5efe86a6793a2f41ed7362b926bde12dd75de Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 19:02:47 +0000 Subject: [PATCH 134/252] Version Bump SDKs (#156) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 70bb5c8..ee762d3 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -0047ffe6-189b-46f1-a01a-fa948a3b5b6a \ No newline at end of file +7573aa90-1ee4-4ae3-b065-72e4eeb91b2c \ No newline at end of file diff --git a/README.md b/README.md index 3913491..b48f958 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.101-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.102-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.101" + "konfig/snaptrade-php-sdk": "2.0.102" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index e22c07c..2230f53 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.101/PHP'; + protected $userAgent = 'Konfig/2.0.102/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.101' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.102' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From a28c4311e8ce6026ebcd8f68ec78b9a9bceeaeca Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 15:28:51 +0000 Subject: [PATCH 135/252] Regenerate SDKs (#157) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/Account.php | 77 ++++++++++++++++++++++++++++++++++++++ test/Model/AccountTest.php | 9 +++++ 3 files changed, 87 insertions(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index ee762d3..599edbc 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -7573aa90-1ee4-4ae3-b065-72e4eeb91b2c \ No newline at end of file +ed3e5648-4e7c-4b55-a8f7-16c467b5d79c \ No newline at end of file diff --git a/lib/Model/Account.php b/lib/Model/Account.php index f529716..3e541e1 100644 --- a/lib/Model/Account.php +++ b/lib/Model/Account.php @@ -59,6 +59,7 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'created_date' => '\DateTime', 'sync_status' => '\SnapTrade\Model\AccountSyncStatus', 'balance' => '\SnapTrade\Model\AccountBalance', + 'status' => 'string', 'raw_type' => 'string', 'meta' => 'array', 'portfolio_group' => 'string', @@ -81,6 +82,7 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'created_date' => 'date-time', 'sync_status' => null, 'balance' => null, + 'status' => null, 'raw_type' => null, 'meta' => null, 'portfolio_group' => 'uuid', @@ -101,6 +103,7 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'created_date' => false, 'sync_status' => false, 'balance' => false, + 'status' => true, 'raw_type' => true, 'meta' => false, 'portfolio_group' => false, @@ -201,6 +204,7 @@ public function isNullableSetToNull(string $property): bool 'created_date' => 'created_date', 'sync_status' => 'sync_status', 'balance' => 'balance', + 'status' => 'status', 'raw_type' => 'raw_type', 'meta' => 'meta', 'portfolio_group' => 'portfolio_group', @@ -221,6 +225,7 @@ public function isNullableSetToNull(string $property): bool 'created_date' => 'setCreatedDate', 'sync_status' => 'setSyncStatus', 'balance' => 'setBalance', + 'status' => 'setStatus', 'raw_type' => 'setRawType', 'meta' => 'setMeta', 'portfolio_group' => 'setPortfolioGroup', @@ -241,6 +246,7 @@ public function isNullableSetToNull(string $property): bool 'created_date' => 'getCreatedDate', 'sync_status' => 'getSyncStatus', 'balance' => 'getBalance', + 'status' => 'getStatus', 'raw_type' => 'getRawType', 'meta' => 'getMeta', 'portfolio_group' => 'getPortfolioGroup', @@ -288,6 +294,21 @@ public function getModelName() return self::$openAPIModelName; } + public const STATUS_OPEN = 'open'; + public const STATUS_CLOSED = 'closed'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_OPEN, + self::STATUS_CLOSED, + ]; + } /** * Associative array for storing property values @@ -312,6 +333,7 @@ public function __construct(array $data = null) $this->setIfExists('created_date', $data ?? [], null); $this->setIfExists('sync_status', $data ?? [], null); $this->setIfExists('balance', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); $this->setIfExists('raw_type', $data ?? [], null); $this->setIfExists('meta', $data ?? [], null); $this->setIfExists('portfolio_group', $data ?? [], null); @@ -369,6 +391,15 @@ public function listInvalidProperties() if ($this->container['balance'] === null) { $invalidProperties[] = "'balance' can't be null"; } + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + return $invalidProperties; } @@ -623,6 +654,52 @@ public function setBalance($balance) return $this; } + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status The current status of the account. Can be either \"open\", \"closed\", or null if the status is unknown or not provided by the brokerage. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($status)) { + array_push($this->openAPINullablesSetToNull, 'status'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('status', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['status'] = $status; + + return $this; + } + /** * Gets raw_type * diff --git a/test/Model/AccountTest.php b/test/Model/AccountTest.php index c63d53c..426b0f6 100644 --- a/test/Model/AccountTest.php +++ b/test/Model/AccountTest.php @@ -144,6 +144,15 @@ public function testPropertyBalance() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "status" + */ + public function testPropertyStatus() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "raw_type" */ From 6d964a726572b4425ae063080bf7b1a8089bc9a5 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 15:33:04 +0000 Subject: [PATCH 136/252] Version Bump SDKs (#158) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 599edbc..34cf8b5 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ed3e5648-4e7c-4b55-a8f7-16c467b5d79c \ No newline at end of file +822efb6a-f497-45af-a224-c6155ef94e41 \ No newline at end of file diff --git a/README.md b/README.md index b48f958..6152cc1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.102-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.103-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.102" + "konfig/snaptrade-php-sdk": "2.0.103" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 2230f53..ee09b85 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.102/PHP'; + protected $userAgent = 'Konfig/2.0.103/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.102' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.103' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 98892f5c6b030ca209735fee03453fd066a8ef4b Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:13:57 +0000 Subject: [PATCH 137/252] Regenerate SDKs (#159) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 5 +++- lib/Api/TradingApi.php | 4 +++ lib/Model/MlegTradeForm.php | 43 ++++++++++++++++++++++++++++++++ test/Model/MlegTradeFormTest.php | 9 +++++++ 5 files changed, 61 insertions(+), 2 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 34cf8b5..51574d5 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -822efb6a-f497-45af-a224-c6155ef94e41 \ No newline at end of file +5964deaa-7c38-413a-bc5e-67ea2ca3496d \ No newline at end of file diff --git a/README.md b/README.md index 6152cc1..257e677 100644 --- a/README.md +++ b/README.md @@ -2124,7 +2124,8 @@ $result = $snaptrade->trading->placeMlegOrder( user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", limit_price: "", - stop_price: "" + stop_price: "", + price_effect: "DEBIT" ); ``` @@ -2150,6 +2151,8 @@ The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT. The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT. +##### price_effect: [`string`](./lib/Model/string.php) + #### πŸ”„ Return diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index cb08fdc..644fb07 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -3557,6 +3557,7 @@ public function placeMlegOrder( $account_id, $limit_price = SENTINEL_VALUE, $stop_price = SENTINEL_VALUE, + $price_effect = SENTINEL_VALUE, string $contentType = self::contentTypes['placeMlegOrder'][0] ) { @@ -3565,6 +3566,7 @@ public function placeMlegOrder( $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "limit_price", $limit_price); $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "price_effect", $price_effect); $this->setRequestBodyProperty($_body, "legs", $legs); $mleg_trade_form = $_body; @@ -3744,6 +3746,7 @@ public function placeMlegOrderAsync( $account_id, $limit_price = SENTINEL_VALUE, $stop_price = SENTINEL_VALUE, + $price_effect = SENTINEL_VALUE, string $contentType = self::contentTypes['placeMlegOrder'][0] ) { @@ -3752,6 +3755,7 @@ public function placeMlegOrderAsync( $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); $this->setRequestBodyProperty($_body, "limit_price", $limit_price); $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "price_effect", $price_effect); $this->setRequestBodyProperty($_body, "legs", $legs); $mleg_trade_form = $_body; diff --git a/lib/Model/MlegTradeForm.php b/lib/Model/MlegTradeForm.php index 3e209ce..d6ed7ae 100644 --- a/lib/Model/MlegTradeForm.php +++ b/lib/Model/MlegTradeForm.php @@ -55,6 +55,7 @@ class MlegTradeForm implements ModelInterface, ArrayAccess, \JsonSerializable 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', 'limit_price' => 'float', 'stop_price' => 'float', + 'price_effect' => 'string', 'legs' => '\SnapTrade\Model\MlegLeg[]' ]; @@ -70,6 +71,7 @@ class MlegTradeForm implements ModelInterface, ArrayAccess, \JsonSerializable 'time_in_force' => null, 'limit_price' => 'decimal', 'stop_price' => 'decimal', + 'price_effect' => null, 'legs' => null ]; @@ -83,6 +85,7 @@ class MlegTradeForm implements ModelInterface, ArrayAccess, \JsonSerializable 'time_in_force' => false, 'limit_price' => true, 'stop_price' => true, + 'price_effect' => true, 'legs' => false ]; @@ -176,6 +179,7 @@ public function isNullableSetToNull(string $property): bool 'time_in_force' => 'time_in_force', 'limit_price' => 'limit_price', 'stop_price' => 'stop_price', + 'price_effect' => 'price_effect', 'legs' => 'legs' ]; @@ -189,6 +193,7 @@ public function isNullableSetToNull(string $property): bool 'time_in_force' => 'setTimeInForce', 'limit_price' => 'setLimitPrice', 'stop_price' => 'setStopPrice', + 'price_effect' => 'setPriceEffect', 'legs' => 'setLegs' ]; @@ -202,6 +207,7 @@ public function isNullableSetToNull(string $property): bool 'time_in_force' => 'getTimeInForce', 'limit_price' => 'getLimitPrice', 'stop_price' => 'getStopPrice', + 'price_effect' => 'getPriceEffect', 'legs' => 'getLegs' ]; @@ -266,6 +272,7 @@ public function __construct(array $data = null) $this->setIfExists('time_in_force', $data ?? [], null); $this->setIfExists('limit_price', $data ?? [], null); $this->setIfExists('stop_price', $data ?? [], null); + $this->setIfExists('price_effect', $data ?? [], null); $this->setIfExists('legs', $data ?? [], null); } @@ -450,6 +457,42 @@ public function setStopPrice($stop_price) return $this; } + /** + * Gets price_effect + * + * @return string|null + */ + public function getPriceEffect() + { + return $this->container['price_effect']; + } + + /** + * Sets price_effect + * + * @param string|null $price_effect price_effect + * + * @return self + */ + public function setPriceEffect($price_effect) + { + + if (is_null($price_effect)) { + array_push($this->openAPINullablesSetToNull, 'price_effect'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('price_effect', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['price_effect'] = $price_effect; + + return $this; + } + /** * Gets legs * diff --git a/test/Model/MlegTradeFormTest.php b/test/Model/MlegTradeFormTest.php index 2ea3866..651ff8c 100644 --- a/test/Model/MlegTradeFormTest.php +++ b/test/Model/MlegTradeFormTest.php @@ -108,6 +108,15 @@ public function testPropertyStopPrice() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "price_effect" + */ + public function testPropertyPriceEffect() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "legs" */ From 720777da35dc30fba8c4dc2f2bba7469af1cf083 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:17:45 +0000 Subject: [PATCH 138/252] Version Bump SDKs (#160) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 51574d5..9c3eb61 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -5964deaa-7c38-413a-bc5e-67ea2ca3496d \ No newline at end of file +f6114d84-1fc8-47e2-bcc9-886c02ada71f \ No newline at end of file diff --git a/README.md b/README.md index 257e677..47e2c50 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.103-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.104-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.103" + "konfig/snaptrade-php-sdk": "2.0.104" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index ee09b85..ed6bd57 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.103/PHP'; + protected $userAgent = 'Konfig/2.0.104/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.103' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.104' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 5b3165c5632379f9f848d11a39262f4c44885a66 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 13:46:22 +0000 Subject: [PATCH 139/252] Regenerate SDKs (#161) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/Account.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 9c3eb61..299063e 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f6114d84-1fc8-47e2-bcc9-886c02ada71f \ No newline at end of file +b53fb892-cb06-44d4-a8bb-1f444c0a0705 \ No newline at end of file diff --git a/lib/Model/Account.php b/lib/Model/Account.php index 3e541e1..cea088c 100644 --- a/lib/Model/Account.php +++ b/lib/Model/Account.php @@ -296,6 +296,7 @@ public function getModelName() public const STATUS_OPEN = 'open'; public const STATUS_CLOSED = 'closed'; + public const STATUS_ARCHIVED = 'archived'; /** * Gets allowable values of the enum @@ -307,6 +308,7 @@ public function getStatusAllowableValues() return [ self::STATUS_OPEN, self::STATUS_CLOSED, + self::STATUS_ARCHIVED, ]; } @@ -667,7 +669,7 @@ public function getStatus() /** * Sets status * - * @param string|null $status The current status of the account. Can be either \"open\", \"closed\", or null if the status is unknown or not provided by the brokerage. + * @param string|null $status The current status of the account. Can be either \"open\", \"closed\", \"archived\" or null if the status is unknown or not provided by the brokerage. * * @return self */ From beefe8ffcac66957d063af1975c8b1c6cd525153 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 13:50:30 +0000 Subject: [PATCH 140/252] Version Bump SDKs (#162) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 299063e..b889417 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -b53fb892-cb06-44d4-a8bb-1f444c0a0705 \ No newline at end of file +dd6acfea-2d99-405a-812a-20fd5e504a90 \ No newline at end of file diff --git a/README.md b/README.md index 47e2c50..55400fc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.104-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.105-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.104" + "konfig/snaptrade-php-sdk": "2.0.105" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index ed6bd57..465e276 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.104/PHP'; + protected $userAgent = 'Konfig/2.0.105/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.104' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.105' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 38719f9f24bed5fb016cea5c044144db97ca89b4 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 19:18:28 +0000 Subject: [PATCH 141/252] Version Bump SDKs (#165) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 346 +-- lib/Api/CryptoTradingApi.php | 1576 ++++++++++++++ lib/Api/TradingApi.php | 3329 +++++++++-------------------- lib/Client.php | 3 + lib/Configuration.php | 4 +- test/Api/CryptoTradingApiTest.php | 96 + test/Api/TradingApiTest.php | 36 - 8 files changed, 2804 insertions(+), 2588 deletions(-) create mode 100644 lib/Api/CryptoTradingApi.php create mode 100644 test/Api/CryptoTradingApiTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b889417..b3e2842 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -dd6acfea-2d99-405a-812a-20fd5e504a90 \ No newline at end of file +53e11c38-5085-4f22-ac4b-c617dc909229 \ No newline at end of file diff --git a/README.md b/README.md index 55400fc..35a957f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.105-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.106-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -45,6 +45,9 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.connections.removeBrokerageAuthorization`](#snaptradeconnectionsremovebrokerageauthorization) * [`snaptrade.connections.returnRates`](#snaptradeconnectionsreturnrates) * [`snaptrade.connections.sessionEvents`](#snaptradeconnectionssessionevents) + * [`snaptrade.cryptoTrading.getCryptocurrencyPairQuote`](#snaptradecryptotradinggetcryptocurrencypairquote) + * [`snaptrade.cryptoTrading.placeSimpleOrder`](#snaptradecryptotradingplacesimpleorder) + * [`snaptrade.cryptoTrading.searchCryptocurrencyPairInstruments`](#snaptradecryptotradingsearchcryptocurrencypairinstruments) * [`snaptrade.options.getOptionStrategy`](#snaptradeoptionsgetoptionstrategy) * [`snaptrade.options.getOptionsChain`](#snaptradeoptionsgetoptionschain) * [`snaptrade.options.getOptionsStrategyQuote`](#snaptradeoptionsgetoptionsstrategyquote) @@ -63,17 +66,14 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.referenceData.symbolSearchUserAccount`](#snaptradereferencedatasymbolsearchuseraccount) * [`snaptrade.trading.cancelOrder`](#snaptradetradingcancelorder) * [`snaptrade.trading.cancelUserAccountOrder`](#snaptradetradingcanceluseraccountorder) - * [`snaptrade.trading.getCryptocurrencyPairQuote`](#snaptradetradinggetcryptocurrencypairquote) * [`snaptrade.trading.getOrderImpact`](#snaptradetradinggetorderimpact) * [`snaptrade.trading.getUserAccountQuotes`](#snaptradetradinggetuseraccountquotes) * [`snaptrade.trading.placeBracketOrder`](#snaptradetradingplacebracketorder) * [`snaptrade.trading.placeForceOrder`](#snaptradetradingplaceforceorder) * [`snaptrade.trading.placeMlegOrder`](#snaptradetradingplacemlegorder) * [`snaptrade.trading.placeOrder`](#snaptradetradingplaceorder) - * [`snaptrade.trading.placeSimpleOrder`](#snaptradetradingplacesimpleorder) * [`snaptrade.trading.previewSimpleOrder`](#snaptradetradingpreviewsimpleorder) * [`snaptrade.trading.replaceOrder`](#snaptradetradingreplaceorder) - * [`snaptrade.trading.searchCryptocurrencyPairInstruments`](#snaptradetradingsearchcryptocurrencypairinstruments) * [`snaptrade.transactionsAndReporting.getActivities`](#snaptradetransactionsandreportinggetactivities) * [`snaptrade.transactionsAndReporting.getReportingCustomRange`](#snaptradetransactionsandreportinggetreportingcustomrange) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.105" + "konfig/snaptrade-php-sdk": "2.0.106" } } ``` @@ -1121,6 +1121,174 @@ Optional comma separated list of session IDs used to filter the request on speci --- +### `snaptrade.cryptoTrading.getCryptocurrencyPairQuote` + +Gets a quote for the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->cryptoTrading->getCryptocurrencyPairQuote( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + instrument_symbol: "BTC-USD" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### instrument_symbol: `string` + + +#### πŸ”„ Return + +[**CryptocurrencyPairQuote**](./lib/Model/CryptocurrencyPairQuote.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + +### `snaptrade.cryptoTrading.placeSimpleOrder` + +Places an order in the specified account. +This endpoint does not compute the impact to the account balance from the order before submitting the order. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->cryptoTrading->placeSimpleOrder( + instrument: [ + "symbol" => "AAPL", + "type" => "EQUITY", + ], + side: "BUY", + type: "MARKET", + time_in_force: "GTC", + amount: "123.45", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + limit_price: "123.45", + stop_price: "123.45", + post_only: False, + expiration_date: "2024-01-01T00:00:00Z" +); +``` + +#### βš™οΈ Parameters + +##### instrument: [`TradingInstrument`](./lib/Model/TradingInstrument.php) + +##### side: + +##### type: `string` + +The type of order to place. + +##### time_in_force: `string` + +The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. + +##### amount: `float` + +The amount of the base currency to buy or sell. + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### limit_price: `float` + +The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. + +##### stop_price: `float` + +The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. + +##### post_only: `bool` + +Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. + +##### expiration_date: `\DateTime` + +The expiration date of the order. Required if the time_in_force is GTD. + + +#### πŸ”„ Return + +[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/simple` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + +### `snaptrade.cryptoTrading.searchCryptocurrencyPairInstruments` + +Searches cryptocurrency pairs instruments accessible to the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->cryptoTrading->searchCryptocurrencyPairInstruments( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + base: "BTC", + quote: "USD" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### base: `string` + +##### quote: `string` + + +#### πŸ”„ Return + +[**TradingSearchCryptocurrencyPairInstruments200Response**](./lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.options.getOptionStrategy` Creates an option strategy object that will be used to place an option strategy order. @@ -1773,47 +1941,6 @@ Order ID returned by brokerage. This is the unique identifier for the order in t --- -### `snaptrade.trading.getCryptocurrencyPairQuote` - -Gets a quote for the specified account. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->trading->getCryptocurrencyPairQuote( - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - instrument_symbol: "BTC-USD" -); -``` - -#### βš™οΈ Parameters - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### instrument_symbol: `string` - - -#### πŸ”„ Return - -[**CryptocurrencyPairQuote**](./lib/Model/CryptocurrencyPairQuote.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote` `GET` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - ### `snaptrade.trading.getOrderImpact` Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. @@ -2214,89 +2341,6 @@ Optional, defaults to true. Determines if a wait is performed to check on order --- -### `snaptrade.trading.placeSimpleOrder` - -Places an order in the specified account. -This endpoint does not compute the impact to the account balance from the order before submitting the order. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->trading->placeSimpleOrder( - instrument: [ - "symbol" => "AAPL", - "type" => "EQUITY", - ], - side: "BUY", - type: "MARKET", - time_in_force: "GTC", - amount: "123.45", - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - limit_price: "123.45", - stop_price: "123.45", - post_only: False, - expiration_date: "2024-01-01T00:00:00Z" -); -``` - -#### βš™οΈ Parameters - -##### instrument: [`TradingInstrument`](./lib/Model/TradingInstrument.php) - -##### side: - -##### type: `string` - -The type of order to place. - -##### time_in_force: `string` - -The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. - -##### amount: `float` - -The amount of the base currency to buy or sell. - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### limit_price: `float` - -The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. - -##### stop_price: `float` - -The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. - -##### post_only: `bool` - -Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. - -##### expiration_date: `\DateTime` - -The expiration date of the order. Required if the time_in_force is GTD. - - -#### πŸ”„ Return - -[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/simple` `POST` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - ### `snaptrade.trading.previewSimpleOrder` Previews an order using the specified account. @@ -2453,50 +2497,6 @@ The price at which a stop order is triggered for `Stop` and `StopLimit` orders. --- -### `snaptrade.trading.searchCryptocurrencyPairInstruments` - -Searches cryptocurrency pairs instruments accessible to the specified account. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->trading->searchCryptocurrencyPairInstruments( - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - base: "BTC", - quote: "USD" -); -``` - -#### βš™οΈ Parameters - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### base: `string` - -##### quote: `string` - - -#### πŸ”„ Return - -[**TradingSearchCryptocurrencyPairInstruments200Response**](./lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs` `GET` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - ### `snaptrade.transactionsAndReporting.getActivities` ![Deprecated](https://img.shields.io/badge/deprecated-yellow) diff --git a/lib/Api/CryptoTradingApi.php b/lib/Api/CryptoTradingApi.php new file mode 100644 index 0000000..570e794 --- /dev/null +++ b/lib/Api/CryptoTradingApi.php @@ -0,0 +1,1576 @@ + [ + 'application/json', + ], + 'placeSimpleOrder' => [ + 'application/json', + ], + 'searchCryptocurrencyPairInstruments' => [ + 'application/json', + ], + ]; + +/** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + Configuration $config = null, + ClientInterface $client = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $clientOptions = []; + if (!$config->getVerifySsl()) $clientOptions["verify"] = false; + + // Do not truncate error messages + // https://github.com/guzzle/guzzle/issues/2185#issuecomment-800293420 + $stack = new HandlerStack(Utils::chooseHandler()); + $stack->push(Middleware::httpErrors(new BodySummarizer(10000)), 'http_errors'); + $stack->push(Middleware::redirect(), 'allow_redirects'); + $stack->push(Middleware::cookies(), 'cookies'); + $stack->push(Middleware::prepareBody(), 'prepare_body'); + $clientOptions["handler"] = $stack; + + $this->client = $client ?: new Client($clientOptions); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * For initializing request body parameter + */ + private function setRequestBodyProperty(&$body, $property, $value) { + if ($body === null) $body = []; + // user did not pass in a value for this parameter + if ($value === SENTINEL_VALUE) return; + $body[$property] = $value; + } + + /** + * Operation getCryptocurrencyPairQuote + * + * Get cryptocurrency pair quote + * + * Gets a quote for the specified account. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param string $instrument_symbol instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\CryptocurrencyPairQuote|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function getCryptocurrencyPairQuote( + $user_id, + $user_secret, + $account_id, + $instrument_symbol, + + string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0] + ) + { + + list($response) = $this->getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); + return $response; + } + + /** + * Operation getCryptocurrencyPairQuoteWithHttpInfo + * + * Get cryptocurrency pair quote + * + * Gets a quote for the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\CryptocurrencyPairQuote|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->getCryptocurrencyPairQuoteWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $instrument_symbol, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\CryptocurrencyPairQuote' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\CryptocurrencyPairQuote' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\CryptocurrencyPairQuote', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\CryptocurrencyPairQuote'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\CryptocurrencyPairQuote', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCryptocurrencyPairQuoteAsync + * + * Get cryptocurrency pair quote + * + * Gets a quote for the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCryptocurrencyPairQuoteAsync( + $user_id, + $user_secret, + $account_id, + $instrument_symbol, + + string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0] + ) + { + + return $this->getCryptocurrencyPairQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCryptocurrencyPairQuoteAsyncWithHttpInfo + * + * Get cryptocurrency pair quote + * + * Gets a quote for the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCryptocurrencyPairQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\CryptocurrencyPairQuote'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCryptocurrencyPairQuote' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getCryptocurrencyPairQuote' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getCryptocurrencyPairQuote' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getCryptocurrencyPairQuote' + ); + } + // Check if $instrument_symbol is a string + if ($instrument_symbol !== SENTINEL_VALUE && !is_string($instrument_symbol)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($instrument_symbol, true), gettype($instrument_symbol))); + } + // verify the required parameter 'instrument_symbol' is set + if ($instrument_symbol === SENTINEL_VALUE || (is_array($instrument_symbol) && count($instrument_symbol) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter instrument_symbol when calling getCryptocurrencyPairQuote' + ); + } + + + $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($instrument_symbol !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'instrumentSymbol' . '}', + ObjectSerializer::toPathValue($instrument_symbol), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation placeSimpleOrder + * + * Place order + * + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function placeSimpleOrder( + + $instrument, + $side, + $type, + $time_in_force, + $amount, + $user_id, + $user_secret, + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeSimpleOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $simple_order_form = $_body; + + list($response) = $this->placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + return $response; + } + + /** + * Operation placeSimpleOrderWithHttpInfo + * + * Place order + * + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->placeSimpleOrderWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $simple_order_form, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\OrderUpdatedResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation placeSimpleOrderAsync + * + * Place order + * + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeSimpleOrderAsync( + + $instrument, + $side, + $type, + $time_in_force, + $amount, + $user_id, + $user_secret, + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeSimpleOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $simple_order_form = $_body; + + return $this->placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation placeSimpleOrderAsyncWithHttpInfo + * + * Place order + * + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'placeSimpleOrder' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling placeSimpleOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling placeSimpleOrder' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling placeSimpleOrder' + ); + } + if ($simple_order_form !== SENTINEL_VALUE) { + if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { + if (!is_array($simple_order_form)) + throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm CryptoTradingApi.placeSimpleOrder.'); + else + $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); + } + } + // verify the required parameter 'simple_order_form' is set + if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter simple_order_form when calling placeSimpleOrder' + ); + } + + + $resourcePath = '/accounts/{accountId}/trading/simple'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($simple_order_form)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); + } else { + $httpBody = $simple_order_form; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation searchCryptocurrencyPairInstruments + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param string $base base (optional) + * @param string $quote quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function searchCryptocurrencyPairInstruments( + $user_id, + $user_secret, + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] + ) + { + + list($response) = $this->searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); + return $response; + } + + /** + * Operation searchCryptocurrencyPairInstrumentsWithHttpInfo + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->searchCryptocurrencyPairInstrumentsWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $base, + $quote, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchCryptocurrencyPairInstrumentsAsync + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchCryptocurrencyPairInstrumentsAsync( + $user_id, + $user_secret, + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] + ) + { + + return $this->searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchCryptocurrencyPairInstruments' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling searchCryptocurrencyPairInstruments' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling searchCryptocurrencyPairInstruments' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling searchCryptocurrencyPairInstruments' + ); + } + // Check if $base is a string + if ($base !== SENTINEL_VALUE && !is_string($base)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); + } + // Check if $quote is a string + if ($quote !== SENTINEL_VALUE && !is_string($quote)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); + } + + + $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($base !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $base, + 'base', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($quote !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $quote, + 'quote', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 644fb07..96286bc 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -68,9 +68,6 @@ class TradingApi extends \SnapTrade\CustomApi 'cancelUserAccountOrder' => [ 'application/json', ], - 'getCryptocurrencyPairQuote' => [ - 'application/json', - ], 'getOrderImpact' => [ 'application/json', ], @@ -89,18 +86,12 @@ class TradingApi extends \SnapTrade\CustomApi 'placeOrder' => [ 'application/json', ], - 'placeSimpleOrder' => [ - 'application/json', - ], 'previewSimpleOrder' => [ 'application/json', ], 'replaceOrder' => [ 'application/json', ], - 'searchCryptocurrencyPairInstruments' => [ - 'application/json', - ], ]; /** @@ -1106,59 +1097,75 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i } /** - * Operation getCryptocurrencyPairQuote + * Operation getOrderImpact * - * Get cryptocurrency pair quote + * Check order impact * - * Gets a quote for the specified account. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param string $instrument_symbol instrument_symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\CryptocurrencyPairQuote|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse */ - public function getCryptocurrencyPairQuote( + public function getOrderImpact( + + $account_id, + $action, + $universal_symbol_id, + $order_type, + $time_in_force, $user_id, $user_secret, - $account_id, - $instrument_symbol, - - string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0] + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['getOrderImpact'][0] ) { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form = $_body; - list($response) = $this->getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); + list($response) = $this->getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType); return $response; } /** - * Operation getCryptocurrencyPairQuoteWithHttpInfo + * Operation getOrderImpactWithHttpInfo * - * Get cryptocurrency pair quote + * Check order impact * - * Gets a quote for the specified account. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $instrument_symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\CryptocurrencyPairQuote|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); try { $options = $this->createHttpClientOption(); @@ -1170,11 +1177,10 @@ public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $ !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->getCryptocurrencyPairQuoteWithHttpInfo( + return $this->getOrderImpactWithHttpInfo( $user_id, $user_secret, - $account_id, - $instrument_symbol, + $manual_trade_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -1212,17 +1218,17 @@ public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $ switch($statusCode) { case 200: - if ('\SnapTrade\Model\CryptocurrencyPairQuote' === '\SplFileObject') { + if ('\SnapTrade\Model\ManualTradeAndImpact' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\CryptocurrencyPairQuote' !== 'string') { + if ('\SnapTrade\Model\ManualTradeAndImpact' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\CryptocurrencyPairQuote', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\ManualTradeAndImpact', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -1241,9 +1247,24 @@ public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $ $response->getStatusCode(), $response->getHeaders() ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } - $returnType = '\SnapTrade\Model\CryptocurrencyPairQuote'; + $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -1264,7 +1285,7 @@ public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $ case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\CryptocurrencyPairQuote', + '\SnapTrade\Model\ManualTradeAndImpact', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -1277,38 +1298,63 @@ public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $ ); $e->setResponseObject($data); break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } } /** - * Operation getCryptocurrencyPairQuoteAsync + * Operation getOrderImpactAsync * - * Get cryptocurrency pair quote + * Check order impact * - * Gets a quote for the specified account. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $instrument_symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getCryptocurrencyPairQuoteAsync( + public function getOrderImpactAsync( + + $account_id, + $action, + $universal_symbol_id, + $order_type, + $time_in_force, $user_id, $user_secret, - $account_id, - $instrument_symbol, - - string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0] + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['getOrderImpact'][0] ) { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form = $_body; - return $this->getCryptocurrencyPairQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, $contentType) + return $this->getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType) ->then( function ($response) { return $response[0]; @@ -1317,28 +1363,27 @@ function ($response) { } /** - * Operation getCryptocurrencyPairQuoteAsyncWithHttpInfo + * Operation getOrderImpactAsyncWithHttpInfo * - * Get cryptocurrency pair quote + * Check order impact * - * Gets a quote for the specified account. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $instrument_symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getCryptocurrencyPairQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\CryptocurrencyPairQuote'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); + $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1377,18 +1422,17 @@ function ($exception) { } /** - * Create request for operation 'getCryptocurrencyPairQuote' + * Create request for operation 'getOrderImpact' * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $instrument_symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0]) + public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0]) { // Check if $user_id is a string @@ -1398,7 +1442,7 @@ public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $accou // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getCryptocurrencyPairQuote' + 'Missing the required parameter user_id when calling getOrderImpact' ); } // Check if $user_secret is a string @@ -1408,32 +1452,26 @@ public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $accou // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getCryptocurrencyPairQuote' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling getCryptocurrencyPairQuote' + 'Missing the required parameter user_secret when calling getOrderImpact' ); } - // Check if $instrument_symbol is a string - if ($instrument_symbol !== SENTINEL_VALUE && !is_string($instrument_symbol)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($instrument_symbol, true), gettype($instrument_symbol))); + if ($manual_trade_form !== SENTINEL_VALUE) { + if (!($manual_trade_form instanceof \SnapTrade\Model\ManualTradeForm)) { + if (!is_array($manual_trade_form)) + throw new \InvalidArgumentException('"manual_trade_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeForm TradingApi.getOrderImpact.'); + else + $manual_trade_form = new \SnapTrade\Model\ManualTradeForm($manual_trade_form); + } } - // verify the required parameter 'instrument_symbol' is set - if ($instrument_symbol === SENTINEL_VALUE || (is_array($instrument_symbol) && count($instrument_symbol) === 0)) { + // verify the required parameter 'manual_trade_form' is set + if ($manual_trade_form === SENTINEL_VALUE || (is_array($manual_trade_form) && count($manual_trade_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter instrument_symbol when calling getCryptocurrencyPairQuote' + 'Missing the required parameter manual_trade_form when calling getOrderImpact' ); } - $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote'; + $resourcePath = '/trade/impact'; $formParams = []; $queryParams = []; $headerParams = []; @@ -1464,22 +1502,6 @@ public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $accou } - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - // path params - if ($instrument_symbol !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'instrumentSymbol' . '}', - ObjectSerializer::toPathValue($instrument_symbol), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -1489,7 +1511,14 @@ public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $accou ); // for model (json/xml) - if (count($formParams) > 0) { + if (isset($manual_trade_form)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form)); + } else { + $httpBody = $manual_trade_form; + } + } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -1540,7 +1569,7 @@ public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $accou $headers ); - $method = 'GET'; + $method = 'POST'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); @@ -1557,75 +1586,62 @@ public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $accou } /** - * Operation getOrderImpact + * Operation getUserAccountQuotes * - * Check order impact + * Get symbol quotes * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse */ - public function getOrderImpact( - - $account_id, - $action, - $universal_symbol_id, - $order_type, - $time_in_force, + public function getUserAccountQuotes( $user_id, $user_secret, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['getOrderImpact'][0] + $symbols, + $account_id, + $use_ticker = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getUserAccountQuotes'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form = $_body; - list($response) = $this->getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType); + list($response) = $this->getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); return $response; } /** - * Operation getOrderImpactWithHttpInfo + * Operation getUserAccountQuotesWithHttpInfo * - * Check order impact + * Get symbol quotes * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); try { $options = $this->createHttpClientOption(); @@ -1637,10 +1653,12 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->getOrderImpactWithHttpInfo( + return $this->getUserAccountQuotesWithHttpInfo( $user_id, $user_secret, - $manual_trade_form, + $symbols, + $account_id, + $use_ticker, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -1678,53 +1696,38 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade switch($statusCode) { case 200: - if ('\SnapTrade\Model\ManualTradeAndImpact' === '\SplFileObject') { + if ('\SnapTrade\Model\SymbolsQuotesInner[]' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\ManualTradeAndImpact' !== 'string') { + if ('\SnapTrade\Model\SymbolsQuotesInner[]' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\ManualTradeAndImpact', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\SymbolsQuotesInner[]', []), $response->getStatusCode(), $response->getHeaders() ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } - $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; + $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -1745,23 +1748,15 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\ManualTradeAndImpact', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', + '\SnapTrade\Model\SymbolsQuotesInner[]', $e->getResponseHeaders() ); $e->setResponseObject($data); break; - case 403: + case 500: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -1772,49 +1767,34 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade } /** - * Operation getOrderImpactAsync + * Operation getUserAccountQuotesAsync * - * Check order impact + * Get symbol quotes * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOrderImpactAsync( - - $account_id, - $action, - $universal_symbol_id, - $order_type, - $time_in_force, + public function getUserAccountQuotesAsync( $user_id, $user_secret, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['getOrderImpact'][0] + $symbols, + $account_id, + $use_ticker = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getUserAccountQuotes'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form = $_body; - return $this->getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType) + return $this->getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType) ->then( function ($response) { return $response[0]; @@ -1823,27 +1803,29 @@ function ($response) { } /** - * Operation getOrderImpactAsyncWithHttpInfo + * Operation getUserAccountQuotesAsyncWithHttpInfo * - * Check order impact + * Get symbol quotes * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); + $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1882,17 +1864,19 @@ function ($exception) { } /** - * Create request for operation 'getOrderImpact' + * Create request for operation 'getUserAccountQuotes' * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0]) + public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountQuotes'][0]) { // Check if $user_id is a string @@ -1902,7 +1886,7 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getOrderImpact' + 'Missing the required parameter user_id when calling getUserAccountQuotes' ); } // Check if $user_secret is a string @@ -1912,26 +1896,32 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getOrderImpact' + 'Missing the required parameter user_secret when calling getUserAccountQuotes' ); } - if ($manual_trade_form !== SENTINEL_VALUE) { - if (!($manual_trade_form instanceof \SnapTrade\Model\ManualTradeForm)) { - if (!is_array($manual_trade_form)) - throw new \InvalidArgumentException('"manual_trade_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeForm TradingApi.getOrderImpact.'); - else - $manual_trade_form = new \SnapTrade\Model\ManualTradeForm($manual_trade_form); - } + // Check if $symbols is a string + if ($symbols !== SENTINEL_VALUE && !is_string($symbols)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($symbols, true), gettype($symbols))); } - // verify the required parameter 'manual_trade_form' is set - if ($manual_trade_form === SENTINEL_VALUE || (is_array($manual_trade_form) && count($manual_trade_form) === 0)) { + // verify the required parameter 'symbols' is set + if ($symbols === SENTINEL_VALUE || (is_array($symbols) && count($symbols) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form when calling getOrderImpact' + 'Missing the required parameter symbols when calling getUserAccountQuotes' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getUserAccountQuotes' ); } - $resourcePath = '/trade/impact'; + $resourcePath = '/accounts/{accountId}/quotes'; $formParams = []; $queryParams = []; $headerParams = []; @@ -1960,1493 +1950,38 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form true // required ) ?? []); } - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (isset($manual_trade_form)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form)); - } else { - $httpBody = $manual_trade_form; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + if ($symbols !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $symbols, + 'symbols', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'POST'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation getUserAccountQuotes - * - * Get symbol quotes - * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) - * @param string $account_id account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse - */ - public function getUserAccountQuotes( - $user_id, - $user_secret, - $symbols, - $account_id, - $use_ticker = SENTINEL_VALUE, - - string $contentType = self::contentTypes['getUserAccountQuotes'][0] - ) - { - - list($response) = $this->getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); - return $response; - } - - /** - * Operation getUserAccountQuotesWithHttpInfo - * - * Get symbol quotes - * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) - * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->getUserAccountQuotesWithHttpInfo( - $user_id, - $user_secret, - $symbols, - $account_id, - $use_ticker, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\SymbolsQuotesInner[]' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\SymbolsQuotesInner[]' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\SymbolsQuotesInner[]', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 500: - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\SymbolsQuotesInner[]', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 500: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model500UnexpectedExceptionResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getUserAccountQuotesAsync - * - * Get symbol quotes - * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) - * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getUserAccountQuotesAsync( - $user_id, - $user_secret, - $symbols, - $account_id, - $use_ticker = SENTINEL_VALUE, - - string $contentType = self::contentTypes['getUserAccountQuotes'][0] - ) - { - - return $this->getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getUserAccountQuotesAsyncWithHttpInfo - * - * Get symbol quotes - * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) - * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'getUserAccountQuotes' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) - * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountQuotes'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getUserAccountQuotes' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getUserAccountQuotes' - ); - } - // Check if $symbols is a string - if ($symbols !== SENTINEL_VALUE && !is_string($symbols)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($symbols, true), gettype($symbols))); - } - // verify the required parameter 'symbols' is set - if ($symbols === SENTINEL_VALUE || (is_array($symbols) && count($symbols) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter symbols when calling getUserAccountQuotes' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling getUserAccountQuotes' - ); - } - - - $resourcePath = '/accounts/{accountId}/quotes'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($symbols !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $symbols, - 'symbols', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($use_ticker !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $use_ticker, - 'use_ticker', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'GET'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation placeBracketOrder - * - * Place a Bracket Order - * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages - * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse - */ - public function placeBracketOrder( - - $action, - $instrument, - $order_type, - $time_in_force, - $stop_loss, - $take_profit, - $account_id, - $user_id, - $user_secret, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeBracketOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); - $this->setRequestBodyProperty($_body, "take_profit", $take_profit); - $manual_trade_form_bracket = $_body; - - list($response) = $this->placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); - return $response; - } - - /** - * Operation placeBracketOrderWithHttpInfo - * - * Place a Bracket Order - * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages - * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $user_id (required) - * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->placeBracketOrderWithHttpInfo( - $account_id, - $user_id, - $user_secret, - $manual_trade_form_bracket, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation placeBracketOrderAsync - * - * Place a Bracket Order - * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages - * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $user_id (required) - * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function placeBracketOrderAsync( - - $action, - $instrument, - $order_type, - $time_in_force, - $stop_loss, - $take_profit, - $account_id, - $user_id, - $user_secret, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeBracketOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); - $this->setRequestBodyProperty($_body, "take_profit", $take_profit); - $manual_trade_form_bracket = $_body; - - return $this->placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation placeBracketOrderAsyncWithHttpInfo - * - * Place a Bracket Order - * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages - * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $user_id (required) - * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'placeBracketOrder' - * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $user_id (required) - * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0]) - { - - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling placeBracketOrder' - ); - } - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeBracketOrder' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeBracketOrder' - ); - } - if ($manual_trade_form_bracket !== SENTINEL_VALUE) { - if (!($manual_trade_form_bracket instanceof \SnapTrade\Model\ManualTradeFormBracket)) { - if (!is_array($manual_trade_form_bracket)) - throw new \InvalidArgumentException('"manual_trade_form_bracket" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormBracket TradingApi.placeBracketOrder.'); - else - $manual_trade_form_bracket = new \SnapTrade\Model\ManualTradeFormBracket($manual_trade_form_bracket); - } - } - // verify the required parameter 'manual_trade_form_bracket' is set - if ($manual_trade_form_bracket === SENTINEL_VALUE || (is_array($manual_trade_form_bracket) && count($manual_trade_form_bracket) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form_bracket when calling placeBracketOrder' - ); - } - - - $resourcePath = '/accounts/{accountId}/trading/bracket'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (isset($manual_trade_form_bracket)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_bracket)); - } else { - $httpBody = $manual_trade_form_bracket; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'POST'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation placeForceOrder - * - * Place order - * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse - */ - public function placeForceOrder( - - $account_id, - $action, - $order_type, - $time_in_force, - $user_id, - $user_secret, - $universal_symbol_id = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeForceOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form_with_options = $_body; - - list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); - return $response; - } - - /** - * Operation placeForceOrderWithHttpInfo - * - * Place order - * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->placeForceOrderWithHttpInfo( - $user_id, - $user_secret, - $manual_trade_form_with_options, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation placeForceOrderAsync - * - * Place order - * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function placeForceOrderAsync( - - $account_id, - $action, - $order_type, - $time_in_force, - $user_id, - $user_secret, - $universal_symbol_id = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeForceOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form_with_options = $_body; - - return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation placeForceOrderAsyncWithHttpInfo - * - * Place order - * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'placeForceOrder' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeForceOrder' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeForceOrder' - ); - } - if ($manual_trade_form_with_options !== SENTINEL_VALUE) { - if (!($manual_trade_form_with_options instanceof \SnapTrade\Model\ManualTradeFormWithOptions)) { - if (!is_array($manual_trade_form_with_options)) - throw new \InvalidArgumentException('"manual_trade_form_with_options" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormWithOptions TradingApi.placeForceOrder.'); - else - $manual_trade_form_with_options = new \SnapTrade\Model\ManualTradeFormWithOptions($manual_trade_form_with_options); - } - } - // verify the required parameter 'manual_trade_form_with_options' is set - if ($manual_trade_form_with_options === SENTINEL_VALUE || (is_array($manual_trade_form_with_options) && count($manual_trade_form_with_options) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form_with_options when calling placeForceOrder' - ); - } - - - $resourcePath = '/trade/place'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { + if ($use_ticker !== SENTINEL_VALUE) { // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $use_ticker, + 'use_ticker', // param base name + 'boolean', // openApiType 'form', // style true, // explode - true // required + false // required ) ?? []); } + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -3456,14 +1991,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for ); // for model (json/xml) - if (isset($manual_trade_form_with_options)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_with_options)); - } else { - $httpBody = $manual_trade_form_with_options; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -3514,7 +2042,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for $headers ); - $method = 'POST'; + $method = 'GET'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); @@ -3531,69 +2059,77 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for } /** - * Operation placeMlegOrder + * Operation placeBracketOrder * - * Place multi-leg option order + * Place a Bracket Order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse */ - public function placeMlegOrder( + public function placeBracketOrder( + $action, + $instrument, $order_type, $time_in_force, - $legs, + $stop_loss, + $take_profit, + $account_id, $user_id, $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $price_effect = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeMlegOrder'][0] + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeBracketOrder'][0] ) { $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "instrument", $instrument); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "price_effect", $price_effect); - $this->setRequestBodyProperty($_body, "legs", $legs); - $mleg_trade_form = $_body; + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); + $this->setRequestBodyProperty($_body, "take_profit", $take_profit); + $manual_trade_form_bracket = $_body; - list($response) = $this->placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); + list($response) = $this->placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); return $response; } /** - * Operation placeMlegOrderWithHttpInfo + * Operation placeBracketOrderWithHttpInfo * - * Place multi-leg option order + * Place a Bracket Order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3608,11 +2144,11 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeMlegOrderWithHttpInfo( + return $this->placeBracketOrderWithHttpInfo( + $account_id, $user_id, $user_secret, - $account_id, - $mleg_trade_form, + $manual_trade_form_bracket, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -3650,17 +2186,17 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, switch($statusCode) { case 200: - if ('\SnapTrade\Model\MlegOrderResponse' === '\SplFileObject') { + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\MlegOrderResponse' !== 'string') { + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\MlegOrderResponse', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -3679,9 +2215,24 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $response->getStatusCode(), $response->getHeaders() ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } - $returnType = '\SnapTrade\Model\MlegOrderResponse'; + $returnType = '\SnapTrade\Model\AccountOrderRecord'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -3702,7 +2253,7 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\MlegOrderResponse', + '\SnapTrade\Model\AccountOrderRecord', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -3715,51 +2266,67 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, ); $e->setResponseObject($data); break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } } /** - * Operation placeMlegOrderAsync + * Operation placeBracketOrderAsync * - * Place multi-leg option order + * Place a Bracket Order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeMlegOrderAsync( + public function placeBracketOrderAsync( + $action, + $instrument, $order_type, $time_in_force, - $legs, + $stop_loss, + $take_profit, + $account_id, $user_id, $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $price_effect = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeMlegOrder'][0] + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeBracketOrder'][0] ) { $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "instrument", $instrument); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "price_effect", $price_effect); - $this->setRequestBodyProperty($_body, "legs", $legs); - $mleg_trade_form = $_body; + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); + $this->setRequestBodyProperty($_body, "take_profit", $take_profit); + $manual_trade_form_bracket = $_body; - return $this->placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType) + return $this->placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType) ->then( function ($response) { return $response[0]; @@ -3768,25 +2335,25 @@ function ($response) { } /** - * Operation placeMlegOrderAsyncWithHttpInfo + * Operation placeBracketOrderAsyncWithHttpInfo * - * Place multi-leg option order + * Place a Bracket Order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\MlegOrderResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3828,20 +2395,30 @@ function ($exception) { } /** - * Create request for operation 'placeMlegOrder' + * Create request for operation 'placeBracketOrder' * + * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0]) + public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0]) { + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling placeBracketOrder' + ); + } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -3849,7 +2426,7 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeMlegOrder' + 'Missing the required parameter user_id when calling placeBracketOrder' ); } // Check if $user_secret is a string @@ -3859,36 +2436,26 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeMlegOrder' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling placeMlegOrder' + 'Missing the required parameter user_secret when calling placeBracketOrder' ); } - if ($mleg_trade_form !== SENTINEL_VALUE) { - if (!($mleg_trade_form instanceof \SnapTrade\Model\MlegTradeForm)) { - if (!is_array($mleg_trade_form)) - throw new \InvalidArgumentException('"mleg_trade_form" must be associative array or an instance of \SnapTrade\Model\MlegTradeForm TradingApi.placeMlegOrder.'); + if ($manual_trade_form_bracket !== SENTINEL_VALUE) { + if (!($manual_trade_form_bracket instanceof \SnapTrade\Model\ManualTradeFormBracket)) { + if (!is_array($manual_trade_form_bracket)) + throw new \InvalidArgumentException('"manual_trade_form_bracket" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormBracket TradingApi.placeBracketOrder.'); else - $mleg_trade_form = new \SnapTrade\Model\MlegTradeForm($mleg_trade_form); + $manual_trade_form_bracket = new \SnapTrade\Model\ManualTradeFormBracket($manual_trade_form_bracket); } } - // verify the required parameter 'mleg_trade_form' is set - if ($mleg_trade_form === SENTINEL_VALUE || (is_array($mleg_trade_form) && count($mleg_trade_form) === 0)) { + // verify the required parameter 'manual_trade_form_bracket' is set + if ($manual_trade_form_bracket === SENTINEL_VALUE || (is_array($manual_trade_form_bracket) && count($manual_trade_form_bracket) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter mleg_trade_form when calling placeMlegOrder' + 'Missing the required parameter manual_trade_form_bracket when calling placeBracketOrder' ); } - $resourcePath = '/accounts/{accountId}/trading/options'; + $resourcePath = '/accounts/{accountId}/trading/bracket'; $formParams = []; $queryParams = []; $headerParams = []; @@ -3936,12 +2503,12 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg ); // for model (json/xml) - if (isset($mleg_trade_form)) { + if (isset($manual_trade_form_bracket)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($mleg_trade_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_bracket)); } else { - $httpBody = $mleg_trade_form; + $httpBody = $manual_trade_form_bracket; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -4011,59 +2578,74 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg } /** - * Operation placeOrder + * Operation placeForceOrder * - * Place checked order + * Place order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse */ - public function placeOrder( - $trade_id, + public function placeForceOrder( + + $account_id, + $action, + $order_type, + $time_in_force, $user_id, $user_secret, - $wait_to_confirm = SENTINEL_VALUE, - - string $contentType = self::contentTypes['placeOrder'][0] + $universal_symbol_id = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeForceOrder'][0] ) { - $_body = null; - $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); - $validated_trade_body = $_body; + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form_with_options = $_body; - list($response) = $this->placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); return $response; } /** - * Operation placeOrderWithHttpInfo + * Operation placeForceOrderWithHttpInfo * - * Place checked order + * Place order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4078,11 +2660,10 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeOrderWithHttpInfo( - $trade_id, + return $this->placeForceOrderWithHttpInfo( $user_id, $user_secret, - $validated_trade_body, + $manual_trade_form_with_options, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -4149,6 +2730,21 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid $response->getStatusCode(), $response->getHeaders() ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } $returnType = '\SnapTrade\Model\AccountOrderRecord'; @@ -4185,41 +2781,65 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid ); $e->setResponseObject($data); break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } } /** - * Operation placeOrderAsync + * Operation placeForceOrderAsync * - * Place checked order + * Place order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeOrderAsync( - $trade_id, + public function placeForceOrderAsync( + + $account_id, + $action, + $order_type, + $time_in_force, $user_id, $user_secret, - $wait_to_confirm = SENTINEL_VALUE, - - string $contentType = self::contentTypes['placeOrder'][0] + $universal_symbol_id = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeForceOrder'][0] ) { - $_body = null; - $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); - $validated_trade_body = $_body; + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form_with_options = $_body; - return $this->placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType) + return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) ->then( function ($response) { return $response[0]; @@ -4228,25 +2848,24 @@ function ($response) { } /** - * Operation placeOrderAsyncWithHttpInfo + * Operation placeForceOrderAsyncWithHttpInfo * - * Place checked order + * Place order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4288,30 +2907,19 @@ function ($exception) { } /** - * Create request for operation 'placeOrder' + * Create request for operation 'placeForceOrder' * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body = SENTINEL_VALUE, string $contentType = self::contentTypes['placeOrder'][0]) + public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0]) { - // Check if $trade_id is a string - if ($trade_id !== SENTINEL_VALUE && !is_string($trade_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trade_id, true), gettype($trade_id))); - } - // verify the required parameter 'trade_id' is set - if ($trade_id === SENTINEL_VALUE || (is_array($trade_id) && count($trade_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter trade_id when calling placeOrder' - ); - } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -4319,7 +2927,7 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeOrder' + 'Missing the required parameter user_id when calling placeForceOrder' ); } // Check if $user_secret is a string @@ -4329,20 +2937,26 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeOrder' + 'Missing the required parameter user_secret when calling placeForceOrder' ); } - if ($validated_trade_body !== SENTINEL_VALUE) { - if (!($validated_trade_body instanceof \SnapTrade\Model\ValidatedTradeBody)) { - if (!is_array($validated_trade_body)) - throw new \InvalidArgumentException('"validated_trade_body" must be associative array or an instance of \SnapTrade\Model\ValidatedTradeBody TradingApi.placeOrder.'); + if ($manual_trade_form_with_options !== SENTINEL_VALUE) { + if (!($manual_trade_form_with_options instanceof \SnapTrade\Model\ManualTradeFormWithOptions)) { + if (!is_array($manual_trade_form_with_options)) + throw new \InvalidArgumentException('"manual_trade_form_with_options" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormWithOptions TradingApi.placeForceOrder.'); else - $validated_trade_body = new \SnapTrade\Model\ValidatedTradeBody($validated_trade_body); + $manual_trade_form_with_options = new \SnapTrade\Model\ManualTradeFormWithOptions($manual_trade_form_with_options); } } + // verify the required parameter 'manual_trade_form_with_options' is set + if ($manual_trade_form_with_options === SENTINEL_VALUE || (is_array($manual_trade_form_with_options) && count($manual_trade_form_with_options) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter manual_trade_form_with_options when calling placeForceOrder' + ); + } - $resourcePath = '/trade/{tradeId}'; + $resourcePath = '/trade/place'; $formParams = []; $queryParams = []; $headerParams = []; @@ -4373,14 +2987,6 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ } - // path params - if ($trade_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'tradeId' . '}', - ObjectSerializer::toPathValue($trade_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -4390,12 +2996,12 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ ); // for model (json/xml) - if (isset($validated_trade_body)) { + if (isset($manual_trade_form_with_options)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($validated_trade_body)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_with_options)); } else { - $httpBody = $validated_trade_body; + $httpBody = $manual_trade_form_with_options; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -4465,75 +3071,69 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ } /** - * Operation placeSimpleOrder + * Operation placeMlegOrder * - * Place order + * Place multi-leg option order * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse */ - public function placeSimpleOrder( + public function placeMlegOrder( - $instrument, - $side, - $type, + $order_type, $time_in_force, - $amount, + $legs, $user_id, $user_secret, $account_id, $limit_price = SENTINEL_VALUE, $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeSimpleOrder'][0] + $price_effect = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeMlegOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); $this->setRequestBodyProperty($_body, "limit_price", $limit_price); $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; + $this->setRequestBodyProperty($_body, "price_effect", $price_effect); + $this->setRequestBodyProperty($_body, "legs", $legs); + $mleg_trade_form = $_body; - list($response) = $this->placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + list($response) = $this->placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); return $response; } /** - * Operation placeSimpleOrderWithHttpInfo + * Operation placeMlegOrderWithHttpInfo * - * Place order + * Place multi-leg option order * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4548,11 +3148,11 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeSimpleOrderWithHttpInfo( + return $this->placeMlegOrderWithHttpInfo( $user_id, $user_secret, $account_id, - $simple_order_form, + $mleg_trade_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -4590,17 +3190,17 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id switch($statusCode) { case 200: - if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { + if ('\SnapTrade\Model\MlegOrderResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { + if ('\SnapTrade\Model\MlegOrderResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\MlegOrderResponse', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -4621,7 +3221,7 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id ]; } - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; + $returnType = '\SnapTrade\Model\MlegOrderResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -4642,7 +3242,7 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\OrderUpdatedResponse', + '\SnapTrade\Model\MlegOrderResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -4661,51 +3261,45 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id } /** - * Operation placeSimpleOrderAsync + * Operation placeMlegOrderAsync * - * Place order + * Place multi-leg option order * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeSimpleOrderAsync( + public function placeMlegOrderAsync( - $instrument, - $side, - $type, + $order_type, $time_in_force, - $amount, + $legs, $user_id, $user_secret, $account_id, $limit_price = SENTINEL_VALUE, $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeSimpleOrder'][0] + $price_effect = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeMlegOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); $this->setRequestBodyProperty($_body, "limit_price", $limit_price); $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; + $this->setRequestBodyProperty($_body, "price_effect", $price_effect); + $this->setRequestBodyProperty($_body, "legs", $legs); + $mleg_trade_form = $_body; - return $this->placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) + return $this->placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType) ->then( function ($response) { return $response[0]; @@ -4714,25 +3308,25 @@ function ($response) { } /** - * Operation placeSimpleOrderAsyncWithHttpInfo + * Operation placeMlegOrderAsyncWithHttpInfo * - * Place order + * Place multi-leg option order * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + $returnType = '\SnapTrade\Model\MlegOrderResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4774,18 +3368,18 @@ function ($exception) { } /** - * Create request for operation 'placeSimpleOrder' + * Create request for operation 'placeMlegOrder' * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0]) + public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0]) { // Check if $user_id is a string @@ -4795,7 +3389,7 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeSimpleOrder' + 'Missing the required parameter user_id when calling placeMlegOrder' ); } // Check if $user_secret is a string @@ -4805,7 +3399,7 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeSimpleOrder' + 'Missing the required parameter user_secret when calling placeMlegOrder' ); } // Check if $account_id is a string @@ -4815,26 +3409,26 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si // verify the required parameter 'account_id' is set if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling placeSimpleOrder' + 'Missing the required parameter account_id when calling placeMlegOrder' ); } - if ($simple_order_form !== SENTINEL_VALUE) { - if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { - if (!is_array($simple_order_form)) - throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm TradingApi.placeSimpleOrder.'); + if ($mleg_trade_form !== SENTINEL_VALUE) { + if (!($mleg_trade_form instanceof \SnapTrade\Model\MlegTradeForm)) { + if (!is_array($mleg_trade_form)) + throw new \InvalidArgumentException('"mleg_trade_form" must be associative array or an instance of \SnapTrade\Model\MlegTradeForm TradingApi.placeMlegOrder.'); else - $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); + $mleg_trade_form = new \SnapTrade\Model\MlegTradeForm($mleg_trade_form); } } - // verify the required parameter 'simple_order_form' is set - if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { + // verify the required parameter 'mleg_trade_form' is set + if ($mleg_trade_form === SENTINEL_VALUE || (is_array($mleg_trade_form) && count($mleg_trade_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter simple_order_form when calling placeSimpleOrder' + 'Missing the required parameter mleg_trade_form when calling placeMlegOrder' ); } - $resourcePath = '/accounts/{accountId}/trading/simple'; + $resourcePath = '/accounts/{accountId}/trading/options'; $formParams = []; $queryParams = []; $headerParams = []; @@ -4882,12 +3476,12 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si ); // for model (json/xml) - if (isset($simple_order_form)) { + if (isset($mleg_trade_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($mleg_trade_form)); } else { - $httpBody = $simple_order_form; + $httpBody = $mleg_trade_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -4957,75 +3551,59 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si } /** - * Operation previewSimpleOrder + * Operation placeOrder * - * Preview order + * Place checked order * - * Previews an order using the specified account. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse */ - public function previewSimpleOrder( - - $instrument, - $side, - $type, - $time_in_force, - $amount, + public function placeOrder( + $trade_id, $user_id, $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['previewSimpleOrder'][0] + $wait_to_confirm = SENTINEL_VALUE, + + string $contentType = self::contentTypes['placeOrder'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; + $_body = null; + $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); + $validated_trade_body = $_body; - list($response) = $this->previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + list($response) = $this->placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); return $response; } /** - * Operation previewSimpleOrderWithHttpInfo + * Operation placeOrderWithHttpInfo * - * Preview order + * Place checked order * - * Previews an order using the specified account. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -5040,11 +3618,11 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->previewSimpleOrderWithHttpInfo( + return $this->placeOrderWithHttpInfo( + $trade_id, $user_id, $user_secret, - $account_id, - $simple_order_form, + $validated_trade_body, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -5082,17 +3660,17 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ switch($statusCode) { case 200: - if ('\SnapTrade\Model\SimpleOrderPreview' === '\SplFileObject') { + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\SimpleOrderPreview' !== 'string') { + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\SimpleOrderPreview', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -5113,7 +3691,7 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ ]; } - $returnType = '\SnapTrade\Model\SimpleOrderPreview'; + $returnType = '\SnapTrade\Model\AccountOrderRecord'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -5134,7 +3712,7 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\SimpleOrderPreview', + '\SnapTrade\Model\AccountOrderRecord', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -5153,51 +3731,35 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ } /** - * Operation previewSimpleOrderAsync + * Operation placeOrderAsync * - * Preview order + * Place checked order * - * Previews an order using the specified account. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function previewSimpleOrderAsync( - - $instrument, - $side, - $type, - $time_in_force, - $amount, + public function placeOrderAsync( + $trade_id, $user_id, $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['previewSimpleOrder'][0] + $wait_to_confirm = SENTINEL_VALUE, + + string $contentType = self::contentTypes['placeOrder'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; + $_body = null; + $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); + $validated_trade_body = $_body; - return $this->previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) + return $this->placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType) ->then( function ($response) { return $response[0]; @@ -5206,25 +3768,25 @@ function ($response) { } /** - * Operation previewSimpleOrderAsyncWithHttpInfo + * Operation placeOrderAsyncWithHttpInfo * - * Preview order + * Place checked order * - * Previews an order using the specified account. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\SimpleOrderPreview'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -5266,20 +3828,30 @@ function ($exception) { } /** - * Create request for operation 'previewSimpleOrder' + * Create request for operation 'placeOrder' * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0]) + public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body = SENTINEL_VALUE, string $contentType = self::contentTypes['placeOrder'][0]) { + // Check if $trade_id is a string + if ($trade_id !== SENTINEL_VALUE && !is_string($trade_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trade_id, true), gettype($trade_id))); + } + // verify the required parameter 'trade_id' is set + if ($trade_id === SENTINEL_VALUE || (is_array($trade_id) && count($trade_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter trade_id when calling placeOrder' + ); + } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -5287,46 +3859,30 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling previewSimpleOrder' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling previewSimpleOrder' + 'Missing the required parameter user_id when calling placeOrder' ); } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling previewSimpleOrder' + 'Missing the required parameter user_secret when calling placeOrder' ); } - if ($simple_order_form !== SENTINEL_VALUE) { - if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { - if (!is_array($simple_order_form)) - throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm TradingApi.previewSimpleOrder.'); + if ($validated_trade_body !== SENTINEL_VALUE) { + if (!($validated_trade_body instanceof \SnapTrade\Model\ValidatedTradeBody)) { + if (!is_array($validated_trade_body)) + throw new \InvalidArgumentException('"validated_trade_body" must be associative array or an instance of \SnapTrade\Model\ValidatedTradeBody TradingApi.placeOrder.'); else - $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); + $validated_trade_body = new \SnapTrade\Model\ValidatedTradeBody($validated_trade_body); } } - // verify the required parameter 'simple_order_form' is set - if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter simple_order_form when calling previewSimpleOrder' - ); - } - $resourcePath = '/accounts/{accountId}/trading/simple/preview'; + $resourcePath = '/trade/{tradeId}'; $formParams = []; $queryParams = []; $headerParams = []; @@ -5358,10 +3914,10 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ // path params - if ($account_id !== SENTINEL_VALUE) { + if ($trade_id !== SENTINEL_VALUE) { $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), + '{' . 'tradeId' . '}', + ObjectSerializer::toPathValue($trade_id), $resourcePath ); } @@ -5374,12 +3930,12 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ ); // for model (json/xml) - if (isset($simple_order_form)) { + if (isset($validated_trade_body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($validated_trade_body)); } else { - $httpBody = $simple_order_form; + $httpBody = $validated_trade_body; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -5449,74 +4005,75 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ } /** - * Operation replaceOrder + * Operation previewSimpleOrder * - * Replaces an order with a new one + * Preview order * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Previews an order using the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse */ - public function replaceOrder( + public function previewSimpleOrder( - $action, - $order_type, + $instrument, + $side, + $type, $time_in_force, - $account_id, - $brokerage_order_id, + $amount, $user_id, $user_secret, - $price = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['replaceOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['previewSimpleOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $manual_trade_replace_form = $_body; + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $simple_order_form = $_body; - list($response) = $this->replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + list($response) = $this->previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); return $response; } /** - * Operation replaceOrderWithHttpInfo + * Operation previewSimpleOrderWithHttpInfo * - * Replaces an order with a new one + * Preview order * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Previews an order using the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -5531,12 +4088,11 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->replaceOrderWithHttpInfo( - $account_id, - $brokerage_order_id, + return $this->previewSimpleOrderWithHttpInfo( $user_id, $user_secret, - $manual_trade_replace_form, + $account_id, + $simple_order_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -5574,17 +4130,17 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\SimpleOrderPreview' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\SimpleOrderPreview' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\SimpleOrderPreview', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -5603,24 +4159,9 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user $response->getStatusCode(), $response->getHeaders() ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\SimpleOrderPreview'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -5641,7 +4182,7 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\SimpleOrderPreview', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -5654,63 +4195,57 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user ); $e->setResponseObject($data); break; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; } throw $e; } } /** - * Operation replaceOrderAsync + * Operation previewSimpleOrderAsync * - * Replaces an order with a new one + * Preview order * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Previews an order using the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function replaceOrderAsync( + public function previewSimpleOrderAsync( - $action, - $order_type, + $instrument, + $side, + $type, $time_in_force, - $account_id, - $brokerage_order_id, + $amount, $user_id, $user_secret, - $price = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['replaceOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['previewSimpleOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $manual_trade_replace_form = $_body; + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $simple_order_form = $_body; - return $this->replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType) + return $this->previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) ->then( function ($response) { return $response[0]; @@ -5719,26 +4254,25 @@ function ($response) { } /** - * Operation replaceOrderAsyncWithHttpInfo + * Operation previewSimpleOrderAsyncWithHttpInfo * - * Replaces an order with a new one + * Preview order * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Previews an order using the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + $returnType = '\SnapTrade\Model\SimpleOrderPreview'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -5780,41 +4314,20 @@ function ($exception) { } /** - * Create request for operation 'replaceOrder' + * Create request for operation 'previewSimpleOrder' * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0]) - { - - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling replaceOrder' - ); - } - // Check if $brokerage_order_id is a string - if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); - } - // verify the required parameter 'brokerage_order_id' is set - if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter brokerage_order_id when calling replaceOrder' - ); - } + public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0]) + { + // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -5822,7 +4335,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling replaceOrder' + 'Missing the required parameter user_id when calling previewSimpleOrder' ); } // Check if $user_secret is a string @@ -5832,26 +4345,36 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling replaceOrder' + 'Missing the required parameter user_secret when calling previewSimpleOrder' ); } - if ($manual_trade_replace_form !== SENTINEL_VALUE) { - if (!($manual_trade_replace_form instanceof \SnapTrade\Model\ManualTradeReplaceForm)) { - if (!is_array($manual_trade_replace_form)) - throw new \InvalidArgumentException('"manual_trade_replace_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeReplaceForm TradingApi.replaceOrder.'); + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling previewSimpleOrder' + ); + } + if ($simple_order_form !== SENTINEL_VALUE) { + if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { + if (!is_array($simple_order_form)) + throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm TradingApi.previewSimpleOrder.'); else - $manual_trade_replace_form = new \SnapTrade\Model\ManualTradeReplaceForm($manual_trade_replace_form); + $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); } } - // verify the required parameter 'manual_trade_replace_form' is set - if ($manual_trade_replace_form === SENTINEL_VALUE || (is_array($manual_trade_replace_form) && count($manual_trade_replace_form) === 0)) { + // verify the required parameter 'simple_order_form' is set + if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_replace_form when calling replaceOrder' + 'Missing the required parameter simple_order_form when calling previewSimpleOrder' ); } - $resourcePath = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace'; + $resourcePath = '/accounts/{accountId}/trading/simple/preview'; $formParams = []; $queryParams = []; $headerParams = []; @@ -5890,14 +4413,6 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $resourcePath ); } - // path params - if ($brokerage_order_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'brokerageOrderId' . '}', - ObjectSerializer::toPathValue($brokerage_order_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -5907,12 +4422,12 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, ); // for model (json/xml) - if (isset($manual_trade_replace_form)) { + if (isset($simple_order_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_replace_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); } else { - $httpBody = $manual_trade_replace_form; + $httpBody = $simple_order_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -5965,7 +4480,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $headers ); - $method = 'PATCH'; + $method = 'POST'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); @@ -5982,62 +4497,77 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, } /** - * Operation searchCryptocurrencyPairInstruments + * Operation replaceOrder * - * Search cryptocurrency pairs instruments + * Replaces an order with a new one * - * Searches cryptocurrency pairs instruments accessible to the specified account. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param string $base base (optional) - * @param string $quote quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse */ - public function searchCryptocurrencyPairInstruments( + public function replaceOrder( + + $action, + $order_type, + $time_in_force, + $account_id, + $brokerage_order_id, $user_id, $user_secret, - $account_id, - $base = SENTINEL_VALUE, - $quote = SENTINEL_VALUE, - - string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] + $price = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['replaceOrder'][0] ) { + $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $manual_trade_replace_form = $_body; - list($response) = $this->searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); + list($response) = $this->replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); return $response; } /** - * Operation searchCryptocurrencyPairInstrumentsWithHttpInfo + * Operation replaceOrderWithHttpInfo * - * Search cryptocurrency pairs instruments + * Replaces an order with a new one * - * Searches cryptocurrency pairs instruments accessible to the specified account. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); try { $options = $this->createHttpClientOption(); @@ -6049,12 +4579,12 @@ public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_ !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->searchCryptocurrencyPairInstrumentsWithHttpInfo( + return $this->replaceOrderWithHttpInfo( + $account_id, + $brokerage_order_id, $user_id, $user_secret, - $account_id, - $base, - $quote, + $manual_trade_replace_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -6092,17 +4622,17 @@ public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_ switch($statusCode) { case 200: - if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' === '\SplFileObject') { + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' !== 'string') { + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -6121,9 +4651,24 @@ public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_ $response->getStatusCode(), $response->getHeaders() ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } - $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; + $returnType = '\SnapTrade\Model\AccountOrderRecord'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -6144,7 +4689,7 @@ public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_ case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', + '\SnapTrade\Model\AccountOrderRecord', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -6157,40 +4702,63 @@ public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_ ); $e->setResponseObject($data); break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } } /** - * Operation searchCryptocurrencyPairInstrumentsAsync + * Operation replaceOrderAsync * - * Search cryptocurrency pairs instruments + * Replaces an order with a new one * - * Searches cryptocurrency pairs instruments accessible to the specified account. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function searchCryptocurrencyPairInstrumentsAsync( + public function replaceOrderAsync( + + $action, + $order_type, + $time_in_force, + $account_id, + $brokerage_order_id, $user_id, $user_secret, - $account_id, - $base = SENTINEL_VALUE, - $quote = SENTINEL_VALUE, - - string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] + $price = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['replaceOrder'][0] ) { + $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $manual_trade_replace_form = $_body; - return $this->searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) + return $this->replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType) ->then( function ($response) { return $response[0]; @@ -6199,29 +4767,29 @@ function ($response) { } /** - * Operation searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo + * Operation replaceOrderAsyncWithHttpInfo * - * Search cryptocurrency pairs instruments + * Replaces an order with a new one * - * Searches cryptocurrency pairs instruments accessible to the specified account. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -6260,21 +4828,41 @@ function ($exception) { } /** - * Create request for operation 'searchCryptocurrencyPairInstruments' + * Create request for operation 'replaceOrder' * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0]) + public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0]) { + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling replaceOrder' + ); + } + // Check if $brokerage_order_id is a string + if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); + } + // verify the required parameter 'brokerage_order_id' is set + if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter brokerage_order_id when calling replaceOrder' + ); + } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -6282,7 +4870,7 @@ public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secre // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling searchCryptocurrencyPairInstruments' + 'Missing the required parameter user_id when calling replaceOrder' ); } // Check if $user_secret is a string @@ -6292,30 +4880,26 @@ public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secre // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling searchCryptocurrencyPairInstruments' + 'Missing the required parameter user_secret when calling replaceOrder' ); } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + if ($manual_trade_replace_form !== SENTINEL_VALUE) { + if (!($manual_trade_replace_form instanceof \SnapTrade\Model\ManualTradeReplaceForm)) { + if (!is_array($manual_trade_replace_form)) + throw new \InvalidArgumentException('"manual_trade_replace_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeReplaceForm TradingApi.replaceOrder.'); + else + $manual_trade_replace_form = new \SnapTrade\Model\ManualTradeReplaceForm($manual_trade_replace_form); + } } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + // verify the required parameter 'manual_trade_replace_form' is set + if ($manual_trade_replace_form === SENTINEL_VALUE || (is_array($manual_trade_replace_form) && count($manual_trade_replace_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling searchCryptocurrencyPairInstruments' + 'Missing the required parameter manual_trade_replace_form when calling replaceOrder' ); } - // Check if $base is a string - if ($base !== SENTINEL_VALUE && !is_string($base)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); - } - // Check if $quote is a string - if ($quote !== SENTINEL_VALUE && !is_string($quote)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); - } - $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs'; + $resourcePath = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace'; $formParams = []; $queryParams = []; $headerParams = []; @@ -6344,28 +4928,6 @@ public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secre true // required ) ?? []); } - if ($base !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $base, - 'base', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } - if ($quote !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $quote, - 'quote', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } // path params @@ -6376,6 +4938,14 @@ public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secre $resourcePath ); } + // path params + if ($brokerage_order_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'brokerageOrderId' . '}', + ObjectSerializer::toPathValue($brokerage_order_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -6385,7 +4955,14 @@ public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secre ); // for model (json/xml) - if (count($formParams) > 0) { + if (isset($manual_trade_replace_form)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_replace_form)); + } else { + $httpBody = $manual_trade_replace_form; + } + } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -6436,7 +5013,7 @@ public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secre $headers ); - $method = 'GET'; + $method = 'PATCH'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); diff --git a/lib/Client.php b/lib/Client.php index b8de060..bf70220 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -13,6 +13,8 @@ class Client public readonly \SnapTrade\Api\ConnectionsApi $connections; + public readonly \SnapTrade\Api\CryptoTradingApi $cryptoTrading; + public readonly \SnapTrade\Api\OptionsApi $options; public readonly \SnapTrade\Api\ReferenceDataApi $referenceData; @@ -48,6 +50,7 @@ public function __construct( $this->apiStatus = new \SnapTrade\Api\ApiStatusApi($config); $this->authentication = new \SnapTrade\Api\AuthenticationApi($config); $this->connections = new \SnapTrade\Api\ConnectionsApi($config); + $this->cryptoTrading = new \SnapTrade\Api\CryptoTradingApi($config); $this->options = new \SnapTrade\Api\OptionsApi($config); $this->referenceData = new \SnapTrade\Api\ReferenceDataApi($config); $this->trading = new \SnapTrade\Api\TradingApi($config); diff --git a/lib/Configuration.php b/lib/Configuration.php index 465e276..d7ef022 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.105/PHP'; + protected $userAgent = 'Konfig/2.0.106/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.105' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.106' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; diff --git a/test/Api/CryptoTradingApiTest.php b/test/Api/CryptoTradingApiTest.php new file mode 100644 index 0000000..5d65626 --- /dev/null +++ b/test/Api/CryptoTradingApiTest.php @@ -0,0 +1,96 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test case for placeSimpleOrder + * + * Place order. + * + */ + public function testPlaceSimpleOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test case for searchCryptocurrencyPairInstruments + * + * Search cryptocurrency pairs instruments. + * + */ + public function testSearchCryptocurrencyPairInstruments() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index add1d24..1444f5c 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -82,18 +82,6 @@ public function testCancelUserAccountOrder() $this->markTestIncomplete('Not implemented'); } - /** - * Test case for getCryptocurrencyPairQuote - * - * Get cryptocurrency pair quote. - * - */ - public function testGetCryptocurrencyPairQuote() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test case for getOrderImpact * @@ -166,18 +154,6 @@ public function testPlaceOrder() $this->markTestIncomplete('Not implemented'); } - /** - * Test case for placeSimpleOrder - * - * Place order. - * - */ - public function testPlaceSimpleOrder() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test case for previewSimpleOrder * @@ -201,16 +177,4 @@ public function testReplaceOrder() // TODO: implement $this->markTestIncomplete('Not implemented'); } - - /** - * Test case for searchCryptocurrencyPairInstruments - * - * Search cryptocurrency pairs instruments. - * - */ - public function testSearchCryptocurrencyPairInstruments() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } } From b7caf7a68bb342914d1678cc09f44b6c1b9c11c0 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 14:07:17 +0000 Subject: [PATCH 142/252] Regenerate SDKs (#166) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 342 +-- lib/Api/CryptoTradingApi.php | 1576 -------------- lib/Api/TradingApi.php | 3301 +++++++++++++++++++++-------- lib/Client.php | 3 - test/Api/CryptoTradingApiTest.php | 96 - test/Api/TradingApiTest.php | 36 + 7 files changed, 2570 insertions(+), 2786 deletions(-) delete mode 100644 lib/Api/CryptoTradingApi.php delete mode 100644 test/Api/CryptoTradingApiTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b3e2842..cfc5aa3 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -53e11c38-5085-4f22-ac4b-c617dc909229 \ No newline at end of file +ae1f1867-4fee-48bf-8eb9-28d3e066dbe1 \ No newline at end of file diff --git a/README.md b/README.md index 35a957f..ffe16e9 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,6 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.connections.removeBrokerageAuthorization`](#snaptradeconnectionsremovebrokerageauthorization) * [`snaptrade.connections.returnRates`](#snaptradeconnectionsreturnrates) * [`snaptrade.connections.sessionEvents`](#snaptradeconnectionssessionevents) - * [`snaptrade.cryptoTrading.getCryptocurrencyPairQuote`](#snaptradecryptotradinggetcryptocurrencypairquote) - * [`snaptrade.cryptoTrading.placeSimpleOrder`](#snaptradecryptotradingplacesimpleorder) - * [`snaptrade.cryptoTrading.searchCryptocurrencyPairInstruments`](#snaptradecryptotradingsearchcryptocurrencypairinstruments) * [`snaptrade.options.getOptionStrategy`](#snaptradeoptionsgetoptionstrategy) * [`snaptrade.options.getOptionsChain`](#snaptradeoptionsgetoptionschain) * [`snaptrade.options.getOptionsStrategyQuote`](#snaptradeoptionsgetoptionsstrategyquote) @@ -66,14 +63,17 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.referenceData.symbolSearchUserAccount`](#snaptradereferencedatasymbolsearchuseraccount) * [`snaptrade.trading.cancelOrder`](#snaptradetradingcancelorder) * [`snaptrade.trading.cancelUserAccountOrder`](#snaptradetradingcanceluseraccountorder) + * [`snaptrade.trading.getCryptocurrencyPairQuote`](#snaptradetradinggetcryptocurrencypairquote) * [`snaptrade.trading.getOrderImpact`](#snaptradetradinggetorderimpact) * [`snaptrade.trading.getUserAccountQuotes`](#snaptradetradinggetuseraccountquotes) * [`snaptrade.trading.placeBracketOrder`](#snaptradetradingplacebracketorder) * [`snaptrade.trading.placeForceOrder`](#snaptradetradingplaceforceorder) * [`snaptrade.trading.placeMlegOrder`](#snaptradetradingplacemlegorder) * [`snaptrade.trading.placeOrder`](#snaptradetradingplaceorder) + * [`snaptrade.trading.placeSimpleOrder`](#snaptradetradingplacesimpleorder) * [`snaptrade.trading.previewSimpleOrder`](#snaptradetradingpreviewsimpleorder) * [`snaptrade.trading.replaceOrder`](#snaptradetradingreplaceorder) + * [`snaptrade.trading.searchCryptocurrencyPairInstruments`](#snaptradetradingsearchcryptocurrencypairinstruments) * [`snaptrade.transactionsAndReporting.getActivities`](#snaptradetransactionsandreportinggetactivities) * [`snaptrade.transactionsAndReporting.getReportingCustomRange`](#snaptradetransactionsandreportinggetreportingcustomrange) @@ -1121,174 +1121,6 @@ Optional comma separated list of session IDs used to filter the request on speci --- -### `snaptrade.cryptoTrading.getCryptocurrencyPairQuote` - -Gets a quote for the specified account. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->cryptoTrading->getCryptocurrencyPairQuote( - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - instrument_symbol: "BTC-USD" -); -``` - -#### βš™οΈ Parameters - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### instrument_symbol: `string` - - -#### πŸ”„ Return - -[**CryptocurrencyPairQuote**](./lib/Model/CryptocurrencyPairQuote.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote` `GET` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - -### `snaptrade.cryptoTrading.placeSimpleOrder` - -Places an order in the specified account. -This endpoint does not compute the impact to the account balance from the order before submitting the order. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->cryptoTrading->placeSimpleOrder( - instrument: [ - "symbol" => "AAPL", - "type" => "EQUITY", - ], - side: "BUY", - type: "MARKET", - time_in_force: "GTC", - amount: "123.45", - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - limit_price: "123.45", - stop_price: "123.45", - post_only: False, - expiration_date: "2024-01-01T00:00:00Z" -); -``` - -#### βš™οΈ Parameters - -##### instrument: [`TradingInstrument`](./lib/Model/TradingInstrument.php) - -##### side: - -##### type: `string` - -The type of order to place. - -##### time_in_force: `string` - -The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. - -##### amount: `float` - -The amount of the base currency to buy or sell. - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### limit_price: `float` - -The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. - -##### stop_price: `float` - -The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. - -##### post_only: `bool` - -Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. - -##### expiration_date: `\DateTime` - -The expiration date of the order. Required if the time_in_force is GTD. - - -#### πŸ”„ Return - -[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/simple` `POST` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - -### `snaptrade.cryptoTrading.searchCryptocurrencyPairInstruments` - -Searches cryptocurrency pairs instruments accessible to the specified account. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->cryptoTrading->searchCryptocurrencyPairInstruments( - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - base: "BTC", - quote: "USD" -); -``` - -#### βš™οΈ Parameters - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### base: `string` - -##### quote: `string` - - -#### πŸ”„ Return - -[**TradingSearchCryptocurrencyPairInstruments200Response**](./lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs` `GET` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - ### `snaptrade.options.getOptionStrategy` Creates an option strategy object that will be used to place an option strategy order. @@ -1941,6 +1773,47 @@ Order ID returned by brokerage. This is the unique identifier for the order in t --- +### `snaptrade.trading.getCryptocurrencyPairQuote` + +Gets a quote for the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->getCryptocurrencyPairQuote( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + instrument_symbol: "BTC-USD" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### instrument_symbol: `string` + + +#### πŸ”„ Return + +[**CryptocurrencyPairQuote**](./lib/Model/CryptocurrencyPairQuote.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.trading.getOrderImpact` Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. @@ -2341,6 +2214,89 @@ Optional, defaults to true. Determines if a wait is performed to check on order --- +### `snaptrade.trading.placeSimpleOrder` + +Places an order in the specified account. +This endpoint does not compute the impact to the account balance from the order before submitting the order. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->placeSimpleOrder( + instrument: [ + "symbol" => "AAPL", + "type" => "EQUITY", + ], + side: "BUY", + type: "MARKET", + time_in_force: "GTC", + amount: "123.45", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + limit_price: "123.45", + stop_price: "123.45", + post_only: False, + expiration_date: "2024-01-01T00:00:00Z" +); +``` + +#### βš™οΈ Parameters + +##### instrument: [`TradingInstrument`](./lib/Model/TradingInstrument.php) + +##### side: + +##### type: `string` + +The type of order to place. + +##### time_in_force: `string` + +The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. + +##### amount: `float` + +The amount of the base currency to buy or sell. + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### limit_price: `float` + +The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. + +##### stop_price: `float` + +The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. + +##### post_only: `bool` + +Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. + +##### expiration_date: `\DateTime` + +The expiration date of the order. Required if the time_in_force is GTD. + + +#### πŸ”„ Return + +[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/simple` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.trading.previewSimpleOrder` Previews an order using the specified account. @@ -2497,6 +2453,50 @@ The price at which a stop order is triggered for `Stop` and `StopLimit` orders. --- +### `snaptrade.trading.searchCryptocurrencyPairInstruments` + +Searches cryptocurrency pairs instruments accessible to the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->searchCryptocurrencyPairInstruments( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + base: "BTC", + quote: "USD" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### base: `string` + +##### quote: `string` + + +#### πŸ”„ Return + +[**TradingSearchCryptocurrencyPairInstruments200Response**](./lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.transactionsAndReporting.getActivities` ![Deprecated](https://img.shields.io/badge/deprecated-yellow) diff --git a/lib/Api/CryptoTradingApi.php b/lib/Api/CryptoTradingApi.php deleted file mode 100644 index 570e794..0000000 --- a/lib/Api/CryptoTradingApi.php +++ /dev/null @@ -1,1576 +0,0 @@ - [ - 'application/json', - ], - 'placeSimpleOrder' => [ - 'application/json', - ], - 'searchCryptocurrencyPairInstruments' => [ - 'application/json', - ], - ]; - -/** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - Configuration $config = null, - ClientInterface $client = null, - HeaderSelector $selector = null, - $hostIndex = 0 - ) { - $clientOptions = []; - if (!$config->getVerifySsl()) $clientOptions["verify"] = false; - - // Do not truncate error messages - // https://github.com/guzzle/guzzle/issues/2185#issuecomment-800293420 - $stack = new HandlerStack(Utils::chooseHandler()); - $stack->push(Middleware::httpErrors(new BodySummarizer(10000)), 'http_errors'); - $stack->push(Middleware::redirect(), 'allow_redirects'); - $stack->push(Middleware::cookies(), 'cookies'); - $stack->push(Middleware::prepareBody(), 'prepare_body'); - $clientOptions["handler"] = $stack; - - $this->client = $client ?: new Client($clientOptions); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * For initializing request body parameter - */ - private function setRequestBodyProperty(&$body, $property, $value) { - if ($body === null) $body = []; - // user did not pass in a value for this parameter - if ($value === SENTINEL_VALUE) return; - $body[$property] = $value; - } - - /** - * Operation getCryptocurrencyPairQuote - * - * Get cryptocurrency pair quote - * - * Gets a quote for the specified account. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param string $instrument_symbol instrument_symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\CryptocurrencyPairQuote|\SnapTrade\Model\Model400FailedRequestResponse - */ - public function getCryptocurrencyPairQuote( - $user_id, - $user_secret, - $account_id, - $instrument_symbol, - - string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0] - ) - { - - list($response) = $this->getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); - return $response; - } - - /** - * Operation getCryptocurrencyPairQuoteWithHttpInfo - * - * Get cryptocurrency pair quote - * - * Gets a quote for the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $instrument_symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\CryptocurrencyPairQuote|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->getCryptocurrencyPairQuoteWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $instrument_symbol, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\CryptocurrencyPairQuote' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\CryptocurrencyPairQuote' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\CryptocurrencyPairQuote', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\CryptocurrencyPairQuote'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\CryptocurrencyPairQuote', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getCryptocurrencyPairQuoteAsync - * - * Get cryptocurrency pair quote - * - * Gets a quote for the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $instrument_symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getCryptocurrencyPairQuoteAsync( - $user_id, - $user_secret, - $account_id, - $instrument_symbol, - - string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0] - ) - { - - return $this->getCryptocurrencyPairQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getCryptocurrencyPairQuoteAsyncWithHttpInfo - * - * Get cryptocurrency pair quote - * - * Gets a quote for the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $instrument_symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getCryptocurrencyPairQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\CryptocurrencyPairQuote'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'getCryptocurrencyPairQuote' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $instrument_symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getCryptocurrencyPairQuote' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getCryptocurrencyPairQuote' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling getCryptocurrencyPairQuote' - ); - } - // Check if $instrument_symbol is a string - if ($instrument_symbol !== SENTINEL_VALUE && !is_string($instrument_symbol)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($instrument_symbol, true), gettype($instrument_symbol))); - } - // verify the required parameter 'instrument_symbol' is set - if ($instrument_symbol === SENTINEL_VALUE || (is_array($instrument_symbol) && count($instrument_symbol) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter instrument_symbol when calling getCryptocurrencyPairQuote' - ); - } - - - $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - // path params - if ($instrument_symbol !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'instrumentSymbol' . '}', - ObjectSerializer::toPathValue($instrument_symbol), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'GET'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation placeSimpleOrder - * - * Place order - * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse - */ - public function placeSimpleOrder( - - $instrument, - $side, - $type, - $time_in_force, - $amount, - $user_id, - $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeSimpleOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; - - list($response) = $this->placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); - return $response; - } - - /** - * Operation placeSimpleOrderWithHttpInfo - * - * Place order - * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->placeSimpleOrderWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $simple_order_form, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\OrderUpdatedResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation placeSimpleOrderAsync - * - * Place order - * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function placeSimpleOrderAsync( - - $instrument, - $side, - $type, - $time_in_force, - $amount, - $user_id, - $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeSimpleOrder'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; - - return $this->placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation placeSimpleOrderAsyncWithHttpInfo - * - * Place order - * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'placeSimpleOrder' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeSimpleOrder' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeSimpleOrder' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling placeSimpleOrder' - ); - } - if ($simple_order_form !== SENTINEL_VALUE) { - if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { - if (!is_array($simple_order_form)) - throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm CryptoTradingApi.placeSimpleOrder.'); - else - $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); - } - } - // verify the required parameter 'simple_order_form' is set - if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter simple_order_form when calling placeSimpleOrder' - ); - } - - - $resourcePath = '/accounts/{accountId}/trading/simple'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (isset($simple_order_form)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); - } else { - $httpBody = $simple_order_form; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'POST'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation searchCryptocurrencyPairInstruments - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param string $base base (optional) - * @param string $quote quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse - */ - public function searchCryptocurrencyPairInstruments( - $user_id, - $user_secret, - $account_id, - $base = SENTINEL_VALUE, - $quote = SENTINEL_VALUE, - - string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] - ) - { - - list($response) = $this->searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); - return $response; - } - - /** - * Operation searchCryptocurrencyPairInstrumentsWithHttpInfo - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->searchCryptocurrencyPairInstrumentsWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $base, - $quote, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation searchCryptocurrencyPairInstrumentsAsync - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function searchCryptocurrencyPairInstrumentsAsync( - $user_id, - $user_secret, - $account_id, - $base = SENTINEL_VALUE, - $quote = SENTINEL_VALUE, - - string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] - ) - { - - return $this->searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'searchCryptocurrencyPairInstruments' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling searchCryptocurrencyPairInstruments' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling searchCryptocurrencyPairInstruments' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling searchCryptocurrencyPairInstruments' - ); - } - // Check if $base is a string - if ($base !== SENTINEL_VALUE && !is_string($base)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); - } - // Check if $quote is a string - if ($quote !== SENTINEL_VALUE && !is_string($quote)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); - } - - - $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($base !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $base, - 'base', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } - if ($quote !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $quote, - 'quote', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'GET'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 96286bc..644fb07 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -68,6 +68,9 @@ class TradingApi extends \SnapTrade\CustomApi 'cancelUserAccountOrder' => [ 'application/json', ], + 'getCryptocurrencyPairQuote' => [ + 'application/json', + ], 'getOrderImpact' => [ 'application/json', ], @@ -86,12 +89,18 @@ class TradingApi extends \SnapTrade\CustomApi 'placeOrder' => [ 'application/json', ], + 'placeSimpleOrder' => [ + 'application/json', + ], 'previewSimpleOrder' => [ 'application/json', ], 'replaceOrder' => [ 'application/json', ], + 'searchCryptocurrencyPairInstruments' => [ + 'application/json', + ], ]; /** @@ -1097,75 +1106,59 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i } /** - * Operation getOrderImpact + * Operation getCryptocurrencyPairQuote * - * Check order impact + * Get cryptocurrency pair quote * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Gets a quote for the specified account. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param string $instrument_symbol instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\CryptocurrencyPairQuote|\SnapTrade\Model\Model400FailedRequestResponse */ - public function getOrderImpact( - - $account_id, - $action, - $universal_symbol_id, - $order_type, - $time_in_force, + public function getCryptocurrencyPairQuote( $user_id, $user_secret, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['getOrderImpact'][0] + $account_id, + $instrument_symbol, + + string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form = $_body; - list($response) = $this->getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType); + list($response) = $this->getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); return $response; } /** - * Operation getOrderImpactWithHttpInfo + * Operation getCryptocurrencyPairQuoteWithHttpInfo * - * Check order impact + * Get cryptocurrency pair quote * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Gets a quote for the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\CryptocurrencyPairQuote|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); try { $options = $this->createHttpClientOption(); @@ -1177,10 +1170,11 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->getOrderImpactWithHttpInfo( + return $this->getCryptocurrencyPairQuoteWithHttpInfo( $user_id, $user_secret, - $manual_trade_form, + $account_id, + $instrument_symbol, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -1218,17 +1212,17 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade switch($statusCode) { case 200: - if ('\SnapTrade\Model\ManualTradeAndImpact' === '\SplFileObject') { + if ('\SnapTrade\Model\CryptocurrencyPairQuote' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\ManualTradeAndImpact' !== 'string') { + if ('\SnapTrade\Model\CryptocurrencyPairQuote' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\ManualTradeAndImpact', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\CryptocurrencyPairQuote', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -1247,24 +1241,9 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade $response->getStatusCode(), $response->getHeaders() ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; } - $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; + $returnType = '\SnapTrade\Model\CryptocurrencyPairQuote'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -1285,7 +1264,7 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\ManualTradeAndImpact', + '\SnapTrade\Model\CryptocurrencyPairQuote', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -1298,63 +1277,38 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade ); $e->setResponseObject($data); break; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; } throw $e; } } /** - * Operation getOrderImpactAsync + * Operation getCryptocurrencyPairQuoteAsync * - * Check order impact + * Get cryptocurrency pair quote * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Gets a quote for the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOrderImpactAsync( - - $account_id, - $action, - $universal_symbol_id, - $order_type, - $time_in_force, + public function getCryptocurrencyPairQuoteAsync( $user_id, $user_secret, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['getOrderImpact'][0] + $account_id, + $instrument_symbol, + + string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form = $_body; - return $this->getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType) + return $this->getCryptocurrencyPairQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, $contentType) ->then( function ($response) { return $response[0]; @@ -1363,27 +1317,28 @@ function ($response) { } /** - * Operation getOrderImpactAsyncWithHttpInfo + * Operation getCryptocurrencyPairQuoteAsyncWithHttpInfo * - * Check order impact + * Get cryptocurrency pair quote * - * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. + * Gets a quote for the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getCryptocurrencyPairQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); + $returnType = '\SnapTrade\Model\CryptocurrencyPairQuote'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1422,17 +1377,18 @@ function ($exception) { } /** - * Create request for operation 'getOrderImpact' + * Create request for operation 'getCryptocurrencyPairQuote' * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $instrument_symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCryptocurrencyPairQuote'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0]) + public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $account_id, $instrument_symbol, string $contentType = self::contentTypes['getCryptocurrencyPairQuote'][0]) { // Check if $user_id is a string @@ -1442,7 +1398,7 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getOrderImpact' + 'Missing the required parameter user_id when calling getCryptocurrencyPairQuote' ); } // Check if $user_secret is a string @@ -1452,26 +1408,32 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getOrderImpact' + 'Missing the required parameter user_secret when calling getCryptocurrencyPairQuote' ); } - if ($manual_trade_form !== SENTINEL_VALUE) { - if (!($manual_trade_form instanceof \SnapTrade\Model\ManualTradeForm)) { - if (!is_array($manual_trade_form)) - throw new \InvalidArgumentException('"manual_trade_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeForm TradingApi.getOrderImpact.'); - else - $manual_trade_form = new \SnapTrade\Model\ManualTradeForm($manual_trade_form); - } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); } - // verify the required parameter 'manual_trade_form' is set - if ($manual_trade_form === SENTINEL_VALUE || (is_array($manual_trade_form) && count($manual_trade_form) === 0)) { + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form when calling getOrderImpact' + 'Missing the required parameter account_id when calling getCryptocurrencyPairQuote' + ); + } + // Check if $instrument_symbol is a string + if ($instrument_symbol !== SENTINEL_VALUE && !is_string($instrument_symbol)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($instrument_symbol, true), gettype($instrument_symbol))); + } + // verify the required parameter 'instrument_symbol' is set + if ($instrument_symbol === SENTINEL_VALUE || (is_array($instrument_symbol) && count($instrument_symbol) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter instrument_symbol when calling getCryptocurrencyPairQuote' ); } - $resourcePath = '/trade/impact'; + $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote'; $formParams = []; $queryParams = []; $headerParams = []; @@ -1502,6 +1464,22 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form } + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($instrument_symbol !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'instrumentSymbol' . '}', + ObjectSerializer::toPathValue($instrument_symbol), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -1511,14 +1489,7 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form ); // for model (json/xml) - if (isset($manual_trade_form)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form)); - } else { - $httpBody = $manual_trade_form; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -1569,7 +1540,7 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form $headers ); - $method = 'POST'; + $method = 'GET'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); @@ -1586,62 +1557,75 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form } /** - * Operation getUserAccountQuotes + * Operation getOrderImpact * - * Get symbol quotes + * Check order impact * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) - * @param string $account_id account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse + * @return \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse */ - public function getUserAccountQuotes( + public function getOrderImpact( + + $account_id, + $action, + $universal_symbol_id, + $order_type, + $time_in_force, $user_id, $user_secret, - $symbols, - $account_id, - $use_ticker = SENTINEL_VALUE, - - string $contentType = self::contentTypes['getUserAccountQuotes'][0] + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['getOrderImpact'][0] ) { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form = $_body; - list($response) = $this->getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + list($response) = $this->getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType); return $response; } /** - * Operation getUserAccountQuotesWithHttpInfo + * Operation getOrderImpactWithHttpInfo * - * Get symbol quotes + * Check order impact * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) - * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\ManualTradeAndImpact|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); try { $options = $this->createHttpClientOption(); @@ -1653,12 +1637,10 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->getUserAccountQuotesWithHttpInfo( + return $this->getOrderImpactWithHttpInfo( $user_id, $user_secret, - $symbols, - $account_id, - $use_ticker, + $manual_trade_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -1696,38 +1678,53 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol switch($statusCode) { case 200: - if ('\SnapTrade\Model\SymbolsQuotesInner[]' === '\SplFileObject') { + if ('\SnapTrade\Model\ManualTradeAndImpact' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\SymbolsQuotesInner[]' !== 'string') { + if ('\SnapTrade\Model\ManualTradeAndImpact' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\SymbolsQuotesInner[]', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\ManualTradeAndImpact', []), $response->getStatusCode(), $response->getHeaders() ]; - case 500: - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } - $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; + $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -1748,15 +1745,23 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\SymbolsQuotesInner[]', + '\SnapTrade\Model\ManualTradeAndImpact', $e->getResponseHeaders() ); $e->setResponseObject($data); break; - case 500: + case 400: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -1767,34 +1772,49 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol } /** - * Operation getUserAccountQuotesAsync + * Operation getOrderImpactAsync * - * Get symbol quotes + * Check order impact * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) - * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getUserAccountQuotesAsync( + public function getOrderImpactAsync( + + $account_id, + $action, + $universal_symbol_id, + $order_type, + $time_in_force, $user_id, $user_secret, - $symbols, - $account_id, - $use_ticker = SENTINEL_VALUE, - - string $contentType = self::contentTypes['getUserAccountQuotes'][0] + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['getOrderImpact'][0] ) { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form = $_body; - return $this->getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType) + return $this->getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, $contentType) ->then( function ($response) { return $response[0]; @@ -1803,29 +1823,27 @@ function ($response) { } /** - * Operation getUserAccountQuotesAsyncWithHttpInfo + * Operation getOrderImpactAsyncWithHttpInfo * - * Get symbol quotes + * Check order impact * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) - * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getOrderImpactAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + $returnType = '\SnapTrade\Model\ManualTradeAndImpact'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1864,19 +1882,17 @@ function ($exception) { } /** - * Create request for operation 'getUserAccountQuotes' + * Create request for operation 'getOrderImpact' * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) - * @param string $account_id (required) - * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeForm $manual_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderImpact'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountQuotes'][0]) + public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form, string $contentType = self::contentTypes['getOrderImpact'][0]) { // Check if $user_id is a string @@ -1886,7 +1902,7 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getUserAccountQuotes' + 'Missing the required parameter user_id when calling getOrderImpact' ); } // Check if $user_secret is a string @@ -1896,32 +1912,26 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getUserAccountQuotes' - ); - } - // Check if $symbols is a string - if ($symbols !== SENTINEL_VALUE && !is_string($symbols)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($symbols, true), gettype($symbols))); - } - // verify the required parameter 'symbols' is set - if ($symbols === SENTINEL_VALUE || (is_array($symbols) && count($symbols) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter symbols when calling getUserAccountQuotes' + 'Missing the required parameter user_secret when calling getOrderImpact' ); } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + if ($manual_trade_form !== SENTINEL_VALUE) { + if (!($manual_trade_form instanceof \SnapTrade\Model\ManualTradeForm)) { + if (!is_array($manual_trade_form)) + throw new \InvalidArgumentException('"manual_trade_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeForm TradingApi.getOrderImpact.'); + else + $manual_trade_form = new \SnapTrade\Model\ManualTradeForm($manual_trade_form); + } } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + // verify the required parameter 'manual_trade_form' is set + if ($manual_trade_form === SENTINEL_VALUE || (is_array($manual_trade_form) && count($manual_trade_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling getUserAccountQuotes' + 'Missing the required parameter manual_trade_form when calling getOrderImpact' ); } - $resourcePath = '/accounts/{accountId}/quotes'; + $resourcePath = '/trade/impact'; $formParams = []; $queryParams = []; $headerParams = []; @@ -1950,38 +1960,1493 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a true // required ) ?? []); } - if ($symbols !== SENTINEL_VALUE) { + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($manual_trade_form)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form)); + } else { + $httpBody = $manual_trade_form; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation getUserAccountQuotes + * + * Get symbol quotes + * + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse + */ + public function getUserAccountQuotes( + $user_id, + $user_secret, + $symbols, + $account_id, + $use_ticker = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getUserAccountQuotes'][0] + ) + { + + list($response) = $this->getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + return $response; + } + + /** + * Operation getUserAccountQuotesWithHttpInfo + * + * Get symbol quotes + * + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\SymbolsQuotesInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->getUserAccountQuotesWithHttpInfo( + $user_id, + $user_secret, + $symbols, + $account_id, + $use_ticker, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\SymbolsQuotesInner[]' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\SymbolsQuotesInner[]' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\SymbolsQuotesInner[]', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\SymbolsQuotesInner[]', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getUserAccountQuotesAsync + * + * Get symbol quotes + * + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountQuotesAsync( + $user_id, + $user_secret, + $symbols, + $account_id, + $use_ticker = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getUserAccountQuotes'][0] + ) + { + + return $this->getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getUserAccountQuotesAsyncWithHttpInfo + * + * Get symbol quotes + * + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountQuotesAsyncWithHttpInfo($user_id, $user_secret, $symbols, $account_id, $use_ticker = null, string $contentType = self::contentTypes['getUserAccountQuotes'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\SymbolsQuotesInner[]'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getUserAccountQuotes' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $symbols List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator (required) + * @param string $account_id (required) + * @param bool $use_ticker Should be set to `True` if `symbols` are comprised of tickers. Defaults to `False` if not provided. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountQuotes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $account_id, $use_ticker = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountQuotes'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getUserAccountQuotes' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getUserAccountQuotes' + ); + } + // Check if $symbols is a string + if ($symbols !== SENTINEL_VALUE && !is_string($symbols)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($symbols, true), gettype($symbols))); + } + // verify the required parameter 'symbols' is set + if ($symbols === SENTINEL_VALUE || (is_array($symbols) && count($symbols) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter symbols when calling getUserAccountQuotes' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getUserAccountQuotes' + ); + } + + + $resourcePath = '/accounts/{accountId}/quotes'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($symbols !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $symbols, + 'symbols', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($use_ticker !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $use_ticker, + 'use_ticker', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation placeBracketOrder + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + */ + public function placeBracketOrder( + + $action, + $instrument, + $order_type, + $time_in_force, + $stop_loss, + $take_profit, + $account_id, + $user_id, + $user_secret, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeBracketOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); + $this->setRequestBodyProperty($_body, "take_profit", $take_profit); + $manual_trade_form_bracket = $_body; + + list($response) = $this->placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + return $response; + } + + /** + * Operation placeBracketOrderWithHttpInfo + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->placeBracketOrderWithHttpInfo( + $account_id, + $user_id, + $user_secret, + $manual_trade_form_bracket, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation placeBracketOrderAsync + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeBracketOrderAsync( + + $action, + $instrument, + $order_type, + $time_in_force, + $stop_loss, + $take_profit, + $account_id, + $user_id, + $user_secret, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeBracketOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); + $this->setRequestBodyProperty($_body, "take_profit", $take_profit); + $manual_trade_form_bracket = $_body; + + return $this->placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation placeBracketOrderAsyncWithHttpInfo + * + * Place a Bracket Order + * + * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'placeBracketOrder' + * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0]) + { + + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling placeBracketOrder' + ); + } + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling placeBracketOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling placeBracketOrder' + ); + } + if ($manual_trade_form_bracket !== SENTINEL_VALUE) { + if (!($manual_trade_form_bracket instanceof \SnapTrade\Model\ManualTradeFormBracket)) { + if (!is_array($manual_trade_form_bracket)) + throw new \InvalidArgumentException('"manual_trade_form_bracket" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormBracket TradingApi.placeBracketOrder.'); + else + $manual_trade_form_bracket = new \SnapTrade\Model\ManualTradeFormBracket($manual_trade_form_bracket); + } + } + // verify the required parameter 'manual_trade_form_bracket' is set + if ($manual_trade_form_bracket === SENTINEL_VALUE || (is_array($manual_trade_form_bracket) && count($manual_trade_form_bracket) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter manual_trade_form_bracket when calling placeBracketOrder' + ); + } + + + $resourcePath = '/accounts/{accountId}/trading/bracket'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($manual_trade_form_bracket)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_bracket)); + } else { + $httpBody = $manual_trade_form_bracket; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation placeForceOrder + * + * Place order + * + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + */ + public function placeForceOrder( + + $account_id, + $action, + $order_type, + $time_in_force, + $user_id, + $user_secret, + $universal_symbol_id = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeForceOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form_with_options = $_body; + + list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + return $response; + } + + /** + * Operation placeForceOrderWithHttpInfo + * + * Place order + * + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->placeForceOrderWithHttpInfo( + $user_id, + $user_secret, + $manual_trade_form_with_options, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation placeForceOrderAsync + * + * Place order + * + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeForceOrderAsync( + + $account_id, + $action, + $order_type, + $time_in_force, + $user_id, + $user_secret, + $universal_symbol_id = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeForceOrder'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form_with_options = $_body; + + return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation placeForceOrderAsyncWithHttpInfo + * + * Place order + * + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'placeForceOrder' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling placeForceOrder' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling placeForceOrder' + ); + } + if ($manual_trade_form_with_options !== SENTINEL_VALUE) { + if (!($manual_trade_form_with_options instanceof \SnapTrade\Model\ManualTradeFormWithOptions)) { + if (!is_array($manual_trade_form_with_options)) + throw new \InvalidArgumentException('"manual_trade_form_with_options" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormWithOptions TradingApi.placeForceOrder.'); + else + $manual_trade_form_with_options = new \SnapTrade\Model\ManualTradeFormWithOptions($manual_trade_form_with_options); + } + } + // verify the required parameter 'manual_trade_form_with_options' is set + if ($manual_trade_form_with_options === SENTINEL_VALUE || (is_array($manual_trade_form_with_options) && count($manual_trade_form_with_options) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter manual_trade_form_with_options when calling placeForceOrder' + ); + } + + + $resourcePath = '/trade/place'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $symbols, - 'symbols', // param base name + $user_id, + 'userId', // param base name 'string', // openApiType 'form', // style true, // explode true // required ) ?? []); } - if ($use_ticker !== SENTINEL_VALUE) { + if ($user_secret !== SENTINEL_VALUE) { // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $use_ticker, - 'use_ticker', // param base name - 'boolean', // openApiType + $user_secret, + 'userSecret', // param base name + 'string', // openApiType 'form', // style true, // explode - false // required + true // required ) ?? []); } - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -1991,7 +3456,14 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a ); // for model (json/xml) - if (count($formParams) > 0) { + if (isset($manual_trade_form_with_options)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_with_options)); + } else { + $httpBody = $manual_trade_form_with_options; + } + } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -2042,7 +3514,7 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a $headers ); - $method = 'GET'; + $method = 'POST'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); @@ -2059,77 +3531,69 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a } /** - * Operation placeBracketOrder + * Operation placeMlegOrder * - * Place a Bracket Order + * Place multi-leg option order * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * - * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse */ - public function placeBracketOrder( + public function placeMlegOrder( - $action, - $instrument, $order_type, $time_in_force, - $stop_loss, - $take_profit, - $account_id, + $legs, $user_id, $user_secret, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeBracketOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $price_effect = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeMlegOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "instrument", $instrument); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); - $this->setRequestBodyProperty($_body, "take_profit", $take_profit); - $manual_trade_form_bracket = $_body; + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "price_effect", $price_effect); + $this->setRequestBodyProperty($_body, "legs", $legs); + $mleg_trade_form = $_body; - list($response) = $this->placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + list($response) = $this->placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); return $response; } /** - * Operation placeBracketOrderWithHttpInfo + * Operation placeMlegOrderWithHttpInfo * - * Place a Bracket Order + * Place multi-leg option order * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * - * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -2144,11 +3608,11 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeBracketOrderWithHttpInfo( - $account_id, + return $this->placeMlegOrderWithHttpInfo( $user_id, $user_secret, - $manual_trade_form_bracket, + $account_id, + $mleg_trade_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -2186,17 +3650,17 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\MlegOrderResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\MlegOrderResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\MlegOrderResponse', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -2215,24 +3679,9 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre $response->getStatusCode(), $response->getHeaders() ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\MlegOrderResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -2253,7 +3702,7 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\MlegOrderResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -2266,67 +3715,51 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre ); $e->setResponseObject($data); break; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; } throw $e; } } /** - * Operation placeBracketOrderAsync + * Operation placeMlegOrderAsync * - * Place a Bracket Order + * Place multi-leg option order * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * - * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeBracketOrderAsync( + public function placeMlegOrderAsync( - $action, - $instrument, $order_type, $time_in_force, - $stop_loss, - $take_profit, - $account_id, + $legs, $user_id, $user_secret, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeBracketOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $price_effect = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeMlegOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "instrument", $instrument); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "stop_loss", $stop_loss); - $this->setRequestBodyProperty($_body, "take_profit", $take_profit); - $manual_trade_form_bracket = $_body; + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "price_effect", $price_effect); + $this->setRequestBodyProperty($_body, "legs", $legs); + $mleg_trade_form = $_body; - return $this->placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType) + return $this->placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType) ->then( function ($response) { return $response[0]; @@ -2335,25 +3768,25 @@ function ($response) { } /** - * Operation placeBracketOrderAsyncWithHttpInfo + * Operation placeMlegOrderAsyncWithHttpInfo * - * Place a Bracket Order + * Place multi-leg option order * - * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * - * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeBracketOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, $contentType); + $returnType = '\SnapTrade\Model\MlegOrderResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -2395,30 +3828,20 @@ function ($exception) { } /** - * Create request for operation 'placeBracketOrder' + * Create request for operation 'placeMlegOrder' * - * @param string $account_id The ID of the account to execute the trade on. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormBracket $manual_trade_form_bracket (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeBracketOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $manual_trade_form_bracket, string $contentType = self::contentTypes['placeBracketOrder'][0]) + public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0]) { - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling placeBracketOrder' - ); - } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -2426,7 +3849,7 @@ public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $m // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeBracketOrder' + 'Missing the required parameter user_id when calling placeMlegOrder' ); } // Check if $user_secret is a string @@ -2436,26 +3859,36 @@ public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $m // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeBracketOrder' + 'Missing the required parameter user_secret when calling placeMlegOrder' ); } - if ($manual_trade_form_bracket !== SENTINEL_VALUE) { - if (!($manual_trade_form_bracket instanceof \SnapTrade\Model\ManualTradeFormBracket)) { - if (!is_array($manual_trade_form_bracket)) - throw new \InvalidArgumentException('"manual_trade_form_bracket" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormBracket TradingApi.placeBracketOrder.'); + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling placeMlegOrder' + ); + } + if ($mleg_trade_form !== SENTINEL_VALUE) { + if (!($mleg_trade_form instanceof \SnapTrade\Model\MlegTradeForm)) { + if (!is_array($mleg_trade_form)) + throw new \InvalidArgumentException('"mleg_trade_form" must be associative array or an instance of \SnapTrade\Model\MlegTradeForm TradingApi.placeMlegOrder.'); else - $manual_trade_form_bracket = new \SnapTrade\Model\ManualTradeFormBracket($manual_trade_form_bracket); + $mleg_trade_form = new \SnapTrade\Model\MlegTradeForm($mleg_trade_form); } } - // verify the required parameter 'manual_trade_form_bracket' is set - if ($manual_trade_form_bracket === SENTINEL_VALUE || (is_array($manual_trade_form_bracket) && count($manual_trade_form_bracket) === 0)) { + // verify the required parameter 'mleg_trade_form' is set + if ($mleg_trade_form === SENTINEL_VALUE || (is_array($mleg_trade_form) && count($mleg_trade_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form_bracket when calling placeBracketOrder' + 'Missing the required parameter mleg_trade_form when calling placeMlegOrder' ); } - $resourcePath = '/accounts/{accountId}/trading/bracket'; + $resourcePath = '/accounts/{accountId}/trading/options'; $formParams = []; $queryParams = []; $headerParams = []; @@ -2503,12 +3936,12 @@ public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $m ); // for model (json/xml) - if (isset($manual_trade_form_bracket)) { + if (isset($mleg_trade_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_bracket)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($mleg_trade_form)); } else { - $httpBody = $manual_trade_form_bracket; + $httpBody = $mleg_trade_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -2578,74 +4011,59 @@ public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $m } /** - * Operation placeForceOrder + * Operation placeOrder * - * Place order + * Place checked order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse */ - public function placeForceOrder( - - $account_id, - $action, - $order_type, - $time_in_force, + public function placeOrder( + $trade_id, $user_id, $user_secret, - $universal_symbol_id = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeForceOrder'][0] + $wait_to_confirm = SENTINEL_VALUE, + + string $contentType = self::contentTypes['placeOrder'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form_with_options = $_body; + $_body = null; + $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); + $validated_trade_body = $_body; - list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + list($response) = $this->placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); return $response; } /** - * Operation placeForceOrderWithHttpInfo + * Operation placeOrderWithHttpInfo * - * Place order + * Place checked order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -2660,10 +4078,11 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeForceOrderWithHttpInfo( + return $this->placeOrderWithHttpInfo( + $trade_id, $user_id, $user_secret, - $manual_trade_form_with_options, + $validated_trade_body, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -2730,21 +4149,6 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad $response->getStatusCode(), $response->getHeaders() ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; } $returnType = '\SnapTrade\Model\AccountOrderRecord'; @@ -2781,65 +4185,41 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad ); $e->setResponseObject($data); break; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; } throw $e; } } /** - * Operation placeForceOrderAsync + * Operation placeOrderAsync * - * Place order + * Place checked order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeForceOrderAsync( - - $account_id, - $action, - $order_type, - $time_in_force, + public function placeOrderAsync( + $trade_id, $user_id, $user_secret, - $universal_symbol_id = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeForceOrder'][0] + $wait_to_confirm = SENTINEL_VALUE, + + string $contentType = self::contentTypes['placeOrder'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form_with_options = $_body; + $_body = null; + $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); + $validated_trade_body = $_body; - return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) + return $this->placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType) ->then( function ($response) { return $response[0]; @@ -2848,24 +4228,25 @@ function ($response) { } /** - * Operation placeForceOrderAsyncWithHttpInfo + * Operation placeOrderAsyncWithHttpInfo * - * Place order + * Place checked order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -2907,19 +4288,30 @@ function ($exception) { } /** - * Create request for operation 'placeForceOrder' + * Create request for operation 'placeOrder' * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0]) + public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body = SENTINEL_VALUE, string $contentType = self::contentTypes['placeOrder'][0]) { + // Check if $trade_id is a string + if ($trade_id !== SENTINEL_VALUE && !is_string($trade_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trade_id, true), gettype($trade_id))); + } + // verify the required parameter 'trade_id' is set + if ($trade_id === SENTINEL_VALUE || (is_array($trade_id) && count($trade_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter trade_id when calling placeOrder' + ); + } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -2927,7 +4319,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeForceOrder' + 'Missing the required parameter user_id when calling placeOrder' ); } // Check if $user_secret is a string @@ -2937,26 +4329,20 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeForceOrder' + 'Missing the required parameter user_secret when calling placeOrder' ); } - if ($manual_trade_form_with_options !== SENTINEL_VALUE) { - if (!($manual_trade_form_with_options instanceof \SnapTrade\Model\ManualTradeFormWithOptions)) { - if (!is_array($manual_trade_form_with_options)) - throw new \InvalidArgumentException('"manual_trade_form_with_options" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormWithOptions TradingApi.placeForceOrder.'); + if ($validated_trade_body !== SENTINEL_VALUE) { + if (!($validated_trade_body instanceof \SnapTrade\Model\ValidatedTradeBody)) { + if (!is_array($validated_trade_body)) + throw new \InvalidArgumentException('"validated_trade_body" must be associative array or an instance of \SnapTrade\Model\ValidatedTradeBody TradingApi.placeOrder.'); else - $manual_trade_form_with_options = new \SnapTrade\Model\ManualTradeFormWithOptions($manual_trade_form_with_options); + $validated_trade_body = new \SnapTrade\Model\ValidatedTradeBody($validated_trade_body); } } - // verify the required parameter 'manual_trade_form_with_options' is set - if ($manual_trade_form_with_options === SENTINEL_VALUE || (is_array($manual_trade_form_with_options) && count($manual_trade_form_with_options) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form_with_options when calling placeForceOrder' - ); - } - $resourcePath = '/trade/place'; + $resourcePath = '/trade/{tradeId}'; $formParams = []; $queryParams = []; $headerParams = []; @@ -2987,6 +4373,14 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for } + // path params + if ($trade_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'tradeId' . '}', + ObjectSerializer::toPathValue($trade_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -2996,12 +4390,12 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for ); // for model (json/xml) - if (isset($manual_trade_form_with_options)) { + if (isset($validated_trade_body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_with_options)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($validated_trade_body)); } else { - $httpBody = $manual_trade_form_with_options; + $httpBody = $validated_trade_body; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -3071,69 +4465,75 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for } /** - * Operation placeMlegOrder + * Operation placeSimpleOrder * - * Place multi-leg option order + * Place order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse */ - public function placeMlegOrder( + public function placeSimpleOrder( - $order_type, + $instrument, + $side, + $type, $time_in_force, - $legs, + $amount, $user_id, $user_secret, $account_id, $limit_price = SENTINEL_VALUE, $stop_price = SENTINEL_VALUE, - $price_effect = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeMlegOrder'][0] + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeSimpleOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); $this->setRequestBodyProperty($_body, "limit_price", $limit_price); $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "price_effect", $price_effect); - $this->setRequestBodyProperty($_body, "legs", $legs); - $mleg_trade_form = $_body; + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $simple_order_form = $_body; - list($response) = $this->placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); + list($response) = $this->placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); return $response; } /** - * Operation placeMlegOrderWithHttpInfo + * Operation placeSimpleOrderWithHttpInfo * - * Place multi-leg option order + * Place order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3148,11 +4548,11 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeMlegOrderWithHttpInfo( + return $this->placeSimpleOrderWithHttpInfo( $user_id, $user_secret, $account_id, - $mleg_trade_form, + $simple_order_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -3190,17 +4590,17 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, switch($statusCode) { case 200: - if ('\SnapTrade\Model\MlegOrderResponse' === '\SplFileObject') { + if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\MlegOrderResponse' !== 'string') { + if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\MlegOrderResponse', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -3221,7 +4621,7 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, ]; } - $returnType = '\SnapTrade\Model\MlegOrderResponse'; + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -3242,7 +4642,7 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\MlegOrderResponse', + '\SnapTrade\Model\OrderUpdatedResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -3261,45 +4661,51 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, } /** - * Operation placeMlegOrderAsync + * Operation placeSimpleOrderAsync * - * Place multi-leg option order + * Place order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeMlegOrderAsync( + public function placeSimpleOrderAsync( - $order_type, + $instrument, + $side, + $type, $time_in_force, - $legs, + $amount, $user_id, $user_secret, $account_id, $limit_price = SENTINEL_VALUE, $stop_price = SENTINEL_VALUE, - $price_effect = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeMlegOrder'][0] + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeSimpleOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); $this->setRequestBodyProperty($_body, "limit_price", $limit_price); $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "price_effect", $price_effect); - $this->setRequestBodyProperty($_body, "legs", $legs); - $mleg_trade_form = $_body; + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $simple_order_form = $_body; - return $this->placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType) + return $this->placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) ->then( function ($response) { return $response[0]; @@ -3308,25 +4714,25 @@ function ($response) { } /** - * Operation placeMlegOrderAsyncWithHttpInfo + * Operation placeSimpleOrderAsyncWithHttpInfo * - * Place multi-leg option order + * Place order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\MlegOrderResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3368,18 +4774,18 @@ function ($exception) { } /** - * Create request for operation 'placeMlegOrder' + * Create request for operation 'placeSimpleOrder' * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0]) + public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0]) { // Check if $user_id is a string @@ -3389,7 +4795,7 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeMlegOrder' + 'Missing the required parameter user_id when calling placeSimpleOrder' ); } // Check if $user_secret is a string @@ -3399,7 +4805,7 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeMlegOrder' + 'Missing the required parameter user_secret when calling placeSimpleOrder' ); } // Check if $account_id is a string @@ -3409,26 +4815,26 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg // verify the required parameter 'account_id' is set if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling placeMlegOrder' + 'Missing the required parameter account_id when calling placeSimpleOrder' ); } - if ($mleg_trade_form !== SENTINEL_VALUE) { - if (!($mleg_trade_form instanceof \SnapTrade\Model\MlegTradeForm)) { - if (!is_array($mleg_trade_form)) - throw new \InvalidArgumentException('"mleg_trade_form" must be associative array or an instance of \SnapTrade\Model\MlegTradeForm TradingApi.placeMlegOrder.'); + if ($simple_order_form !== SENTINEL_VALUE) { + if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { + if (!is_array($simple_order_form)) + throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm TradingApi.placeSimpleOrder.'); else - $mleg_trade_form = new \SnapTrade\Model\MlegTradeForm($mleg_trade_form); + $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); } } - // verify the required parameter 'mleg_trade_form' is set - if ($mleg_trade_form === SENTINEL_VALUE || (is_array($mleg_trade_form) && count($mleg_trade_form) === 0)) { + // verify the required parameter 'simple_order_form' is set + if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter mleg_trade_form when calling placeMlegOrder' + 'Missing the required parameter simple_order_form when calling placeSimpleOrder' ); } - $resourcePath = '/accounts/{accountId}/trading/options'; + $resourcePath = '/accounts/{accountId}/trading/simple'; $formParams = []; $queryParams = []; $headerParams = []; @@ -3476,12 +4882,12 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg ); // for model (json/xml) - if (isset($mleg_trade_form)) { + if (isset($simple_order_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($mleg_trade_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); } else { - $httpBody = $mleg_trade_form; + $httpBody = $simple_order_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -3551,59 +4957,75 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg } /** - * Operation placeOrder + * Operation previewSimpleOrder * - * Place checked order + * Preview order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Previews an order using the specified account. * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse */ - public function placeOrder( - $trade_id, + public function previewSimpleOrder( + + $instrument, + $side, + $type, + $time_in_force, + $amount, $user_id, $user_secret, - $wait_to_confirm = SENTINEL_VALUE, - - string $contentType = self::contentTypes['placeOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['previewSimpleOrder'][0] ) { - $_body = null; - $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); - $validated_trade_body = $_body; + $_body = []; + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $simple_order_form = $_body; - list($response) = $this->placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + list($response) = $this->previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); return $response; } /** - * Operation placeOrderWithHttpInfo + * Operation previewSimpleOrderWithHttpInfo * - * Place checked order + * Preview order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Previews an order using the specified account. * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3618,11 +5040,11 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeOrderWithHttpInfo( - $trade_id, + return $this->previewSimpleOrderWithHttpInfo( $user_id, $user_secret, - $validated_trade_body, + $account_id, + $simple_order_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -3660,17 +5082,17 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\SimpleOrderPreview' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\SimpleOrderPreview' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\SimpleOrderPreview', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -3691,7 +5113,7 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\SimpleOrderPreview'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -3712,7 +5134,7 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\SimpleOrderPreview', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -3731,35 +5153,51 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid } /** - * Operation placeOrderAsync + * Operation previewSimpleOrderAsync * - * Place checked order + * Preview order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Previews an order using the specified account. * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeOrderAsync( - $trade_id, + public function previewSimpleOrderAsync( + + $instrument, + $side, + $type, + $time_in_force, + $amount, $user_id, $user_secret, - $wait_to_confirm = SENTINEL_VALUE, - - string $contentType = self::contentTypes['placeOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['previewSimpleOrder'][0] ) { - $_body = null; - $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); - $validated_trade_body = $_body; + $_body = []; + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $simple_order_form = $_body; - return $this->placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType) + return $this->previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) ->then( function ($response) { return $response[0]; @@ -3768,25 +5206,25 @@ function ($response) { } /** - * Operation placeOrderAsyncWithHttpInfo + * Operation previewSimpleOrderAsyncWithHttpInfo * - * Place checked order + * Preview order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Previews an order using the specified account. * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + $returnType = '\SnapTrade\Model\SimpleOrderPreview'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3828,30 +5266,20 @@ function ($exception) { } /** - * Create request for operation 'placeOrder' + * Create request for operation 'previewSimpleOrder' * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body = SENTINEL_VALUE, string $contentType = self::contentTypes['placeOrder'][0]) + public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0]) { - // Check if $trade_id is a string - if ($trade_id !== SENTINEL_VALUE && !is_string($trade_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trade_id, true), gettype($trade_id))); - } - // verify the required parameter 'trade_id' is set - if ($trade_id === SENTINEL_VALUE || (is_array($trade_id) && count($trade_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter trade_id when calling placeOrder' - ); - } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -3859,7 +5287,7 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeOrder' + 'Missing the required parameter user_id when calling previewSimpleOrder' ); } // Check if $user_secret is a string @@ -3869,20 +5297,36 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeOrder' + 'Missing the required parameter user_secret when calling previewSimpleOrder' ); } - if ($validated_trade_body !== SENTINEL_VALUE) { - if (!($validated_trade_body instanceof \SnapTrade\Model\ValidatedTradeBody)) { - if (!is_array($validated_trade_body)) - throw new \InvalidArgumentException('"validated_trade_body" must be associative array or an instance of \SnapTrade\Model\ValidatedTradeBody TradingApi.placeOrder.'); + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling previewSimpleOrder' + ); + } + if ($simple_order_form !== SENTINEL_VALUE) { + if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { + if (!is_array($simple_order_form)) + throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm TradingApi.previewSimpleOrder.'); else - $validated_trade_body = new \SnapTrade\Model\ValidatedTradeBody($validated_trade_body); + $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); } } + // verify the required parameter 'simple_order_form' is set + if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter simple_order_form when calling previewSimpleOrder' + ); + } - $resourcePath = '/trade/{tradeId}'; + $resourcePath = '/accounts/{accountId}/trading/simple/preview'; $formParams = []; $queryParams = []; $headerParams = []; @@ -3914,10 +5358,10 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // path params - if ($trade_id !== SENTINEL_VALUE) { + if ($account_id !== SENTINEL_VALUE) { $resourcePath = str_replace( - '{' . 'tradeId' . '}', - ObjectSerializer::toPathValue($trade_id), + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), $resourcePath ); } @@ -3930,12 +5374,12 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ ); // for model (json/xml) - if (isset($validated_trade_body)) { + if (isset($simple_order_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($validated_trade_body)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); } else { - $httpBody = $validated_trade_body; + $httpBody = $simple_order_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -4005,75 +5449,74 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ } /** - * Operation previewSimpleOrder + * Operation replaceOrder * - * Preview order + * Replaces an order with a new one * - * Previews an order using the specified account. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse */ - public function previewSimpleOrder( + public function replaceOrder( - $instrument, - $side, - $type, + $action, + $order_type, $time_in_force, - $amount, + $account_id, + $brokerage_order_id, $user_id, $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['previewSimpleOrder'][0] + $price = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['replaceOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $manual_trade_replace_form = $_body; - list($response) = $this->previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + list($response) = $this->replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); return $response; } /** - * Operation previewSimpleOrderWithHttpInfo + * Operation replaceOrderWithHttpInfo * - * Preview order + * Replaces an order with a new one * - * Previews an order using the specified account. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4088,11 +5531,12 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->previewSimpleOrderWithHttpInfo( + return $this->replaceOrderWithHttpInfo( + $account_id, + $brokerage_order_id, $user_id, $user_secret, - $account_id, - $simple_order_form, + $manual_trade_replace_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -4130,17 +5574,17 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ switch($statusCode) { case 200: - if ('\SnapTrade\Model\SimpleOrderPreview' === '\SplFileObject') { + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\SimpleOrderPreview' !== 'string') { + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\SimpleOrderPreview', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -4159,9 +5603,24 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ $response->getStatusCode(), $response->getHeaders() ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } - $returnType = '\SnapTrade\Model\SimpleOrderPreview'; + $returnType = '\SnapTrade\Model\AccountOrderRecord'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -4182,7 +5641,7 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\SimpleOrderPreview', + '\SnapTrade\Model\AccountOrderRecord', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -4195,57 +5654,63 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ ); $e->setResponseObject($data); break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } } /** - * Operation previewSimpleOrderAsync + * Operation replaceOrderAsync * - * Preview order + * Replaces an order with a new one * - * Previews an order using the specified account. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function previewSimpleOrderAsync( + public function replaceOrderAsync( - $instrument, - $side, - $type, + $action, + $order_type, $time_in_force, - $amount, + $account_id, + $brokerage_order_id, $user_id, $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['previewSimpleOrder'][0] + $price = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + string $contentType = self::contentTypes['replaceOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "symbol", $symbol); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $manual_trade_replace_form = $_body; - return $this->previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) + return $this->replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType) ->then( function ($response) { return $response[0]; @@ -4254,25 +5719,26 @@ function ($response) { } /** - * Operation previewSimpleOrderAsyncWithHttpInfo + * Operation replaceOrderAsyncWithHttpInfo * - * Preview order + * Replaces an order with a new one * - * Previews an order using the specified account. + * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\SimpleOrderPreview'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4314,20 +5780,41 @@ function ($exception) { } /** - * Create request for operation 'previewSimpleOrder' + * Create request for operation 'replaceOrder' * + * @param string $account_id The ID of the account to execute the trade on. (required) + * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0]) + public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0]) { + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling replaceOrder' + ); + } + // Check if $brokerage_order_id is a string + if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); + } + // verify the required parameter 'brokerage_order_id' is set + if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter brokerage_order_id when calling replaceOrder' + ); + } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -4335,7 +5822,7 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling previewSimpleOrder' + 'Missing the required parameter user_id when calling replaceOrder' ); } // Check if $user_secret is a string @@ -4345,36 +5832,26 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling previewSimpleOrder' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling previewSimpleOrder' + 'Missing the required parameter user_secret when calling replaceOrder' ); } - if ($simple_order_form !== SENTINEL_VALUE) { - if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { - if (!is_array($simple_order_form)) - throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm TradingApi.previewSimpleOrder.'); + if ($manual_trade_replace_form !== SENTINEL_VALUE) { + if (!($manual_trade_replace_form instanceof \SnapTrade\Model\ManualTradeReplaceForm)) { + if (!is_array($manual_trade_replace_form)) + throw new \InvalidArgumentException('"manual_trade_replace_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeReplaceForm TradingApi.replaceOrder.'); else - $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); + $manual_trade_replace_form = new \SnapTrade\Model\ManualTradeReplaceForm($manual_trade_replace_form); } } - // verify the required parameter 'simple_order_form' is set - if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { + // verify the required parameter 'manual_trade_replace_form' is set + if ($manual_trade_replace_form === SENTINEL_VALUE || (is_array($manual_trade_replace_form) && count($manual_trade_replace_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter simple_order_form when calling previewSimpleOrder' + 'Missing the required parameter manual_trade_replace_form when calling replaceOrder' ); } - $resourcePath = '/accounts/{accountId}/trading/simple/preview'; + $resourcePath = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace'; $formParams = []; $queryParams = []; $headerParams = []; @@ -4413,6 +5890,14 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ $resourcePath ); } + // path params + if ($brokerage_order_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'brokerageOrderId' . '}', + ObjectSerializer::toPathValue($brokerage_order_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -4422,12 +5907,12 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ ); // for model (json/xml) - if (isset($simple_order_form)) { + if (isset($manual_trade_replace_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_replace_form)); } else { - $httpBody = $simple_order_form; + $httpBody = $manual_trade_replace_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -4480,7 +5965,7 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ $headers ); - $method = 'POST'; + $method = 'PATCH'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); @@ -4497,77 +5982,62 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ } /** - * Operation replaceOrder + * Operation searchCryptocurrencyPairInstruments * - * Replaces an order with a new one + * Search cryptocurrency pairs instruments * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Searches cryptocurrency pairs instruments accessible to the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param string $base base (optional) + * @param string $quote quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse */ - public function replaceOrder( - - $action, - $order_type, - $time_in_force, - $account_id, - $brokerage_order_id, + public function searchCryptocurrencyPairInstruments( $user_id, $user_secret, - $price = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['replaceOrder'][0] + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $manual_trade_replace_form = $_body; - list($response) = $this->replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + list($response) = $this->searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); return $response; } /** - * Operation replaceOrderWithHttpInfo + * Operation searchCryptocurrencyPairInstrumentsWithHttpInfo * - * Replaces an order with a new one + * Search cryptocurrency pairs instruments * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Searches cryptocurrency pairs instruments accessible to the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); try { $options = $this->createHttpClientOption(); @@ -4579,12 +6049,12 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->replaceOrderWithHttpInfo( - $account_id, - $brokerage_order_id, + return $this->searchCryptocurrencyPairInstrumentsWithHttpInfo( $user_id, $user_secret, - $manual_trade_replace_form, + $account_id, + $base, + $quote, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -4622,17 +6092,17 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -4651,24 +6121,9 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user $response->getStatusCode(), $response->getHeaders() ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -4689,7 +6144,7 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -4702,63 +6157,40 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user ); $e->setResponseObject($data); break; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; } throw $e; } } /** - * Operation replaceOrderAsync + * Operation searchCryptocurrencyPairInstrumentsAsync * - * Replaces an order with a new one + * Search cryptocurrency pairs instruments * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Searches cryptocurrency pairs instruments accessible to the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function replaceOrderAsync( - - $action, - $order_type, - $time_in_force, - $account_id, - $brokerage_order_id, + public function searchCryptocurrencyPairInstrumentsAsync( $user_id, $user_secret, - $price = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - string $contentType = self::contentTypes['replaceOrder'][0] + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $manual_trade_replace_form = $_body; - return $this->replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType) + return $this->searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) ->then( function ($response) { return $response[0]; @@ -4767,29 +6199,29 @@ function ($response) { } /** - * Operation replaceOrderAsyncWithHttpInfo + * Operation searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo * - * Replaces an order with a new one + * Search cryptocurrency pairs instruments * - * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages + * Searches cryptocurrency pairs instruments accessible to the specified account. * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -4828,41 +6260,21 @@ function ($exception) { } /** - * Create request for operation 'replaceOrder' + * Create request for operation 'searchCryptocurrencyPairInstruments' * - * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['replaceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0]) + public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0]) { - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling replaceOrder' - ); - } - // Check if $brokerage_order_id is a string - if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); - } - // verify the required parameter 'brokerage_order_id' is set - if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter brokerage_order_id when calling replaceOrder' - ); - } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -4870,7 +6282,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling replaceOrder' + 'Missing the required parameter user_id when calling searchCryptocurrencyPairInstruments' ); } // Check if $user_secret is a string @@ -4880,26 +6292,30 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling replaceOrder' + 'Missing the required parameter user_secret when calling searchCryptocurrencyPairInstruments' ); } - if ($manual_trade_replace_form !== SENTINEL_VALUE) { - if (!($manual_trade_replace_form instanceof \SnapTrade\Model\ManualTradeReplaceForm)) { - if (!is_array($manual_trade_replace_form)) - throw new \InvalidArgumentException('"manual_trade_replace_form" must be associative array or an instance of \SnapTrade\Model\ManualTradeReplaceForm TradingApi.replaceOrder.'); - else - $manual_trade_replace_form = new \SnapTrade\Model\ManualTradeReplaceForm($manual_trade_replace_form); - } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); } - // verify the required parameter 'manual_trade_replace_form' is set - if ($manual_trade_replace_form === SENTINEL_VALUE || (is_array($manual_trade_replace_form) && count($manual_trade_replace_form) === 0)) { + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_replace_form when calling replaceOrder' + 'Missing the required parameter account_id when calling searchCryptocurrencyPairInstruments' ); } + // Check if $base is a string + if ($base !== SENTINEL_VALUE && !is_string($base)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); + } + // Check if $quote is a string + if ($quote !== SENTINEL_VALUE && !is_string($quote)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); + } - $resourcePath = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace'; + $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs'; $formParams = []; $queryParams = []; $headerParams = []; @@ -4928,6 +6344,28 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, true // required ) ?? []); } + if ($base !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $base, + 'base', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($quote !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $quote, + 'quote', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } // path params @@ -4938,14 +6376,6 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $resourcePath ); } - // path params - if ($brokerage_order_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'brokerageOrderId' . '}', - ObjectSerializer::toPathValue($brokerage_order_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -4955,14 +6385,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, ); // for model (json/xml) - if (isset($manual_trade_replace_form)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_replace_form)); - } else { - $httpBody = $manual_trade_replace_form; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -5013,7 +6436,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $headers ); - $method = 'PATCH'; + $method = 'GET'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); diff --git a/lib/Client.php b/lib/Client.php index bf70220..b8de060 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -13,8 +13,6 @@ class Client public readonly \SnapTrade\Api\ConnectionsApi $connections; - public readonly \SnapTrade\Api\CryptoTradingApi $cryptoTrading; - public readonly \SnapTrade\Api\OptionsApi $options; public readonly \SnapTrade\Api\ReferenceDataApi $referenceData; @@ -50,7 +48,6 @@ public function __construct( $this->apiStatus = new \SnapTrade\Api\ApiStatusApi($config); $this->authentication = new \SnapTrade\Api\AuthenticationApi($config); $this->connections = new \SnapTrade\Api\ConnectionsApi($config); - $this->cryptoTrading = new \SnapTrade\Api\CryptoTradingApi($config); $this->options = new \SnapTrade\Api\OptionsApi($config); $this->referenceData = new \SnapTrade\Api\ReferenceDataApi($config); $this->trading = new \SnapTrade\Api\TradingApi($config); diff --git a/test/Api/CryptoTradingApiTest.php b/test/Api/CryptoTradingApiTest.php deleted file mode 100644 index 5d65626..0000000 --- a/test/Api/CryptoTradingApiTest.php +++ /dev/null @@ -1,96 +0,0 @@ -markTestIncomplete('Not implemented'); - } - - /** - * Test case for placeSimpleOrder - * - * Place order. - * - */ - public function testPlaceSimpleOrder() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test case for searchCryptocurrencyPairInstruments - * - * Search cryptocurrency pairs instruments. - * - */ - public function testSearchCryptocurrencyPairInstruments() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } -} diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 1444f5c..add1d24 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -82,6 +82,18 @@ public function testCancelUserAccountOrder() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for getCryptocurrencyPairQuote + * + * Get cryptocurrency pair quote. + * + */ + public function testGetCryptocurrencyPairQuote() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for getOrderImpact * @@ -154,6 +166,18 @@ public function testPlaceOrder() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for placeSimpleOrder + * + * Place order. + * + */ + public function testPlaceSimpleOrder() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for previewSimpleOrder * @@ -177,4 +201,16 @@ public function testReplaceOrder() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test case for searchCryptocurrencyPairInstruments + * + * Search cryptocurrency pairs instruments. + * + */ + public function testSearchCryptocurrencyPairInstruments() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } From 89aea2b2e75030c72ad6dee501df7dd5c439e5bf Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 14:11:21 +0000 Subject: [PATCH 143/252] Version Bump SDKs (#167) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index cfc5aa3..b5594c3 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ae1f1867-4fee-48bf-8eb9-28d3e066dbe1 \ No newline at end of file +7e414ad1-54b9-43e9-8767-cfcd23fb4c3b \ No newline at end of file diff --git a/README.md b/README.md index ffe16e9..d5deead 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.106-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.107-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.106" + "konfig/snaptrade-php-sdk": "2.0.107" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index d7ef022..e54225d 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.106/PHP'; + protected $userAgent = 'Konfig/2.0.107/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.106' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.107' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 4b86d51f17395a7f2754c9484d35e473ebee1dd9 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:10:05 +0000 Subject: [PATCH 144/252] Regenerate SDKs (#170) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b5594c3..a517390 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -7e414ad1-54b9-43e9-8767-cfcd23fb4c3b \ No newline at end of file +bdb3150f-de6a-4016-8fbd-0e066d1f4afc \ No newline at end of file From a655827516c46f957432e7bf753a13a523126b6f Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:14:07 +0000 Subject: [PATCH 145/252] Version Bump SDKs (#171) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a517390..33f1d40 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -bdb3150f-de6a-4016-8fbd-0e066d1f4afc \ No newline at end of file +a456218f-570e-4e1c-a957-e0545d870817 \ No newline at end of file diff --git a/README.md b/README.md index d5deead..b3249be 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.107-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.108-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.107" + "konfig/snaptrade-php-sdk": "2.0.108" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index e54225d..9113e41 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.107/PHP'; + protected $userAgent = 'Konfig/2.0.108/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.107' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.108' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From cda759247189b7d121b0356f4af2ad11dcbba292 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 25 Jun 2025 17:28:10 +0000 Subject: [PATCH 146/252] Regenerate SDKs (#173) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/TradingApi.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 33f1d40..7b2f73b 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -a456218f-570e-4e1c-a957-e0545d870817 \ No newline at end of file +0653cb9f-8d5b-4e5a-a237-83a3fefb9f1e \ No newline at end of file diff --git a/README.md b/README.md index b3249be..26f5caf 100644 --- a/README.md +++ b/README.md @@ -2100,7 +2100,7 @@ For Equity orders, this represents the number of shares for the order. This can ### `snaptrade.trading.placeMlegOrder` -Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support +Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support. diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 644fb07..d0bbb4f 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -3535,7 +3535,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for * * Place multi-leg option order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -3579,7 +3579,7 @@ public function placeMlegOrder( * * Place multi-leg option order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support. * * @param string $user_id (required) * @param string $user_secret (required) @@ -3725,7 +3725,7 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, * * Place multi-leg option order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support. * * @param string $user_id (required) * @param string $user_secret (required) @@ -3772,7 +3772,7 @@ function ($response) { * * Place multi-leg option order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support. * * @param string $user_id (required) * @param string $user_secret (required) From af7280e33998dd8c009d8d24046e6f120358cf45 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 25 Jun 2025 17:32:19 +0000 Subject: [PATCH 147/252] Version Bump SDKs (#172) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 7b2f73b..8da717e 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -0653cb9f-8d5b-4e5a-a237-83a3fefb9f1e \ No newline at end of file +74fcea5c-8629-433c-aadb-0be37b3ff930 \ No newline at end of file diff --git a/README.md b/README.md index 26f5caf..067c621 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.108-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.109-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.108" + "konfig/snaptrade-php-sdk": "2.0.109" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 9113e41..119f5d2 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.108/PHP'; + protected $userAgent = 'Konfig/2.0.109/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.108' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.109' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 024714f2b0d1d00e2c5f6f94f3671c3eb4770512 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 4 Jul 2025 17:16:54 +0000 Subject: [PATCH 148/252] Regenerate SDKs (#175) * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 92 ++--- lib/Api/CryptoTradingApi.php | 627 ++++++++++++++++++++++++++++++ lib/Api/TradingApi.php | 482 +---------------------- lib/Client.php | 3 + test/Api/CryptoTradingApiTest.php | 72 ++++ test/Api/TradingApiTest.php | 12 - 7 files changed, 753 insertions(+), 537 deletions(-) create mode 100644 lib/Api/CryptoTradingApi.php create mode 100644 test/Api/CryptoTradingApiTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 8da717e..68ee380 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -74fcea5c-8629-433c-aadb-0be37b3ff930 \ No newline at end of file +eaa0b093-bd4c-43bc-a0ea-b0d35491d6b9 \ No newline at end of file diff --git a/README.md b/README.md index 067c621..5b61232 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.connections.removeBrokerageAuthorization`](#snaptradeconnectionsremovebrokerageauthorization) * [`snaptrade.connections.returnRates`](#snaptradeconnectionsreturnrates) * [`snaptrade.connections.sessionEvents`](#snaptradeconnectionssessionevents) + * [`snaptrade.cryptoTrading.searchCryptocurrencyPairInstruments`](#snaptradecryptotradingsearchcryptocurrencypairinstruments) * [`snaptrade.options.getOptionStrategy`](#snaptradeoptionsgetoptionstrategy) * [`snaptrade.options.getOptionsChain`](#snaptradeoptionsgetoptionschain) * [`snaptrade.options.getOptionsStrategyQuote`](#snaptradeoptionsgetoptionsstrategyquote) @@ -73,7 +74,6 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.trading.placeSimpleOrder`](#snaptradetradingplacesimpleorder) * [`snaptrade.trading.previewSimpleOrder`](#snaptradetradingpreviewsimpleorder) * [`snaptrade.trading.replaceOrder`](#snaptradetradingreplaceorder) - * [`snaptrade.trading.searchCryptocurrencyPairInstruments`](#snaptradetradingsearchcryptocurrencypairinstruments) * [`snaptrade.transactionsAndReporting.getActivities`](#snaptradetransactionsandreportinggetactivities) * [`snaptrade.transactionsAndReporting.getReportingCustomRange`](#snaptradetransactionsandreportinggetreportingcustomrange) @@ -1121,6 +1121,50 @@ Optional comma separated list of session IDs used to filter the request on speci --- +### `snaptrade.cryptoTrading.searchCryptocurrencyPairInstruments` + +Searches cryptocurrency pairs instruments accessible to the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->cryptoTrading->searchCryptocurrencyPairInstruments( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + base: "BTC", + quote: "USD" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### base: `string` + +##### quote: `string` + + +#### πŸ”„ Return + +[**TradingSearchCryptocurrencyPairInstruments200Response**](./lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.options.getOptionStrategy` Creates an option strategy object that will be used to place an option strategy order. @@ -2100,7 +2144,7 @@ For Equity orders, this represents the number of shares for the order. This can ### `snaptrade.trading.placeMlegOrder` -Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support. +Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support @@ -2453,50 +2497,6 @@ The price at which a stop order is triggered for `Stop` and `StopLimit` orders. --- -### `snaptrade.trading.searchCryptocurrencyPairInstruments` - -Searches cryptocurrency pairs instruments accessible to the specified account. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->trading->searchCryptocurrencyPairInstruments( - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - base: "BTC", - quote: "USD" -); -``` - -#### βš™οΈ Parameters - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### base: `string` - -##### quote: `string` - - -#### πŸ”„ Return - -[**TradingSearchCryptocurrencyPairInstruments200Response**](./lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs` `GET` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - ### `snaptrade.transactionsAndReporting.getActivities` ![Deprecated](https://img.shields.io/badge/deprecated-yellow) diff --git a/lib/Api/CryptoTradingApi.php b/lib/Api/CryptoTradingApi.php new file mode 100644 index 0000000..5b78342 --- /dev/null +++ b/lib/Api/CryptoTradingApi.php @@ -0,0 +1,627 @@ + [ + 'application/json', + ], + ]; + +/** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + Configuration $config = null, + ClientInterface $client = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $clientOptions = []; + if (!$config->getVerifySsl()) $clientOptions["verify"] = false; + + // Do not truncate error messages + // https://github.com/guzzle/guzzle/issues/2185#issuecomment-800293420 + $stack = new HandlerStack(Utils::chooseHandler()); + $stack->push(Middleware::httpErrors(new BodySummarizer(10000)), 'http_errors'); + $stack->push(Middleware::redirect(), 'allow_redirects'); + $stack->push(Middleware::cookies(), 'cookies'); + $stack->push(Middleware::prepareBody(), 'prepare_body'); + $clientOptions["handler"] = $stack; + + $this->client = $client ?: new Client($clientOptions); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * For initializing request body parameter + */ + private function setRequestBodyProperty(&$body, $property, $value) { + if ($body === null) $body = []; + // user did not pass in a value for this parameter + if ($value === SENTINEL_VALUE) return; + $body[$property] = $value; + } + + /** + * Operation searchCryptocurrencyPairInstruments + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param string $base base (optional) + * @param string $quote quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function searchCryptocurrencyPairInstruments( + $user_id, + $user_secret, + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] + ) + { + + list($response) = $this->searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); + return $response; + } + + /** + * Operation searchCryptocurrencyPairInstrumentsWithHttpInfo + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->searchCryptocurrencyPairInstrumentsWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $base, + $quote, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchCryptocurrencyPairInstrumentsAsync + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchCryptocurrencyPairInstrumentsAsync( + $user_id, + $user_secret, + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] + ) + { + + return $this->searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchCryptocurrencyPairInstruments' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling searchCryptocurrencyPairInstruments' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling searchCryptocurrencyPairInstruments' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling searchCryptocurrencyPairInstruments' + ); + } + // Check if $base is a string + if ($base !== SENTINEL_VALUE && !is_string($base)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); + } + // Check if $quote is a string + if ($quote !== SENTINEL_VALUE && !is_string($quote)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); + } + + + $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($base !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $base, + 'base', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($quote !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $quote, + 'quote', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index d0bbb4f..6493aaa 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -98,9 +98,6 @@ class TradingApi extends \SnapTrade\CustomApi 'replaceOrder' => [ 'application/json', ], - 'searchCryptocurrencyPairInstruments' => [ - 'application/json', - ], ]; /** @@ -3535,7 +3532,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for * * Place multi-leg option order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -3579,7 +3576,7 @@ public function placeMlegOrder( * * Place multi-leg option order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * * @param string $user_id (required) * @param string $user_secret (required) @@ -3725,7 +3722,7 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, * * Place multi-leg option order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * * @param string $user_id (required) * @param string $user_secret (required) @@ -3772,7 +3769,7 @@ function ($response) { * * Place multi-leg option order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * * @param string $user_id (required) * @param string $user_secret (required) @@ -5981,477 +5978,6 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, ]; } - /** - * Operation searchCryptocurrencyPairInstruments - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param string $base base (optional) - * @param string $quote quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse - */ - public function searchCryptocurrencyPairInstruments( - $user_id, - $user_secret, - $account_id, - $base = SENTINEL_VALUE, - $quote = SENTINEL_VALUE, - - string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] - ) - { - - list($response) = $this->searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); - return $response; - } - - /** - * Operation searchCryptocurrencyPairInstrumentsWithHttpInfo - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->searchCryptocurrencyPairInstrumentsWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $base, - $quote, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation searchCryptocurrencyPairInstrumentsAsync - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function searchCryptocurrencyPairInstrumentsAsync( - $user_id, - $user_secret, - $account_id, - $base = SENTINEL_VALUE, - $quote = SENTINEL_VALUE, - - string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] - ) - { - - return $this->searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'searchCryptocurrencyPairInstruments' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling searchCryptocurrencyPairInstruments' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling searchCryptocurrencyPairInstruments' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling searchCryptocurrencyPairInstruments' - ); - } - // Check if $base is a string - if ($base !== SENTINEL_VALUE && !is_string($base)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); - } - // Check if $quote is a string - if ($quote !== SENTINEL_VALUE && !is_string($quote)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); - } - - - $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($base !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $base, - 'base', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } - if ($quote !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $quote, - 'quote', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'GET'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - /** * Create http client option * diff --git a/lib/Client.php b/lib/Client.php index b8de060..bf70220 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -13,6 +13,8 @@ class Client public readonly \SnapTrade\Api\ConnectionsApi $connections; + public readonly \SnapTrade\Api\CryptoTradingApi $cryptoTrading; + public readonly \SnapTrade\Api\OptionsApi $options; public readonly \SnapTrade\Api\ReferenceDataApi $referenceData; @@ -48,6 +50,7 @@ public function __construct( $this->apiStatus = new \SnapTrade\Api\ApiStatusApi($config); $this->authentication = new \SnapTrade\Api\AuthenticationApi($config); $this->connections = new \SnapTrade\Api\ConnectionsApi($config); + $this->cryptoTrading = new \SnapTrade\Api\CryptoTradingApi($config); $this->options = new \SnapTrade\Api\OptionsApi($config); $this->referenceData = new \SnapTrade\Api\ReferenceDataApi($config); $this->trading = new \SnapTrade\Api\TradingApi($config); diff --git a/test/Api/CryptoTradingApiTest.php b/test/Api/CryptoTradingApiTest.php new file mode 100644 index 0000000..43dc6d1 --- /dev/null +++ b/test/Api/CryptoTradingApiTest.php @@ -0,0 +1,72 @@ +markTestIncomplete('Not implemented'); + } +} diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index add1d24..15ebf7f 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -201,16 +201,4 @@ public function testReplaceOrder() // TODO: implement $this->markTestIncomplete('Not implemented'); } - - /** - * Test case for searchCryptocurrencyPairInstruments - * - * Search cryptocurrency pairs instruments. - * - */ - public function testSearchCryptocurrencyPairInstruments() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } } From 16d8dc3864429417e3d1036c8e05ce2c61e50f35 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 4 Jul 2025 17:20:54 +0000 Subject: [PATCH 149/252] Version Bump SDKs (#176) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 68ee380..2176280 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -eaa0b093-bd4c-43bc-a0ea-b0d35491d6b9 \ No newline at end of file +d8766904-3149-4e1f-888b-86d89e37670d \ No newline at end of file diff --git a/README.md b/README.md index 5b61232..e1f494b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.109-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.110-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.109" + "konfig/snaptrade-php-sdk": "2.0.110" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 119f5d2..fc62818 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.109/PHP'; + protected $userAgent = 'Konfig/2.0.110/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.109' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.110' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 5485e7fe7d52cb2058cefb85a5b12b41040e5d6e Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 12:42:47 +0000 Subject: [PATCH 150/252] Regenerate SDKs (#177) * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 90 ++--- lib/Api/CryptoTradingApi.php | 627 ------------------------------ lib/Api/TradingApi.php | 474 ++++++++++++++++++++++ lib/Client.php | 3 - test/Api/CryptoTradingApiTest.php | 72 ---- test/Api/TradingApiTest.php | 12 + 7 files changed, 532 insertions(+), 748 deletions(-) delete mode 100644 lib/Api/CryptoTradingApi.php delete mode 100644 test/Api/CryptoTradingApiTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 2176280..ec457bf 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d8766904-3149-4e1f-888b-86d89e37670d \ No newline at end of file +b0d4fc62-8be2-4b4c-a87c-b62a77b3e392 \ No newline at end of file diff --git a/README.md b/README.md index e1f494b..ab20270 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,6 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.connections.removeBrokerageAuthorization`](#snaptradeconnectionsremovebrokerageauthorization) * [`snaptrade.connections.returnRates`](#snaptradeconnectionsreturnrates) * [`snaptrade.connections.sessionEvents`](#snaptradeconnectionssessionevents) - * [`snaptrade.cryptoTrading.searchCryptocurrencyPairInstruments`](#snaptradecryptotradingsearchcryptocurrencypairinstruments) * [`snaptrade.options.getOptionStrategy`](#snaptradeoptionsgetoptionstrategy) * [`snaptrade.options.getOptionsChain`](#snaptradeoptionsgetoptionschain) * [`snaptrade.options.getOptionsStrategyQuote`](#snaptradeoptionsgetoptionsstrategyquote) @@ -74,6 +73,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.trading.placeSimpleOrder`](#snaptradetradingplacesimpleorder) * [`snaptrade.trading.previewSimpleOrder`](#snaptradetradingpreviewsimpleorder) * [`snaptrade.trading.replaceOrder`](#snaptradetradingreplaceorder) + * [`snaptrade.trading.searchCryptocurrencyPairInstruments`](#snaptradetradingsearchcryptocurrencypairinstruments) * [`snaptrade.transactionsAndReporting.getActivities`](#snaptradetransactionsandreportinggetactivities) * [`snaptrade.transactionsAndReporting.getReportingCustomRange`](#snaptradetransactionsandreportinggetreportingcustomrange) @@ -1121,50 +1121,6 @@ Optional comma separated list of session IDs used to filter the request on speci --- -### `snaptrade.cryptoTrading.searchCryptocurrencyPairInstruments` - -Searches cryptocurrency pairs instruments accessible to the specified account. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->cryptoTrading->searchCryptocurrencyPairInstruments( - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - base: "BTC", - quote: "USD" -); -``` - -#### βš™οΈ Parameters - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### base: `string` - -##### quote: `string` - - -#### πŸ”„ Return - -[**TradingSearchCryptocurrencyPairInstruments200Response**](./lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs` `GET` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - ### `snaptrade.options.getOptionStrategy` Creates an option strategy object that will be used to place an option strategy order. @@ -2497,6 +2453,50 @@ The price at which a stop order is triggered for `Stop` and `StopLimit` orders. --- +### `snaptrade.trading.searchCryptocurrencyPairInstruments` + +Searches cryptocurrency pairs instruments accessible to the specified account. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->searchCryptocurrencyPairInstruments( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + base: "BTC", + quote: "USD" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### base: `string` + +##### quote: `string` + + +#### πŸ”„ Return + +[**TradingSearchCryptocurrencyPairInstruments200Response**](./lib/Model/TradingSearchCryptocurrencyPairInstruments200Response.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/instruments/cryptocurrencyPairs` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.transactionsAndReporting.getActivities` ![Deprecated](https://img.shields.io/badge/deprecated-yellow) diff --git a/lib/Api/CryptoTradingApi.php b/lib/Api/CryptoTradingApi.php deleted file mode 100644 index 5b78342..0000000 --- a/lib/Api/CryptoTradingApi.php +++ /dev/null @@ -1,627 +0,0 @@ - [ - 'application/json', - ], - ]; - -/** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - Configuration $config = null, - ClientInterface $client = null, - HeaderSelector $selector = null, - $hostIndex = 0 - ) { - $clientOptions = []; - if (!$config->getVerifySsl()) $clientOptions["verify"] = false; - - // Do not truncate error messages - // https://github.com/guzzle/guzzle/issues/2185#issuecomment-800293420 - $stack = new HandlerStack(Utils::chooseHandler()); - $stack->push(Middleware::httpErrors(new BodySummarizer(10000)), 'http_errors'); - $stack->push(Middleware::redirect(), 'allow_redirects'); - $stack->push(Middleware::cookies(), 'cookies'); - $stack->push(Middleware::prepareBody(), 'prepare_body'); - $clientOptions["handler"] = $stack; - - $this->client = $client ?: new Client($clientOptions); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * For initializing request body parameter - */ - private function setRequestBodyProperty(&$body, $property, $value) { - if ($body === null) $body = []; - // user did not pass in a value for this parameter - if ($value === SENTINEL_VALUE) return; - $body[$property] = $value; - } - - /** - * Operation searchCryptocurrencyPairInstruments - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param string $base base (optional) - * @param string $quote quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse - */ - public function searchCryptocurrencyPairInstruments( - $user_id, - $user_secret, - $account_id, - $base = SENTINEL_VALUE, - $quote = SENTINEL_VALUE, - - string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] - ) - { - - list($response) = $this->searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); - return $response; - } - - /** - * Operation searchCryptocurrencyPairInstrumentsWithHttpInfo - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->searchCryptocurrencyPairInstrumentsWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $base, - $quote, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation searchCryptocurrencyPairInstrumentsAsync - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function searchCryptocurrencyPairInstrumentsAsync( - $user_id, - $user_secret, - $account_id, - $base = SENTINEL_VALUE, - $quote = SENTINEL_VALUE, - - string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] - ) - { - - return $this->searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo - * - * Search cryptocurrency pairs instruments - * - * Searches cryptocurrency pairs instruments accessible to the specified account. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'searchCryptocurrencyPairInstruments' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $base (optional) - * @param string $quote (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling searchCryptocurrencyPairInstruments' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling searchCryptocurrencyPairInstruments' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling searchCryptocurrencyPairInstruments' - ); - } - // Check if $base is a string - if ($base !== SENTINEL_VALUE && !is_string($base)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); - } - // Check if $quote is a string - if ($quote !== SENTINEL_VALUE && !is_string($quote)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); - } - - - $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($base !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $base, - 'base', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } - if ($quote !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $quote, - 'quote', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'GET'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 6493aaa..644fb07 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -98,6 +98,9 @@ class TradingApi extends \SnapTrade\CustomApi 'replaceOrder' => [ 'application/json', ], + 'searchCryptocurrencyPairInstruments' => [ + 'application/json', + ], ]; /** @@ -5978,6 +5981,477 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, ]; } + /** + * Operation searchCryptocurrencyPairInstruments + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param string $base base (optional) + * @param string $quote quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse + */ + public function searchCryptocurrencyPairInstruments( + $user_id, + $user_secret, + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] + ) + { + + list($response) = $this->searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType); + return $response; + } + + /** + * Operation searchCryptocurrencyPairInstrumentsWithHttpInfo + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->searchCryptocurrencyPairInstrumentsWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $base, + $quote, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchCryptocurrencyPairInstrumentsAsync + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchCryptocurrencyPairInstrumentsAsync( + $user_id, + $user_secret, + $account_id, + $base = SENTINEL_VALUE, + $quote = SENTINEL_VALUE, + + string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0] + ) + { + + return $this->searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base, $quote, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo + * + * Search cryptocurrency pairs instruments + * + * Searches cryptocurrency pairs instruments accessible to the specified account. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $base = null, $quote = null, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\TradingSearchCryptocurrencyPairInstruments200Response'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base, $quote, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchCryptocurrencyPairInstruments' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $base (optional) + * @param string $quote (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchCryptocurrencyPairInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchCryptocurrencyPairInstrumentsRequest($user_id, $user_secret, $account_id, $base = SENTINEL_VALUE, $quote = SENTINEL_VALUE, string $contentType = self::contentTypes['searchCryptocurrencyPairInstruments'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling searchCryptocurrencyPairInstruments' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling searchCryptocurrencyPairInstruments' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling searchCryptocurrencyPairInstruments' + ); + } + // Check if $base is a string + if ($base !== SENTINEL_VALUE && !is_string($base)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($base, true), gettype($base))); + } + // Check if $quote is a string + if ($quote !== SENTINEL_VALUE && !is_string($quote)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quote, true), gettype($quote))); + } + + + $resourcePath = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($base !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $base, + 'base', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($quote !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $quote, + 'quote', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + /** * Create http client option * diff --git a/lib/Client.php b/lib/Client.php index bf70220..b8de060 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -13,8 +13,6 @@ class Client public readonly \SnapTrade\Api\ConnectionsApi $connections; - public readonly \SnapTrade\Api\CryptoTradingApi $cryptoTrading; - public readonly \SnapTrade\Api\OptionsApi $options; public readonly \SnapTrade\Api\ReferenceDataApi $referenceData; @@ -50,7 +48,6 @@ public function __construct( $this->apiStatus = new \SnapTrade\Api\ApiStatusApi($config); $this->authentication = new \SnapTrade\Api\AuthenticationApi($config); $this->connections = new \SnapTrade\Api\ConnectionsApi($config); - $this->cryptoTrading = new \SnapTrade\Api\CryptoTradingApi($config); $this->options = new \SnapTrade\Api\OptionsApi($config); $this->referenceData = new \SnapTrade\Api\ReferenceDataApi($config); $this->trading = new \SnapTrade\Api\TradingApi($config); diff --git a/test/Api/CryptoTradingApiTest.php b/test/Api/CryptoTradingApiTest.php deleted file mode 100644 index 43dc6d1..0000000 --- a/test/Api/CryptoTradingApiTest.php +++ /dev/null @@ -1,72 +0,0 @@ -markTestIncomplete('Not implemented'); - } -} diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 15ebf7f..add1d24 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -201,4 +201,16 @@ public function testReplaceOrder() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test case for searchCryptocurrencyPairInstruments + * + * Search cryptocurrency pairs instruments. + * + */ + public function testSearchCryptocurrencyPairInstruments() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } From 7742b8d534621e9e83a5e3f14615b5f336c8c2ba Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 12:46:42 +0000 Subject: [PATCH 151/252] Version Bump SDKs (#178) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index ec457bf..75a9791 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -b0d4fc62-8be2-4b4c-a87c-b62a77b3e392 \ No newline at end of file +4be64eb4-4833-4679-8d94-0799c915fbc6 \ No newline at end of file diff --git a/README.md b/README.md index ab20270..656de36 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.110-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.111-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.110" + "konfig/snaptrade-php-sdk": "2.0.111" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index fc62818..85a4f61 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.110/PHP'; + protected $userAgent = 'Konfig/2.0.111/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.110' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.111' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From ed0636dffa4183dad945efa1560890f1a5c7d455 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 17:32:24 +0000 Subject: [PATCH 152/252] Regenerate SDKs (#179) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Api/TradingApi.php | 32 ++++++++++++++++---------------- test/Api/TradingApiTest.php | 8 ++++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 75a9791..74c2465 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -4be64eb4-4833-4679-8d94-0799c915fbc6 \ No newline at end of file +7358abfb-3c42-46a6-89aa-617d6d022379 \ No newline at end of file diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 644fb07..3b3025a 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -174,7 +174,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { /** * Operation cancelOrder * - * Cancel an order. + * Cancel crypto order * * Cancels an order in the specified account. * @@ -205,7 +205,7 @@ public function cancelOrder( /** * Operation cancelOrderWithHttpInfo * - * Cancel an order. + * Cancel crypto order * * Cancels an order in the specified account. * @@ -351,7 +351,7 @@ public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $br /** * Operation cancelOrderAsync * - * Cancel an order. + * Cancel crypto order * * Cancels an order in the specified account. * @@ -385,7 +385,7 @@ function ($response) { /** * Operation cancelOrderAsyncWithHttpInfo * - * Cancel an order. + * Cancel crypto order * * Cancels an order in the specified account. * @@ -4467,7 +4467,7 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ /** * Operation placeSimpleOrder * - * Place order + * Place crypto order * * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * @@ -4517,7 +4517,7 @@ public function placeSimpleOrder( /** * Operation placeSimpleOrderWithHttpInfo * - * Place order + * Place crypto order * * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * @@ -4663,7 +4663,7 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id /** * Operation placeSimpleOrderAsync * - * Place order + * Place crypto order * * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * @@ -4716,7 +4716,7 @@ function ($response) { /** * Operation placeSimpleOrderAsyncWithHttpInfo * - * Place order + * Place crypto order * * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * @@ -4959,7 +4959,7 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si /** * Operation previewSimpleOrder * - * Preview order + * Preview crypto order * * Previews an order using the specified account. * @@ -5009,7 +5009,7 @@ public function previewSimpleOrder( /** * Operation previewSimpleOrderWithHttpInfo * - * Preview order + * Preview crypto order * * Previews an order using the specified account. * @@ -5155,7 +5155,7 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ /** * Operation previewSimpleOrderAsync * - * Preview order + * Preview crypto order * * Previews an order using the specified account. * @@ -5208,7 +5208,7 @@ function ($response) { /** * Operation previewSimpleOrderAsyncWithHttpInfo * - * Preview order + * Preview crypto order * * Previews an order using the specified account. * @@ -5451,7 +5451,7 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ /** * Operation replaceOrder * - * Replaces an order with a new one + * Replace crypto order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * @@ -5499,7 +5499,7 @@ public function replaceOrder( /** * Operation replaceOrderWithHttpInfo * - * Replaces an order with a new one + * Replace crypto order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * @@ -5670,7 +5670,7 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user /** * Operation replaceOrderAsync * - * Replaces an order with a new one + * Replace crypto order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * @@ -5721,7 +5721,7 @@ function ($response) { /** * Operation replaceOrderAsyncWithHttpInfo * - * Replaces an order with a new one + * Replace crypto order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index add1d24..724f457 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -61,7 +61,7 @@ public static function tearDownAfterClass(): void /** * Test case for cancelOrder * - * Cancel an order.. + * Cancel crypto order. * */ public function testCancelOrder() @@ -169,7 +169,7 @@ public function testPlaceOrder() /** * Test case for placeSimpleOrder * - * Place order. + * Place crypto order. * */ public function testPlaceSimpleOrder() @@ -181,7 +181,7 @@ public function testPlaceSimpleOrder() /** * Test case for previewSimpleOrder * - * Preview order. + * Preview crypto order. * */ public function testPreviewSimpleOrder() @@ -193,7 +193,7 @@ public function testPreviewSimpleOrder() /** * Test case for replaceOrder * - * Replaces an order with a new one. + * Replace crypto order. * */ public function testReplaceOrder() From 6a1ed7ef44e6f6296a910e7fe7daf1400c7b5dd4 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 17:36:35 +0000 Subject: [PATCH 153/252] Version Bump SDKs (#180) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 74c2465..e63348a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -7358abfb-3c42-46a6-89aa-617d6d022379 \ No newline at end of file +5593bc94-86ef-45d6-9c95-984fe139e868 \ No newline at end of file diff --git a/README.md b/README.md index 656de36..2077799 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.111-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.112-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.111" + "konfig/snaptrade-php-sdk": "2.0.112" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 85a4f61..07dafaf 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.111/PHP'; + protected $userAgent = 'Konfig/2.0.112/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.111' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.112' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 8ba99c0c4946fab29b379911d0c3de47f7e26fbb Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 9 Jul 2025 12:50:22 +0000 Subject: [PATCH 154/252] Regenerate SDKs (#181) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Api/TradingApi.php | 72 ++++++++++++++++++------------------- test/Api/TradingApiTest.php | 18 +++++----- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index e63348a..255371e 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -5593bc94-86ef-45d6-9c95-984fe139e868 \ No newline at end of file +dfa8b54d-b769-4f43-a7f3-3bcdd823ecee \ No newline at end of file diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 3b3025a..e9b5d5a 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -625,7 +625,7 @@ public function cancelOrderRequest($user_id, $user_secret, $account_id, $brokera /** * Operation cancelUserAccountOrder * - * Cancel order + * Cancel equity order * * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * @@ -659,7 +659,7 @@ public function cancelUserAccountOrder( /** * Operation cancelUserAccountOrderWithHttpInfo * - * Cancel order + * Cancel equity order * * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * @@ -828,7 +828,7 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco /** * Operation cancelUserAccountOrderAsync * - * Cancel order + * Cancel equity order * * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * @@ -865,7 +865,7 @@ function ($response) { /** * Operation cancelUserAccountOrderAsyncWithHttpInfo * - * Cancel order + * Cancel equity order * * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * @@ -1108,7 +1108,7 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i /** * Operation getCryptocurrencyPairQuote * - * Get cryptocurrency pair quote + * Get crypto pair quote * * Gets a quote for the specified account. * @@ -1139,7 +1139,7 @@ public function getCryptocurrencyPairQuote( /** * Operation getCryptocurrencyPairQuoteWithHttpInfo * - * Get cryptocurrency pair quote + * Get crypto pair quote * * Gets a quote for the specified account. * @@ -1285,7 +1285,7 @@ public function getCryptocurrencyPairQuoteWithHttpInfo($user_id, $user_secret, $ /** * Operation getCryptocurrencyPairQuoteAsync * - * Get cryptocurrency pair quote + * Get crypto pair quote * * Gets a quote for the specified account. * @@ -1319,7 +1319,7 @@ function ($response) { /** * Operation getCryptocurrencyPairQuoteAsyncWithHttpInfo * - * Get cryptocurrency pair quote + * Get crypto pair quote * * Gets a quote for the specified account. * @@ -1559,7 +1559,7 @@ public function getCryptocurrencyPairQuoteRequest($user_id, $user_secret, $accou /** * Operation getOrderImpact * - * Check order impact + * Check equity order impact * * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * @@ -1607,7 +1607,7 @@ public function getOrderImpact( /** * Operation getOrderImpactWithHttpInfo * - * Check order impact + * Check equity order impact * * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * @@ -1774,7 +1774,7 @@ public function getOrderImpactWithHttpInfo($user_id, $user_secret, $manual_trade /** * Operation getOrderImpactAsync * - * Check order impact + * Check equity order impact * * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * @@ -1825,7 +1825,7 @@ function ($response) { /** * Operation getOrderImpactAsyncWithHttpInfo * - * Check order impact + * Check equity order impact * * Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected. * @@ -2048,7 +2048,7 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form /** * Operation getUserAccountQuotes * - * Get symbol quotes + * Get equity symbol quotes * * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * @@ -2081,7 +2081,7 @@ public function getUserAccountQuotes( /** * Operation getUserAccountQuotesWithHttpInfo * - * Get symbol quotes + * Get equity symbol quotes * * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * @@ -2229,7 +2229,7 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol /** * Operation getUserAccountQuotesAsync * - * Get symbol quotes + * Get equity symbol quotes * * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * @@ -2265,7 +2265,7 @@ function ($response) { /** * Operation getUserAccountQuotesAsyncWithHttpInfo * - * Get symbol quotes + * Get equity symbol quotes * * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. * @@ -2521,7 +2521,7 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a /** * Operation placeBracketOrder * - * Place a Bracket Order + * Place bracket equity order * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * @@ -2573,7 +2573,7 @@ public function placeBracketOrder( /** * Operation placeBracketOrderWithHttpInfo * - * Place a Bracket Order + * Place bracket equity order * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * @@ -2742,7 +2742,7 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre /** * Operation placeBracketOrderAsync * - * Place a Bracket Order + * Place bracket equity order * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * @@ -2797,7 +2797,7 @@ function ($response) { /** * Operation placeBracketOrderAsyncWithHttpInfo * - * Place a Bracket Order + * Place bracket equity order * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * @@ -3040,7 +3040,7 @@ public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $m /** * Operation placeForceOrder * - * Place order + * Place equity order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -3090,7 +3090,7 @@ public function placeForceOrder( /** * Operation placeForceOrderWithHttpInfo * - * Place order + * Place equity order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -3257,7 +3257,7 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad /** * Operation placeForceOrderAsync * - * Place order + * Place equity order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -3310,7 +3310,7 @@ function ($response) { /** * Operation placeForceOrderAsyncWithHttpInfo * - * Place order + * Place equity order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -3533,7 +3533,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for /** * Operation placeMlegOrder * - * Place multi-leg option order + * Place option order * * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * @@ -3577,7 +3577,7 @@ public function placeMlegOrder( /** * Operation placeMlegOrderWithHttpInfo * - * Place multi-leg option order + * Place option order * * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * @@ -3723,7 +3723,7 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, /** * Operation placeMlegOrderAsync * - * Place multi-leg option order + * Place option order * * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * @@ -3770,7 +3770,7 @@ function ($response) { /** * Operation placeMlegOrderAsyncWithHttpInfo * - * Place multi-leg option order + * Place option order * * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * @@ -4013,7 +4013,7 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg /** * Operation placeOrder * - * Place checked order + * Place checked equity order * * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -4047,7 +4047,7 @@ public function placeOrder( /** * Operation placeOrderWithHttpInfo * - * Place checked order + * Place checked equity order * * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -4193,7 +4193,7 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid /** * Operation placeOrderAsync * - * Place checked order + * Place checked equity order * * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -4230,7 +4230,7 @@ function ($response) { /** * Operation placeOrderAsyncWithHttpInfo * - * Place checked order + * Place checked equity order * * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -5984,7 +5984,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, /** * Operation searchCryptocurrencyPairInstruments * - * Search cryptocurrency pairs instruments + * Get crypto pairs * * Searches cryptocurrency pairs instruments accessible to the specified account. * @@ -6017,7 +6017,7 @@ public function searchCryptocurrencyPairInstruments( /** * Operation searchCryptocurrencyPairInstrumentsWithHttpInfo * - * Search cryptocurrency pairs instruments + * Get crypto pairs * * Searches cryptocurrency pairs instruments accessible to the specified account. * @@ -6165,7 +6165,7 @@ public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_ /** * Operation searchCryptocurrencyPairInstrumentsAsync * - * Search cryptocurrency pairs instruments + * Get crypto pairs * * Searches cryptocurrency pairs instruments accessible to the specified account. * @@ -6201,7 +6201,7 @@ function ($response) { /** * Operation searchCryptocurrencyPairInstrumentsAsyncWithHttpInfo * - * Search cryptocurrency pairs instruments + * Get crypto pairs * * Searches cryptocurrency pairs instruments accessible to the specified account. * diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 724f457..22272c4 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -73,7 +73,7 @@ public function testCancelOrder() /** * Test case for cancelUserAccountOrder * - * Cancel order. + * Cancel equity order. * */ public function testCancelUserAccountOrder() @@ -85,7 +85,7 @@ public function testCancelUserAccountOrder() /** * Test case for getCryptocurrencyPairQuote * - * Get cryptocurrency pair quote. + * Get crypto pair quote. * */ public function testGetCryptocurrencyPairQuote() @@ -97,7 +97,7 @@ public function testGetCryptocurrencyPairQuote() /** * Test case for getOrderImpact * - * Check order impact. + * Check equity order impact. * */ public function testGetOrderImpact() @@ -109,7 +109,7 @@ public function testGetOrderImpact() /** * Test case for getUserAccountQuotes * - * Get symbol quotes. + * Get equity symbol quotes. * */ public function testGetUserAccountQuotes() @@ -121,7 +121,7 @@ public function testGetUserAccountQuotes() /** * Test case for placeBracketOrder * - * Place a Bracket Order. + * Place bracket equity order. * */ public function testPlaceBracketOrder() @@ -133,7 +133,7 @@ public function testPlaceBracketOrder() /** * Test case for placeForceOrder * - * Place order. + * Place equity order. * */ public function testPlaceForceOrder() @@ -145,7 +145,7 @@ public function testPlaceForceOrder() /** * Test case for placeMlegOrder * - * Place multi-leg option order. + * Place option order. * */ public function testPlaceMlegOrder() @@ -157,7 +157,7 @@ public function testPlaceMlegOrder() /** * Test case for placeOrder * - * Place checked order. + * Place checked equity order. * */ public function testPlaceOrder() @@ -205,7 +205,7 @@ public function testReplaceOrder() /** * Test case for searchCryptocurrencyPairInstruments * - * Search cryptocurrency pairs instruments. + * Get crypto pairs. * */ public function testSearchCryptocurrencyPairInstruments() From d19bd184d58099435ca400fc824c8bae40476281 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 9 Jul 2025 12:54:24 +0000 Subject: [PATCH 155/252] Version Bump SDKs (#182) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 255371e..10adb1a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -dfa8b54d-b769-4f43-a7f3-3bcdd823ecee \ No newline at end of file +a042ba9f-401e-4a8a-8744-07eb13cb83fd \ No newline at end of file diff --git a/README.md b/README.md index 2077799..2bba966 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.112-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.113-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.112" + "konfig/snaptrade-php-sdk": "2.0.113" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 07dafaf..f99ed4e 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.112/PHP'; + protected $userAgent = 'Konfig/2.0.113/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.112' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.113' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From d19e39841c528f0bbe47c9d29be4bd32db79171b Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 17:32:38 +0000 Subject: [PATCH 156/252] Regenerate SDKs (#183) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Api/TradingApi.php | 8 ++++---- test/Api/TradingApiTest.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 10adb1a..6b18fb0 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -a042ba9f-401e-4a8a-8744-07eb13cb83fd \ No newline at end of file +b77217a0-0f00-41eb-917c-e00f81acf3fa \ No newline at end of file diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index e9b5d5a..25e79da 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -5451,7 +5451,7 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ /** * Operation replaceOrder * - * Replace crypto order + * Replace equity order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * @@ -5499,7 +5499,7 @@ public function replaceOrder( /** * Operation replaceOrderWithHttpInfo * - * Replace crypto order + * Replace equity order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * @@ -5670,7 +5670,7 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user /** * Operation replaceOrderAsync * - * Replace crypto order + * Replace equity order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * @@ -5721,7 +5721,7 @@ function ($response) { /** * Operation replaceOrderAsyncWithHttpInfo * - * Replace crypto order + * Replace equity order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 22272c4..5190bbc 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -193,7 +193,7 @@ public function testPreviewSimpleOrder() /** * Test case for replaceOrder * - * Replace crypto order. + * Replace equity order. * */ public function testReplaceOrder() From 499df0c21756ac1203cb4810976e346bdba0b67b Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 17:36:37 +0000 Subject: [PATCH 157/252] Version Bump SDKs (#184) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 6b18fb0..d0cb985 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -b77217a0-0f00-41eb-917c-e00f81acf3fa \ No newline at end of file +90f734b2-9507-4694-8084-9ae7cc9b7e30 \ No newline at end of file diff --git a/README.md b/README.md index 2bba966..68cf14f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.113-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.114-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.113" + "konfig/snaptrade-php-sdk": "2.0.114" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index f99ed4e..1016bd5 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.113/PHP'; + protected $userAgent = 'Konfig/2.0.114/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.113' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.114' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 91f638bced125e447a43d543b499bed663a033f2 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 04:10:08 +0000 Subject: [PATCH 158/252] Regenerate SDKs (#185) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Model/MlegPriceEffectStrict.php | 59 +++++++++++++++++++ lib/Model/MlegTradeForm.php | 6 +- test/Model/MlegPriceEffectStrictTest.php | 74 ++++++++++++++++++++++++ 5 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 lib/Model/MlegPriceEffectStrict.php create mode 100644 test/Model/MlegPriceEffectStrictTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index d0cb985..f3b4a8d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -90f734b2-9507-4694-8084-9ae7cc9b7e30 \ No newline at end of file +3d9acac5-fdf3-43c4-b3ae-00eef97afe7c \ No newline at end of file diff --git a/README.md b/README.md index 68cf14f..f0aa37a 100644 --- a/README.md +++ b/README.md @@ -2151,7 +2151,7 @@ The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT. The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT. -##### price_effect: [`string`](./lib/Model/string.php) +##### price_effect: [`MlegPriceEffectStrict`](./lib/Model/MlegPriceEffectStrict.php) #### πŸ”„ Return diff --git a/lib/Model/MlegPriceEffectStrict.php b/lib/Model/MlegPriceEffectStrict.php new file mode 100644 index 0000000..d56ba91 --- /dev/null +++ b/lib/Model/MlegPriceEffectStrict.php @@ -0,0 +1,59 @@ + '\SnapTrade\Model\TimeInForceStrict', 'limit_price' => 'float', 'stop_price' => 'float', - 'price_effect' => 'string', + 'price_effect' => 'MlegPriceEffectStrict', 'legs' => '\SnapTrade\Model\MlegLeg[]' ]; @@ -460,7 +460,7 @@ public function setStopPrice($stop_price) /** * Gets price_effect * - * @return string|null + * @return MlegPriceEffectStrict|null */ public function getPriceEffect() { @@ -470,7 +470,7 @@ public function getPriceEffect() /** * Sets price_effect * - * @param string|null $price_effect price_effect + * @param MlegPriceEffectStrict|null $price_effect price_effect * * @return self */ diff --git a/test/Model/MlegPriceEffectStrictTest.php b/test/Model/MlegPriceEffectStrictTest.php new file mode 100644 index 0000000..f90485e --- /dev/null +++ b/test/Model/MlegPriceEffectStrictTest.php @@ -0,0 +1,74 @@ +markTestIncomplete('Not implemented'); + } +} From b37e429d4525920a4234bd5eb69b2b40d93534dd Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 04:14:21 +0000 Subject: [PATCH 159/252] Version Bump SDKs (#186) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f3b4a8d..4bf45dc 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -3d9acac5-fdf3-43c4-b3ae-00eef97afe7c \ No newline at end of file +302f2dfc-0093-4a88-b15f-1ce53ef7ba37 \ No newline at end of file diff --git a/README.md b/README.md index f0aa37a..b88cf41 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.114-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.115-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.114" + "konfig/snaptrade-php-sdk": "2.0.115" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 1016bd5..ac1e660 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.114/PHP'; + protected $userAgent = 'Konfig/2.0.115/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.114' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.115' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 506245fb1c8c597085d116825ab3186771f37291 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 15:15:32 +0000 Subject: [PATCH 160/252] Regenerate SDKs (#187) * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 6 +- lib/Api/TradingApi.php | 103 +++--- lib/Model/CancelOrderResponse.php | 450 +++++++++++++++++++++++++ test/Api/TradingApiTest.php | 2 +- test/Model/CancelOrderResponseTest.php | 92 +++++ 6 files changed, 604 insertions(+), 51 deletions(-) create mode 100644 lib/Model/CancelOrderResponse.php create mode 100644 test/Model/CancelOrderResponseTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 4bf45dc..f9b01cb 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -302f2dfc-0093-4a88-b15f-1ce53ef7ba37 \ No newline at end of file +630eb1c8-fcc9-4ae4-bd73-3a99770be81d \ No newline at end of file diff --git a/README.md b/README.md index b88cf41..270749a 100644 --- a/README.md +++ b/README.md @@ -1716,14 +1716,16 @@ $result = $snaptrade->trading->cancelOrder( ##### brokerage_order_id: `string` +Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + #### πŸ”„ Return -[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) +[**CancelOrderResponse**](./lib/Model/CancelOrderResponse.php) #### 🌐 Endpoint -`/accounts/{accountId}/trading/simple/{brokerageOrderId}/cancel` `POST` +`/accounts/{accountId}/trading/cancel` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 25e79da..bc6bc2f 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -174,57 +174,60 @@ private function setRequestBodyProperty(&$body, $property, $value) { /** * Operation cancelOrder * - * Cancel crypto order + * Cancel order * * Cancels an order in the specified account. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) - * @param string $brokerage_order_id brokerage_order_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request trading_cancel_user_account_order_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\CancelOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse */ public function cancelOrder( + $user_id, $user_secret, $account_id, - $brokerage_order_id, - + $brokerage_order_id = SENTINEL_VALUE, string $contentType = self::contentTypes['cancelOrder'][0] ) { + $_body = []; + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); + $trading_cancel_user_account_order_request = $_body; - list($response) = $this->cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); + list($response) = $this->cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); return $response; } /** * Operation cancelOrderWithHttpInfo * - * Cancel crypto order + * Cancel order * * Cancels an order in the specified account. * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param string $brokerage_order_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\CancelOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['cancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelOrderRequest($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); try { $options = $this->createHttpClientOption(); @@ -240,7 +243,7 @@ public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $br $user_id, $user_secret, $account_id, - $brokerage_order_id, + $trading_cancel_user_account_order_request, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -278,17 +281,17 @@ public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $br switch($statusCode) { case 200: - if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { + if ('\SnapTrade\Model\CancelOrderResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { + if ('\SnapTrade\Model\CancelOrderResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\CancelOrderResponse', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -309,7 +312,7 @@ public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $br ]; } - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; + $returnType = '\SnapTrade\Model\CancelOrderResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -330,7 +333,7 @@ public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $br case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\OrderUpdatedResponse', + '\SnapTrade\Model\CancelOrderResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -351,30 +354,33 @@ public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $br /** * Operation cancelOrderAsync * - * Cancel crypto order + * Cancel order * * Cancels an order in the specified account. * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param string $brokerage_order_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function cancelOrderAsync( + $user_id, $user_secret, $account_id, - $brokerage_order_id, - + $brokerage_order_id = SENTINEL_VALUE, string $contentType = self::contentTypes['cancelOrder'][0] ) { + $_body = []; + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); + $trading_cancel_user_account_order_request = $_body; - return $this->cancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType) + return $this->cancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType) ->then( function ($response) { return $response[0]; @@ -385,26 +391,26 @@ function ($response) { /** * Operation cancelOrderAsyncWithHttpInfo * - * Cancel crypto order + * Cancel order * * Cancels an order in the specified account. * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param string $brokerage_order_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function cancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['cancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function cancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelOrderRequest($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); + $returnType = '\SnapTrade\Model\CancelOrderResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -448,13 +454,13 @@ function ($exception) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param string $brokerage_order_id (required) + * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function cancelOrderRequest($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['cancelOrder'][0]) + public function cancelOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelOrder'][0]) { // Check if $user_id is a string @@ -487,19 +493,23 @@ public function cancelOrderRequest($user_id, $user_secret, $account_id, $brokera 'Missing the required parameter account_id when calling cancelOrder' ); } - // Check if $brokerage_order_id is a string - if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); + if ($trading_cancel_user_account_order_request !== SENTINEL_VALUE) { + if (!($trading_cancel_user_account_order_request instanceof \SnapTrade\Model\TradingCancelUserAccountOrderRequest)) { + if (!is_array($trading_cancel_user_account_order_request)) + throw new \InvalidArgumentException('"trading_cancel_user_account_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCancelUserAccountOrderRequest TradingApi.cancelOrder.'); + else + $trading_cancel_user_account_order_request = new \SnapTrade\Model\TradingCancelUserAccountOrderRequest($trading_cancel_user_account_order_request); + } } - // verify the required parameter 'brokerage_order_id' is set - if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { + // verify the required parameter 'trading_cancel_user_account_order_request' is set + if ($trading_cancel_user_account_order_request === SENTINEL_VALUE || (is_array($trading_cancel_user_account_order_request) && count($trading_cancel_user_account_order_request) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter brokerage_order_id when calling cancelOrder' + 'Missing the required parameter trading_cancel_user_account_order_request when calling cancelOrder' ); } - $resourcePath = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/cancel'; + $resourcePath = '/accounts/{accountId}/trading/cancel'; $formParams = []; $queryParams = []; $headerParams = []; @@ -538,14 +548,6 @@ public function cancelOrderRequest($user_id, $user_secret, $account_id, $brokera $resourcePath ); } - // path params - if ($brokerage_order_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'brokerageOrderId' . '}', - ObjectSerializer::toPathValue($brokerage_order_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -555,7 +557,14 @@ public function cancelOrderRequest($user_id, $user_secret, $account_id, $brokera ); // for model (json/xml) - if (count($formParams) > 0) { + if (isset($trading_cancel_user_account_order_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_cancel_user_account_order_request)); + } else { + $httpBody = $trading_cancel_user_account_order_request; + } + } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { diff --git a/lib/Model/CancelOrderResponse.php b/lib/Model/CancelOrderResponse.php new file mode 100644 index 0000000..37a0d06 --- /dev/null +++ b/lib/Model/CancelOrderResponse.php @@ -0,0 +1,450 @@ + + */ +class CancelOrderResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CancelOrderResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'brokerage_order_id' => 'string', + 'raw_response' => 'array' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'brokerage_order_id' => null, + 'raw_response' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'brokerage_order_id' => false, + 'raw_response' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'brokerage_order_id' => 'brokerage_order_id', + 'raw_response' => 'raw_response' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'brokerage_order_id' => 'setBrokerageOrderId', + 'raw_response' => 'setRawResponse' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'brokerage_order_id' => 'getBrokerageOrderId', + 'raw_response' => 'getRawResponse' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('brokerage_order_id', $data ?? [], null); + $this->setIfExists('raw_response', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['brokerage_order_id'] === null) { + $invalidProperties[] = "'brokerage_order_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets brokerage_order_id + * + * @return string + */ + public function getBrokerageOrderId() + { + return $this->container['brokerage_order_id']; + } + + /** + * Sets brokerage_order_id + * + * @param string $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + * + * @return self + */ + public function setBrokerageOrderId($brokerage_order_id) + { + + if (is_null($brokerage_order_id)) { + throw new \InvalidArgumentException('non-nullable brokerage_order_id cannot be null'); + } + + $this->container['brokerage_order_id'] = $brokerage_order_id; + + return $this; + } + + /** + * Gets raw_response + * + * @return array|null + */ + public function getRawResponse() + { + return $this->container['raw_response']; + } + + /** + * Sets raw_response + * + * @param array|null $raw_response The raw response from the brokerage. + * + * @return self + */ + public function setRawResponse($raw_response) + { + + if (is_null($raw_response)) { + array_push($this->openAPINullablesSetToNull, 'raw_response'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('raw_response', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['raw_response'] = $raw_response; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 5190bbc..7ddf0d5 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -61,7 +61,7 @@ public static function tearDownAfterClass(): void /** * Test case for cancelOrder * - * Cancel crypto order. + * Cancel order. * */ public function testCancelOrder() diff --git a/test/Model/CancelOrderResponseTest.php b/test/Model/CancelOrderResponseTest.php new file mode 100644 index 0000000..ce54c8e --- /dev/null +++ b/test/Model/CancelOrderResponseTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "brokerage_order_id" + */ + public function testPropertyBrokerageOrderId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "raw_response" + */ + public function testPropertyRawResponse() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From 746ca794e391115cccce63d4adb2b2ab4485d327 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 15:19:59 +0000 Subject: [PATCH 161/252] Version Bump SDKs (#188) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f9b01cb..517cad6 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -630eb1c8-fcc9-4ae4-bd73-3a99770be81d \ No newline at end of file +1962f8c7-5569-4fba-829d-68c9e3489431 \ No newline at end of file diff --git a/README.md b/README.md index 270749a..9ad2871 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.115-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.116-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -98,7 +98,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.115" + "konfig/snaptrade-php-sdk": "2.0.116" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index ac1e660..f29e4ca 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.115/PHP'; + protected $userAgent = 'Konfig/2.0.116/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.115' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.116' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 11bf6b6b7681bee8cca56dea16c936638139ae0d Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 30 Jul 2025 14:28:16 +0000 Subject: [PATCH 162/252] Regenerate SDKs (#189) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 32 + lib/Api/ReferenceDataApi.php | 347 +++++++++++ lib/Model/BrokerageInstrument.php | 576 ++++++++++++++++++ lib/Model/BrokerageInstrumentsResponse.php | 404 ++++++++++++ test/Api/ReferenceDataApiTest.php | 12 + test/Model/BrokerageInstrumentTest.php | 119 ++++ .../BrokerageInstrumentsResponseTest.php | 83 +++ 8 files changed, 1574 insertions(+), 1 deletion(-) create mode 100644 lib/Model/BrokerageInstrument.php create mode 100644 lib/Model/BrokerageInstrumentsResponse.php create mode 100644 test/Model/BrokerageInstrumentTest.php create mode 100644 test/Model/BrokerageInstrumentsResponseTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 517cad6..a0aa1fa 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -1962f8c7-5569-4fba-829d-68c9e3489431 \ No newline at end of file +51002cc0-1058-4dc7-b4c3-9804a3aac6d4 \ No newline at end of file diff --git a/README.md b/README.md index 9ad2871..40d88b2 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.referenceData.getSymbols`](#snaptradereferencedatagetsymbols) * [`snaptrade.referenceData.getSymbolsByTicker`](#snaptradereferencedatagetsymbolsbyticker) * [`snaptrade.referenceData.listAllBrokerageAuthorizationType`](#snaptradereferencedatalistallbrokerageauthorizationtype) + * [`snaptrade.referenceData.listAllBrokerageInstruments`](#snaptradereferencedatalistallbrokerageinstruments) * [`snaptrade.referenceData.listAllBrokerages`](#snaptradereferencedatalistallbrokerages) * [`snaptrade.referenceData.listAllCurrencies`](#snaptradereferencedatalistallcurrencies) * [`snaptrade.referenceData.listAllCurrenciesRates`](#snaptradereferencedatalistallcurrenciesrates) @@ -1569,6 +1570,37 @@ Comma separated value of brokerage slugs --- +### `snaptrade.referenceData.listAllBrokerageInstruments` + +Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->referenceData->listAllBrokerageInstruments( + brokerage_id: "87b24961-b51e-4db8-9226-f198f6518a89" +); +``` + +#### βš™οΈ Parameters + +##### brokerage_id: `string` + + +#### πŸ”„ Return + +[**BrokerageInstrumentsResponse**](./lib/Model/BrokerageInstrumentsResponse.php) + +#### 🌐 Endpoint + +`/brokerages/{brokerageId}/instruments` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.referenceData.listAllBrokerages` Returns a list of all defined Brokerage objects. diff --git a/lib/Api/ReferenceDataApi.php b/lib/Api/ReferenceDataApi.php index e5a1a8f..bc3d59a 100644 --- a/lib/Api/ReferenceDataApi.php +++ b/lib/Api/ReferenceDataApi.php @@ -83,6 +83,9 @@ class ReferenceDataApi extends \SnapTrade\CustomApi 'listAllBrokerageAuthorizationType' => [ 'application/json', ], + 'listAllBrokerageInstruments' => [ + 'application/json', + ], 'listAllBrokerages' => [ 'application/json', ], @@ -2519,6 +2522,350 @@ public function listAllBrokerageAuthorizationTypeRequest($brokerage = SENTINEL_V + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation listAllBrokerageInstruments + * + * Get a list of instruments available on the brokerage. + * + * Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. + * + * @param string $brokerage_id brokerage_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\BrokerageInstrumentsResponse + */ + public function listAllBrokerageInstruments( + $brokerage_id, + + string $contentType = self::contentTypes['listAllBrokerageInstruments'][0] + ) + { + + list($response) = $this->listAllBrokerageInstrumentsWithHttpInfo($brokerage_id, $contentType); + return $response; + } + + /** + * Operation listAllBrokerageInstrumentsWithHttpInfo + * + * Get a list of instruments available on the brokerage. + * + * Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. + * + * @param string $brokerage_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\BrokerageInstrumentsResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function listAllBrokerageInstrumentsWithHttpInfo($brokerage_id, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->listAllBrokerageInstrumentsRequest($brokerage_id, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->listAllBrokerageInstrumentsWithHttpInfo( + $brokerage_id, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\BrokerageInstrumentsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\BrokerageInstrumentsResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\BrokerageInstrumentsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\BrokerageInstrumentsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\BrokerageInstrumentsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listAllBrokerageInstrumentsAsync + * + * Get a list of instruments available on the brokerage. + * + * Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. + * + * @param string $brokerage_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listAllBrokerageInstrumentsAsync( + $brokerage_id, + + string $contentType = self::contentTypes['listAllBrokerageInstruments'][0] + ) + { + + return $this->listAllBrokerageInstrumentsAsyncWithHttpInfo($brokerage_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listAllBrokerageInstrumentsAsyncWithHttpInfo + * + * Get a list of instruments available on the brokerage. + * + * Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. + * + * @param string $brokerage_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listAllBrokerageInstrumentsAsyncWithHttpInfo($brokerage_id, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\BrokerageInstrumentsResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->listAllBrokerageInstrumentsRequest($brokerage_id, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listAllBrokerageInstruments' + * + * @param string $brokerage_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listAllBrokerageInstrumentsRequest($brokerage_id, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0]) + { + + // Check if $brokerage_id is a string + if ($brokerage_id !== SENTINEL_VALUE && !is_string($brokerage_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_id, true), gettype($brokerage_id))); + } + // verify the required parameter 'brokerage_id' is set + if ($brokerage_id === SENTINEL_VALUE || (is_array($brokerage_id) && count($brokerage_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter brokerage_id when calling listAllBrokerageInstruments' + ); + } + + + $resourcePath = '/brokerages/{brokerageId}/instruments'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($brokerage_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'brokerageId' . '}', + ObjectSerializer::toPathValue($brokerage_id), + $resourcePath + ); + } + + $headers = $this->headerSelector->selectHeaders( ['application/json', ], $contentType, diff --git a/lib/Model/BrokerageInstrument.php b/lib/Model/BrokerageInstrument.php new file mode 100644 index 0000000..65f95c0 --- /dev/null +++ b/lib/Model/BrokerageInstrument.php @@ -0,0 +1,576 @@ + + */ +class BrokerageInstrument implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BrokerageInstrument'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'symbol' => 'string', + 'exchange_mic' => 'string', + 'tradeable' => 'bool', + 'fractionable' => 'bool', + 'universal_symbol_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'symbol' => null, + 'exchange_mic' => null, + 'tradeable' => null, + 'fractionable' => null, + 'universal_symbol_id' => 'uuid' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'symbol' => false, + 'exchange_mic' => true, + 'tradeable' => true, + 'fractionable' => true, + 'universal_symbol_id' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'symbol' => 'symbol', + 'exchange_mic' => 'exchange_mic', + 'tradeable' => 'tradeable', + 'fractionable' => 'fractionable', + 'universal_symbol_id' => 'universal_symbol_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'symbol' => 'setSymbol', + 'exchange_mic' => 'setExchangeMic', + 'tradeable' => 'setTradeable', + 'fractionable' => 'setFractionable', + 'universal_symbol_id' => 'setUniversalSymbolId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'symbol' => 'getSymbol', + 'exchange_mic' => 'getExchangeMic', + 'tradeable' => 'getTradeable', + 'fractionable' => 'getFractionable', + 'universal_symbol_id' => 'getUniversalSymbolId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('exchange_mic', $data ?? [], null); + $this->setIfExists('tradeable', $data ?? [], null); + $this->setIfExists('fractionable', $data ?? [], null); + $this->setIfExists('universal_symbol_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets symbol + * + * @return string|null + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string|null $symbol The instrument's trading symbol / ticker. + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets exchange_mic + * + * @return string|null + */ + public function getExchangeMic() + { + return $this->container['exchange_mic']; + } + + /** + * Sets exchange_mic + * + * @param string|null $exchange_mic The MIC code of the exchange where the instrument is traded. + * + * @return self + */ + public function setExchangeMic($exchange_mic) + { + + if (is_null($exchange_mic)) { + array_push($this->openAPINullablesSetToNull, 'exchange_mic'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('exchange_mic', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['exchange_mic'] = $exchange_mic; + + return $this; + } + + /** + * Gets tradeable + * + * @return bool|null + */ + public function getTradeable() + { + return $this->container['tradeable']; + } + + /** + * Sets tradeable + * + * @param bool|null $tradeable Whether the instrument is tradeable through the brokerage. `null` if the tradeability is unknown. + * + * @return self + */ + public function setTradeable($tradeable) + { + + if (is_null($tradeable)) { + array_push($this->openAPINullablesSetToNull, 'tradeable'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tradeable', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['tradeable'] = $tradeable; + + return $this; + } + + /** + * Gets fractionable + * + * @return bool|null + */ + public function getFractionable() + { + return $this->container['fractionable']; + } + + /** + * Sets fractionable + * + * @param bool|null $fractionable Whether the instrument allows fractional units. `null` if the fractionability is unknown. + * + * @return self + */ + public function setFractionable($fractionable) + { + + if (is_null($fractionable)) { + array_push($this->openAPINullablesSetToNull, 'fractionable'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('fractionable', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['fractionable'] = $fractionable; + + return $this; + } + + /** + * Gets universal_symbol_id + * + * @return string|null + */ + public function getUniversalSymbolId() + { + return $this->container['universal_symbol_id']; + } + + /** + * Sets universal_symbol_id + * + * @param string|null $universal_symbol_id The universal symbol ID of the instrument. This is the ID used to reference the instrument in SnapTrade API calls. + * + * @return self + */ + public function setUniversalSymbolId($universal_symbol_id) + { + + if (is_null($universal_symbol_id)) { + array_push($this->openAPINullablesSetToNull, 'universal_symbol_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('universal_symbol_id', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['universal_symbol_id'] = $universal_symbol_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/BrokerageInstrumentsResponse.php b/lib/Model/BrokerageInstrumentsResponse.php new file mode 100644 index 0000000..9a5405d --- /dev/null +++ b/lib/Model/BrokerageInstrumentsResponse.php @@ -0,0 +1,404 @@ + + */ +class BrokerageInstrumentsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BrokerageInstrumentsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'instruments' => '\SnapTrade\Model\BrokerageInstrument[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'instruments' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'instruments' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'instruments' => 'instruments' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'instruments' => 'setInstruments' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'instruments' => 'getInstruments' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('instruments', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets instruments + * + * @return \SnapTrade\Model\BrokerageInstrument[]|null + */ + public function getInstruments() + { + return $this->container['instruments']; + } + + /** + * Sets instruments + * + * @param \SnapTrade\Model\BrokerageInstrument[]|null $instruments instruments + * + * @return self + */ + public function setInstruments($instruments) + { + + if (is_null($instruments)) { + throw new \InvalidArgumentException('non-nullable instruments cannot be null'); + } + + $this->container['instruments'] = $instruments; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/ReferenceDataApiTest.php b/test/Api/ReferenceDataApiTest.php index 0671507..63e8916 100644 --- a/test/Api/ReferenceDataApiTest.php +++ b/test/Api/ReferenceDataApiTest.php @@ -142,6 +142,18 @@ public function testListAllBrokerageAuthorizationType() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for listAllBrokerageInstruments + * + * Get a list of instruments available on the brokerage.. + * + */ + public function testListAllBrokerageInstruments() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for listAllBrokerages * diff --git a/test/Model/BrokerageInstrumentTest.php b/test/Model/BrokerageInstrumentTest.php new file mode 100644 index 0000000..c568cb1 --- /dev/null +++ b/test/Model/BrokerageInstrumentTest.php @@ -0,0 +1,119 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "exchange_mic" + */ + public function testPropertyExchangeMic() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "tradeable" + */ + public function testPropertyTradeable() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "fractionable" + */ + public function testPropertyFractionable() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "universal_symbol_id" + */ + public function testPropertyUniversalSymbolId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/BrokerageInstrumentsResponseTest.php b/test/Model/BrokerageInstrumentsResponseTest.php new file mode 100644 index 0000000..bb15f8c --- /dev/null +++ b/test/Model/BrokerageInstrumentsResponseTest.php @@ -0,0 +1,83 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "instruments" + */ + public function testPropertyInstruments() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From cf018671b852d152832f19b20d41b8fc709a60a9 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 30 Jul 2025 14:32:45 +0000 Subject: [PATCH 163/252] Version Bump SDKs (#190) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a0aa1fa..e425f81 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -51002cc0-1058-4dc7-b4c3-9804a3aac6d4 \ No newline at end of file +22398fdd-2b5e-4853-b444-44691cc0570d \ No newline at end of file diff --git a/README.md b/README.md index 40d88b2..3fb9f1b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.116-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.117-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.116" + "konfig/snaptrade-php-sdk": "2.0.117" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index f29e4ca..b11e4d4 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.116/PHP'; + protected $userAgent = 'Konfig/2.0.117/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.116' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.117' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 1fb7ff8ca4abfc3e112fd3ba0f3adc07f0871234 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 30 Jul 2025 21:50:58 +0000 Subject: [PATCH 164/252] Regenerate SDKs (#191) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/ReferenceDataApi.php | 16 ++++++++-------- test/Api/ReferenceDataApiTest.php | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index e425f81..9738bff 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -22398fdd-2b5e-4853-b444-44691cc0570d \ No newline at end of file +2cd2dae3-b9c1-4485-a20e-ecb5a1fd7718 \ No newline at end of file diff --git a/README.md b/README.md index 3fb9f1b..96c7d87 100644 --- a/README.md +++ b/README.md @@ -1572,7 +1572,7 @@ Comma separated value of brokerage slugs ### `snaptrade.referenceData.listAllBrokerageInstruments` -Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. +Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list. #### πŸ› οΈ Usage diff --git a/lib/Api/ReferenceDataApi.php b/lib/Api/ReferenceDataApi.php index bc3d59a..3a10fe8 100644 --- a/lib/Api/ReferenceDataApi.php +++ b/lib/Api/ReferenceDataApi.php @@ -2599,9 +2599,9 @@ public function listAllBrokerageAuthorizationTypeRequest($brokerage = SENTINEL_V /** * Operation listAllBrokerageInstruments * - * Get a list of instruments available on the brokerage. + * Get brokerage instruments * - * Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. + * Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list. * * @param string $brokerage_id brokerage_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation @@ -2624,9 +2624,9 @@ public function listAllBrokerageInstruments( /** * Operation listAllBrokerageInstrumentsWithHttpInfo * - * Get a list of instruments available on the brokerage. + * Get brokerage instruments * - * Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. + * Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list. * * @param string $brokerage_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation @@ -2741,9 +2741,9 @@ public function listAllBrokerageInstrumentsWithHttpInfo($brokerage_id, string $c /** * Operation listAllBrokerageInstrumentsAsync * - * Get a list of instruments available on the brokerage. + * Get brokerage instruments * - * Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. + * Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list. * * @param string $brokerage_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation @@ -2769,9 +2769,9 @@ function ($response) { /** * Operation listAllBrokerageInstrumentsAsyncWithHttpInfo * - * Get a list of instruments available on the brokerage. + * Get brokerage instruments * - * Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. + * Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list. * * @param string $brokerage_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation diff --git a/test/Api/ReferenceDataApiTest.php b/test/Api/ReferenceDataApiTest.php index 63e8916..04f5636 100644 --- a/test/Api/ReferenceDataApiTest.php +++ b/test/Api/ReferenceDataApiTest.php @@ -145,7 +145,7 @@ public function testListAllBrokerageAuthorizationType() /** * Test case for listAllBrokerageInstruments * - * Get a list of instruments available on the brokerage.. + * Get brokerage instruments. * */ public function testListAllBrokerageInstruments() From 9028ced3ab156ee3c9dd04cc8afc99b67062d561 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 30 Jul 2025 21:54:53 +0000 Subject: [PATCH 165/252] Version Bump SDKs (#192) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 9738bff..0c8ca28 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2cd2dae3-b9c1-4485-a20e-ecb5a1fd7718 \ No newline at end of file +91e4d74d-d915-4aea-8afc-a7469f30b65b \ No newline at end of file diff --git a/README.md b/README.md index 96c7d87..eae7d42 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.117-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.118-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.117" + "konfig/snaptrade-php-sdk": "2.0.118" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index b11e4d4..783aeb0 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.117/PHP'; + protected $userAgent = 'Konfig/2.0.118/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.117' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.118' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 8b45ce6fc56544e75ea039a4efcea79fc593dfba Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 5 Aug 2025 12:10:46 +0000 Subject: [PATCH 166/252] Regenerate SDKs (#193) * Regenerate SDKs * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 200 ++-- lib/Api/TradingApi.php | 1045 ++++++++--------- lib/Model/CryptoOrderForm.php | 787 +++++++++++++ ...rderPreview.php => CryptoOrderPreview.php} | 14 +- ...php => CryptoOrderPreviewEstimatedFee.php} | 8 +- lib/Model/CryptoTradingInstrument.php | 480 ++++++++ lib/Model/ManualTradeReplaceForm.php | 43 +- test/Api/TradingApiTest.php | 28 +- test/Model/CryptoOrderFormTest.php | 155 +++ ...=> CryptoOrderPreviewEstimatedFeeTest.php} | 10 +- ...iewTest.php => CryptoOrderPreviewTest.php} | 10 +- test/Model/CryptoTradingInstrumentTest.php | 92 ++ test/Model/ManualTradeReplaceFormTest.php | 11 +- 14 files changed, 2216 insertions(+), 669 deletions(-) create mode 100644 lib/Model/CryptoOrderForm.php rename lib/Model/{SimpleOrderPreview.php => CryptoOrderPreview.php} (95%) rename lib/Model/{SimpleOrderPreviewEstimatedFee.php => CryptoOrderPreviewEstimatedFee.php} (97%) create mode 100644 lib/Model/CryptoTradingInstrument.php create mode 100644 test/Model/CryptoOrderFormTest.php rename test/Model/{SimpleOrderPreviewEstimatedFeeTest.php => CryptoOrderPreviewEstimatedFeeTest.php} (85%) rename test/Model/{SimpleOrderPreviewTest.php => CryptoOrderPreviewTest.php} (86%) create mode 100644 test/Model/CryptoTradingInstrumentTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0c8ca28..81b7f05 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -91e4d74d-d915-4aea-8afc-a7469f30b65b \ No newline at end of file +9db79232-713b-4fbd-8cf3-73bd6f8611cf \ No newline at end of file diff --git a/README.md b/README.md index eae7d42..dd667d9 100644 --- a/README.md +++ b/README.md @@ -68,11 +68,11 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.trading.getOrderImpact`](#snaptradetradinggetorderimpact) * [`snaptrade.trading.getUserAccountQuotes`](#snaptradetradinggetuseraccountquotes) * [`snaptrade.trading.placeBracketOrder`](#snaptradetradingplacebracketorder) + * [`snaptrade.trading.placeCryptoOrder`](#snaptradetradingplacecryptoorder) * [`snaptrade.trading.placeForceOrder`](#snaptradetradingplaceforceorder) * [`snaptrade.trading.placeMlegOrder`](#snaptradetradingplacemlegorder) * [`snaptrade.trading.placeOrder`](#snaptradetradingplaceorder) - * [`snaptrade.trading.placeSimpleOrder`](#snaptradetradingplacesimpleorder) - * [`snaptrade.trading.previewSimpleOrder`](#snaptradetradingpreviewsimpleorder) + * [`snaptrade.trading.previewCryptoOrder`](#snaptradetradingpreviewcryptoorder) * [`snaptrade.trading.replaceOrder`](#snaptradetradingreplaceorder) * [`snaptrade.trading.searchCryptocurrencyPairInstruments`](#snaptradetradingsearchcryptocurrencypairinstruments) * [`snaptrade.transactionsAndReporting.getActivities`](#snaptradetransactionsandreportinggetactivities) @@ -1723,7 +1723,7 @@ The search query for symbols. ### `snaptrade.trading.cancelOrder` -Cancels an order in the specified account. +Cancels an order in the specified account. Accepts order IDs for all asset types. @@ -1765,7 +1765,9 @@ Order ID returned by brokerage. This is the unique identifier for the order in t ### `snaptrade.trading.cancelUserAccountOrder` +![Deprecated](https://img.shields.io/badge/deprecated-yellow) +**This endpoint is deprecated. Please switch to [the new cancel order endpoint](/reference/Trading/Trading_cancelOrder) ** Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. @@ -2051,6 +2053,89 @@ Number of shares for the order. This can be a decimal for fractional orders. Mus --- +### `snaptrade.trading.placeCryptoOrder` + +Places an order in the specified account. +This endpoint does not compute the impact to the account balance from the order before submitting the order. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->trading->placeCryptoOrder( + instrument: [ + "symbol" => "BTC", + "type" => "CRYPTOCURRENCY", + ], + side: "BUY", + type: "MARKET", + time_in_force: "GTC", + amount: "123.45", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + limit_price: "123.45", + stop_price: "123.45", + post_only: False, + expiration_date: "2024-01-01T00:00:00Z" +); +``` + +#### βš™οΈ Parameters + +##### instrument: [`CryptoTradingInstrument`](./lib/Model/CryptoTradingInstrument.php) + +##### side: + +##### type: `string` + +The type of order to place. + +##### time_in_force: `string` + +The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. + +##### amount: `float` + +The amount of the base currency to buy or sell. + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### limit_price: `float` + +The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. + +##### stop_price: `float` + +The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. + +##### post_only: `bool` + +Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. + +##### expiration_date: `\DateTime` + +The expiration date of the order. Required if the time_in_force is GTD. + + +#### πŸ”„ Return + +[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/trading/crypto` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.trading.placeForceOrder` Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. @@ -2248,90 +2333,7 @@ Optional, defaults to true. Determines if a wait is performed to check on order --- -### `snaptrade.trading.placeSimpleOrder` - -Places an order in the specified account. -This endpoint does not compute the impact to the account balance from the order before submitting the order. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->trading->placeSimpleOrder( - instrument: [ - "symbol" => "AAPL", - "type" => "EQUITY", - ], - side: "BUY", - type: "MARKET", - time_in_force: "GTC", - amount: "123.45", - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - limit_price: "123.45", - stop_price: "123.45", - post_only: False, - expiration_date: "2024-01-01T00:00:00Z" -); -``` - -#### βš™οΈ Parameters - -##### instrument: [`TradingInstrument`](./lib/Model/TradingInstrument.php) - -##### side: - -##### type: `string` - -The type of order to place. - -##### time_in_force: `string` - -The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. - -##### amount: `float` - -The amount of the base currency to buy or sell. - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -##### limit_price: `float` - -The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. - -##### stop_price: `float` - -The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. - -##### post_only: `bool` - -Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. - -##### expiration_date: `\DateTime` - -The expiration date of the order. Required if the time_in_force is GTD. - - -#### πŸ”„ Return - -[**OrderUpdatedResponse**](./lib/Model/OrderUpdatedResponse.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/trading/simple` `POST` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - -### `snaptrade.trading.previewSimpleOrder` +### `snaptrade.trading.previewCryptoOrder` Previews an order using the specified account. @@ -2340,10 +2342,10 @@ Previews an order using the specified account. #### πŸ› οΈ Usage ```php -$result = $snaptrade->trading->previewSimpleOrder( +$result = $snaptrade->trading->previewCryptoOrder( instrument: [ - "symbol" => "AAPL", - "type" => "EQUITY", + "symbol" => "BTC", + "type" => "CRYPTOCURRENCY", ], side: "BUY", type: "MARKET", @@ -2361,7 +2363,7 @@ $result = $snaptrade->trading->previewSimpleOrder( #### βš™οΈ Parameters -##### instrument: [`TradingInstrument`](./lib/Model/TradingInstrument.php) +##### instrument: [`CryptoTradingInstrument`](./lib/Model/CryptoTradingInstrument.php) ##### side: @@ -2402,11 +2404,11 @@ The expiration date of the order. Required if the time_in_force is GTD. #### πŸ”„ Return -[**SimpleOrderPreview**](./lib/Model/SimpleOrderPreview.php) +[**CryptoOrderPreview**](./lib/Model/CryptoOrderPreview.php) #### 🌐 Endpoint -`/accounts/{accountId}/trading/simple/preview` `POST` +`/accounts/{accountId}/trading/crypto/preview` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) @@ -2425,11 +2427,11 @@ returned in the response going forward. Only supported on some brokerages ```php $result = $snaptrade->trading->replaceOrder( + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", action: "BUY", order_type: "Market", time_in_force: "Day", account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", - brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", price: 31.33, @@ -2441,6 +2443,10 @@ $result = $snaptrade->trading->replaceOrder( #### βš™οΈ Parameters +##### brokerage_order_id: `string` + +Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + ##### action: ##### order_type: @@ -2451,10 +2457,6 @@ $result = $snaptrade->trading->replaceOrder( The ID of the account to execute the trade on. -##### brokerage_order_id: `string` - -The Brokerage Order ID of the order to replace. - ##### user_id: `string` ##### user_secret: `string` @@ -2480,7 +2482,7 @@ The price at which a stop order is triggered for `Stop` and `StopLimit` orders. #### 🌐 Endpoint -`/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace` `PATCH` +`/accounts/{accountId}/trading/replace` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index bc6bc2f..515415f 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -80,6 +80,9 @@ class TradingApi extends \SnapTrade\CustomApi 'placeBracketOrder' => [ 'application/json', ], + 'placeCryptoOrder' => [ + 'application/json', + ], 'placeForceOrder' => [ 'application/json', ], @@ -89,10 +92,7 @@ class TradingApi extends \SnapTrade\CustomApi 'placeOrder' => [ 'application/json', ], - 'placeSimpleOrder' => [ - 'application/json', - ], - 'previewSimpleOrder' => [ + 'previewCryptoOrder' => [ 'application/json', ], 'replaceOrder' => [ @@ -176,7 +176,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * Cancel order * - * Cancels an order in the specified account. + * Cancels an order in the specified account. Accepts order IDs for all asset types. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -210,7 +210,7 @@ public function cancelOrder( * * Cancel order * - * Cancels an order in the specified account. + * Cancels an order in the specified account. Accepts order IDs for all asset types. * * @param string $user_id (required) * @param string $user_secret (required) @@ -356,7 +356,7 @@ public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $tr * * Cancel order * - * Cancels an order in the specified account. + * Cancels an order in the specified account. Accepts order IDs for all asset types. * * @param string $user_id (required) * @param string $user_secret (required) @@ -393,7 +393,7 @@ function ($response) { * * Cancel order * - * Cancels an order in the specified account. + * Cancels an order in the specified account. Accepts order IDs for all asset types. * * @param string $user_id (required) * @param string $user_secret (required) @@ -636,7 +636,7 @@ public function cancelOrderRequest($user_id, $user_secret, $account_id, $trading * * Cancel equity order * - * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. + * **This endpoint is deprecated. Please switch to [the new cancel order endpoint](/reference/Trading/Trading_cancelOrder) ** Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -647,6 +647,7 @@ public function cancelOrderRequest($user_id, $user_secret, $account_id, $trading * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse + * @deprecated */ public function cancelUserAccountOrder( @@ -670,7 +671,7 @@ public function cancelUserAccountOrder( * * Cancel equity order * - * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. + * **This endpoint is deprecated. Please switch to [the new cancel order endpoint](/reference/Trading/Trading_cancelOrder) ** Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) @@ -681,6 +682,7 @@ public function cancelUserAccountOrder( * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated */ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { @@ -839,7 +841,7 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco * * Cancel equity order * - * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. + * **This endpoint is deprecated. Please switch to [the new cancel order endpoint](/reference/Trading/Trading_cancelOrder) ** Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) @@ -849,6 +851,7 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated */ public function cancelUserAccountOrderAsync( @@ -876,7 +879,7 @@ function ($response) { * * Cancel equity order * - * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. + * **This endpoint is deprecated. Please switch to [the new cancel order endpoint](/reference/Trading/Trading_cancelOrder) ** Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected. * * @param string $user_id (required) * @param string $user_secret (required) @@ -886,6 +889,7 @@ function ($response) { * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated */ public function cancelUserAccountOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { @@ -942,6 +946,7 @@ function ($exception) { * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request + * @deprecated */ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0]) { @@ -3047,74 +3052,75 @@ public function placeBracketOrderRequest($account_id, $user_id, $user_secret, $m } /** - * Operation placeForceOrder + * Operation placeCryptoOrder * - * Place equity order + * Place crypto order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\CryptoOrderForm $crypto_order_form crypto_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeCryptoOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse + * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse */ - public function placeForceOrder( + public function placeCryptoOrder( - $account_id, - $action, - $order_type, + $instrument, + $side, + $type, $time_in_force, + $amount, $user_id, $user_secret, - $universal_symbol_id = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeForceOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeCryptoOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form_with_options = $_body; + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $crypto_order_form = $_body; - list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + list($response) = $this->placeCryptoOrderWithHttpInfo($user_id, $user_secret, $account_id, $crypto_order_form, $contentType); return $response; } /** - * Operation placeForceOrderWithHttpInfo + * Operation placeCryptoOrderWithHttpInfo * - * Place equity order + * Place crypto order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\CryptoOrderForm $crypto_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeCryptoOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeCryptoOrderWithHttpInfo($user_id, $user_secret, $account_id, $crypto_order_form, string $contentType = self::contentTypes['placeCryptoOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeCryptoOrderRequest($user_id, $user_secret, $account_id, $crypto_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3129,10 +3135,11 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeForceOrderWithHttpInfo( + return $this->placeCryptoOrderWithHttpInfo( $user_id, $user_secret, - $manual_trade_form_with_options, + $account_id, + $crypto_order_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -3170,17 +3177,17 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -3199,24 +3206,9 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad $response->getStatusCode(), $response->getHeaders() ]; - case 403: - if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -3237,7 +3229,7 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\OrderUpdatedResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -3250,65 +3242,57 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad ); $e->setResponseObject($data); break; - case 403: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model403FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; } throw $e; } } /** - * Operation placeForceOrderAsync + * Operation placeCryptoOrderAsync * - * Place equity order + * Place crypto order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\CryptoOrderForm $crypto_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeCryptoOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeForceOrderAsync( + public function placeCryptoOrderAsync( - $account_id, - $action, - $order_type, + $instrument, + $side, + $type, $time_in_force, + $amount, $user_id, $user_secret, - $universal_symbol_id = SENTINEL_VALUE, - $symbol = SENTINEL_VALUE, - $price = SENTINEL_VALUE, - $stop = SENTINEL_VALUE, - $units = SENTINEL_VALUE, - $notional_value = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeForceOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $post_only = SENTINEL_VALUE, + $expiration_date = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeCryptoOrder'][0] ) { $_body = []; - $this->setRequestBodyProperty($_body, "account_id", $account_id); - $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); - $this->setRequestBodyProperty($_body, "symbol", $symbol); - $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "instrument", $instrument); + $this->setRequestBodyProperty($_body, "side", $side); + $this->setRequestBodyProperty($_body, "type", $type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $this->setRequestBodyProperty($_body, "stop", $stop); - $this->setRequestBodyProperty($_body, "units", $units); - $this->setRequestBodyProperty($_body, "notional_value", $notional_value); - $manual_trade_form_with_options = $_body; + $this->setRequestBodyProperty($_body, "amount", $amount); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "post_only", $post_only); + $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); + $crypto_order_form = $_body; - return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) + return $this->placeCryptoOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $crypto_order_form, $contentType) ->then( function ($response) { return $response[0]; @@ -3317,24 +3301,25 @@ function ($response) { } /** - * Operation placeForceOrderAsyncWithHttpInfo + * Operation placeCryptoOrderAsyncWithHttpInfo * - * Place equity order + * Place crypto order * - * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\CryptoOrderForm $crypto_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeCryptoOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeCryptoOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $crypto_order_form, string $contentType = self::contentTypes['placeCryptoOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); + $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeCryptoOrderRequest($user_id, $user_secret, $account_id, $crypto_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3376,17 +3361,18 @@ function ($exception) { } /** - * Create request for operation 'placeForceOrder' + * Create request for operation 'placeCryptoOrder' * * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\CryptoOrderForm $crypto_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeCryptoOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0]) + public function placeCryptoOrderRequest($user_id, $user_secret, $account_id, $crypto_order_form, string $contentType = self::contentTypes['placeCryptoOrder'][0]) { // Check if $user_id is a string @@ -3396,7 +3382,7 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeForceOrder' + 'Missing the required parameter user_id when calling placeCryptoOrder' ); } // Check if $user_secret is a string @@ -3406,26 +3392,36 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeForceOrder' + 'Missing the required parameter user_secret when calling placeCryptoOrder' ); } - if ($manual_trade_form_with_options !== SENTINEL_VALUE) { - if (!($manual_trade_form_with_options instanceof \SnapTrade\Model\ManualTradeFormWithOptions)) { - if (!is_array($manual_trade_form_with_options)) - throw new \InvalidArgumentException('"manual_trade_form_with_options" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormWithOptions TradingApi.placeForceOrder.'); + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling placeCryptoOrder' + ); + } + if ($crypto_order_form !== SENTINEL_VALUE) { + if (!($crypto_order_form instanceof \SnapTrade\Model\CryptoOrderForm)) { + if (!is_array($crypto_order_form)) + throw new \InvalidArgumentException('"crypto_order_form" must be associative array or an instance of \SnapTrade\Model\CryptoOrderForm TradingApi.placeCryptoOrder.'); else - $manual_trade_form_with_options = new \SnapTrade\Model\ManualTradeFormWithOptions($manual_trade_form_with_options); + $crypto_order_form = new \SnapTrade\Model\CryptoOrderForm($crypto_order_form); } } - // verify the required parameter 'manual_trade_form_with_options' is set - if ($manual_trade_form_with_options === SENTINEL_VALUE || (is_array($manual_trade_form_with_options) && count($manual_trade_form_with_options) === 0)) { + // verify the required parameter 'crypto_order_form' is set + if ($crypto_order_form === SENTINEL_VALUE || (is_array($crypto_order_form) && count($crypto_order_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter manual_trade_form_with_options when calling placeForceOrder' + 'Missing the required parameter crypto_order_form when calling placeCryptoOrder' ); } - $resourcePath = '/trade/place'; + $resourcePath = '/accounts/{accountId}/trading/crypto'; $formParams = []; $queryParams = []; $headerParams = []; @@ -3456,6 +3452,14 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for } + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -3465,12 +3469,12 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for ); // for model (json/xml) - if (isset($manual_trade_form_with_options)) { + if (isset($crypto_order_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_with_options)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($crypto_order_form)); } else { - $httpBody = $manual_trade_form_with_options; + $httpBody = $crypto_order_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -3540,69 +3544,74 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for } /** - * Operation placeMlegOrder + * Operation placeForceOrder * - * Place option order + * Place equity order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse */ - public function placeMlegOrder( + public function placeForceOrder( + $account_id, + $action, $order_type, $time_in_force, - $legs, $user_id, $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $price_effect = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeMlegOrder'][0] + $universal_symbol_id = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeForceOrder'][0] ) { $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "price_effect", $price_effect); - $this->setRequestBodyProperty($_body, "legs", $legs); - $mleg_trade_form = $_body; + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form_with_options = $_body; - list($response) = $this->placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); + list($response) = $this->placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType); return $response; } /** - * Operation placeMlegOrderWithHttpInfo + * Operation placeForceOrderWithHttpInfo * - * Place option order + * Place equity order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3617,11 +3626,10 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeMlegOrderWithHttpInfo( + return $this->placeForceOrderWithHttpInfo( $user_id, $user_secret, - $account_id, - $mleg_trade_form, + $manual_trade_form_with_options, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -3659,17 +3667,17 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, switch($statusCode) { case 200: - if ('\SnapTrade\Model\MlegOrderResponse' === '\SplFileObject') { + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\MlegOrderResponse' !== 'string') { + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\MlegOrderResponse', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -3688,9 +3696,24 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $response->getStatusCode(), $response->getHeaders() ]; + case 403: + if ('\SnapTrade\Model\Model403FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } - $returnType = '\SnapTrade\Model\MlegOrderResponse'; + $returnType = '\SnapTrade\Model\AccountOrderRecord'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -3711,7 +3734,7 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\MlegOrderResponse', + '\SnapTrade\Model\AccountOrderRecord', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -3724,51 +3747,65 @@ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, ); $e->setResponseObject($data); break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } } /** - * Operation placeMlegOrderAsync + * Operation placeForceOrderAsync * - * Place option order + * Place equity order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeMlegOrderAsync( + public function placeForceOrderAsync( + $account_id, + $action, $order_type, $time_in_force, - $legs, $user_id, $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $price_effect = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeMlegOrder'][0] + $universal_symbol_id = SENTINEL_VALUE, + $symbol = SENTINEL_VALUE, + $price = SENTINEL_VALUE, + $stop = SENTINEL_VALUE, + $units = SENTINEL_VALUE, + $notional_value = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeForceOrder'][0] ) { $_body = []; + $this->setRequestBodyProperty($_body, "account_id", $account_id); + $this->setRequestBodyProperty($_body, "action", $action); + $this->setRequestBodyProperty($_body, "universal_symbol_id", $universal_symbol_id); + $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "price_effect", $price_effect); - $this->setRequestBodyProperty($_body, "legs", $legs); - $mleg_trade_form = $_body; + $this->setRequestBodyProperty($_body, "price", $price); + $this->setRequestBodyProperty($_body, "stop", $stop); + $this->setRequestBodyProperty($_body, "units", $units); + $this->setRequestBodyProperty($_body, "notional_value", $notional_value); + $manual_trade_form_with_options = $_body; - return $this->placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType) + return $this->placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, $contentType) ->then( function ($response) { return $response[0]; @@ -3777,25 +3814,24 @@ function ($response) { } /** - * Operation placeMlegOrderAsyncWithHttpInfo + * Operation placeForceOrderAsyncWithHttpInfo * - * Place option order + * Place equity order * - * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support + * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeForceOrderAsyncWithHttpInfo($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\MlegOrderResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -3837,18 +3873,17 @@ function ($exception) { } /** - * Create request for operation 'placeMlegOrder' + * Create request for operation 'placeForceOrder' * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ManualTradeFormWithOptions $manual_trade_form_with_options (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeForceOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0]) + public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_form_with_options, string $contentType = self::contentTypes['placeForceOrder'][0]) { // Check if $user_id is a string @@ -3858,7 +3893,7 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeMlegOrder' + 'Missing the required parameter user_id when calling placeForceOrder' ); } // Check if $user_secret is a string @@ -3868,36 +3903,26 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeMlegOrder' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling placeMlegOrder' + 'Missing the required parameter user_secret when calling placeForceOrder' ); } - if ($mleg_trade_form !== SENTINEL_VALUE) { - if (!($mleg_trade_form instanceof \SnapTrade\Model\MlegTradeForm)) { - if (!is_array($mleg_trade_form)) - throw new \InvalidArgumentException('"mleg_trade_form" must be associative array or an instance of \SnapTrade\Model\MlegTradeForm TradingApi.placeMlegOrder.'); + if ($manual_trade_form_with_options !== SENTINEL_VALUE) { + if (!($manual_trade_form_with_options instanceof \SnapTrade\Model\ManualTradeFormWithOptions)) { + if (!is_array($manual_trade_form_with_options)) + throw new \InvalidArgumentException('"manual_trade_form_with_options" must be associative array or an instance of \SnapTrade\Model\ManualTradeFormWithOptions TradingApi.placeForceOrder.'); else - $mleg_trade_form = new \SnapTrade\Model\MlegTradeForm($mleg_trade_form); + $manual_trade_form_with_options = new \SnapTrade\Model\ManualTradeFormWithOptions($manual_trade_form_with_options); } } - // verify the required parameter 'mleg_trade_form' is set - if ($mleg_trade_form === SENTINEL_VALUE || (is_array($mleg_trade_form) && count($mleg_trade_form) === 0)) { + // verify the required parameter 'manual_trade_form_with_options' is set + if ($manual_trade_form_with_options === SENTINEL_VALUE || (is_array($manual_trade_form_with_options) && count($manual_trade_form_with_options) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter mleg_trade_form when calling placeMlegOrder' + 'Missing the required parameter manual_trade_form_with_options when calling placeForceOrder' ); } - $resourcePath = '/accounts/{accountId}/trading/options'; + $resourcePath = '/trade/place'; $formParams = []; $queryParams = []; $headerParams = []; @@ -3928,14 +3953,6 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg } - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -3945,12 +3962,12 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg ); // for model (json/xml) - if (isset($mleg_trade_form)) { + if (isset($manual_trade_form_with_options)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($mleg_trade_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($manual_trade_form_with_options)); } else { - $httpBody = $mleg_trade_form; + $httpBody = $manual_trade_form_with_options; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -4020,59 +4037,69 @@ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg } /** - * Operation placeOrder + * Operation placeMlegOrder * - * Place checked equity order + * Place option order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse */ - public function placeOrder( - $trade_id, + public function placeMlegOrder( + + $order_type, + $time_in_force, + $legs, $user_id, $user_secret, - $wait_to_confirm = SENTINEL_VALUE, - - string $contentType = self::contentTypes['placeOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $price_effect = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeMlegOrder'][0] ) { - $_body = null; - $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); - $validated_trade_body = $_body; + $_body = []; + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "price_effect", $price_effect); + $this->setRequestBodyProperty($_body, "legs", $legs); + $mleg_trade_form = $_body; - list($response) = $this->placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + list($response) = $this->placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); return $response; } /** - * Operation placeOrderWithHttpInfo + * Operation placeMlegOrderWithHttpInfo * - * Place checked equity order + * Place option order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4087,11 +4114,11 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeOrderWithHttpInfo( - $trade_id, + return $this->placeMlegOrderWithHttpInfo( $user_id, $user_secret, - $validated_trade_body, + $account_id, + $mleg_trade_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -4129,17 +4156,17 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid switch($statusCode) { case 200: - if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + if ('\SnapTrade\Model\MlegOrderResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + if ('\SnapTrade\Model\MlegOrderResponse' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\MlegOrderResponse', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -4160,7 +4187,7 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid ]; } - $returnType = '\SnapTrade\Model\AccountOrderRecord'; + $returnType = '\SnapTrade\Model\MlegOrderResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -4181,7 +4208,7 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\AccountOrderRecord', + '\SnapTrade\Model\MlegOrderResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -4200,35 +4227,45 @@ public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $valid } /** - * Operation placeOrderAsync + * Operation placeMlegOrderAsync * - * Place checked equity order + * Place option order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeOrderAsync( - $trade_id, + public function placeMlegOrderAsync( + + $order_type, + $time_in_force, + $legs, $user_id, $user_secret, - $wait_to_confirm = SENTINEL_VALUE, - - string $contentType = self::contentTypes['placeOrder'][0] + $account_id, + $limit_price = SENTINEL_VALUE, + $stop_price = SENTINEL_VALUE, + $price_effect = SENTINEL_VALUE, + string $contentType = self::contentTypes['placeMlegOrder'][0] ) { - $_body = null; - $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); - $validated_trade_body = $_body; + $_body = []; + $this->setRequestBodyProperty($_body, "order_type", $order_type); + $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "limit_price", $limit_price); + $this->setRequestBodyProperty($_body, "stop_price", $stop_price); + $this->setRequestBodyProperty($_body, "price_effect", $price_effect); + $this->setRequestBodyProperty($_body, "legs", $legs); + $mleg_trade_form = $_body; - return $this->placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType) + return $this->placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType) ->then( function ($response) { return $response[0]; @@ -4237,25 +4274,25 @@ function ($response) { } /** - * Operation placeOrderAsyncWithHttpInfo + * Operation placeMlegOrderAsyncWithHttpInfo * - * Place checked equity order + * Place option order * - * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. + * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); + $returnType = '\SnapTrade\Model\MlegOrderResponse'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4297,30 +4334,20 @@ function ($exception) { } /** - * Create request for operation 'placeOrder' + * Create request for operation 'placeMlegOrder' * - * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation + * @param string $account_id (required) + * @param \SnapTrade\Model\MlegTradeForm $mleg_trade_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body = SENTINEL_VALUE, string $contentType = self::contentTypes['placeOrder'][0]) + public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $mleg_trade_form, string $contentType = self::contentTypes['placeMlegOrder'][0]) { - // Check if $trade_id is a string - if ($trade_id !== SENTINEL_VALUE && !is_string($trade_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trade_id, true), gettype($trade_id))); - } - // verify the required parameter 'trade_id' is set - if ($trade_id === SENTINEL_VALUE || (is_array($trade_id) && count($trade_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter trade_id when calling placeOrder' - ); - } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -4328,7 +4355,7 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeOrder' + 'Missing the required parameter user_id when calling placeMlegOrder' ); } // Check if $user_secret is a string @@ -4338,20 +4365,36 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeOrder' + 'Missing the required parameter user_secret when calling placeMlegOrder' ); } - if ($validated_trade_body !== SENTINEL_VALUE) { - if (!($validated_trade_body instanceof \SnapTrade\Model\ValidatedTradeBody)) { - if (!is_array($validated_trade_body)) - throw new \InvalidArgumentException('"validated_trade_body" must be associative array or an instance of \SnapTrade\Model\ValidatedTradeBody TradingApi.placeOrder.'); + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling placeMlegOrder' + ); + } + if ($mleg_trade_form !== SENTINEL_VALUE) { + if (!($mleg_trade_form instanceof \SnapTrade\Model\MlegTradeForm)) { + if (!is_array($mleg_trade_form)) + throw new \InvalidArgumentException('"mleg_trade_form" must be associative array or an instance of \SnapTrade\Model\MlegTradeForm TradingApi.placeMlegOrder.'); else - $validated_trade_body = new \SnapTrade\Model\ValidatedTradeBody($validated_trade_body); + $mleg_trade_form = new \SnapTrade\Model\MlegTradeForm($mleg_trade_form); } } + // verify the required parameter 'mleg_trade_form' is set + if ($mleg_trade_form === SENTINEL_VALUE || (is_array($mleg_trade_form) && count($mleg_trade_form) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter mleg_trade_form when calling placeMlegOrder' + ); + } - $resourcePath = '/trade/{tradeId}'; + $resourcePath = '/accounts/{accountId}/trading/options'; $formParams = []; $queryParams = []; $headerParams = []; @@ -4383,10 +4426,10 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ // path params - if ($trade_id !== SENTINEL_VALUE) { + if ($account_id !== SENTINEL_VALUE) { $resourcePath = str_replace( - '{' . 'tradeId' . '}', - ObjectSerializer::toPathValue($trade_id), + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), $resourcePath ); } @@ -4399,12 +4442,12 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ ); // for model (json/xml) - if (isset($validated_trade_body)) { + if (isset($mleg_trade_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($validated_trade_body)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($mleg_trade_form)); } else { - $httpBody = $validated_trade_body; + $httpBody = $mleg_trade_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -4474,75 +4517,59 @@ public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_ } /** - * Operation placeSimpleOrder + * Operation placeOrder * - * Place crypto order + * Place checked equity order * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse */ - public function placeSimpleOrder( - - $instrument, - $side, - $type, - $time_in_force, - $amount, + public function placeOrder( + $trade_id, $user_id, $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeSimpleOrder'][0] + $wait_to_confirm = SENTINEL_VALUE, + + string $contentType = self::contentTypes['placeOrder'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; + $_body = null; + $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); + $validated_trade_body = $_body; - list($response) = $this->placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + list($response) = $this->placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); return $response; } /** - * Operation placeSimpleOrderWithHttpInfo + * Operation placeOrderWithHttpInfo * - * Place crypto order + * Place checked equity order * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\OrderUpdatedResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeOrderWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4557,11 +4584,11 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->placeSimpleOrderWithHttpInfo( + return $this->placeOrderWithHttpInfo( + $trade_id, $user_id, $user_secret, - $account_id, - $simple_order_form, + $validated_trade_body, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -4599,17 +4626,17 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id switch($statusCode) { case 200: - if ('\SnapTrade\Model\OrderUpdatedResponse' === '\SplFileObject') { + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\OrderUpdatedResponse' !== 'string') { + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\OrderUpdatedResponse', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -4630,7 +4657,7 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id ]; } - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; + $returnType = '\SnapTrade\Model\AccountOrderRecord'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -4651,7 +4678,7 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\OrderUpdatedResponse', + '\SnapTrade\Model\AccountOrderRecord', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -4670,51 +4697,35 @@ public function placeSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id } /** - * Operation placeSimpleOrderAsync + * Operation placeOrderAsync * - * Place crypto order + * Place checked equity order * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeSimpleOrderAsync( - - $instrument, - $side, - $type, - $time_in_force, - $amount, + public function placeOrderAsync( + $trade_id, $user_id, $user_secret, - $account_id, - $limit_price = SENTINEL_VALUE, - $stop_price = SENTINEL_VALUE, - $post_only = SENTINEL_VALUE, - $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeSimpleOrder'][0] + $wait_to_confirm = SENTINEL_VALUE, + + string $contentType = self::contentTypes['placeOrder'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "instrument", $instrument); - $this->setRequestBodyProperty($_body, "side", $side); - $this->setRequestBodyProperty($_body, "type", $type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "amount", $amount); - $this->setRequestBodyProperty($_body, "limit_price", $limit_price); - $this->setRequestBodyProperty($_body, "stop_price", $stop_price); - $this->setRequestBodyProperty($_body, "post_only", $post_only); - $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; + $_body = null; + $this->setRequestBodyProperty($_body, "wait_to_confirm", $wait_to_confirm); + $validated_trade_body = $_body; - return $this->placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) + return $this->placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType) ->then( function ($response) { return $response[0]; @@ -4723,25 +4734,25 @@ function ($response) { } /** - * Operation placeSimpleOrderAsyncWithHttpInfo + * Operation placeOrderAsyncWithHttpInfo * - * Place crypto order + * Place checked equity order * - * Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order. + * Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function placeOrderAsyncWithHttpInfo($trade_id, $user_id, $user_secret, $validated_trade_body = null, string $contentType = self::contentTypes['placeOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\OrderUpdatedResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -4783,20 +4794,30 @@ function ($exception) { } /** - * Create request for operation 'placeSimpleOrder' + * Create request for operation 'placeOrder' * + * @param string $trade_id Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact) (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\ValidatedTradeBody $validated_trade_body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['placeSimpleOrder'][0]) + public function placeOrderRequest($trade_id, $user_id, $user_secret, $validated_trade_body = SENTINEL_VALUE, string $contentType = self::contentTypes['placeOrder'][0]) { + // Check if $trade_id is a string + if ($trade_id !== SENTINEL_VALUE && !is_string($trade_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trade_id, true), gettype($trade_id))); + } + // verify the required parameter 'trade_id' is set + if ($trade_id === SENTINEL_VALUE || (is_array($trade_id) && count($trade_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter trade_id when calling placeOrder' + ); + } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -4804,7 +4825,7 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeSimpleOrder' + 'Missing the required parameter user_id when calling placeOrder' ); } // Check if $user_secret is a string @@ -4814,36 +4835,20 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeSimpleOrder' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling placeSimpleOrder' + 'Missing the required parameter user_secret when calling placeOrder' ); } - if ($simple_order_form !== SENTINEL_VALUE) { - if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { - if (!is_array($simple_order_form)) - throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm TradingApi.placeSimpleOrder.'); + if ($validated_trade_body !== SENTINEL_VALUE) { + if (!($validated_trade_body instanceof \SnapTrade\Model\ValidatedTradeBody)) { + if (!is_array($validated_trade_body)) + throw new \InvalidArgumentException('"validated_trade_body" must be associative array or an instance of \SnapTrade\Model\ValidatedTradeBody TradingApi.placeOrder.'); else - $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); + $validated_trade_body = new \SnapTrade\Model\ValidatedTradeBody($validated_trade_body); } } - // verify the required parameter 'simple_order_form' is set - if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter simple_order_form when calling placeSimpleOrder' - ); - } - $resourcePath = '/accounts/{accountId}/trading/simple'; + $resourcePath = '/trade/{tradeId}'; $formParams = []; $queryParams = []; $headerParams = []; @@ -4875,10 +4880,10 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si // path params - if ($account_id !== SENTINEL_VALUE) { + if ($trade_id !== SENTINEL_VALUE) { $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), + '{' . 'tradeId' . '}', + ObjectSerializer::toPathValue($trade_id), $resourcePath ); } @@ -4891,12 +4896,12 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si ); // for model (json/xml) - if (isset($simple_order_form)) { + if (isset($validated_trade_body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($validated_trade_body)); } else { - $httpBody = $simple_order_form; + $httpBody = $validated_trade_body; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -4966,7 +4971,7 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si } /** - * Operation previewSimpleOrder + * Operation previewCryptoOrder * * Preview crypto order * @@ -4975,14 +4980,14 @@ public function placeSimpleOrderRequest($user_id, $user_secret, $account_id, $si * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\CryptoOrderForm $crypto_order_form crypto_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewCryptoOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse + * @return \SnapTrade\Model\CryptoOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse */ - public function previewSimpleOrder( + public function previewCryptoOrder( $instrument, $side, @@ -4996,7 +5001,7 @@ public function previewSimpleOrder( $stop_price = SENTINEL_VALUE, $post_only = SENTINEL_VALUE, $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['previewSimpleOrder'][0] + string $contentType = self::contentTypes['previewCryptoOrder'][0] ) { $_body = []; @@ -5009,14 +5014,14 @@ public function previewSimpleOrder( $this->setRequestBodyProperty($_body, "stop_price", $stop_price); $this->setRequestBodyProperty($_body, "post_only", $post_only); $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; + $crypto_order_form = $_body; - list($response) = $this->previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + list($response) = $this->previewCryptoOrderWithHttpInfo($user_id, $user_secret, $account_id, $crypto_order_form, $contentType); return $response; } /** - * Operation previewSimpleOrderWithHttpInfo + * Operation previewCryptoOrderWithHttpInfo * * Preview crypto order * @@ -5025,16 +5030,16 @@ public function previewSimpleOrder( * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\CryptoOrderForm $crypto_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewCryptoOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\SimpleOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\CryptoOrderPreview|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function previewCryptoOrderWithHttpInfo($user_id, $user_secret, $account_id, $crypto_order_form, string $contentType = self::contentTypes['previewCryptoOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->previewCryptoOrderRequest($user_id, $user_secret, $account_id, $crypto_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -5049,11 +5054,11 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->previewSimpleOrderWithHttpInfo( + return $this->previewCryptoOrderWithHttpInfo( $user_id, $user_secret, $account_id, - $simple_order_form, + $crypto_order_form, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -5091,17 +5096,17 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ switch($statusCode) { case 200: - if ('\SnapTrade\Model\SimpleOrderPreview' === '\SplFileObject') { + if ('\SnapTrade\Model\CryptoOrderPreview' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\SimpleOrderPreview' !== 'string') { + if ('\SnapTrade\Model\CryptoOrderPreview' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\SimpleOrderPreview', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\CryptoOrderPreview', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -5122,7 +5127,7 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ ]; } - $returnType = '\SnapTrade\Model\SimpleOrderPreview'; + $returnType = '\SnapTrade\Model\CryptoOrderPreview'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -5143,7 +5148,7 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\SimpleOrderPreview', + '\SnapTrade\Model\CryptoOrderPreview', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -5162,7 +5167,7 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ } /** - * Operation previewSimpleOrderAsync + * Operation previewCryptoOrderAsync * * Preview crypto order * @@ -5171,13 +5176,13 @@ public function previewSimpleOrderWithHttpInfo($user_id, $user_secret, $account_ * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\CryptoOrderForm $crypto_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewCryptoOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function previewSimpleOrderAsync( + public function previewCryptoOrderAsync( $instrument, $side, @@ -5191,7 +5196,7 @@ public function previewSimpleOrderAsync( $stop_price = SENTINEL_VALUE, $post_only = SENTINEL_VALUE, $expiration_date = SENTINEL_VALUE, - string $contentType = self::contentTypes['previewSimpleOrder'][0] + string $contentType = self::contentTypes['previewCryptoOrder'][0] ) { $_body = []; @@ -5204,9 +5209,9 @@ public function previewSimpleOrderAsync( $this->setRequestBodyProperty($_body, "stop_price", $stop_price); $this->setRequestBodyProperty($_body, "post_only", $post_only); $this->setRequestBodyProperty($_body, "expiration_date", $expiration_date); - $simple_order_form = $_body; + $crypto_order_form = $_body; - return $this->previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, $contentType) + return $this->previewCryptoOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $crypto_order_form, $contentType) ->then( function ($response) { return $response[0]; @@ -5215,7 +5220,7 @@ function ($response) { } /** - * Operation previewSimpleOrderAsyncWithHttpInfo + * Operation previewCryptoOrderAsyncWithHttpInfo * * Preview crypto order * @@ -5224,16 +5229,16 @@ function ($response) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\CryptoOrderForm $crypto_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewCryptoOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function previewSimpleOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function previewCryptoOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $crypto_order_form, string $contentType = self::contentTypes['previewCryptoOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\SimpleOrderPreview'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, $contentType); + $returnType = '\SnapTrade\Model\CryptoOrderPreview'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->previewCryptoOrderRequest($user_id, $user_secret, $account_id, $crypto_order_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -5275,18 +5280,18 @@ function ($exception) { } /** - * Create request for operation 'previewSimpleOrder' + * Create request for operation 'previewCryptoOrder' * * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\SimpleOrderForm $simple_order_form (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewSimpleOrder'] to see the possible values for this operation + * @param \SnapTrade\Model\CryptoOrderForm $crypto_order_form (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['previewCryptoOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $simple_order_form, string $contentType = self::contentTypes['previewSimpleOrder'][0]) + public function previewCryptoOrderRequest($user_id, $user_secret, $account_id, $crypto_order_form, string $contentType = self::contentTypes['previewCryptoOrder'][0]) { // Check if $user_id is a string @@ -5296,7 +5301,7 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling previewSimpleOrder' + 'Missing the required parameter user_id when calling previewCryptoOrder' ); } // Check if $user_secret is a string @@ -5306,7 +5311,7 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling previewSimpleOrder' + 'Missing the required parameter user_secret when calling previewCryptoOrder' ); } // Check if $account_id is a string @@ -5316,26 +5321,26 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ // verify the required parameter 'account_id' is set if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling previewSimpleOrder' + 'Missing the required parameter account_id when calling previewCryptoOrder' ); } - if ($simple_order_form !== SENTINEL_VALUE) { - if (!($simple_order_form instanceof \SnapTrade\Model\SimpleOrderForm)) { - if (!is_array($simple_order_form)) - throw new \InvalidArgumentException('"simple_order_form" must be associative array or an instance of \SnapTrade\Model\SimpleOrderForm TradingApi.previewSimpleOrder.'); + if ($crypto_order_form !== SENTINEL_VALUE) { + if (!($crypto_order_form instanceof \SnapTrade\Model\CryptoOrderForm)) { + if (!is_array($crypto_order_form)) + throw new \InvalidArgumentException('"crypto_order_form" must be associative array or an instance of \SnapTrade\Model\CryptoOrderForm TradingApi.previewCryptoOrder.'); else - $simple_order_form = new \SnapTrade\Model\SimpleOrderForm($simple_order_form); + $crypto_order_form = new \SnapTrade\Model\CryptoOrderForm($crypto_order_form); } } - // verify the required parameter 'simple_order_form' is set - if ($simple_order_form === SENTINEL_VALUE || (is_array($simple_order_form) && count($simple_order_form) === 0)) { + // verify the required parameter 'crypto_order_form' is set + if ($crypto_order_form === SENTINEL_VALUE || (is_array($crypto_order_form) && count($crypto_order_form) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter simple_order_form when calling previewSimpleOrder' + 'Missing the required parameter crypto_order_form when calling previewCryptoOrder' ); } - $resourcePath = '/accounts/{accountId}/trading/simple/preview'; + $resourcePath = '/accounts/{accountId}/trading/crypto/preview'; $formParams = []; $queryParams = []; $headerParams = []; @@ -5383,12 +5388,12 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ ); // for model (json/xml) - if (isset($simple_order_form)) { + if (isset($crypto_order_form)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($simple_order_form)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($crypto_order_form)); } else { - $httpBody = $simple_order_form; + $httpBody = $crypto_order_form; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -5465,7 +5470,6 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form manual_trade_replace_form (required) @@ -5477,11 +5481,11 @@ public function previewSimpleOrderRequest($user_id, $user_secret, $account_id, $ */ public function replaceOrder( + $brokerage_order_id, $action, $order_type, $time_in_force, $account_id, - $brokerage_order_id, $user_id, $user_secret, $price = SENTINEL_VALUE, @@ -5492,6 +5496,7 @@ public function replaceOrder( ) { $_body = []; + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); $this->setRequestBodyProperty($_body, "action", $action); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); @@ -5501,7 +5506,7 @@ public function replaceOrder( $this->setRequestBodyProperty($_body, "units", $units); $manual_trade_replace_form = $_body; - list($response) = $this->replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + list($response) = $this->replaceOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); return $response; } @@ -5513,7 +5518,6 @@ public function replaceOrder( * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) @@ -5523,9 +5527,9 @@ public function replaceOrder( * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model403FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function replaceOrderWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -5542,7 +5546,6 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user ) { return $this->replaceOrderWithHttpInfo( $account_id, - $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, @@ -5684,7 +5687,6 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) @@ -5695,11 +5697,11 @@ public function replaceOrderWithHttpInfo($account_id, $brokerage_order_id, $user */ public function replaceOrderAsync( + $brokerage_order_id, $action, $order_type, $time_in_force, $account_id, - $brokerage_order_id, $user_id, $user_secret, $price = SENTINEL_VALUE, @@ -5710,6 +5712,7 @@ public function replaceOrderAsync( ) { $_body = []; + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); $this->setRequestBodyProperty($_body, "action", $action); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); @@ -5719,7 +5722,7 @@ public function replaceOrderAsync( $this->setRequestBodyProperty($_body, "units", $units); $manual_trade_replace_form = $_body; - return $this->replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType) + return $this->replaceOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType) ->then( function ($response) { return $response[0]; @@ -5735,7 +5738,6 @@ function ($response) { * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) @@ -5744,10 +5746,10 @@ function ($response) { * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function replaceOrderAsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function replaceOrderAsyncWithHttpInfo($account_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->replaceOrderRequest($account_id, $user_id, $user_secret, $manual_trade_replace_form, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -5792,7 +5794,6 @@ function ($exception) { * Create request for operation 'replaceOrder' * * @param string $account_id The ID of the account to execute the trade on. (required) - * @param string $brokerage_order_id The Brokerage Order ID of the order to replace. (required) * @param string $user_id (required) * @param string $user_secret (required) * @param \SnapTrade\Model\ManualTradeReplaceForm $manual_trade_replace_form (required) @@ -5801,7 +5802,7 @@ function ($exception) { * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0]) + public function replaceOrderRequest($account_id, $user_id, $user_secret, $manual_trade_replace_form, string $contentType = self::contentTypes['replaceOrder'][0]) { // Check if $account_id is a string @@ -5814,16 +5815,6 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, 'Missing the required parameter account_id when calling replaceOrder' ); } - // Check if $brokerage_order_id is a string - if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); - } - // verify the required parameter 'brokerage_order_id' is set - if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter brokerage_order_id when calling replaceOrder' - ); - } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -5860,7 +5851,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, } - $resourcePath = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace'; + $resourcePath = '/accounts/{accountId}/trading/replace'; $formParams = []; $queryParams = []; $headerParams = []; @@ -5899,14 +5890,6 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $resourcePath ); } - // path params - if ($brokerage_order_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'brokerageOrderId' . '}', - ObjectSerializer::toPathValue($brokerage_order_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -5974,7 +5957,7 @@ public function replaceOrderRequest($account_id, $brokerage_order_id, $user_id, $headers ); - $method = 'PATCH'; + $method = 'POST'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); diff --git a/lib/Model/CryptoOrderForm.php b/lib/Model/CryptoOrderForm.php new file mode 100644 index 0000000..03e6b0e --- /dev/null +++ b/lib/Model/CryptoOrderForm.php @@ -0,0 +1,787 @@ + + */ +class CryptoOrderForm implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CryptoOrderForm'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'instrument' => '\SnapTrade\Model\CryptoTradingInstrument', + 'side' => '\SnapTrade\Model\ActionStrict', + 'type' => 'string', + 'time_in_force' => 'string', + 'amount' => 'float', + 'limit_price' => 'float', + 'stop_price' => 'float', + 'post_only' => 'bool', + 'expiration_date' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'instrument' => null, + 'side' => null, + 'type' => null, + 'time_in_force' => null, + 'amount' => 'decimal', + 'limit_price' => 'decimal', + 'stop_price' => 'decimal', + 'post_only' => null, + 'expiration_date' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'instrument' => false, + 'side' => false, + 'type' => false, + 'time_in_force' => false, + 'amount' => false, + 'limit_price' => false, + 'stop_price' => false, + 'post_only' => false, + 'expiration_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'instrument' => 'instrument', + 'side' => 'side', + 'type' => 'type', + 'time_in_force' => 'time_in_force', + 'amount' => 'amount', + 'limit_price' => 'limit_price', + 'stop_price' => 'stop_price', + 'post_only' => 'post_only', + 'expiration_date' => 'expiration_date' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'instrument' => 'setInstrument', + 'side' => 'setSide', + 'type' => 'setType', + 'time_in_force' => 'setTimeInForce', + 'amount' => 'setAmount', + 'limit_price' => 'setLimitPrice', + 'stop_price' => 'setStopPrice', + 'post_only' => 'setPostOnly', + 'expiration_date' => 'setExpirationDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'instrument' => 'getInstrument', + 'side' => 'getSide', + 'type' => 'getType', + 'time_in_force' => 'getTimeInForce', + 'amount' => 'getAmount', + 'limit_price' => 'getLimitPrice', + 'stop_price' => 'getStopPrice', + 'post_only' => 'getPostOnly', + 'expiration_date' => 'getExpirationDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_MARKET = 'MARKET'; + public const TYPE_LIMIT = 'LIMIT'; + public const TYPE_STOP_LOSS_MARKET = 'STOP_LOSS_MARKET'; + public const TYPE_STOP_LOSS_LIMIT = 'STOP_LOSS_LIMIT'; + public const TYPE_TAKE_PROFIT_MARKET = 'TAKE_PROFIT_MARKET'; + public const TYPE_TAKE_PROFIT_LIMIT = 'TAKE_PROFIT_LIMIT'; + public const TIME_IN_FORCE_GTC = 'GTC'; + public const TIME_IN_FORCE_FOK = 'FOK'; + public const TIME_IN_FORCE_IOC = 'IOC'; + public const TIME_IN_FORCE_GTD = 'GTD'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_MARKET, + self::TYPE_LIMIT, + self::TYPE_STOP_LOSS_MARKET, + self::TYPE_STOP_LOSS_LIMIT, + self::TYPE_TAKE_PROFIT_MARKET, + self::TYPE_TAKE_PROFIT_LIMIT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTimeInForceAllowableValues() + { + return [ + self::TIME_IN_FORCE_GTC, + self::TIME_IN_FORCE_FOK, + self::TIME_IN_FORCE_IOC, + self::TIME_IN_FORCE_GTD, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('instrument', $data ?? [], null); + $this->setIfExists('side', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('time_in_force', $data ?? [], null); + $this->setIfExists('amount', $data ?? [], null); + $this->setIfExists('limit_price', $data ?? [], null); + $this->setIfExists('stop_price', $data ?? [], null); + $this->setIfExists('post_only', $data ?? [], null); + $this->setIfExists('expiration_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['instrument'] === null) { + $invalidProperties[] = "'instrument' can't be null"; + } + if ($this->container['side'] === null) { + $invalidProperties[] = "'side' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['time_in_force'] === null) { + $invalidProperties[] = "'time_in_force' can't be null"; + } + $allowedValues = $this->getTimeInForceAllowableValues(); + if (!is_null($this->container['time_in_force']) && !in_array($this->container['time_in_force'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'time_in_force', must be one of '%s'", + $this->container['time_in_force'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['amount'] === null) { + $invalidProperties[] = "'amount' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets instrument + * + * @return \SnapTrade\Model\CryptoTradingInstrument + */ + public function getInstrument() + { + return $this->container['instrument']; + } + + /** + * Sets instrument + * + * @param \SnapTrade\Model\CryptoTradingInstrument $instrument instrument + * + * @return self + */ + public function setInstrument($instrument) + { + + if (is_null($instrument)) { + throw new \InvalidArgumentException('non-nullable instrument cannot be null'); + } + + $this->container['instrument'] = $instrument; + + return $this; + } + + /** + * Gets side + * + * @return \SnapTrade\Model\ActionStrict + */ + public function getSide() + { + return $this->container['side']; + } + + /** + * Sets side + * + * @param \SnapTrade\Model\ActionStrict $side side + * + * @return self + */ + public function setSide($side) + { + + if (is_null($side)) { + throw new \InvalidArgumentException('non-nullable side cannot be null'); + } + + $this->container['side'] = $side; + + return $this; + } + + /** + * Gets type + * + * @return string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type The type of order to place. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets time_in_force + * + * @return string + */ + public function getTimeInForce() + { + return $this->container['time_in_force']; + } + + /** + * Sets time_in_force + * + * @param string $time_in_force The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. + * + * @return self + */ + public function setTimeInForce($time_in_force) + { + $allowedValues = $this->getTimeInForceAllowableValues(); + if (!in_array($time_in_force, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'time_in_force', must be one of '%s'", + $time_in_force, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($time_in_force)) { + throw new \InvalidArgumentException('non-nullable time_in_force cannot be null'); + } + + $this->container['time_in_force'] = $time_in_force; + + return $this; + } + + /** + * Gets amount + * + * @return float + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param float $amount The amount of the base currency to buy or sell. + * + * @return self + */ + public function setAmount($amount) + { + + if (is_null($amount)) { + throw new \InvalidArgumentException('non-nullable amount cannot be null'); + } + + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets limit_price + * + * @return float|null + */ + public function getLimitPrice() + { + return $this->container['limit_price']; + } + + /** + * Sets limit_price + * + * @param float|null $limit_price The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT. + * + * @return self + */ + public function setLimitPrice($limit_price) + { + + if (is_null($limit_price)) { + throw new \InvalidArgumentException('non-nullable limit_price cannot be null'); + } + + $this->container['limit_price'] = $limit_price; + + return $this; + } + + /** + * Gets stop_price + * + * @return float|null + */ + public function getStopPrice() + { + return $this->container['stop_price']; + } + + /** + * Sets stop_price + * + * @param float|null $stop_price The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT. + * + * @return self + */ + public function setStopPrice($stop_price) + { + + if (is_null($stop_price)) { + throw new \InvalidArgumentException('non-nullable stop_price cannot be null'); + } + + $this->container['stop_price'] = $stop_price; + + return $this; + } + + /** + * Gets post_only + * + * @return bool|null + */ + public function getPostOnly() + { + return $this->container['post_only']; + } + + /** + * Sets post_only + * + * @param bool|null $post_only Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees. + * + * @return self + */ + public function setPostOnly($post_only) + { + + if (is_null($post_only)) { + throw new \InvalidArgumentException('non-nullable post_only cannot be null'); + } + + $this->container['post_only'] = $post_only; + + return $this; + } + + /** + * Gets expiration_date + * + * @return \DateTime|null + */ + public function getExpirationDate() + { + return $this->container['expiration_date']; + } + + /** + * Sets expiration_date + * + * @param \DateTime|null $expiration_date The expiration date of the order. Required if the time_in_force is GTD. + * + * @return self + */ + public function setExpirationDate($expiration_date) + { + + if (is_null($expiration_date)) { + throw new \InvalidArgumentException('non-nullable expiration_date cannot be null'); + } + + $this->container['expiration_date'] = $expiration_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/SimpleOrderPreview.php b/lib/Model/CryptoOrderPreview.php similarity index 95% rename from lib/Model/SimpleOrderPreview.php rename to lib/Model/CryptoOrderPreview.php index 0a43460..5f1163c 100644 --- a/lib/Model/SimpleOrderPreview.php +++ b/lib/Model/CryptoOrderPreview.php @@ -1,6 +1,6 @@ */ -class SimpleOrderPreview implements ModelInterface, ArrayAccess, \JsonSerializable +class CryptoOrderPreview implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -43,7 +43,7 @@ class SimpleOrderPreview implements ModelInterface, ArrayAccess, \JsonSerializab * * @var string */ - protected static $openAPIModelName = 'SimpleOrderPreview'; + protected static $openAPIModelName = 'CryptoOrderPreview'; /** * Array of property to type mappings. Used for (de)serialization @@ -51,7 +51,7 @@ class SimpleOrderPreview implements ModelInterface, ArrayAccess, \JsonSerializab * @var string[] */ protected static $openAPITypes = [ - 'estimated_fee' => '\SnapTrade\Model\SimpleOrderPreviewEstimatedFee' + 'estimated_fee' => '\SnapTrade\Model\CryptoOrderPreviewEstimatedFee' ]; /** @@ -286,7 +286,7 @@ public function valid() /** * Gets estimated_fee * - * @return \SnapTrade\Model\SimpleOrderPreviewEstimatedFee|null + * @return \SnapTrade\Model\CryptoOrderPreviewEstimatedFee|null */ public function getEstimatedFee() { @@ -296,7 +296,7 @@ public function getEstimatedFee() /** * Sets estimated_fee * - * @param \SnapTrade\Model\SimpleOrderPreviewEstimatedFee|null $estimated_fee estimated_fee + * @param \SnapTrade\Model\CryptoOrderPreviewEstimatedFee|null $estimated_fee estimated_fee * * @return self */ diff --git a/lib/Model/SimpleOrderPreviewEstimatedFee.php b/lib/Model/CryptoOrderPreviewEstimatedFee.php similarity index 97% rename from lib/Model/SimpleOrderPreviewEstimatedFee.php rename to lib/Model/CryptoOrderPreviewEstimatedFee.php index a3c8976..cc6da26 100644 --- a/lib/Model/SimpleOrderPreviewEstimatedFee.php +++ b/lib/Model/CryptoOrderPreviewEstimatedFee.php @@ -1,6 +1,6 @@ */ -class SimpleOrderPreviewEstimatedFee implements ModelInterface, ArrayAccess, \JsonSerializable +class CryptoOrderPreviewEstimatedFee implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -43,7 +43,7 @@ class SimpleOrderPreviewEstimatedFee implements ModelInterface, ArrayAccess, \Js * * @var string */ - protected static $openAPIModelName = 'SimpleOrderPreview_estimated_fee'; + protected static $openAPIModelName = 'CryptoOrderPreview_estimated_fee'; /** * Array of property to type mappings. Used for (de)serialization diff --git a/lib/Model/CryptoTradingInstrument.php b/lib/Model/CryptoTradingInstrument.php new file mode 100644 index 0000000..6d00bb9 --- /dev/null +++ b/lib/Model/CryptoTradingInstrument.php @@ -0,0 +1,480 @@ + + */ +class CryptoTradingInstrument implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CryptoTradingInstrument'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'symbol' => 'string', + 'type' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'symbol' => null, + 'type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'symbol' => false, + 'type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'symbol' => 'symbol', + 'type' => 'type' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'symbol' => 'setSymbol', + 'type' => 'setType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'symbol' => 'getSymbol', + 'type' => 'getType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_CRYPTOCURRENCY = 'CRYPTOCURRENCY'; + public const TYPE_CRYPTOCURRENCY_PAIR = 'CRYPTOCURRENCY_PAIR'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_CRYPTOCURRENCY, + self::TYPE_CRYPTOCURRENCY_PAIR, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['symbol'] === null) { + $invalidProperties[] = "'symbol' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets symbol + * + * @return string + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string $symbol The instrument's trading ticker symbol + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets type + * + * @return string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type The instrument's type + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + + $this->container['type'] = $type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/ManualTradeReplaceForm.php b/lib/Model/ManualTradeReplaceForm.php index 4abbd52..7c20009 100644 --- a/lib/Model/ManualTradeReplaceForm.php +++ b/lib/Model/ManualTradeReplaceForm.php @@ -30,7 +30,7 @@ * ManualTradeReplaceForm Class Doc Comment * * @category Class - * @description Inputs for placing an order with the brokerage. + * @description Inputs for replacing an order with the brokerage. * @package SnapTrade * @implements \ArrayAccess */ @@ -51,6 +51,7 @@ class ManualTradeReplaceForm implements ModelInterface, ArrayAccess, \JsonSerial * @var string[] */ protected static $openAPITypes = [ + 'brokerage_order_id' => 'string', 'action' => '\SnapTrade\Model\ActionStrict', 'order_type' => '\SnapTrade\Model\OrderTypeStrict', 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', @@ -68,6 +69,7 @@ class ManualTradeReplaceForm implements ModelInterface, ArrayAccess, \JsonSerial * @psalm-var array */ protected static $openAPIFormats = [ + 'brokerage_order_id' => null, 'action' => null, 'order_type' => null, 'time_in_force' => null, @@ -83,7 +85,8 @@ class ManualTradeReplaceForm implements ModelInterface, ArrayAccess, \JsonSerial * @var boolean[] */ protected static array $openAPINullables = [ - 'action' => false, + 'brokerage_order_id' => false, + 'action' => false, 'order_type' => false, 'time_in_force' => false, 'price' => true, @@ -178,6 +181,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ + 'brokerage_order_id' => 'brokerage_order_id', 'action' => 'action', 'order_type' => 'order_type', 'time_in_force' => 'time_in_force', @@ -193,6 +197,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ + 'brokerage_order_id' => 'setBrokerageOrderId', 'action' => 'setAction', 'order_type' => 'setOrderType', 'time_in_force' => 'setTimeInForce', @@ -208,6 +213,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ + 'brokerage_order_id' => 'getBrokerageOrderId', 'action' => 'getAction', 'order_type' => 'getOrderType', 'time_in_force' => 'getTimeInForce', @@ -274,6 +280,7 @@ public function getModelName() */ public function __construct(array $data = null) { + $this->setIfExists('brokerage_order_id', $data ?? [], null); $this->setIfExists('action', $data ?? [], null); $this->setIfExists('order_type', $data ?? [], null); $this->setIfExists('time_in_force', $data ?? [], null); @@ -310,6 +317,9 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['brokerage_order_id'] === null) { + $invalidProperties[] = "'brokerage_order_id' can't be null"; + } if ($this->container['action'] === null) { $invalidProperties[] = "'action' can't be null"; } @@ -334,6 +344,35 @@ public function valid() } + /** + * Gets brokerage_order_id + * + * @return string + */ + public function getBrokerageOrderId() + { + return $this->container['brokerage_order_id']; + } + + /** + * Sets brokerage_order_id + * + * @param string $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + * + * @return self + */ + public function setBrokerageOrderId($brokerage_order_id) + { + + if (is_null($brokerage_order_id)) { + throw new \InvalidArgumentException('non-nullable brokerage_order_id cannot be null'); + } + + $this->container['brokerage_order_id'] = $brokerage_order_id; + + return $this; + } + /** * Gets action * diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 7ddf0d5..8cd6723 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -131,60 +131,60 @@ public function testPlaceBracketOrder() } /** - * Test case for placeForceOrder + * Test case for placeCryptoOrder * - * Place equity order. + * Place crypto order. * */ - public function testPlaceForceOrder() + public function testPlaceCryptoOrder() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test case for placeMlegOrder + * Test case for placeForceOrder * - * Place option order. + * Place equity order. * */ - public function testPlaceMlegOrder() + public function testPlaceForceOrder() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test case for placeOrder + * Test case for placeMlegOrder * - * Place checked equity order. + * Place option order. * */ - public function testPlaceOrder() + public function testPlaceMlegOrder() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test case for placeSimpleOrder + * Test case for placeOrder * - * Place crypto order. + * Place checked equity order. * */ - public function testPlaceSimpleOrder() + public function testPlaceOrder() { // TODO: implement $this->markTestIncomplete('Not implemented'); } /** - * Test case for previewSimpleOrder + * Test case for previewCryptoOrder * * Preview crypto order. * */ - public function testPreviewSimpleOrder() + public function testPreviewCryptoOrder() { // TODO: implement $this->markTestIncomplete('Not implemented'); diff --git a/test/Model/CryptoOrderFormTest.php b/test/Model/CryptoOrderFormTest.php new file mode 100644 index 0000000..c898423 --- /dev/null +++ b/test/Model/CryptoOrderFormTest.php @@ -0,0 +1,155 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "instrument" + */ + public function testPropertyInstrument() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "side" + */ + public function testPropertySide() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "time_in_force" + */ + public function testPropertyTimeInForce() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "amount" + */ + public function testPropertyAmount() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "limit_price" + */ + public function testPropertyLimitPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop_price" + */ + public function testPropertyStopPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "post_only" + */ + public function testPropertyPostOnly() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "expiration_date" + */ + public function testPropertyExpirationDate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/SimpleOrderPreviewEstimatedFeeTest.php b/test/Model/CryptoOrderPreviewEstimatedFeeTest.php similarity index 85% rename from test/Model/SimpleOrderPreviewEstimatedFeeTest.php rename to test/Model/CryptoOrderPreviewEstimatedFeeTest.php index e59b41e..9ce792f 100644 --- a/test/Model/SimpleOrderPreviewEstimatedFeeTest.php +++ b/test/Model/CryptoOrderPreviewEstimatedFeeTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); diff --git a/test/Model/SimpleOrderPreviewTest.php b/test/Model/CryptoOrderPreviewTest.php similarity index 86% rename from test/Model/SimpleOrderPreviewTest.php rename to test/Model/CryptoOrderPreviewTest.php index d31075b..059e62a 100644 --- a/test/Model/SimpleOrderPreviewTest.php +++ b/test/Model/CryptoOrderPreviewTest.php @@ -1,6 +1,6 @@ markTestIncomplete('Not implemented'); diff --git a/test/Model/CryptoTradingInstrumentTest.php b/test/Model/CryptoTradingInstrumentTest.php new file mode 100644 index 0000000..8ab63f8 --- /dev/null +++ b/test/Model/CryptoTradingInstrumentTest.php @@ -0,0 +1,92 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/ManualTradeReplaceFormTest.php b/test/Model/ManualTradeReplaceFormTest.php index 6be5c5c..4b12b96 100644 --- a/test/Model/ManualTradeReplaceFormTest.php +++ b/test/Model/ManualTradeReplaceFormTest.php @@ -29,7 +29,7 @@ * ManualTradeReplaceFormTest Class Doc Comment * * @category Class - * @description Inputs for placing an order with the brokerage. + * @description Inputs for replacing an order with the brokerage. * @package SnapTrade */ class ManualTradeReplaceFormTest extends TestCase @@ -72,6 +72,15 @@ public function testManualTradeReplaceForm() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "brokerage_order_id" + */ + public function testPropertyBrokerageOrderId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "action" */ From 123f5ad935b12da36ba0bd247e2f7f01c44e6b85 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 5 Aug 2025 12:14:56 +0000 Subject: [PATCH 167/252] Version Bump SDKs (#194) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 81b7f05..d2ff8de 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -9db79232-713b-4fbd-8cf3-73bd6f8611cf \ No newline at end of file +be11e27a-e933-4880-838f-a6adc1d1bf2e \ No newline at end of file diff --git a/README.md b/README.md index dd667d9..35b24f2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.118-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.119-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.118" + "konfig/snaptrade-php-sdk": "2.0.119" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 783aeb0..19ec93c 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.118/PHP'; + protected $userAgent = 'Konfig/2.0.119/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.118' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.119' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 4b03dd6fccb7d9c7faa22a6cdb5a1ebfb534aa47 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 8 Aug 2025 20:45:18 +0000 Subject: [PATCH 168/252] Regenerate SDKs (#195) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Model/ManualTradeFormWithOptions.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index d2ff8de..4b0c5dc 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -be11e27a-e933-4880-838f-a6adc1d1bf2e \ No newline at end of file +551fd271-f78b-46d0-aa0a-2755a246db31 \ No newline at end of file diff --git a/README.md b/README.md index 35b24f2..6072503 100644 --- a/README.md +++ b/README.md @@ -2157,7 +2157,7 @@ $result = $snaptrade->trading->placeForceOrder( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", - symbol: "AAPL 131124C00240000", + symbol: "AAPL", price: 31.33, stop: 31.33, units: 10.5, @@ -2187,7 +2187,7 @@ The universal symbol ID of the security to trade. Must be 'null' if `symbol` is ##### symbol: `string` -The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example `AAPL 131124C00240000` represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. +The security's trading ticker symbol. If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. ##### price: `float` diff --git a/lib/Model/ManualTradeFormWithOptions.php b/lib/Model/ManualTradeFormWithOptions.php index 24a4b5e..91b1a0d 100644 --- a/lib/Model/ManualTradeFormWithOptions.php +++ b/lib/Model/ManualTradeFormWithOptions.php @@ -465,7 +465,7 @@ public function getSymbol() /** * Sets symbol * - * @param string|null $symbol The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example `AAPL 131124C00240000` represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format). If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. + * @param string|null $symbol The security's trading ticker symbol. If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. * * @return self */ From 64a5be46077fabcbedd8d4bb480447bf2139141c Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 8 Aug 2025 20:49:28 +0000 Subject: [PATCH 169/252] Version Bump SDKs (#196) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 4b0c5dc..483641a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -551fd271-f78b-46d0-aa0a-2755a246db31 \ No newline at end of file +ee85508b-7541-4237-a7dd-69f710e1d233 \ No newline at end of file diff --git a/README.md b/README.md index 6072503..80d918b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.119-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.120-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.119" + "konfig/snaptrade-php-sdk": "2.0.120" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 19ec93c..943bc1b 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.119/PHP'; + protected $userAgent = 'Konfig/2.0.120/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.119' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.120' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 3011fb39adf04aeb0f32cc686f51ab2a1e516270 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 20:02:02 +0000 Subject: [PATCH 170/252] Regenerate SDKs (#197) * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Api/TradingApi.php | 8 ++++---- test/Api/TradingApiTest.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 483641a..1da5fd2 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ee85508b-7541-4237-a7dd-69f710e1d233 \ No newline at end of file +ecb42e89-fd22-4655-8a2b-634a1fdc4e29 \ No newline at end of file diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 515415f..89513ff 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -5465,7 +5465,7 @@ public function previewCryptoOrderRequest($user_id, $user_secret, $account_id, $ /** * Operation replaceOrder * - * Replace equity order + * Replace order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * @@ -5513,7 +5513,7 @@ public function replaceOrder( /** * Operation replaceOrderWithHttpInfo * - * Replace equity order + * Replace order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * @@ -5682,7 +5682,7 @@ public function replaceOrderWithHttpInfo($account_id, $user_id, $user_secret, $m /** * Operation replaceOrderAsync * - * Replace equity order + * Replace order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * @@ -5733,7 +5733,7 @@ function ($response) { /** * Operation replaceOrderAsyncWithHttpInfo * - * Replace equity order + * Replace order * * Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages * diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 8cd6723..cdb63b8 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -193,7 +193,7 @@ public function testPreviewCryptoOrder() /** * Test case for replaceOrder * - * Replace equity order. + * Replace order. * */ public function testReplaceOrder() From 0407696b34c46b0f7ea850211516a53656db1e08 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 20:06:11 +0000 Subject: [PATCH 171/252] Version Bump SDKs (#198) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 1da5fd2..6c8858e 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ecb42e89-fd22-4655-8a2b-634a1fdc4e29 \ No newline at end of file +a373403e-5460-4157-b8b5-a365090ad9d5 \ No newline at end of file diff --git a/README.md b/README.md index 80d918b..d19f32f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.120-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.121-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.120" + "konfig/snaptrade-php-sdk": "2.0.121" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 943bc1b..1674df8 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.120/PHP'; + protected $userAgent = 'Konfig/2.0.121/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.120' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.121' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From c12c997420e6d957625be855581a6a05dd42d63f Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 13:44:52 +0000 Subject: [PATCH 172/252] Regenerate SDKs (#199) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Api/TradingApi.php | 8 +- lib/Model/Position.php | 48 ++- lib/Model/PositionCurrency.php | 477 ++++++++++++++++++++++++++++ test/Api/TradingApiTest.php | 2 +- test/Model/PositionCurrencyTest.php | 101 ++++++ test/Model/PositionTest.php | 9 + 7 files changed, 635 insertions(+), 12 deletions(-) create mode 100644 lib/Model/PositionCurrency.php create mode 100644 test/Model/PositionCurrencyTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 6c8858e..804082d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -a373403e-5460-4157-b8b5-a365090ad9d5 \ No newline at end of file +69db6bc4-2e0a-43bc-b5ad-f9948caafa1b \ No newline at end of file diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 89513ff..d583745 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -3546,7 +3546,7 @@ public function placeCryptoOrderRequest($user_id, $user_secret, $account_id, $cr /** * Operation placeForceOrder * - * Place equity order + * Place order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -3596,7 +3596,7 @@ public function placeForceOrder( /** * Operation placeForceOrderWithHttpInfo * - * Place equity order + * Place order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -3763,7 +3763,7 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad /** * Operation placeForceOrderAsync * - * Place equity order + * Place order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -3816,7 +3816,7 @@ function ($response) { /** * Operation placeForceOrderAsyncWithHttpInfo * - * Place equity order + * Place order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * diff --git a/lib/Model/Position.php b/lib/Model/Position.php index b7363c5..a75fc4f 100644 --- a/lib/Model/Position.php +++ b/lib/Model/Position.php @@ -56,7 +56,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'price' => 'float', 'open_pnl' => 'float', 'average_purchase_price' => 'float', - 'fractional_units' => 'float' + 'fractional_units' => 'float', + 'currency' => '\SnapTrade\Model\PositionCurrency' ]; /** @@ -72,7 +73,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'price' => null, 'open_pnl' => null, 'average_purchase_price' => null, - 'fractional_units' => null + 'fractional_units' => null, + 'currency' => null ]; /** @@ -86,7 +88,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'price' => true, 'open_pnl' => true, 'average_purchase_price' => true, - 'fractional_units' => true + 'fractional_units' => true, + 'currency' => false ]; /** @@ -180,7 +183,8 @@ public function isNullableSetToNull(string $property): bool 'price' => 'price', 'open_pnl' => 'open_pnl', 'average_purchase_price' => 'average_purchase_price', - 'fractional_units' => 'fractional_units' + 'fractional_units' => 'fractional_units', + 'currency' => 'currency' ]; /** @@ -194,7 +198,8 @@ public function isNullableSetToNull(string $property): bool 'price' => 'setPrice', 'open_pnl' => 'setOpenPnl', 'average_purchase_price' => 'setAveragePurchasePrice', - 'fractional_units' => 'setFractionalUnits' + 'fractional_units' => 'setFractionalUnits', + 'currency' => 'setCurrency' ]; /** @@ -208,7 +213,8 @@ public function isNullableSetToNull(string $property): bool 'price' => 'getPrice', 'open_pnl' => 'getOpenPnl', 'average_purchase_price' => 'getAveragePurchasePrice', - 'fractional_units' => 'getFractionalUnits' + 'fractional_units' => 'getFractionalUnits', + 'currency' => 'getCurrency' ]; /** @@ -274,6 +280,7 @@ public function __construct(array $data = null) $this->setIfExists('open_pnl', $data ?? [], null); $this->setIfExists('average_purchase_price', $data ?? [], null); $this->setIfExists('fractional_units', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); } /** @@ -528,6 +535,35 @@ public function setFractionalUnits($fractional_units) return $this; } + + /** + * Gets currency + * + * @return \SnapTrade\Model\PositionCurrency|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \SnapTrade\Model\PositionCurrency|null $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + + $this->container['currency'] = $currency; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/PositionCurrency.php b/lib/Model/PositionCurrency.php new file mode 100644 index 0000000..623bc3a --- /dev/null +++ b/lib/Model/PositionCurrency.php @@ -0,0 +1,477 @@ + + */ +class PositionCurrency implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Position_currency'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'code' => 'string', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'uuid', + 'code' => null, + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'code' => false, + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'code' => 'code', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'code' => 'setCode', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'code' => 'getCode', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('code', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for the currency. This is the UUID used to reference the currency in SnapTrade. + * + * @return self + */ + public function setId($id) + { + + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code The ISO-4217 currency code for the currency. + * + * @return self + */ + public function setCode($code) + { + + if (is_null($code)) { + throw new \InvalidArgumentException('non-nullable code cannot be null'); + } + + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name A human-friendly name of the currency. + * + * @return self + */ + public function setName($name) + { + + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index cdb63b8..0cc29df 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -145,7 +145,7 @@ public function testPlaceCryptoOrder() /** * Test case for placeForceOrder * - * Place equity order. + * Place order. * */ public function testPlaceForceOrder() diff --git a/test/Model/PositionCurrencyTest.php b/test/Model/PositionCurrencyTest.php new file mode 100644 index 0000000..67d515f --- /dev/null +++ b/test/Model/PositionCurrencyTest.php @@ -0,0 +1,101 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "id" + */ + public function testPropertyId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "code" + */ + public function testPropertyCode() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "name" + */ + public function testPropertyName() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/PositionTest.php b/test/Model/PositionTest.php index 535a56f..6d30436 100644 --- a/test/Model/PositionTest.php +++ b/test/Model/PositionTest.php @@ -125,4 +125,13 @@ public function testPropertyFractionalUnits() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "currency" + */ + public function testPropertyCurrency() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } From 27515a0c38484a82dbc96cabfbe07ede30cda42e Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 13:48:58 +0000 Subject: [PATCH 173/252] Version Bump SDKs (#200) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 804082d..99edf69 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -69db6bc4-2e0a-43bc-b5ad-f9948caafa1b \ No newline at end of file +7a1c6159-9797-45fc-8aa5-3c082d8a925a \ No newline at end of file diff --git a/README.md b/README.md index d19f32f..41283f6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.121-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.122-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.121" + "konfig/snaptrade-php-sdk": "2.0.122" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 1674df8..7d3f2bc 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.121/PHP'; + protected $userAgent = 'Konfig/2.0.122/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.121' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.122' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 004a86c7546a53da06dc097800cb0c41e28e9538 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 20 Aug 2025 12:26:19 +0000 Subject: [PATCH 174/252] Regenerate SDKs (#201) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 42 +++ lib/Api/AccountInformationApi.php | 477 +++++++++++++++++++++++++ lib/Model/Account.php | 2 + test/Api/AccountInformationApiTest.php | 12 + 5 files changed, 534 insertions(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 99edf69..da18411 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -7a1c6159-9797-45fc-8aa5-3c082d8a925a \ No newline at end of file +bbc44a74-8c34-4c27-a9f8-632ae69235f5 \ No newline at end of file diff --git a/README.md b/README.md index 41283f6..09950f2 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.accountInformation.getAllUserHoldings`](#snaptradeaccountinformationgetalluserholdings) * [`snaptrade.accountInformation.getUserAccountBalance`](#snaptradeaccountinformationgetuseraccountbalance) * [`snaptrade.accountInformation.getUserAccountDetails`](#snaptradeaccountinformationgetuseraccountdetails) + * [`snaptrade.accountInformation.getUserAccountOrderDetail`](#snaptradeaccountinformationgetuseraccountorderdetail) * [`snaptrade.accountInformation.getUserAccountOrders`](#snaptradeaccountinformationgetuseraccountorders) * [`snaptrade.accountInformation.getUserAccountPositions`](#snaptradeaccountinformationgetuseraccountpositions) * [`snaptrade.accountInformation.getUserAccountRecentOrders`](#snaptradeaccountinformationgetuseraccountrecentorders) @@ -335,6 +336,47 @@ $result = $snaptrade->accountInformation->getUserAccountDetails( --- +### `snaptrade.accountInformation.getUserAccountOrderDetail` + +Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->accountInformation->getUserAccountOrderDetail( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e" +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### brokerage_order_id: `string` + + +#### πŸ”„ Return + +[**AccountOrderRecord**](./lib/Model/AccountOrderRecord.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/orders/{brokerageOrderId}` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.accountInformation.getUserAccountOrders` Returns a list of recent orders in the specified account. diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index ec2084b..68a6c01 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -74,6 +74,9 @@ class AccountInformationApi extends \SnapTrade\CustomApi 'getUserAccountDetails' => [ 'application/json', ], + 'getUserAccountOrderDetail' => [ + 'application/json', + ], 'getUserAccountOrders' => [ 'application/json', ], @@ -1949,6 +1952,480 @@ public function getUserAccountDetailsRequest($user_id, $user_secret, $account_id ]; } + /** + * Operation getUserAccountOrderDetail + * + * Get account order detail + * + * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param string $brokerage_order_id brokerage_order_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetail'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse + */ + public function getUserAccountOrderDetail( + $user_id, + $user_secret, + $account_id, + $brokerage_order_id, + + string $contentType = self::contentTypes['getUserAccountOrderDetail'][0] + ) + { + + list($response) = $this->getUserAccountOrderDetailWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); + return $response; + } + + /** + * Operation getUserAccountOrderDetailWithHttpInfo + * + * Get account order detail + * + * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $brokerage_order_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetail'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getUserAccountOrderDetailWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['getUserAccountOrderDetail'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailRequest($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->getUserAccountOrderDetailWithHttpInfo( + $user_id, + $user_secret, + $account_id, + $brokerage_order_id, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\SnapTrade\Model\Model404FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model404FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model404FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model404FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getUserAccountOrderDetailAsync + * + * Get account order detail + * + * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $brokerage_order_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetail'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountOrderDetailAsync( + $user_id, + $user_secret, + $account_id, + $brokerage_order_id, + + string $contentType = self::contentTypes['getUserAccountOrderDetail'][0] + ) + { + + return $this->getUserAccountOrderDetailAsyncWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getUserAccountOrderDetailAsyncWithHttpInfo + * + * Get account order detail + * + * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $brokerage_order_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetail'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountOrderDetailAsyncWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['getUserAccountOrderDetail'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecord'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailRequest($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getUserAccountOrderDetail' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $brokerage_order_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetail'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getUserAccountOrderDetailRequest($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['getUserAccountOrderDetail'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getUserAccountOrderDetail' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getUserAccountOrderDetail' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getUserAccountOrderDetail' + ); + } + // Check if $brokerage_order_id is a string + if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); + } + // verify the required parameter 'brokerage_order_id' is set + if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter brokerage_order_id when calling getUserAccountOrderDetail' + ); + } + + + $resourcePath = '/accounts/{accountId}/orders/{brokerageOrderId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($brokerage_order_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'brokerageOrderId' . '}', + ObjectSerializer::toPathValue($brokerage_order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + /** * Operation getUserAccountOrders * diff --git a/lib/Model/Account.php b/lib/Model/Account.php index cea088c..b4ee693 100644 --- a/lib/Model/Account.php +++ b/lib/Model/Account.php @@ -297,6 +297,7 @@ public function getModelName() public const STATUS_OPEN = 'open'; public const STATUS_CLOSED = 'closed'; public const STATUS_ARCHIVED = 'archived'; + public const STATUS_UNAVAILABLE = 'unavailable'; /** * Gets allowable values of the enum @@ -309,6 +310,7 @@ public function getStatusAllowableValues() self::STATUS_OPEN, self::STATUS_CLOSED, self::STATUS_ARCHIVED, + self::STATUS_UNAVAILABLE, ]; } diff --git a/test/Api/AccountInformationApiTest.php b/test/Api/AccountInformationApiTest.php index 1e30ea5..c2f46ed 100644 --- a/test/Api/AccountInformationApiTest.php +++ b/test/Api/AccountInformationApiTest.php @@ -106,6 +106,18 @@ public function testGetUserAccountDetails() $this->markTestIncomplete('Not implemented'); } + /** + * Test case for getUserAccountOrderDetail + * + * Get account order detail. + * + */ + public function testGetUserAccountOrderDetail() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for getUserAccountOrders * From 32d23d22eaaa61b92ab1ff23867e4b1f5e76f2bb Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 20 Aug 2025 12:30:13 +0000 Subject: [PATCH 175/252] Version Bump SDKs (#202) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index da18411..cbf7465 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -bbc44a74-8c34-4c27-a9f8-632ae69235f5 \ No newline at end of file +ea895ce1-d5b1-4c4b-8264-21445ccc7369 \ No newline at end of file diff --git a/README.md b/README.md index 09950f2..a49d613 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.122-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.123-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -100,7 +100,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.122" + "konfig/snaptrade-php-sdk": "2.0.123" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 7d3f2bc..d4c7840 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.122/PHP'; + protected $userAgent = 'Konfig/2.0.123/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.122' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.123' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 368ed96dc817e7d6cff80ff2f491b04dd197221d Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 12:06:34 +0000 Subject: [PATCH 176/252] Regenerate SDKs (#203) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 158 -- lib/Api/OptionsApi.php | 1672 ++--------------- lib/Model/OptionsGetOptionStrategyRequest.php | 517 ----- .../OptionsPlaceOptionStrategyRequest.php | 489 ----- test/Api/OptionsApiTest.php | 36 - .../OptionsGetOptionStrategyRequestTest.php | 101 - .../OptionsPlaceOptionStrategyRequestTest.php | 101 - 8 files changed, 126 insertions(+), 2950 deletions(-) delete mode 100644 lib/Model/OptionsGetOptionStrategyRequest.php delete mode 100644 lib/Model/OptionsPlaceOptionStrategyRequest.php delete mode 100644 test/Model/OptionsGetOptionStrategyRequestTest.php delete mode 100644 test/Model/OptionsPlaceOptionStrategyRequestTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index cbf7465..a6fcb61 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ea895ce1-d5b1-4c4b-8264-21445ccc7369 \ No newline at end of file +c78ac1e5-2316-4624-b14e-e8d71ccabbfa \ No newline at end of file diff --git a/README.md b/README.md index a49d613..92c0819 100644 --- a/README.md +++ b/README.md @@ -46,11 +46,8 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.connections.removeBrokerageAuthorization`](#snaptradeconnectionsremovebrokerageauthorization) * [`snaptrade.connections.returnRates`](#snaptradeconnectionsreturnrates) * [`snaptrade.connections.sessionEvents`](#snaptradeconnectionssessionevents) - * [`snaptrade.options.getOptionStrategy`](#snaptradeoptionsgetoptionstrategy) * [`snaptrade.options.getOptionsChain`](#snaptradeoptionsgetoptionschain) - * [`snaptrade.options.getOptionsStrategyQuote`](#snaptradeoptionsgetoptionsstrategyquote) * [`snaptrade.options.listOptionHoldings`](#snaptradeoptionslistoptionholdings) - * [`snaptrade.options.placeOptionStrategy`](#snaptradeoptionsplaceoptionstrategy) * [`snaptrade.referenceData.getCurrencyExchangeRatePair`](#snaptradereferencedatagetcurrencyexchangeratepair) * [`snaptrade.referenceData.getPartnerInfo`](#snaptradereferencedatagetpartnerinfo) * [`snaptrade.referenceData.getSecurityTypes`](#snaptradereferencedatagetsecuritytypes) @@ -1164,61 +1161,6 @@ Optional comma separated list of session IDs used to filter the request on speci --- -### `snaptrade.options.getOptionStrategy` - -Creates an option strategy object that will be used to place an option strategy order. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->options->getOptionStrategy( - underlying_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", - legs: [ - [ - "action" => "BUY_TO_OPEN", - "option_symbol_id" => "SPY220819P00200000", - "quantity" => 1, - ] - ], - strategy_type: "CUSTOM", - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "accountId_example" -); -``` - -#### βš™οΈ Parameters - -##### underlying_symbol_id: `string` - -##### legs: [`OptionLeg`](./lib/Model/OptionLeg.php)[] - -##### strategy_type: `string` - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -The ID of the account to create the option strategy object in. - - -#### πŸ”„ Return - -[**StrategyQuotes**](./lib/Model/StrategyQuotes.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/optionStrategy` `POST` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - ### `snaptrade.options.getOptionsChain` Returns the option chain for the specified symbol in the specified account. @@ -1263,51 +1205,6 @@ Universal symbol ID if symbol --- -### `snaptrade.options.getOptionsStrategyQuote` - -Returns a Strategy Quotes object which has latest market data of the specified option strategy. - - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->options->getOptionsStrategyQuote( - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "accountId_example", - option_strategy_id: "2bcd7cc3-e922-4976-bce1-9858296801c3" -); -``` - -#### βš™οΈ Parameters - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -The ID of the account the strategy will be placed in. - -##### option_strategy_id: `string` - -Option strategy id obtained from response when creating option strategy object - - -#### πŸ”„ Return - -[**StrategyQuotes**](./lib/Model/StrategyQuotes.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/optionStrategy/{optionStrategyId}` `GET` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - ### `snaptrade.options.listOptionHoldings` Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). @@ -1348,61 +1245,6 @@ $result = $snaptrade->options->listOptionHoldings( --- -### `snaptrade.options.placeOptionStrategy` - -Places the option strategy order and returns the order record received from the brokerage. - - -#### πŸ› οΈ Usage - -```php -$result = $snaptrade->options->placeOptionStrategy( - order_type: "Market", - time_in_force: "Day", - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", - option_strategy_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", - price: 31.33 -); -``` - -#### βš™οΈ Parameters - -##### order_type: - -##### time_in_force: - -##### user_id: `string` - -##### user_secret: `string` - -##### account_id: `string` - -The ID of the account to execute the strategy in. - -##### option_strategy_id: `string` - -Option strategy id obtained from response when creating option strategy object - -##### price: `float` - -Trade Price if limit or stop limit order - - -#### πŸ”„ Return - -[**StrategyOrderRecord**](./lib/Model/StrategyOrderRecord.php) - -#### 🌐 Endpoint - -`/accounts/{accountId}/optionStrategy/{optionStrategyId}/execute` `POST` - -[πŸ”™ **Back to Table of Contents**](#table-of-contents) - ---- - - ### `snaptrade.referenceData.getCurrencyExchangeRatePair` Returns an Exchange Rate Pair object for the specified Currency Pair. diff --git a/lib/Api/OptionsApi.php b/lib/Api/OptionsApi.php index 039c278..5238a08 100644 --- a/lib/Api/OptionsApi.php +++ b/lib/Api/OptionsApi.php @@ -62,21 +62,12 @@ class OptionsApi extends \SnapTrade\CustomApi /** @var string[] $contentTypes **/ public const contentTypes = [ - 'getOptionStrategy' => [ - 'application/json', - ], 'getOptionsChain' => [ 'application/json', ], - 'getOptionsStrategyQuote' => [ - 'application/json', - ], 'listOptionHoldings' => [ 'application/json', ], - 'placeOptionStrategy' => [ - 'application/json', - ], ]; /** @@ -148,66 +139,59 @@ private function setRequestBodyProperty(&$body, $property, $value) { } /** - * Operation getOptionStrategy + * Operation getOptionsChain * - * Create options strategy + * Get the options chain for a symbol * - * Creates an option strategy object that will be used to place an option strategy order. + * Returns the option chain for the specified symbol in the specified account. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id The ID of the account to create the option strategy object in. (required) - * @param \SnapTrade\Model\OptionsGetOptionStrategyRequest $options_get_option_strategy_request options_get_option_strategy_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionStrategy'] to see the possible values for this operation + * @param string $account_id The ID of the account to get the options chain from. (required) + * @param string $symbol Universal symbol ID if symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsChain'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\StrategyQuotes|\SnapTrade\Model\Model500UnexpectedExceptionResponse + * @return \SnapTrade\Model\OptionChainInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse */ - public function getOptionStrategy( - - $underlying_symbol_id, - $legs, - $strategy_type, + public function getOptionsChain( $user_id, $user_secret, $account_id, - string $contentType = self::contentTypes['getOptionStrategy'][0] + $symbol, + + string $contentType = self::contentTypes['getOptionsChain'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "underlying_symbol_id", $underlying_symbol_id); - $this->setRequestBodyProperty($_body, "legs", $legs); - $this->setRequestBodyProperty($_body, "strategy_type", $strategy_type); - $options_get_option_strategy_request = $_body; - list($response) = $this->getOptionStrategyWithHttpInfo($user_id, $user_secret, $account_id, $options_get_option_strategy_request, $contentType); + list($response) = $this->getOptionsChainWithHttpInfo($user_id, $user_secret, $account_id, $symbol, $contentType); return $response; } /** - * Operation getOptionStrategyWithHttpInfo + * Operation getOptionsChainWithHttpInfo * - * Create options strategy + * Get the options chain for a symbol * - * Creates an option strategy object that will be used to place an option strategy order. + * Returns the option chain for the specified symbol in the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to create the option strategy object in. (required) - * @param \SnapTrade\Model\OptionsGetOptionStrategyRequest $options_get_option_strategy_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionStrategy'] to see the possible values for this operation + * @param string $account_id The ID of the account to get the options chain from. (required) + * @param string $symbol Universal symbol ID if symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsChain'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\StrategyQuotes|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\OptionChainInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getOptionStrategyWithHttpInfo($user_id, $user_secret, $account_id, $options_get_option_strategy_request, string $contentType = self::contentTypes['getOptionStrategy'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getOptionsChainWithHttpInfo($user_id, $user_secret, $account_id, $symbol, string $contentType = self::contentTypes['getOptionsChain'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOptionStrategyRequest($user_id, $user_secret, $account_id, $options_get_option_strategy_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getOptionsChainRequest($user_id, $user_secret, $account_id, $symbol, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); try { $options = $this->createHttpClientOption(); @@ -219,11 +203,11 @@ public function getOptionStrategyWithHttpInfo($user_id, $user_secret, $account_i !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->getOptionStrategyWithHttpInfo( + return $this->getOptionsChainWithHttpInfo( $user_id, $user_secret, $account_id, - $options_get_option_strategy_request, + $symbol, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -261,17 +245,17 @@ public function getOptionStrategyWithHttpInfo($user_id, $user_secret, $account_i switch($statusCode) { case 200: - if ('\SnapTrade\Model\StrategyQuotes' === '\SplFileObject') { + if ('\SnapTrade\Model\OptionChainInner[]' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\StrategyQuotes' !== 'string') { + if ('\SnapTrade\Model\OptionChainInner[]' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\StrategyQuotes', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\OptionChainInner[]', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -292,7 +276,7 @@ public function getOptionStrategyWithHttpInfo($user_id, $user_secret, $account_i ]; } - $returnType = '\SnapTrade\Model\StrategyQuotes'; + $returnType = '\SnapTrade\Model\OptionChainInner[]'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -313,7 +297,7 @@ public function getOptionStrategyWithHttpInfo($user_id, $user_secret, $account_i case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\StrategyQuotes', + '\SnapTrade\Model\OptionChainInner[]', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -332,39 +316,32 @@ public function getOptionStrategyWithHttpInfo($user_id, $user_secret, $account_i } /** - * Operation getOptionStrategyAsync + * Operation getOptionsChainAsync * - * Create options strategy + * Get the options chain for a symbol * - * Creates an option strategy object that will be used to place an option strategy order. + * Returns the option chain for the specified symbol in the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to create the option strategy object in. (required) - * @param \SnapTrade\Model\OptionsGetOptionStrategyRequest $options_get_option_strategy_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionStrategy'] to see the possible values for this operation + * @param string $account_id The ID of the account to get the options chain from. (required) + * @param string $symbol Universal symbol ID if symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsChain'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOptionStrategyAsync( - - $underlying_symbol_id, - $legs, - $strategy_type, + public function getOptionsChainAsync( $user_id, $user_secret, $account_id, - string $contentType = self::contentTypes['getOptionStrategy'][0] + $symbol, + + string $contentType = self::contentTypes['getOptionsChain'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "underlying_symbol_id", $underlying_symbol_id); - $this->setRequestBodyProperty($_body, "legs", $legs); - $this->setRequestBodyProperty($_body, "strategy_type", $strategy_type); - $options_get_option_strategy_request = $_body; - return $this->getOptionStrategyAsyncWithHttpInfo($user_id, $user_secret, $account_id, $options_get_option_strategy_request, $contentType) + return $this->getOptionsChainAsyncWithHttpInfo($user_id, $user_secret, $account_id, $symbol, $contentType) ->then( function ($response) { return $response[0]; @@ -373,28 +350,28 @@ function ($response) { } /** - * Operation getOptionStrategyAsyncWithHttpInfo + * Operation getOptionsChainAsyncWithHttpInfo * - * Create options strategy + * Get the options chain for a symbol * - * Creates an option strategy object that will be used to place an option strategy order. + * Returns the option chain for the specified symbol in the specified account. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to create the option strategy object in. (required) - * @param \SnapTrade\Model\OptionsGetOptionStrategyRequest $options_get_option_strategy_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionStrategy'] to see the possible values for this operation + * @param string $account_id The ID of the account to get the options chain from. (required) + * @param string $symbol Universal symbol ID if symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsChain'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOptionStrategyAsyncWithHttpInfo($user_id, $user_secret, $account_id, $options_get_option_strategy_request, string $contentType = self::contentTypes['getOptionStrategy'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getOptionsChainAsyncWithHttpInfo($user_id, $user_secret, $account_id, $symbol, string $contentType = self::contentTypes['getOptionsChain'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\StrategyQuotes'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOptionStrategyRequest($user_id, $user_secret, $account_id, $options_get_option_strategy_request, $contentType); + $returnType = '\SnapTrade\Model\OptionChainInner[]'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getOptionsChainRequest($user_id, $user_secret, $account_id, $symbol, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -433,18 +410,18 @@ function ($exception) { } /** - * Create request for operation 'getOptionStrategy' + * Create request for operation 'getOptionsChain' * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to create the option strategy object in. (required) - * @param \SnapTrade\Model\OptionsGetOptionStrategyRequest $options_get_option_strategy_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionStrategy'] to see the possible values for this operation + * @param string $account_id The ID of the account to get the options chain from. (required) + * @param string $symbol Universal symbol ID if symbol (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsChain'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getOptionStrategyRequest($user_id, $user_secret, $account_id, $options_get_option_strategy_request, string $contentType = self::contentTypes['getOptionStrategy'][0]) + public function getOptionsChainRequest($user_id, $user_secret, $account_id, $symbol, string $contentType = self::contentTypes['getOptionsChain'][0]) { // Check if $user_id is a string @@ -454,7 +431,7 @@ public function getOptionStrategyRequest($user_id, $user_secret, $account_id, $o // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getOptionStrategy' + 'Missing the required parameter user_id when calling getOptionsChain' ); } // Check if $user_secret is a string @@ -464,7 +441,7 @@ public function getOptionStrategyRequest($user_id, $user_secret, $account_id, $o // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getOptionStrategy' + 'Missing the required parameter user_secret when calling getOptionsChain' ); } // Check if $account_id is a string @@ -474,26 +451,22 @@ public function getOptionStrategyRequest($user_id, $user_secret, $account_id, $o // verify the required parameter 'account_id' is set if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling getOptionStrategy' + 'Missing the required parameter account_id when calling getOptionsChain' ); } - if ($options_get_option_strategy_request !== SENTINEL_VALUE) { - if (!($options_get_option_strategy_request instanceof \SnapTrade\Model\OptionsGetOptionStrategyRequest)) { - if (!is_array($options_get_option_strategy_request)) - throw new \InvalidArgumentException('"options_get_option_strategy_request" must be associative array or an instance of \SnapTrade\Model\OptionsGetOptionStrategyRequest OptionsApi.getOptionStrategy.'); - else - $options_get_option_strategy_request = new \SnapTrade\Model\OptionsGetOptionStrategyRequest($options_get_option_strategy_request); - } + // Check if $symbol is a string + if ($symbol !== SENTINEL_VALUE && !is_string($symbol)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($symbol, true), gettype($symbol))); } - // verify the required parameter 'options_get_option_strategy_request' is set - if ($options_get_option_strategy_request === SENTINEL_VALUE || (is_array($options_get_option_strategy_request) && count($options_get_option_strategy_request) === 0)) { + // verify the required parameter 'symbol' is set + if ($symbol === SENTINEL_VALUE || (is_array($symbol) && count($symbol) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter options_get_option_strategy_request when calling getOptionStrategy' + 'Missing the required parameter symbol when calling getOptionsChain' ); } - $resourcePath = '/accounts/{accountId}/optionStrategy'; + $resourcePath = '/accounts/{accountId}/optionsChain'; $formParams = []; $queryParams = []; $headerParams = []; @@ -522,6 +495,17 @@ public function getOptionStrategyRequest($user_id, $user_secret, $account_id, $o true // required ) ?? []); } + if ($symbol !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $symbol, + 'symbol', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } // path params @@ -541,14 +525,7 @@ public function getOptionStrategyRequest($user_id, $user_secret, $account_id, $o ); // for model (json/xml) - if (isset($options_get_option_strategy_request)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($options_get_option_strategy_request)); - } else { - $httpBody = $options_get_option_strategy_request; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -599,7 +576,7 @@ public function getOptionStrategyRequest($user_id, $user_secret, $account_id, $o $headers ); - $method = 'POST'; + $method = 'GET'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); @@ -616,56 +593,53 @@ public function getOptionStrategyRequest($user_id, $user_secret, $account_id, $o } /** - * Operation getOptionsChain + * Operation listOptionHoldings * - * Get the options chain for a symbol + * List account option positions * - * Returns the option chain for the specified symbol in the specified account. + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id The ID of the account to get the options chain from. (required) - * @param string $symbol Universal symbol ID if symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsChain'] to see the possible values for this operation + * @param string $account_id account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listOptionHoldings'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\OptionChainInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse + * @return \SnapTrade\Model\OptionsPosition[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse */ - public function getOptionsChain( + public function listOptionHoldings( $user_id, $user_secret, $account_id, - $symbol, - string $contentType = self::contentTypes['getOptionsChain'][0] + string $contentType = self::contentTypes['listOptionHoldings'][0] ) { - list($response) = $this->getOptionsChainWithHttpInfo($user_id, $user_secret, $account_id, $symbol, $contentType); + list($response) = $this->listOptionHoldingsWithHttpInfo($user_id, $user_secret, $account_id, $contentType); return $response; } /** - * Operation getOptionsChainWithHttpInfo + * Operation listOptionHoldingsWithHttpInfo * - * Get the options chain for a symbol + * List account option positions * - * Returns the option chain for the specified symbol in the specified account. + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to get the options chain from. (required) - * @param string $symbol Universal symbol ID if symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsChain'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listOptionHoldings'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\OptionChainInner[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\OptionsPosition[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getOptionsChainWithHttpInfo($user_id, $user_secret, $account_id, $symbol, string $contentType = self::contentTypes['getOptionsChain'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function listOptionHoldingsWithHttpInfo($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['listOptionHoldings'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOptionsChainRequest($user_id, $user_secret, $account_id, $symbol, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->listOptionHoldingsRequest($user_id, $user_secret, $account_id, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config); @@ -680,11 +654,10 @@ public function getOptionsChainWithHttpInfo($user_id, $user_secret, $account_id, !empty($this->getConfig()->getAccessToken()) && $requestOptions->shouldRetryOAuth() ) { - return $this->getOptionsChainWithHttpInfo( + return $this->listOptionHoldingsWithHttpInfo( $user_id, $user_secret, $account_id, - $symbol, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -722,17 +695,17 @@ public function getOptionsChainWithHttpInfo($user_id, $user_secret, $account_id, switch($statusCode) { case 200: - if ('\SnapTrade\Model\OptionChainInner[]' === '\SplFileObject') { + if ('\SnapTrade\Model\OptionsPosition[]' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\SnapTrade\Model\OptionChainInner[]' !== 'string') { + if ('\SnapTrade\Model\OptionsPosition[]' !== 'string') { $content = json_decode($content); } } return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\OptionChainInner[]', []), + ObjectSerializer::deserialize($content, '\SnapTrade\Model\OptionsPosition[]', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -753,7 +726,7 @@ public function getOptionsChainWithHttpInfo($user_id, $user_secret, $account_id, ]; } - $returnType = '\SnapTrade\Model\OptionChainInner[]'; + $returnType = '\SnapTrade\Model\OptionsPosition[]'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -774,7 +747,7 @@ public function getOptionsChainWithHttpInfo($user_id, $user_secret, $account_id, case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\SnapTrade\Model\OptionChainInner[]', + '\SnapTrade\Model\OptionsPosition[]', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -793,32 +766,30 @@ public function getOptionsChainWithHttpInfo($user_id, $user_secret, $account_id, } /** - * Operation getOptionsChainAsync + * Operation listOptionHoldingsAsync * - * Get the options chain for a symbol + * List account option positions * - * Returns the option chain for the specified symbol in the specified account. + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to get the options chain from. (required) - * @param string $symbol Universal symbol ID if symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsChain'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listOptionHoldings'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOptionsChainAsync( + public function listOptionHoldingsAsync( $user_id, $user_secret, $account_id, - $symbol, - string $contentType = self::contentTypes['getOptionsChain'][0] + string $contentType = self::contentTypes['listOptionHoldings'][0] ) { - return $this->getOptionsChainAsyncWithHttpInfo($user_id, $user_secret, $account_id, $symbol, $contentType) + return $this->listOptionHoldingsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $contentType) ->then( function ($response) { return $response[0]; @@ -827,25 +798,24 @@ function ($response) { } /** - * Operation getOptionsChainAsyncWithHttpInfo + * Operation listOptionHoldingsAsyncWithHttpInfo * - * Get the options chain for a symbol + * List account option positions * - * Returns the option chain for the specified symbol in the specified account. + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to get the options chain from. (required) - * @param string $symbol Universal symbol ID if symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsChain'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listOptionHoldings'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOptionsChainAsyncWithHttpInfo($user_id, $user_secret, $account_id, $symbol, string $contentType = self::contentTypes['getOptionsChain'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function listOptionHoldingsAsyncWithHttpInfo($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['listOptionHoldings'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - $returnType = '\SnapTrade\Model\OptionChainInner[]'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOptionsChainRequest($user_id, $user_secret, $account_id, $symbol, $contentType); + $returnType = '\SnapTrade\Model\OptionsPosition[]'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->listOptionHoldingsRequest($user_id, $user_secret, $account_id, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config); @@ -887,18 +857,17 @@ function ($exception) { } /** - * Create request for operation 'getOptionsChain' + * Create request for operation 'listOptionHoldings' * * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id The ID of the account to get the options chain from. (required) - * @param string $symbol Universal symbol ID if symbol (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsChain'] to see the possible values for this operation + * @param string $account_id (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listOptionHoldings'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getOptionsChainRequest($user_id, $user_secret, $account_id, $symbol, string $contentType = self::contentTypes['getOptionsChain'][0]) + public function listOptionHoldingsRequest($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['listOptionHoldings'][0]) { // Check if $user_id is a string @@ -908,7 +877,7 @@ public function getOptionsChainRequest($user_id, $user_secret, $account_id, $sym // verify the required parameter 'user_id' is set if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getOptionsChain' + 'Missing the required parameter user_id when calling listOptionHoldings' ); } // Check if $user_secret is a string @@ -918,7 +887,7 @@ public function getOptionsChainRequest($user_id, $user_secret, $account_id, $sym // verify the required parameter 'user_secret' is set if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getOptionsChain' + 'Missing the required parameter user_secret when calling listOptionHoldings' ); } // Check if $account_id is a string @@ -928,22 +897,12 @@ public function getOptionsChainRequest($user_id, $user_secret, $account_id, $sym // verify the required parameter 'account_id' is set if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling getOptionsChain' - ); - } - // Check if $symbol is a string - if ($symbol !== SENTINEL_VALUE && !is_string($symbol)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($symbol, true), gettype($symbol))); - } - // verify the required parameter 'symbol' is set - if ($symbol === SENTINEL_VALUE || (is_array($symbol) && count($symbol) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter symbol when calling getOptionsChain' + 'Missing the required parameter account_id when calling listOptionHoldings' ); } - $resourcePath = '/accounts/{accountId}/optionsChain'; + $resourcePath = '/accounts/{accountId}/options'; $formParams = []; $queryParams = []; $headerParams = []; @@ -972,17 +931,6 @@ public function getOptionsChainRequest($user_id, $user_secret, $account_id, $sym true // required ) ?? []); } - if ($symbol !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $symbol, - 'symbol', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } // path params @@ -1069,1376 +1017,6 @@ public function getOptionsChainRequest($user_id, $user_secret, $account_id, $sym ]; } - /** - * Operation getOptionsStrategyQuote - * - * Get options strategy quotes - * - * Returns a Strategy Quotes object which has latest market data of the specified option strategy. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id The ID of the account the strategy will be placed in. (required) - * @param string $option_strategy_id Option strategy id obtained from response when creating option strategy object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsStrategyQuote'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\StrategyQuotes|\SnapTrade\Model\Model500UnexpectedExceptionResponse - */ - public function getOptionsStrategyQuote( - $user_id, - $user_secret, - $account_id, - $option_strategy_id, - - string $contentType = self::contentTypes['getOptionsStrategyQuote'][0] - ) - { - - list($response) = $this->getOptionsStrategyQuoteWithHttpInfo($user_id, $user_secret, $account_id, $option_strategy_id, $contentType); - return $response; - } - - /** - * Operation getOptionsStrategyQuoteWithHttpInfo - * - * Get options strategy quotes - * - * Returns a Strategy Quotes object which has latest market data of the specified option strategy. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id The ID of the account the strategy will be placed in. (required) - * @param string $option_strategy_id Option strategy id obtained from response when creating option strategy object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsStrategyQuote'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\StrategyQuotes|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function getOptionsStrategyQuoteWithHttpInfo($user_id, $user_secret, $account_id, $option_strategy_id, string $contentType = self::contentTypes['getOptionsStrategyQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOptionsStrategyQuoteRequest($user_id, $user_secret, $account_id, $option_strategy_id, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->getOptionsStrategyQuoteWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $option_strategy_id, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\StrategyQuotes' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\StrategyQuotes' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\StrategyQuotes', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 500: - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\StrategyQuotes'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\StrategyQuotes', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 500: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model500UnexpectedExceptionResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getOptionsStrategyQuoteAsync - * - * Get options strategy quotes - * - * Returns a Strategy Quotes object which has latest market data of the specified option strategy. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id The ID of the account the strategy will be placed in. (required) - * @param string $option_strategy_id Option strategy id obtained from response when creating option strategy object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsStrategyQuote'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getOptionsStrategyQuoteAsync( - $user_id, - $user_secret, - $account_id, - $option_strategy_id, - - string $contentType = self::contentTypes['getOptionsStrategyQuote'][0] - ) - { - - return $this->getOptionsStrategyQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $option_strategy_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getOptionsStrategyQuoteAsyncWithHttpInfo - * - * Get options strategy quotes - * - * Returns a Strategy Quotes object which has latest market data of the specified option strategy. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id The ID of the account the strategy will be placed in. (required) - * @param string $option_strategy_id Option strategy id obtained from response when creating option strategy object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsStrategyQuote'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getOptionsStrategyQuoteAsyncWithHttpInfo($user_id, $user_secret, $account_id, $option_strategy_id, string $contentType = self::contentTypes['getOptionsStrategyQuote'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\StrategyQuotes'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getOptionsStrategyQuoteRequest($user_id, $user_secret, $account_id, $option_strategy_id, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'getOptionsStrategyQuote' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id The ID of the account the strategy will be placed in. (required) - * @param string $option_strategy_id Option strategy id obtained from response when creating option strategy object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOptionsStrategyQuote'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getOptionsStrategyQuoteRequest($user_id, $user_secret, $account_id, $option_strategy_id, string $contentType = self::contentTypes['getOptionsStrategyQuote'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling getOptionsStrategyQuote' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling getOptionsStrategyQuote' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling getOptionsStrategyQuote' - ); - } - // Check if $option_strategy_id is a string - if ($option_strategy_id !== SENTINEL_VALUE && !is_string($option_strategy_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($option_strategy_id, true), gettype($option_strategy_id))); - } - // verify the required parameter 'option_strategy_id' is set - if ($option_strategy_id === SENTINEL_VALUE || (is_array($option_strategy_id) && count($option_strategy_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter option_strategy_id when calling getOptionsStrategyQuote' - ); - } - - - $resourcePath = '/accounts/{accountId}/optionStrategy/{optionStrategyId}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - // path params - if ($option_strategy_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'optionStrategyId' . '}', - ObjectSerializer::toPathValue($option_strategy_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'GET'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation listOptionHoldings - * - * List account option positions - * - * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listOptionHoldings'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\OptionsPosition[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse - */ - public function listOptionHoldings( - $user_id, - $user_secret, - $account_id, - - string $contentType = self::contentTypes['listOptionHoldings'][0] - ) - { - - list($response) = $this->listOptionHoldingsWithHttpInfo($user_id, $user_secret, $account_id, $contentType); - return $response; - } - - /** - * Operation listOptionHoldingsWithHttpInfo - * - * List account option positions - * - * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listOptionHoldings'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\OptionsPosition[]|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function listOptionHoldingsWithHttpInfo($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['listOptionHoldings'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->listOptionHoldingsRequest($user_id, $user_secret, $account_id, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->listOptionHoldingsWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\OptionsPosition[]' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\OptionsPosition[]' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\OptionsPosition[]', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 500: - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\OptionsPosition[]'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\OptionsPosition[]', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 500: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model500UnexpectedExceptionResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation listOptionHoldingsAsync - * - * List account option positions - * - * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listOptionHoldings'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listOptionHoldingsAsync( - $user_id, - $user_secret, - $account_id, - - string $contentType = self::contentTypes['listOptionHoldings'][0] - ) - { - - return $this->listOptionHoldingsAsyncWithHttpInfo($user_id, $user_secret, $account_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation listOptionHoldingsAsyncWithHttpInfo - * - * List account option positions - * - * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listOptionHoldings'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listOptionHoldingsAsyncWithHttpInfo($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['listOptionHoldings'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\OptionsPosition[]'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->listOptionHoldingsRequest($user_id, $user_secret, $account_id, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'listOptionHoldings' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listOptionHoldings'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function listOptionHoldingsRequest($user_id, $user_secret, $account_id, string $contentType = self::contentTypes['listOptionHoldings'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling listOptionHoldings' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling listOptionHoldings' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling listOptionHoldings' - ); - } - - - $resourcePath = '/accounts/{accountId}/options'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'GET'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - - /** - * Operation placeOptionStrategy - * - * Place an option strategy order - * - * Places the option strategy order and returns the order record received from the brokerage. - * - * @param string $user_id user_id (required) - * @param string $user_secret user_secret (required) - * @param string $account_id The ID of the account to execute the strategy in. (required) - * @param string $option_strategy_id Option strategy id obtained from response when creating option strategy object (required) - * @param \SnapTrade\Model\OptionsPlaceOptionStrategyRequest $options_place_option_strategy_request options_place_option_strategy_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOptionStrategy'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \SnapTrade\Model\StrategyOrderRecord|\SnapTrade\Model\Model500UnexpectedExceptionResponse - */ - public function placeOptionStrategy( - - $order_type, - $time_in_force, - $user_id, - $user_secret, - $account_id, - $option_strategy_id, - $price = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeOptionStrategy'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $options_place_option_strategy_request = $_body; - - list($response) = $this->placeOptionStrategyWithHttpInfo($user_id, $user_secret, $account_id, $option_strategy_id, $options_place_option_strategy_request, $contentType); - return $response; - } - - /** - * Operation placeOptionStrategyWithHttpInfo - * - * Place an option strategy order - * - * Places the option strategy order and returns the order record received from the brokerage. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id The ID of the account to execute the strategy in. (required) - * @param string $option_strategy_id Option strategy id obtained from response when creating option strategy object (required) - * @param \SnapTrade\Model\OptionsPlaceOptionStrategyRequest $options_place_option_strategy_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOptionStrategy'] to see the possible values for this operation - * - * @throws \SnapTrade\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\StrategyOrderRecord|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function placeOptionStrategyWithHttpInfo($user_id, $user_secret, $account_id, $option_strategy_id, $options_place_option_strategy_request, string $contentType = self::contentTypes['placeOptionStrategy'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOptionStrategyRequest($user_id, $user_secret, $account_id, $option_strategy_id, $options_place_option_strategy_request, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - if ( - ($e->getCode() == 401 || $e->getCode() == 403) && - !empty($this->getConfig()->getAccessToken()) && - $requestOptions->shouldRetryOAuth() - ) { - return $this->placeOptionStrategyWithHttpInfo( - $user_id, - $user_secret, - $account_id, - $option_strategy_id, - $options_place_option_strategy_request, - $contentType, - $requestOptions->setRetryOAuth(false) - ); - } - - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\SnapTrade\Model\StrategyOrderRecord' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\StrategyOrderRecord' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\StrategyOrderRecord', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 500: - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\SnapTrade\Model\StrategyOrderRecord'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\StrategyOrderRecord', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 500: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model500UnexpectedExceptionResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation placeOptionStrategyAsync - * - * Place an option strategy order - * - * Places the option strategy order and returns the order record received from the brokerage. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id The ID of the account to execute the strategy in. (required) - * @param string $option_strategy_id Option strategy id obtained from response when creating option strategy object (required) - * @param \SnapTrade\Model\OptionsPlaceOptionStrategyRequest $options_place_option_strategy_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOptionStrategy'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function placeOptionStrategyAsync( - - $order_type, - $time_in_force, - $user_id, - $user_secret, - $account_id, - $option_strategy_id, - $price = SENTINEL_VALUE, - string $contentType = self::contentTypes['placeOptionStrategy'][0] - ) - { - $_body = []; - $this->setRequestBodyProperty($_body, "order_type", $order_type); - $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); - $this->setRequestBodyProperty($_body, "price", $price); - $options_place_option_strategy_request = $_body; - - return $this->placeOptionStrategyAsyncWithHttpInfo($user_id, $user_secret, $account_id, $option_strategy_id, $options_place_option_strategy_request, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation placeOptionStrategyAsyncWithHttpInfo - * - * Place an option strategy order - * - * Places the option strategy order and returns the order record received from the brokerage. - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id The ID of the account to execute the strategy in. (required) - * @param string $option_strategy_id Option strategy id obtained from response when creating option strategy object (required) - * @param \SnapTrade\Model\OptionsPlaceOptionStrategyRequest $options_place_option_strategy_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOptionStrategy'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function placeOptionStrategyAsyncWithHttpInfo($user_id, $user_secret, $account_id, $option_strategy_id, $options_place_option_strategy_request, string $contentType = self::contentTypes['placeOptionStrategy'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) - { - $returnType = '\SnapTrade\Model\StrategyOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->placeOptionStrategyRequest($user_id, $user_secret, $account_id, $option_strategy_id, $options_place_option_strategy_request, $contentType); - - // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'placeOptionStrategy' - * - * @param string $user_id (required) - * @param string $user_secret (required) - * @param string $account_id The ID of the account to execute the strategy in. (required) - * @param string $option_strategy_id Option strategy id obtained from response when creating option strategy object (required) - * @param \SnapTrade\Model\OptionsPlaceOptionStrategyRequest $options_place_option_strategy_request (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOptionStrategy'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function placeOptionStrategyRequest($user_id, $user_secret, $account_id, $option_strategy_id, $options_place_option_strategy_request, string $contentType = self::contentTypes['placeOptionStrategy'][0]) - { - - // Check if $user_id is a string - if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); - } - // verify the required parameter 'user_id' is set - if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_id when calling placeOptionStrategy' - ); - } - // Check if $user_secret is a string - if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); - } - // verify the required parameter 'user_secret' is set - if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter user_secret when calling placeOptionStrategy' - ); - } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling placeOptionStrategy' - ); - } - // Check if $option_strategy_id is a string - if ($option_strategy_id !== SENTINEL_VALUE && !is_string($option_strategy_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($option_strategy_id, true), gettype($option_strategy_id))); - } - // verify the required parameter 'option_strategy_id' is set - if ($option_strategy_id === SENTINEL_VALUE || (is_array($option_strategy_id) && count($option_strategy_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter option_strategy_id when calling placeOptionStrategy' - ); - } - if ($options_place_option_strategy_request !== SENTINEL_VALUE) { - if (!($options_place_option_strategy_request instanceof \SnapTrade\Model\OptionsPlaceOptionStrategyRequest)) { - if (!is_array($options_place_option_strategy_request)) - throw new \InvalidArgumentException('"options_place_option_strategy_request" must be associative array or an instance of \SnapTrade\Model\OptionsPlaceOptionStrategyRequest OptionsApi.placeOptionStrategy.'); - else - $options_place_option_strategy_request = new \SnapTrade\Model\OptionsPlaceOptionStrategyRequest($options_place_option_strategy_request); - } - } - // verify the required parameter 'options_place_option_strategy_request' is set - if ($options_place_option_strategy_request === SENTINEL_VALUE || (is_array($options_place_option_strategy_request) && count($options_place_option_strategy_request) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter options_place_option_strategy_request when calling placeOptionStrategy' - ); - } - - - $resourcePath = '/accounts/{accountId}/optionStrategy/{optionStrategyId}/execute'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - if ($user_id !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_id, - 'userId', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - if ($user_secret !== SENTINEL_VALUE) { - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $user_secret, - 'userSecret', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - } - - - // path params - if ($account_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'accountId' . '}', - ObjectSerializer::toPathValue($account_id), - $resourcePath - ); - } - // path params - if ($option_strategy_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'optionStrategyId' . '}', - ObjectSerializer::toPathValue($option_strategy_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (isset($options_place_option_strategy_request)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($options_place_option_strategy_request)); - } else { - $httpBody = $options_place_option_strategy_request; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\json_encode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('clientId'); - if ($apiKey !== null) { - $queryParams['clientId'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Signature'); - if ($apiKey !== null) { - $headers['Signature'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); - if ($apiKey !== null) { - $queryParams['timestamp'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $method = 'POST'; - $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return [ - "request" => new Request( - $method, - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ), - "serializedBody" => $httpBody - ]; - } - /** * Create http client option * diff --git a/lib/Model/OptionsGetOptionStrategyRequest.php b/lib/Model/OptionsGetOptionStrategyRequest.php deleted file mode 100644 index 591ab06..0000000 --- a/lib/Model/OptionsGetOptionStrategyRequest.php +++ /dev/null @@ -1,517 +0,0 @@ - - */ -class OptionsGetOptionStrategyRequest implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Options_getOptionStrategy_request'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'underlying_symbol_id' => 'string', - 'legs' => '\SnapTrade\Model\OptionLeg[]', - 'strategy_type' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'underlying_symbol_id' => 'uuid', - 'legs' => null, - 'strategy_type' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'underlying_symbol_id' => false, - 'legs' => false, - 'strategy_type' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'underlying_symbol_id' => 'underlying_symbol_id', - 'legs' => 'legs', - 'strategy_type' => 'strategy_type' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'underlying_symbol_id' => 'setUnderlyingSymbolId', - 'legs' => 'setLegs', - 'strategy_type' => 'setStrategyType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'underlying_symbol_id' => 'getUnderlyingSymbolId', - 'legs' => 'getLegs', - 'strategy_type' => 'getStrategyType' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - public const STRATEGY_TYPE_CUSTOM = 'CUSTOM'; - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getStrategyTypeAllowableValues() - { - return [ - self::STRATEGY_TYPE_CUSTOM, - ]; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('underlying_symbol_id', $data ?? [], null); - $this->setIfExists('legs', $data ?? [], null); - $this->setIfExists('strategy_type', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['underlying_symbol_id'] === null) { - $invalidProperties[] = "'underlying_symbol_id' can't be null"; - } - if ($this->container['legs'] === null) { - $invalidProperties[] = "'legs' can't be null"; - } - if ($this->container['strategy_type'] === null) { - $invalidProperties[] = "'strategy_type' can't be null"; - } - $allowedValues = $this->getStrategyTypeAllowableValues(); - if (!is_null($this->container['strategy_type']) && !in_array($this->container['strategy_type'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'strategy_type', must be one of '%s'", - $this->container['strategy_type'], - implode("', '", $allowedValues) - ); - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets underlying_symbol_id - * - * @return string - */ - public function getUnderlyingSymbolId() - { - return $this->container['underlying_symbol_id']; - } - - /** - * Sets underlying_symbol_id - * - * @param string $underlying_symbol_id underlying_symbol_id - * - * @return self - */ - public function setUnderlyingSymbolId($underlying_symbol_id) - { - - if (is_null($underlying_symbol_id)) { - throw new \InvalidArgumentException('non-nullable underlying_symbol_id cannot be null'); - } - - $this->container['underlying_symbol_id'] = $underlying_symbol_id; - - return $this; - } - - /** - * Gets legs - * - * @return \SnapTrade\Model\OptionLeg[] - */ - public function getLegs() - { - return $this->container['legs']; - } - - /** - * Sets legs - * - * @param \SnapTrade\Model\OptionLeg[] $legs legs - * - * @return self - */ - public function setLegs($legs) - { - - if (is_null($legs)) { - throw new \InvalidArgumentException('non-nullable legs cannot be null'); - } - - $this->container['legs'] = $legs; - - return $this; - } - - /** - * Gets strategy_type - * - * @return string - */ - public function getStrategyType() - { - return $this->container['strategy_type']; - } - - /** - * Sets strategy_type - * - * @param string $strategy_type strategy_type - * - * @return self - */ - public function setStrategyType($strategy_type) - { - $allowedValues = $this->getStrategyTypeAllowableValues(); - if (!in_array($strategy_type, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'strategy_type', must be one of '%s'", - $strategy_type, - implode("', '", $allowedValues) - ) - ); - } - - if (is_null($strategy_type)) { - throw new \InvalidArgumentException('non-nullable strategy_type cannot be null'); - } - - $this->container['strategy_type'] = $strategy_type; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/lib/Model/OptionsPlaceOptionStrategyRequest.php b/lib/Model/OptionsPlaceOptionStrategyRequest.php deleted file mode 100644 index 4c18820..0000000 --- a/lib/Model/OptionsPlaceOptionStrategyRequest.php +++ /dev/null @@ -1,489 +0,0 @@ - - */ -class OptionsPlaceOptionStrategyRequest implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Options_placeOptionStrategy_request'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'order_type' => '\SnapTrade\Model\OrderTypeStrict', - 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', - 'price' => 'float' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'order_type' => null, - 'time_in_force' => null, - 'price' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'order_type' => false, - 'time_in_force' => false, - 'price' => true - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'order_type' => 'order_type', - 'time_in_force' => 'time_in_force', - 'price' => 'price' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'order_type' => 'setOrderType', - 'time_in_force' => 'setTimeInForce', - 'price' => 'setPrice' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'order_type' => 'getOrderType', - 'time_in_force' => 'getTimeInForce', - 'price' => 'getPrice' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('order_type', $data ?? [], null); - $this->setIfExists('time_in_force', $data ?? [], null); - $this->setIfExists('price', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['order_type'] === null) { - $invalidProperties[] = "'order_type' can't be null"; - } - if ($this->container['time_in_force'] === null) { - $invalidProperties[] = "'time_in_force' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets order_type - * - * @return \SnapTrade\Model\OrderTypeStrict - */ - public function getOrderType() - { - return $this->container['order_type']; - } - - /** - * Sets order_type - * - * @param \SnapTrade\Model\OrderTypeStrict $order_type order_type - * - * @return self - */ - public function setOrderType($order_type) - { - - if (is_null($order_type)) { - throw new \InvalidArgumentException('non-nullable order_type cannot be null'); - } - - $this->container['order_type'] = $order_type; - - return $this; - } - - /** - * Gets time_in_force - * - * @return \SnapTrade\Model\TimeInForceStrict - */ - public function getTimeInForce() - { - return $this->container['time_in_force']; - } - - /** - * Sets time_in_force - * - * @param \SnapTrade\Model\TimeInForceStrict $time_in_force time_in_force - * - * @return self - */ - public function setTimeInForce($time_in_force) - { - - if (is_null($time_in_force)) { - throw new \InvalidArgumentException('non-nullable time_in_force cannot be null'); - } - - $this->container['time_in_force'] = $time_in_force; - - return $this; - } - - /** - * Gets price - * - * @return float|null - */ - public function getPrice() - { - return $this->container['price']; - } - - /** - * Sets price - * - * @param float|null $price Trade Price if limit or stop limit order - * - * @return self - */ - public function setPrice($price) - { - - if (is_null($price)) { - array_push($this->openAPINullablesSetToNull, 'price'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('price', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - - $this->container['price'] = $price; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/test/Api/OptionsApiTest.php b/test/Api/OptionsApiTest.php index 0a5fd8a..3d7e119 100644 --- a/test/Api/OptionsApiTest.php +++ b/test/Api/OptionsApiTest.php @@ -58,18 +58,6 @@ public static function tearDownAfterClass(): void { } - /** - * Test case for getOptionStrategy - * - * Create options strategy. - * - */ - public function testGetOptionStrategy() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test case for getOptionsChain * @@ -82,18 +70,6 @@ public function testGetOptionsChain() $this->markTestIncomplete('Not implemented'); } - /** - * Test case for getOptionsStrategyQuote - * - * Get options strategy quotes. - * - */ - public function testGetOptionsStrategyQuote() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test case for listOptionHoldings * @@ -105,16 +81,4 @@ public function testListOptionHoldings() // TODO: implement $this->markTestIncomplete('Not implemented'); } - - /** - * Test case for placeOptionStrategy - * - * Place an option strategy order. - * - */ - public function testPlaceOptionStrategy() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } } diff --git a/test/Model/OptionsGetOptionStrategyRequestTest.php b/test/Model/OptionsGetOptionStrategyRequestTest.php deleted file mode 100644 index de6cfcd..0000000 --- a/test/Model/OptionsGetOptionStrategyRequestTest.php +++ /dev/null @@ -1,101 +0,0 @@ -markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "underlying_symbol_id" - */ - public function testPropertyUnderlyingSymbolId() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "legs" - */ - public function testPropertyLegs() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "strategy_type" - */ - public function testPropertyStrategyType() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } -} diff --git a/test/Model/OptionsPlaceOptionStrategyRequestTest.php b/test/Model/OptionsPlaceOptionStrategyRequestTest.php deleted file mode 100644 index fc2aa32..0000000 --- a/test/Model/OptionsPlaceOptionStrategyRequestTest.php +++ /dev/null @@ -1,101 +0,0 @@ -markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "order_type" - */ - public function testPropertyOrderType() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "time_in_force" - */ - public function testPropertyTimeInForce() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "price" - */ - public function testPropertyPrice() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } -} From 79274fba93c6c3e8e392e12c4fb9cafce03b86f1 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 12:10:33 +0000 Subject: [PATCH 177/252] Version Bump SDKs (#204) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a6fcb61..4592c0e 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -c78ac1e5-2316-4624-b14e-e8d71ccabbfa \ No newline at end of file +3f0a1248-cd2b-4907-a604-c49467070ce4 \ No newline at end of file diff --git a/README.md b/README.md index 92c0819..601668e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.123-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.124-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.123" + "konfig/snaptrade-php-sdk": "2.0.124" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index d4c7840..746e57f 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.123/PHP'; + protected $userAgent = 'Konfig/2.0.124/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.123' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.124' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From c53d2dd1ba3bb5b5c6642db9043d887e73c9af0e Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 16:29:57 +0000 Subject: [PATCH 178/252] Regenerate SDKs (#205) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 15 +++++++++++++-- lib/Api/AccountInformationApi.php | 8 ++++---- lib/Api/TradingApi.php | 8 ++++---- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 4592c0e..a7b1a33 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -3f0a1248-cd2b-4907-a604-c49467070ce4 \ No newline at end of file +bff006f6-5b49-4958-ad2f-99b2652ee292 \ No newline at end of file diff --git a/README.md b/README.md index 601668e..0e561c0 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,11 @@ $result = $snaptrade->accountInformation->getUserAccountDetails( ### `snaptrade.accountInformation.getUserAccountOrderDetail` -Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. +Returns the detail of a single order in the specified account. + +This endpoint is always realtime and does not rely on cached data. + +This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. @@ -1805,7 +1809,14 @@ The price at which a stop order is triggered for `Stop` and `StopLimit` orders. ### `snaptrade.trading.getUserAccountQuotes` -Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. +Returns quotes from the brokerage for the specified symbols and account. + +The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. + +This endpoint does not work for options quotes. + +This endpoint is disabled for free plans by default. Please contact support to enable this endpoint if needed. + #### πŸ› οΈ Usage diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 68a6c01..2c1ed49 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -1957,7 +1957,7 @@ public function getUserAccountDetailsRequest($user_id, $user_secret, $account_id * * Get account order detail * - * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. + * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -1988,7 +1988,7 @@ public function getUserAccountOrderDetail( * * Get account order detail * - * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. + * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2157,7 +2157,7 @@ public function getUserAccountOrderDetailWithHttpInfo($user_id, $user_secret, $a * * Get account order detail * - * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. + * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2191,7 +2191,7 @@ function ($response) { * * Get account order detail * - * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. + * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $user_id (required) * @param string $user_secret (required) diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index d583745..32c2b66 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -2064,7 +2064,7 @@ public function getOrderImpactRequest($user_id, $user_secret, $manual_trade_form * * Get equity symbol quotes * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. This endpoint is disabled for free plans by default. Please contact support to enable this endpoint if needed. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -2097,7 +2097,7 @@ public function getUserAccountQuotes( * * Get equity symbol quotes * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. This endpoint is disabled for free plans by default. Please contact support to enable this endpoint if needed. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2245,7 +2245,7 @@ public function getUserAccountQuotesWithHttpInfo($user_id, $user_secret, $symbol * * Get equity symbol quotes * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. This endpoint is disabled for free plans by default. Please contact support to enable this endpoint if needed. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2281,7 +2281,7 @@ function ($response) { * * Get equity symbol quotes * - * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. + * Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes. This endpoint is disabled for free plans by default. Please contact support to enable this endpoint if needed. * * @param string $user_id (required) * @param string $user_secret (required) From a7e5e621c82b16d6dd8f9df3d3651765c08084a3 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 16:34:08 +0000 Subject: [PATCH 179/252] Version Bump SDKs (#206) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a7b1a33..924e10c 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -bff006f6-5b49-4958-ad2f-99b2652ee292 \ No newline at end of file +7e885586-01bc-4ca2-bbe3-95e87e127efb \ No newline at end of file diff --git a/README.md b/README.md index 0e561c0..c9949cc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.124-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.125-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.124" + "konfig/snaptrade-php-sdk": "2.0.125" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 746e57f..44e6132 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.124/PHP'; + protected $userAgent = 'Konfig/2.0.125/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.124' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.125' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 90234d108cef8e05ce29311667ebd1bec8b078f4 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 27 Aug 2025 19:45:55 +0000 Subject: [PATCH 180/252] Regenerate SDKs (#207) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/ConnectionsApi.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 924e10c..a0ac299 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -7e885586-01bc-4ca2-bbe3-95e87e127efb \ No newline at end of file +8b3cc5fd-21bc-403a-be61-1a6e5a4005dd \ No newline at end of file diff --git a/README.md b/README.md index c9949cc..cb73c9c 100644 --- a/README.md +++ b/README.md @@ -1013,7 +1013,7 @@ $result = $snaptrade->connections->listBrokerageAuthorizations( Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. -**Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge of $0.05** +**Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge based on your [Pricing Plan](https://snaptrade.com/pricing)** diff --git a/lib/Api/ConnectionsApi.php b/lib/Api/ConnectionsApi.php index 96215be..4bb8c91 100644 --- a/lib/Api/ConnectionsApi.php +++ b/lib/Api/ConnectionsApi.php @@ -1430,7 +1430,7 @@ public function listBrokerageAuthorizationsRequest($user_id, $user_secret, strin * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge of $0.05** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge based on your [Pricing Plan](https://snaptrade.com/pricing)** * * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) @@ -1459,7 +1459,7 @@ public function refreshBrokerageAuthorization( * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge of $0.05** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge based on your [Pricing Plan](https://snaptrade.com/pricing)** * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1672,7 +1672,7 @@ public function refreshBrokerageAuthorizationWithHttpInfo($authorization_id, $us * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge of $0.05** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge based on your [Pricing Plan](https://snaptrade.com/pricing)** * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1704,7 +1704,7 @@ function ($response) { * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge of $0.05** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge based on your [Pricing Plan](https://snaptrade.com/pricing)** * * @param string $authorization_id (required) * @param string $user_id (required) From 704aca503473a78c3315ff929163ca85ae6c1efb Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 27 Aug 2025 19:49:50 +0000 Subject: [PATCH 181/252] Version Bump SDKs (#208) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a0ac299..6290792 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -8b3cc5fd-21bc-403a-be61-1a6e5a4005dd \ No newline at end of file +c297c52d-64fc-43bb-afd2-4ecdf6310616 \ No newline at end of file diff --git a/README.md b/README.md index cb73c9c..e16e920 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.125-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.126-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.125" + "konfig/snaptrade-php-sdk": "2.0.126" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 44e6132..41b7f4c 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.125/PHP'; + protected $userAgent = 'Konfig/2.0.126/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.125' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.126' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 6e8c8bcf4dd97780f5f1cde5173282e2b96101d2 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 23:10:11 +0000 Subject: [PATCH 182/252] Regenerate SDKs (#209) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 18 +- lib/Api/AccountInformationApi.php | 152 ++++--- ...mationGetUserAccountOrderDetailRequest.php | 407 ++++++++++++++++++ ...onGetUserAccountOrderDetailRequestTest.php | 83 ++++ 5 files changed, 593 insertions(+), 69 deletions(-) create mode 100644 lib/Model/AccountInformationGetUserAccountOrderDetailRequest.php create mode 100644 test/Model/AccountInformationGetUserAccountOrderDetailRequestTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 6290792..508f673 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -c297c52d-64fc-43bb-afd2-4ecdf6310616 \ No newline at end of file +f71de825-1429-43f2-b61d-5819bae134eb \ No newline at end of file diff --git a/README.md b/README.md index e16e920..b1c0d11 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,7 @@ $result = $snaptrade->accountInformation->getUserAccountDetails( ### `snaptrade.accountInformation.getUserAccountOrderDetail` -Returns the detail of a single order in the specified account. +Returns the detail of a single order using the external order ID provided in the request body. This endpoint is always realtime and does not rely on cached data. @@ -347,22 +347,24 @@ This endpoint only returns orders placed through SnapTrade. In other words, orde ```php $result = $snaptrade->accountInformation->getUserAccountOrderDetail( - user_id: "snaptrade-user-123", - user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + external_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e" + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" ); ``` #### βš™οΈ Parameters -##### user_id: `string` +##### external_order_id: `string` -##### user_secret: `string` +Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. ##### account_id: `string` -##### brokerage_order_id: `string` +##### user_id: `string` + +##### user_secret: `string` #### πŸ”„ Return @@ -371,7 +373,7 @@ $result = $snaptrade->accountInformation->getUserAccountOrderDetail( #### 🌐 Endpoint -`/accounts/{accountId}/orders/{brokerageOrderId}` `GET` +`/accounts/{accountId}/orders/details` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 2c1ed49..7f9f366 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -1957,29 +1957,32 @@ public function getUserAccountDetailsRequest($user_id, $user_secret, $account_id * * Get account order detail * - * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the external order ID provided in the request body. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * + * @param string $account_id account_id (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param string $account_id account_id (required) - * @param string $brokerage_order_id brokerage_order_id (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetail'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse + * @return \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse */ public function getUserAccountOrderDetail( + + $external_order_id, + $account_id, $user_id, $user_secret, - $account_id, - $brokerage_order_id, - string $contentType = self::contentTypes['getUserAccountOrderDetail'][0] ) { + $_body = []; + $this->setRequestBodyProperty($_body, "external_order_id", $external_order_id); + $account_information_get_user_account_order_detail_request = $_body; - list($response) = $this->getUserAccountOrderDetailWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); + list($response) = $this->getUserAccountOrderDetailWithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType); return $response; } @@ -1988,24 +1991,24 @@ public function getUserAccountOrderDetail( * * Get account order detail * - * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the external order ID provided in the request body. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * + * @param string $account_id (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $brokerage_order_id (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetail'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getUserAccountOrderDetailWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['getUserAccountOrderDetail'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getUserAccountOrderDetailWithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['getUserAccountOrderDetail'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailRequest($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailRequest($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); try { $options = $this->createHttpClientOption(); @@ -2018,10 +2021,10 @@ public function getUserAccountOrderDetailWithHttpInfo($user_id, $user_secret, $a $requestOptions->shouldRetryOAuth() ) { return $this->getUserAccountOrderDetailWithHttpInfo( + $account_id, $user_id, $user_secret, - $account_id, - $brokerage_order_id, + $account_information_get_user_account_order_detail_request, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -2073,6 +2076,21 @@ public function getUserAccountOrderDetailWithHttpInfo($user_id, $user_secret, $a $response->getStatusCode(), $response->getHeaders() ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; case 404: if ('\SnapTrade\Model\Model404FailedRequestResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -2131,6 +2149,14 @@ public function getUserAccountOrderDetailWithHttpInfo($user_id, $user_secret, $a ); $e->setResponseObject($data); break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; case 404: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2157,28 +2183,31 @@ public function getUserAccountOrderDetailWithHttpInfo($user_id, $user_secret, $a * * Get account order detail * - * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the external order ID provided in the request body. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * + * @param string $account_id (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $brokerage_order_id (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetail'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getUserAccountOrderDetailAsync( + + $external_order_id, + $account_id, $user_id, $user_secret, - $account_id, - $brokerage_order_id, - string $contentType = self::contentTypes['getUserAccountOrderDetail'][0] ) { + $_body = []; + $this->setRequestBodyProperty($_body, "external_order_id", $external_order_id); + $account_information_get_user_account_order_detail_request = $_body; - return $this->getUserAccountOrderDetailAsyncWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType) + return $this->getUserAccountOrderDetailAsyncWithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType) ->then( function ($response) { return $response[0]; @@ -2191,24 +2220,24 @@ function ($response) { * * Get account order detail * - * Returns the detail of a single order in the specified account. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the external order ID provided in the request body. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * + * @param string $account_id (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $brokerage_order_id (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetail'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getUserAccountOrderDetailAsyncWithHttpInfo($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['getUserAccountOrderDetail'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getUserAccountOrderDetailAsyncWithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['getUserAccountOrderDetail'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailRequest($user_id, $user_secret, $account_id, $brokerage_order_id, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailRequest($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config); + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -2249,18 +2278,28 @@ function ($exception) { /** * Create request for operation 'getUserAccountOrderDetail' * + * @param string $account_id (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param string $account_id (required) - * @param string $brokerage_order_id (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetail'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getUserAccountOrderDetailRequest($user_id, $user_secret, $account_id, $brokerage_order_id, string $contentType = self::contentTypes['getUserAccountOrderDetail'][0]) + public function getUserAccountOrderDetailRequest($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['getUserAccountOrderDetail'][0]) { + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getUserAccountOrderDetail' + ); + } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -2281,29 +2320,23 @@ public function getUserAccountOrderDetailRequest($user_id, $user_secret, $accoun 'Missing the required parameter user_secret when calling getUserAccountOrderDetail' ); } - // Check if $account_id is a string - if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); - } - // verify the required parameter 'account_id' is set - if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_id when calling getUserAccountOrderDetail' - ); - } - // Check if $brokerage_order_id is a string - if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); + if ($account_information_get_user_account_order_detail_request !== SENTINEL_VALUE) { + if (!($account_information_get_user_account_order_detail_request instanceof \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest)) { + if (!is_array($account_information_get_user_account_order_detail_request)) + throw new \InvalidArgumentException('"account_information_get_user_account_order_detail_request" must be associative array or an instance of \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest AccountInformationApi.getUserAccountOrderDetail.'); + else + $account_information_get_user_account_order_detail_request = new \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest($account_information_get_user_account_order_detail_request); + } } - // verify the required parameter 'brokerage_order_id' is set - if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { + // verify the required parameter 'account_information_get_user_account_order_detail_request' is set + if ($account_information_get_user_account_order_detail_request === SENTINEL_VALUE || (is_array($account_information_get_user_account_order_detail_request) && count($account_information_get_user_account_order_detail_request) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter brokerage_order_id when calling getUserAccountOrderDetail' + 'Missing the required parameter account_information_get_user_account_order_detail_request when calling getUserAccountOrderDetail' ); } - $resourcePath = '/accounts/{accountId}/orders/{brokerageOrderId}'; + $resourcePath = '/accounts/{accountId}/orders/details'; $formParams = []; $queryParams = []; $headerParams = []; @@ -2342,14 +2375,6 @@ public function getUserAccountOrderDetailRequest($user_id, $user_secret, $accoun $resourcePath ); } - // path params - if ($brokerage_order_id !== SENTINEL_VALUE) { - $resourcePath = str_replace( - '{' . 'brokerageOrderId' . '}', - ObjectSerializer::toPathValue($brokerage_order_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -2359,7 +2384,14 @@ public function getUserAccountOrderDetailRequest($user_id, $user_secret, $accoun ); // for model (json/xml) - if (count($formParams) > 0) { + if (isset($account_information_get_user_account_order_detail_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($account_information_get_user_account_order_detail_request)); + } else { + $httpBody = $account_information_get_user_account_order_detail_request; + } + } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -2410,7 +2442,7 @@ public function getUserAccountOrderDetailRequest($user_id, $user_secret, $accoun $headers ); - $method = 'GET'; + $method = 'POST'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); diff --git a/lib/Model/AccountInformationGetUserAccountOrderDetailRequest.php b/lib/Model/AccountInformationGetUserAccountOrderDetailRequest.php new file mode 100644 index 0000000..ca2e0fe --- /dev/null +++ b/lib/Model/AccountInformationGetUserAccountOrderDetailRequest.php @@ -0,0 +1,407 @@ + + */ +class AccountInformationGetUserAccountOrderDetailRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AccountInformation_getUserAccountOrderDetail_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'external_order_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'external_order_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'external_order_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'external_order_id' => 'external_order_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'external_order_id' => 'setExternalOrderId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'external_order_id' => 'getExternalOrderId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('external_order_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['external_order_id'] === null) { + $invalidProperties[] = "'external_order_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets external_order_id + * + * @return string + */ + public function getExternalOrderId() + { + return $this->container['external_order_id']; + } + + /** + * Sets external_order_id + * + * @param string $external_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + * + * @return self + */ + public function setExternalOrderId($external_order_id) + { + + if (is_null($external_order_id)) { + throw new \InvalidArgumentException('non-nullable external_order_id cannot be null'); + } + + $this->container['external_order_id'] = $external_order_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Model/AccountInformationGetUserAccountOrderDetailRequestTest.php b/test/Model/AccountInformationGetUserAccountOrderDetailRequestTest.php new file mode 100644 index 0000000..d66b19d --- /dev/null +++ b/test/Model/AccountInformationGetUserAccountOrderDetailRequestTest.php @@ -0,0 +1,83 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "external_order_id" + */ + public function testPropertyExternalOrderId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From 61cc9b0fbe5879803ba89fcef64ecf3b9c89dca1 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 23:13:59 +0000 Subject: [PATCH 183/252] Version Bump SDKs (#210) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 508f673..74c746a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f71de825-1429-43f2-b61d-5819bae134eb \ No newline at end of file +05802d82-33f0-4321-81c9-5b089dc61790 \ No newline at end of file diff --git a/README.md b/README.md index b1c0d11..4c5f2d5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.126-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.127-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.126" + "konfig/snaptrade-php-sdk": "2.0.127" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 41b7f4c..8ffeeea 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.126/PHP'; + protected $userAgent = 'Konfig/2.0.127/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.126' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.127' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 7aabb0145e36abda3c4467753460eeb2836831af Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 22:23:51 +0000 Subject: [PATCH 184/252] Regenerate SDKs (#211) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 8 +++-- lib/Api/ReferenceDataApi.php | 50 +++++++++++++++---------------- lib/Model/BrokerageInstrument.php | 7 +++-- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 74c746a..0ea134c 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -05802d82-33f0-4321-81c9-5b089dc61790 \ No newline at end of file +54e605e3-4cb2-48c0-af03-e99ddcedd089 \ No newline at end of file diff --git a/README.md b/README.md index 4c5f2d5..7d1cc13 100644 --- a/README.md +++ b/README.md @@ -1469,13 +1469,15 @@ Returns a list of all brokerage instruments available for a given brokerage. Not ```php $result = $snaptrade->referenceData->listAllBrokerageInstruments( - brokerage_id: "87b24961-b51e-4db8-9226-f198f6518a89" + slug: "QUESTRADE" ); ``` #### βš™οΈ Parameters -##### brokerage_id: `string` +##### slug: `string` + +A short, unique identifier for the brokerage. It is usually the name of the brokerage in capital letters and will never change. #### πŸ”„ Return @@ -1484,7 +1486,7 @@ $result = $snaptrade->referenceData->listAllBrokerageInstruments( #### 🌐 Endpoint -`/brokerages/{brokerageId}/instruments` `GET` +`/brokerages/{slug}/instruments` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) diff --git a/lib/Api/ReferenceDataApi.php b/lib/Api/ReferenceDataApi.php index 3a10fe8..96e7233 100644 --- a/lib/Api/ReferenceDataApi.php +++ b/lib/Api/ReferenceDataApi.php @@ -2603,7 +2603,7 @@ public function listAllBrokerageAuthorizationTypeRequest($brokerage = SENTINEL_V * * Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list. * - * @param string $brokerage_id brokerage_id (required) + * @param string $slug A short, unique identifier for the brokerage. It is usually the name of the brokerage in capital letters and will never change. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -2611,13 +2611,13 @@ public function listAllBrokerageAuthorizationTypeRequest($brokerage = SENTINEL_V * @return \SnapTrade\Model\BrokerageInstrumentsResponse */ public function listAllBrokerageInstruments( - $brokerage_id, + $slug, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0] ) { - list($response) = $this->listAllBrokerageInstrumentsWithHttpInfo($brokerage_id, $contentType); + list($response) = $this->listAllBrokerageInstrumentsWithHttpInfo($slug, $contentType); return $response; } @@ -2628,16 +2628,16 @@ public function listAllBrokerageInstruments( * * Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list. * - * @param string $brokerage_id (required) + * @param string $slug A short, unique identifier for the brokerage. It is usually the name of the brokerage in capital letters and will never change. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\BrokerageInstrumentsResponse, HTTP status code, HTTP response headers (array of strings) */ - public function listAllBrokerageInstrumentsWithHttpInfo($brokerage_id, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function listAllBrokerageInstrumentsWithHttpInfo($slug, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->listAllBrokerageInstrumentsRequest($brokerage_id, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->listAllBrokerageInstrumentsRequest($slug, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config); @@ -2653,7 +2653,7 @@ public function listAllBrokerageInstrumentsWithHttpInfo($brokerage_id, string $c $requestOptions->shouldRetryOAuth() ) { return $this->listAllBrokerageInstrumentsWithHttpInfo( - $brokerage_id, + $slug, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -2745,20 +2745,20 @@ public function listAllBrokerageInstrumentsWithHttpInfo($brokerage_id, string $c * * Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list. * - * @param string $brokerage_id (required) + * @param string $slug A short, unique identifier for the brokerage. It is usually the name of the brokerage in capital letters and will never change. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function listAllBrokerageInstrumentsAsync( - $brokerage_id, + $slug, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0] ) { - return $this->listAllBrokerageInstrumentsAsyncWithHttpInfo($brokerage_id, $contentType) + return $this->listAllBrokerageInstrumentsAsyncWithHttpInfo($slug, $contentType) ->then( function ($response) { return $response[0]; @@ -2773,16 +2773,16 @@ function ($response) { * * Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list. * - * @param string $brokerage_id (required) + * @param string $slug A short, unique identifier for the brokerage. It is usually the name of the brokerage in capital letters and will never change. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function listAllBrokerageInstrumentsAsyncWithHttpInfo($brokerage_id, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function listAllBrokerageInstrumentsAsyncWithHttpInfo($slug, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\BrokerageInstrumentsResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->listAllBrokerageInstrumentsRequest($brokerage_id, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->listAllBrokerageInstrumentsRequest($slug, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config); @@ -2826,28 +2826,28 @@ function ($exception) { /** * Create request for operation 'listAllBrokerageInstruments' * - * @param string $brokerage_id (required) + * @param string $slug A short, unique identifier for the brokerage. It is usually the name of the brokerage in capital letters and will never change. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listAllBrokerageInstruments'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function listAllBrokerageInstrumentsRequest($brokerage_id, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0]) + public function listAllBrokerageInstrumentsRequest($slug, string $contentType = self::contentTypes['listAllBrokerageInstruments'][0]) { - // Check if $brokerage_id is a string - if ($brokerage_id !== SENTINEL_VALUE && !is_string($brokerage_id)) { - throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_id, true), gettype($brokerage_id))); + // Check if $slug is a string + if ($slug !== SENTINEL_VALUE && !is_string($slug)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($slug, true), gettype($slug))); } - // verify the required parameter 'brokerage_id' is set - if ($brokerage_id === SENTINEL_VALUE || (is_array($brokerage_id) && count($brokerage_id) === 0)) { + // verify the required parameter 'slug' is set + if ($slug === SENTINEL_VALUE || (is_array($slug) && count($slug) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter brokerage_id when calling listAllBrokerageInstruments' + 'Missing the required parameter slug when calling listAllBrokerageInstruments' ); } - $resourcePath = '/brokerages/{brokerageId}/instruments'; + $resourcePath = '/brokerages/{slug}/instruments'; $formParams = []; $queryParams = []; $headerParams = []; @@ -2857,10 +2857,10 @@ public function listAllBrokerageInstrumentsRequest($brokerage_id, string $conten // path params - if ($brokerage_id !== SENTINEL_VALUE) { + if ($slug !== SENTINEL_VALUE) { $resourcePath = str_replace( - '{' . 'brokerageId' . '}', - ObjectSerializer::toPathValue($brokerage_id), + '{' . 'slug' . '}', + ObjectSerializer::toPathValue($slug), $resourcePath ); } diff --git a/lib/Model/BrokerageInstrument.php b/lib/Model/BrokerageInstrument.php index 65f95c0..7b6fdd3 100644 --- a/lib/Model/BrokerageInstrument.php +++ b/lib/Model/BrokerageInstrument.php @@ -295,6 +295,9 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['symbol'] === null) { + $invalidProperties[] = "'symbol' can't be null"; + } return $invalidProperties; } @@ -313,7 +316,7 @@ public function valid() /** * Gets symbol * - * @return string|null + * @return string */ public function getSymbol() { @@ -323,7 +326,7 @@ public function getSymbol() /** * Sets symbol * - * @param string|null $symbol The instrument's trading symbol / ticker. + * @param string $symbol The instrument's trading symbol / ticker. * * @return self */ From b7a3af4b31e6b4582666c1fa3f180446ee2346c7 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 22:28:05 +0000 Subject: [PATCH 185/252] Version Bump SDKs (#212) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0ea134c..761cf32 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -54e605e3-4cb2-48c0-af03-e99ddcedd089 \ No newline at end of file +c5d559ba-00ef-493e-8c11-c8c04475ea27 \ No newline at end of file diff --git a/README.md b/README.md index 7d1cc13..0fa1018 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.127-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.128-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.127" + "konfig/snaptrade-php-sdk": "2.0.128" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 8ffeeea..78ab3ac 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.127/PHP'; + protected $userAgent = 'Konfig/2.0.128/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.127' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.128' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 4ffef540a9ef38151be808c89c0991200dc6e0b4 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 5 Sep 2025 02:40:26 +0000 Subject: [PATCH 186/252] Regenerate SDKs (#213) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 +-- lib/Api/AccountInformationApi.php | 8 ++--- ...mationGetUserAccountOrderDetailRequest.php | 36 +++++++++---------- ...onGetUserAccountOrderDetailRequestTest.php | 4 +-- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 761cf32..7043352 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -c5d559ba-00ef-493e-8c11-c8c04475ea27 \ No newline at end of file +7ac6f7e1-59d1-4381-9e0e-e5dc0f7d49cd \ No newline at end of file diff --git a/README.md b/README.md index 0fa1018..decd593 100644 --- a/README.md +++ b/README.md @@ -347,7 +347,7 @@ This endpoint only returns orders placed through SnapTrade. In other words, orde ```php $result = $snaptrade->accountInformation->getUserAccountOrderDetail( - external_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" @@ -356,7 +356,7 @@ $result = $snaptrade->accountInformation->getUserAccountOrderDetail( #### βš™οΈ Parameters -##### external_order_id: `string` +##### brokerage_order_id: `string` Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 7f9f366..dd18cba 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -1971,7 +1971,7 @@ public function getUserAccountDetailsRequest($user_id, $user_secret, $account_id */ public function getUserAccountOrderDetail( - $external_order_id, + $brokerage_order_id, $account_id, $user_id, $user_secret, @@ -1979,7 +1979,7 @@ public function getUserAccountOrderDetail( ) { $_body = []; - $this->setRequestBodyProperty($_body, "external_order_id", $external_order_id); + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); $account_information_get_user_account_order_detail_request = $_body; list($response) = $this->getUserAccountOrderDetailWithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType); @@ -2196,7 +2196,7 @@ public function getUserAccountOrderDetailWithHttpInfo($account_id, $user_id, $us */ public function getUserAccountOrderDetailAsync( - $external_order_id, + $brokerage_order_id, $account_id, $user_id, $user_secret, @@ -2204,7 +2204,7 @@ public function getUserAccountOrderDetailAsync( ) { $_body = []; - $this->setRequestBodyProperty($_body, "external_order_id", $external_order_id); + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); $account_information_get_user_account_order_detail_request = $_body; return $this->getUserAccountOrderDetailAsyncWithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType) diff --git a/lib/Model/AccountInformationGetUserAccountOrderDetailRequest.php b/lib/Model/AccountInformationGetUserAccountOrderDetailRequest.php index ca2e0fe..5fe4e12 100644 --- a/lib/Model/AccountInformationGetUserAccountOrderDetailRequest.php +++ b/lib/Model/AccountInformationGetUserAccountOrderDetailRequest.php @@ -50,7 +50,7 @@ class AccountInformationGetUserAccountOrderDetailRequest implements ModelInterfa * @var string[] */ protected static $openAPITypes = [ - 'external_order_id' => 'string' + 'brokerage_order_id' => 'string' ]; /** @@ -61,7 +61,7 @@ class AccountInformationGetUserAccountOrderDetailRequest implements ModelInterfa * @psalm-var array */ protected static $openAPIFormats = [ - 'external_order_id' => null + 'brokerage_order_id' => null ]; /** @@ -70,7 +70,7 @@ class AccountInformationGetUserAccountOrderDetailRequest implements ModelInterfa * @var boolean[] */ protected static array $openAPINullables = [ - 'external_order_id' => false + 'brokerage_order_id' => false ]; /** @@ -159,7 +159,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'external_order_id' => 'external_order_id' + 'brokerage_order_id' => 'brokerage_order_id' ]; /** @@ -168,7 +168,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'external_order_id' => 'setExternalOrderId' + 'brokerage_order_id' => 'setBrokerageOrderId' ]; /** @@ -177,7 +177,7 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'external_order_id' => 'getExternalOrderId' + 'brokerage_order_id' => 'getBrokerageOrderId' ]; /** @@ -237,7 +237,7 @@ public function getModelName() */ public function __construct(array $data = null) { - $this->setIfExists('external_order_id', $data ?? [], null); + $this->setIfExists('brokerage_order_id', $data ?? [], null); } /** @@ -267,8 +267,8 @@ public function listInvalidProperties() { $invalidProperties = []; - if ($this->container['external_order_id'] === null) { - $invalidProperties[] = "'external_order_id' can't be null"; + if ($this->container['brokerage_order_id'] === null) { + $invalidProperties[] = "'brokerage_order_id' can't be null"; } return $invalidProperties; } @@ -286,30 +286,30 @@ public function valid() /** - * Gets external_order_id + * Gets brokerage_order_id * * @return string */ - public function getExternalOrderId() + public function getBrokerageOrderId() { - return $this->container['external_order_id']; + return $this->container['brokerage_order_id']; } /** - * Sets external_order_id + * Sets brokerage_order_id * - * @param string $external_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + * @param string $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. * * @return self */ - public function setExternalOrderId($external_order_id) + public function setBrokerageOrderId($brokerage_order_id) { - if (is_null($external_order_id)) { - throw new \InvalidArgumentException('non-nullable external_order_id cannot be null'); + if (is_null($brokerage_order_id)) { + throw new \InvalidArgumentException('non-nullable brokerage_order_id cannot be null'); } - $this->container['external_order_id'] = $external_order_id; + $this->container['brokerage_order_id'] = $brokerage_order_id; return $this; } diff --git a/test/Model/AccountInformationGetUserAccountOrderDetailRequestTest.php b/test/Model/AccountInformationGetUserAccountOrderDetailRequestTest.php index d66b19d..483faf2 100644 --- a/test/Model/AccountInformationGetUserAccountOrderDetailRequestTest.php +++ b/test/Model/AccountInformationGetUserAccountOrderDetailRequestTest.php @@ -73,9 +73,9 @@ public function testAccountInformationGetUserAccountOrderDetailRequest() } /** - * Test attribute "external_order_id" + * Test attribute "brokerage_order_id" */ - public function testPropertyExternalOrderId() + public function testPropertyBrokerageOrderId() { // TODO: implement $this->markTestIncomplete('Not implemented'); From c31ac802b0dba78a19100221c941e66cfef05379 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 5 Sep 2025 02:44:18 +0000 Subject: [PATCH 187/252] Version Bump SDKs (#214) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 7043352..0e731cb 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -7ac6f7e1-59d1-4381-9e0e-e5dc0f7d49cd \ No newline at end of file +13b5e175-f43e-4fa0-a00c-1db6c5afafc4 \ No newline at end of file diff --git a/README.md b/README.md index decd593..e2637ea 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.128-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.129-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.128" + "konfig/snaptrade-php-sdk": "2.0.129" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 78ab3ac..51af462 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.128/PHP'; + protected $userAgent = 'Konfig/2.0.129/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.128' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.129' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 2ea05014d1d961b3d158ca32a41ec01397d71bda Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 5 Sep 2025 22:30:40 +0000 Subject: [PATCH 188/252] Regenerate SDKs (#215) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Model/MlegPriceEffectStrict.php | 2 +- lib/Model/SnapTradeLoginUserRequestBody.php | 4 +++- test/Model/MlegPriceEffectStrictTest.php | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0e731cb..7de3aea 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -13b5e175-f43e-4fa0-a00c-1db6c5afafc4 \ No newline at end of file +92c86616-d88e-4d0f-a355-bbc29e812570 \ No newline at end of file diff --git a/README.md b/README.md index e2637ea..6b53d75 100644 --- a/README.md +++ b/README.md @@ -799,7 +799,7 @@ The UUID of the brokerage connection to be reconnected. This parameter should be ##### connectionType: `string` -Sets whether the connection should be read-only or trade-enabled. Defaults to read-only if not specified. +Determines connection permissions (default: read) - `read`: Data access only. - `trade`: Data and trading access. - `trade-if-available`: Attempts to establish a trading connection if the brokerage supports it, otherwise falls back to read-only access automatically. ##### connectionPortalVersion: `string` diff --git a/lib/Model/MlegPriceEffectStrict.php b/lib/Model/MlegPriceEffectStrict.php index d56ba91..81a16de 100644 --- a/lib/Model/MlegPriceEffectStrict.php +++ b/lib/Model/MlegPriceEffectStrict.php @@ -28,7 +28,7 @@ * MlegPriceEffectStrict Class Doc Comment * * @category Class - * @description The desired price_effect for LIMIT and STOP_LOSS_LIMIT orders. Only required for certain brokerages like ETrade. + * @description The desired price_effect for LIMIT and STOP_LOSS_LIMIT orders * @package SnapTrade */ class MlegPriceEffectStrict diff --git a/lib/Model/SnapTradeLoginUserRequestBody.php b/lib/Model/SnapTradeLoginUserRequestBody.php index 2d856dd..ccd3611 100644 --- a/lib/Model/SnapTradeLoginUserRequestBody.php +++ b/lib/Model/SnapTradeLoginUserRequestBody.php @@ -254,6 +254,7 @@ public function getModelName() public const CONNECTION_TYPE_READ = 'read'; public const CONNECTION_TYPE_TRADE = 'trade'; + public const CONNECTION_TYPE_TRADE_IF_AVAILABLE = 'trade-if-available'; public const CONNECTION_PORTAL_VERSION_V4 = 'v4'; public const CONNECTION_PORTAL_VERSION_V3 = 'v3'; public const CONNECTION_PORTAL_VERSION_V2 = 'v2'; @@ -268,6 +269,7 @@ public function getConnectionTypeAllowableValues() return [ self::CONNECTION_TYPE_READ, self::CONNECTION_TYPE_TRADE, + self::CONNECTION_TYPE_TRADE_IF_AVAILABLE, ]; } @@ -497,7 +499,7 @@ public function getConnectionType() /** * Sets connection_type * - * @param string|null $connection_type Sets whether the connection should be read-only or trade-enabled. Defaults to read-only if not specified. + * @param string|null $connection_type Determines connection permissions (default: read) - `read`: Data access only. - `trade`: Data and trading access. - `trade-if-available`: Attempts to establish a trading connection if the brokerage supports it, otherwise falls back to read-only access automatically. * * @return self */ diff --git a/test/Model/MlegPriceEffectStrictTest.php b/test/Model/MlegPriceEffectStrictTest.php index f90485e..9217146 100644 --- a/test/Model/MlegPriceEffectStrictTest.php +++ b/test/Model/MlegPriceEffectStrictTest.php @@ -29,7 +29,7 @@ * MlegPriceEffectStrictTest Class Doc Comment * * @category Class - * @description The desired price_effect for LIMIT and STOP_LOSS_LIMIT orders. Only required for certain brokerages like ETrade. + * @description The desired price_effect for LIMIT and STOP_LOSS_LIMIT orders * @package SnapTrade */ class MlegPriceEffectStrictTest extends TestCase From 6031b51642ed8ff1fd60aeff664d1df9f5ae5c16 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 5 Sep 2025 22:34:49 +0000 Subject: [PATCH 189/252] Version Bump SDKs (#216) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 7de3aea..d31ee07 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -92c86616-d88e-4d0f-a355-bbc29e812570 \ No newline at end of file +effc755a-4186-4409-8200-1c4d0b9ca28a \ No newline at end of file diff --git a/README.md b/README.md index 6b53d75..5754eab 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.129-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.130-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.129" + "konfig/snaptrade-php-sdk": "2.0.130" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 51af462..81ee735 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.129/PHP'; + protected $userAgent = 'Konfig/2.0.130/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.129' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.130' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 4dafa59612aebbf7ce501e78df34f12f0a9987da Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 11 Sep 2025 17:28:30 +0000 Subject: [PATCH 190/252] Regenerate SDKs (#218) * Regenerate SDKs * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 28 +- lib/Api/AccountInformationApi.php | 8 +- lib/Api/ConnectionsApi.php | 8 +- lib/Api/TradingApi.php | 112 ++--- lib/Model/StopLoss.php | 2 +- lib/Model/TakeProfit.php | 2 +- .../TradingCancelUserAccountOrderRequest.php | 404 ------------------ test/Model/StopLossTest.php | 2 +- test/Model/TakeProfitTest.php | 2 +- ...adingCancelUserAccountOrderRequestTest.php | 83 ---- 11 files changed, 83 insertions(+), 570 deletions(-) delete mode 100644 lib/Model/TradingCancelUserAccountOrderRequest.php delete mode 100644 test/Model/TradingCancelUserAccountOrderRequestTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index d31ee07..244f1bd 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -effc755a-4186-4409-8200-1c4d0b9ca28a \ No newline at end of file +02c2938d-377f-4f5b-a7d9-9d9c98af612e \ No newline at end of file diff --git a/README.md b/README.md index 5754eab..6394727 100644 --- a/README.md +++ b/README.md @@ -476,7 +476,7 @@ A lightweight endpoint that returns a list of orders executed in the last 24 hou This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false -**Please contact support for access as this endpoint is not enabled by default.** +**Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** @@ -1015,7 +1015,7 @@ $result = $snaptrade->connections->listBrokerageAuthorizations( Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. -**Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge based on your [Pricing Plan](https://snaptrade.com/pricing)** +**Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** @@ -1623,25 +1623,25 @@ Cancels an order in the specified account. Accepts order IDs for all asset types ```php $result = $snaptrade->trading->cancelOrder( + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e" + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" ); ``` #### βš™οΈ Parameters +##### brokerage_order_id: `string` + +Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + ##### user_id: `string` ##### user_secret: `string` ##### account_id: `string` -##### brokerage_order_id: `string` - -Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. - #### πŸ”„ Return @@ -1668,25 +1668,25 @@ Attempts to cancel an open order with the brokerage. If the order is no longer c ```php $result = $snaptrade->trading->cancelUserAccountOrder( + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", - brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e" + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" ); ``` #### βš™οΈ Parameters +##### brokerage_order_id: `string` + +Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + ##### user_id: `string` ##### user_secret: `string` ##### account_id: `string` -##### brokerage_order_id: `string` - -Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. - #### πŸ”„ Return diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index dd18cba..77db8c8 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -3335,7 +3335,7 @@ public function getUserAccountPositionsRequest($user_id, $user_secret, $account_ * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Please contact support for access as this endpoint is not enabled by default.** + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -3366,7 +3366,7 @@ public function getUserAccountRecentOrders( * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Please contact support for access as this endpoint is not enabled by default.** + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $user_id (required) * @param string $user_secret (required) @@ -3535,7 +3535,7 @@ public function getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $ * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Please contact support for access as this endpoint is not enabled by default.** + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $user_id (required) * @param string $user_secret (required) @@ -3569,7 +3569,7 @@ function ($response) { * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Please contact support for access as this endpoint is not enabled by default.** + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $user_id (required) * @param string $user_secret (required) diff --git a/lib/Api/ConnectionsApi.php b/lib/Api/ConnectionsApi.php index 4bb8c91..b5305a2 100644 --- a/lib/Api/ConnectionsApi.php +++ b/lib/Api/ConnectionsApi.php @@ -1430,7 +1430,7 @@ public function listBrokerageAuthorizationsRequest($user_id, $user_secret, strin * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge based on your [Pricing Plan](https://snaptrade.com/pricing)** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) @@ -1459,7 +1459,7 @@ public function refreshBrokerageAuthorization( * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge based on your [Pricing Plan](https://snaptrade.com/pricing)** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1672,7 +1672,7 @@ public function refreshBrokerageAuthorizationWithHttpInfo($authorization_id, $us * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge based on your [Pricing Plan](https://snaptrade.com/pricing)** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1704,7 +1704,7 @@ function ($response) { * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs a additional charge based on your [Pricing Plan](https://snaptrade.com/pricing)** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $authorization_id (required) * @param string $user_id (required) diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 32c2b66..38fda10 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -181,7 +181,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request trading_cancel_user_account_order_request (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -190,18 +190,18 @@ private function setRequestBodyProperty(&$body, $property, $value) { */ public function cancelOrder( + $brokerage_order_id, $user_id, $user_secret, $account_id, - $brokerage_order_id = SENTINEL_VALUE, string $contentType = self::contentTypes['cancelOrder'][0] ) { $_body = []; $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); - $trading_cancel_user_account_order_request = $_body; + $account_information_get_user_account_order_detail_request = $_body; - list($response) = $this->cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); + list($response) = $this->cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, $contentType); return $response; } @@ -215,16 +215,16 @@ public function cancelOrder( * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \SnapTrade\Model\CancelOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings) */ - public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['cancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelOrderRequest($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -243,7 +243,7 @@ public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $tr $user_id, $user_secret, $account_id, - $trading_cancel_user_account_order_request, + $account_information_get_user_account_order_detail_request, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -361,7 +361,7 @@ public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $tr * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -369,18 +369,18 @@ public function cancelOrderWithHttpInfo($user_id, $user_secret, $account_id, $tr */ public function cancelOrderAsync( + $brokerage_order_id, $user_id, $user_secret, $account_id, - $brokerage_order_id = SENTINEL_VALUE, string $contentType = self::contentTypes['cancelOrder'][0] ) { $_body = []; $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); - $trading_cancel_user_account_order_request = $_body; + $account_information_get_user_account_order_detail_request = $_body; - return $this->cancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType) + return $this->cancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, $contentType) ->then( function ($response) { return $response[0]; @@ -398,16 +398,16 @@ function ($response) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function cancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function cancelOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['cancelOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\CancelOrderResponse'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelOrderRequest($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -454,13 +454,13 @@ function ($exception) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function cancelOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelOrder'][0]) + public function cancelOrderRequest($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['cancelOrder'][0]) { // Check if $user_id is a string @@ -493,18 +493,18 @@ public function cancelOrderRequest($user_id, $user_secret, $account_id, $trading 'Missing the required parameter account_id when calling cancelOrder' ); } - if ($trading_cancel_user_account_order_request !== SENTINEL_VALUE) { - if (!($trading_cancel_user_account_order_request instanceof \SnapTrade\Model\TradingCancelUserAccountOrderRequest)) { - if (!is_array($trading_cancel_user_account_order_request)) - throw new \InvalidArgumentException('"trading_cancel_user_account_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCancelUserAccountOrderRequest TradingApi.cancelOrder.'); + if ($account_information_get_user_account_order_detail_request !== SENTINEL_VALUE) { + if (!($account_information_get_user_account_order_detail_request instanceof \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest)) { + if (!is_array($account_information_get_user_account_order_detail_request)) + throw new \InvalidArgumentException('"account_information_get_user_account_order_detail_request" must be associative array or an instance of \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest TradingApi.cancelOrder.'); else - $trading_cancel_user_account_order_request = new \SnapTrade\Model\TradingCancelUserAccountOrderRequest($trading_cancel_user_account_order_request); + $account_information_get_user_account_order_detail_request = new \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest($account_information_get_user_account_order_detail_request); } } - // verify the required parameter 'trading_cancel_user_account_order_request' is set - if ($trading_cancel_user_account_order_request === SENTINEL_VALUE || (is_array($trading_cancel_user_account_order_request) && count($trading_cancel_user_account_order_request) === 0)) { + // verify the required parameter 'account_information_get_user_account_order_detail_request' is set + if ($account_information_get_user_account_order_detail_request === SENTINEL_VALUE || (is_array($account_information_get_user_account_order_detail_request) && count($account_information_get_user_account_order_detail_request) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter trading_cancel_user_account_order_request when calling cancelOrder' + 'Missing the required parameter account_information_get_user_account_order_detail_request when calling cancelOrder' ); } @@ -557,12 +557,12 @@ public function cancelOrderRequest($user_id, $user_secret, $account_id, $trading ); // for model (json/xml) - if (isset($trading_cancel_user_account_order_request)) { + if (isset($account_information_get_user_account_order_detail_request)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_cancel_user_account_order_request)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($account_information_get_user_account_order_detail_request)); } else { - $httpBody = $trading_cancel_user_account_order_request; + $httpBody = $account_information_get_user_account_order_detail_request; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -641,7 +641,7 @@ public function cancelOrderRequest($user_id, $user_secret, $account_id, $trading * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) * @param string $account_id account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request trading_cancel_user_account_order_request (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -651,18 +651,18 @@ public function cancelOrderRequest($user_id, $user_secret, $account_id, $trading */ public function cancelUserAccountOrder( + $brokerage_order_id, $user_id, $user_secret, $account_id, - $brokerage_order_id = SENTINEL_VALUE, string $contentType = self::contentTypes['cancelUserAccountOrder'][0] ) { $_body = []; $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); - $trading_cancel_user_account_order_request = $_body; + $account_information_get_user_account_order_detail_request = $_body; - list($response) = $this->cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); + list($response) = $this->cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, $contentType); return $response; } @@ -676,7 +676,7 @@ public function cancelUserAccountOrder( * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -684,9 +684,9 @@ public function cancelUserAccountOrder( * @return array of \SnapTrade\Model\AccountOrderRecord|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) * @deprecated */ - public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -705,7 +705,7 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco $user_id, $user_secret, $account_id, - $trading_cancel_user_account_order_request, + $account_information_get_user_account_order_detail_request, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -846,7 +846,7 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -855,18 +855,18 @@ public function cancelUserAccountOrderWithHttpInfo($user_id, $user_secret, $acco */ public function cancelUserAccountOrderAsync( + $brokerage_order_id, $user_id, $user_secret, $account_id, - $brokerage_order_id = SENTINEL_VALUE, string $contentType = self::contentTypes['cancelUserAccountOrder'][0] ) { $_body = []; $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); - $trading_cancel_user_account_order_request = $_body; + $account_information_get_user_account_order_detail_request = $_body; - return $this->cancelUserAccountOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType) + return $this->cancelUserAccountOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, $contentType) ->then( function ($response) { return $response[0]; @@ -884,17 +884,17 @@ function ($response) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface * @deprecated */ - public function cancelUserAccountOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function cancelUserAccountOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\AccountOrderRecord'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, $contentType); // Customization hook $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); @@ -941,14 +941,14 @@ function ($exception) { * @param string $user_id (required) * @param string $user_secret (required) * @param string $account_id (required) - * @param \SnapTrade\Model\TradingCancelUserAccountOrderRequest $trading_cancel_user_account_order_request (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['cancelUserAccountOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request * @deprecated */ - public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $trading_cancel_user_account_order_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0]) + public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_id, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['cancelUserAccountOrder'][0]) { // Check if $user_id is a string @@ -981,18 +981,18 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i 'Missing the required parameter account_id when calling cancelUserAccountOrder' ); } - if ($trading_cancel_user_account_order_request !== SENTINEL_VALUE) { - if (!($trading_cancel_user_account_order_request instanceof \SnapTrade\Model\TradingCancelUserAccountOrderRequest)) { - if (!is_array($trading_cancel_user_account_order_request)) - throw new \InvalidArgumentException('"trading_cancel_user_account_order_request" must be associative array or an instance of \SnapTrade\Model\TradingCancelUserAccountOrderRequest TradingApi.cancelUserAccountOrder.'); + if ($account_information_get_user_account_order_detail_request !== SENTINEL_VALUE) { + if (!($account_information_get_user_account_order_detail_request instanceof \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest)) { + if (!is_array($account_information_get_user_account_order_detail_request)) + throw new \InvalidArgumentException('"account_information_get_user_account_order_detail_request" must be associative array or an instance of \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest TradingApi.cancelUserAccountOrder.'); else - $trading_cancel_user_account_order_request = new \SnapTrade\Model\TradingCancelUserAccountOrderRequest($trading_cancel_user_account_order_request); + $account_information_get_user_account_order_detail_request = new \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest($account_information_get_user_account_order_detail_request); } } - // verify the required parameter 'trading_cancel_user_account_order_request' is set - if ($trading_cancel_user_account_order_request === SENTINEL_VALUE || (is_array($trading_cancel_user_account_order_request) && count($trading_cancel_user_account_order_request) === 0)) { + // verify the required parameter 'account_information_get_user_account_order_detail_request' is set + if ($account_information_get_user_account_order_detail_request === SENTINEL_VALUE || (is_array($account_information_get_user_account_order_detail_request) && count($account_information_get_user_account_order_detail_request) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter trading_cancel_user_account_order_request when calling cancelUserAccountOrder' + 'Missing the required parameter account_information_get_user_account_order_detail_request when calling cancelUserAccountOrder' ); } @@ -1045,12 +1045,12 @@ public function cancelUserAccountOrderRequest($user_id, $user_secret, $account_i ); // for model (json/xml) - if (isset($trading_cancel_user_account_order_request)) { + if (isset($account_information_get_user_account_order_detail_request)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_cancel_user_account_order_request)); + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($account_information_get_user_account_order_detail_request)); } else { - $httpBody = $trading_cancel_user_account_order_request; + $httpBody = $account_information_get_user_account_order_detail_request; } } elseif (count($formParams) > 0) { if ($multipart) { diff --git a/lib/Model/StopLoss.php b/lib/Model/StopLoss.php index 18ff94f..74a06d8 100644 --- a/lib/Model/StopLoss.php +++ b/lib/Model/StopLoss.php @@ -30,7 +30,7 @@ * StopLoss Class Doc Comment * * @category Class - * @description Details of the stop loss order. Only to be used when order_class = BRACKET. stop_price is required, limit_price is optional + * @description Takes in string value for stop_price and limit_price. stop_price is required, limit_price is optional * @package SnapTrade * @implements \ArrayAccess */ diff --git a/lib/Model/TakeProfit.php b/lib/Model/TakeProfit.php index 749dfd6..ae795d5 100644 --- a/lib/Model/TakeProfit.php +++ b/lib/Model/TakeProfit.php @@ -30,7 +30,7 @@ * TakeProfit Class Doc Comment * * @category Class - * @description Details of the take profit order. Only to be used when order_class = BRACKET. + * @description Takes in a string value for limit_price * @package SnapTrade * @implements \ArrayAccess */ diff --git a/lib/Model/TradingCancelUserAccountOrderRequest.php b/lib/Model/TradingCancelUserAccountOrderRequest.php deleted file mode 100644 index 25ccf9d..0000000 --- a/lib/Model/TradingCancelUserAccountOrderRequest.php +++ /dev/null @@ -1,404 +0,0 @@ - - */ -class TradingCancelUserAccountOrderRequest implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Trading_cancelUserAccountOrder_request'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'brokerage_order_id' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'brokerage_order_id' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'brokerage_order_id' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'brokerage_order_id' => 'brokerage_order_id' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'brokerage_order_id' => 'setBrokerageOrderId' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'brokerage_order_id' => 'getBrokerageOrderId' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('brokerage_order_id', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets brokerage_order_id - * - * @return string|null - */ - public function getBrokerageOrderId() - { - return $this->container['brokerage_order_id']; - } - - /** - * Sets brokerage_order_id - * - * @param string|null $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. - * - * @return self - */ - public function setBrokerageOrderId($brokerage_order_id) - { - - if (is_null($brokerage_order_id)) { - throw new \InvalidArgumentException('non-nullable brokerage_order_id cannot be null'); - } - - $this->container['brokerage_order_id'] = $brokerage_order_id; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/test/Model/StopLossTest.php b/test/Model/StopLossTest.php index c1523a9..607f755 100644 --- a/test/Model/StopLossTest.php +++ b/test/Model/StopLossTest.php @@ -29,7 +29,7 @@ * StopLossTest Class Doc Comment * * @category Class - * @description Details of the stop loss order. Only to be used when order_class = BRACKET. stop_price is required, limit_price is optional + * @description Takes in string value for stop_price and limit_price. stop_price is required, limit_price is optional * @package SnapTrade */ class StopLossTest extends TestCase diff --git a/test/Model/TakeProfitTest.php b/test/Model/TakeProfitTest.php index 00ff289..ee1f127 100644 --- a/test/Model/TakeProfitTest.php +++ b/test/Model/TakeProfitTest.php @@ -29,7 +29,7 @@ * TakeProfitTest Class Doc Comment * * @category Class - * @description Details of the take profit order. Only to be used when order_class = BRACKET. + * @description Takes in a string value for limit_price * @package SnapTrade */ class TakeProfitTest extends TestCase diff --git a/test/Model/TradingCancelUserAccountOrderRequestTest.php b/test/Model/TradingCancelUserAccountOrderRequestTest.php deleted file mode 100644 index ae1078a..0000000 --- a/test/Model/TradingCancelUserAccountOrderRequestTest.php +++ /dev/null @@ -1,83 +0,0 @@ -markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "brokerage_order_id" - */ - public function testPropertyBrokerageOrderId() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } -} From 2603b888314b7b2577900ec898d744a6bc32ccfd Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 11 Sep 2025 17:32:46 +0000 Subject: [PATCH 191/252] Version Bump SDKs (#219) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 244f1bd..49e1569 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -02c2938d-377f-4f5b-a7d9-9d9c98af612e \ No newline at end of file +764c7413-014e-4424-afbb-649af95da335 \ No newline at end of file diff --git a/README.md b/README.md index 6394727..cddf5ab 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.130-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.131-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.130" + "konfig/snaptrade-php-sdk": "2.0.131" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 81ee735..e42fe64 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.130/PHP'; + protected $userAgent = 'Konfig/2.0.131/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.130' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.131' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 976388ac487b06c54bf0338ad5ba360067f0e6ed Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 15 Sep 2025 16:34:55 +0000 Subject: [PATCH 192/252] Regenerate SDKs (#220) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 ++ lib/Api/AccountInformationApi.php | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 49e1569..73a5149 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -764c7413-014e-4424-afbb-649af95da335 \ No newline at end of file +7815541e-cb86-4867-83c1-f9e1ddecd5df \ No newline at end of file diff --git a/README.md b/README.md index cddf5ab..a79d89f 100644 --- a/README.md +++ b/README.md @@ -337,6 +337,8 @@ $result = $snaptrade->accountInformation->getUserAccountDetails( Returns the detail of a single order using the external order ID provided in the request body. +This endpoint only works for single-leg orders at this time. Support for multi-leg orders will be added in the future. + This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 77db8c8..6e7919b 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -1957,7 +1957,7 @@ public function getUserAccountDetailsRequest($user_id, $user_secret, $account_id * * Get account order detail * - * Returns the detail of a single order using the external order ID provided in the request body. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the external order ID provided in the request body. This endpoint only works for single-leg orders at this time. Support for multi-leg orders will be added in the future. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $account_id account_id (required) * @param string $user_id user_id (required) @@ -1991,7 +1991,7 @@ public function getUserAccountOrderDetail( * * Get account order detail * - * Returns the detail of a single order using the external order ID provided in the request body. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the external order ID provided in the request body. This endpoint only works for single-leg orders at this time. Support for multi-leg orders will be added in the future. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $account_id (required) * @param string $user_id (required) @@ -2183,7 +2183,7 @@ public function getUserAccountOrderDetailWithHttpInfo($account_id, $user_id, $us * * Get account order detail * - * Returns the detail of a single order using the external order ID provided in the request body. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the external order ID provided in the request body. This endpoint only works for single-leg orders at this time. Support for multi-leg orders will be added in the future. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $account_id (required) * @param string $user_id (required) @@ -2220,7 +2220,7 @@ function ($response) { * * Get account order detail * - * Returns the detail of a single order using the external order ID provided in the request body. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the external order ID provided in the request body. This endpoint only works for single-leg orders at this time. Support for multi-leg orders will be added in the future. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $account_id (required) * @param string $user_id (required) From bf3bf7f9d186f591f0b9a0cefff3b32eef64d89f Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 15 Sep 2025 16:39:04 +0000 Subject: [PATCH 193/252] Version Bump SDKs (#221) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 73a5149..c223ca1 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -7815541e-cb86-4867-83c1-f9e1ddecd5df \ No newline at end of file +b8ca48a6-80ff-454b-be98-59b8e9db5b95 \ No newline at end of file diff --git a/README.md b/README.md index a79d89f..410dcf2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.131-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.132-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.131" + "konfig/snaptrade-php-sdk": "2.0.132" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index e42fe64..2938e40 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.131/PHP'; + protected $userAgent = 'Konfig/2.0.132/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.131' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.132' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From f58ef8a128fa985cb5044248e561debf0c2b2ef8 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 19:08:01 +0000 Subject: [PATCH 194/252] Regenerate SDKs (#222) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 5 ---- lib/Api/TradingApi.php | 4 --- lib/Model/ManualTradeFormBracket.php | 36 ----------------------- test/Model/ManualTradeFormBracketTest.php | 9 ------ 5 files changed, 1 insertion(+), 55 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index c223ca1..e7abe47 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -b8ca48a6-80ff-454b-be98-59b8e9db5b95 \ No newline at end of file +5798ccf7-dae5-40c7-b22b-76c2e2216387 \ No newline at end of file diff --git a/README.md b/README.md index 410dcf2..90b37d5 100644 --- a/README.md +++ b/README.md @@ -1895,7 +1895,6 @@ $result = $snaptrade->trading->placeBracketOrder( account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", - symbol: "AAPL", price: 31.33, stop: 31.33, units: 10.5 @@ -1924,10 +1923,6 @@ The ID of the account to execute the trade on. ##### user_secret: `string` -##### symbol: `string` - -The security's trading ticker symbol. - ##### price: `float` The limit price for `Limit` and `StopLimit` orders. diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 38fda10..368d903 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -2560,7 +2560,6 @@ public function placeBracketOrder( $account_id, $user_id, $user_secret, - $symbol = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, @@ -2569,7 +2568,6 @@ public function placeBracketOrder( { $_body = []; $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "instrument", $instrument); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); @@ -2780,7 +2778,6 @@ public function placeBracketOrderAsync( $account_id, $user_id, $user_secret, - $symbol = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, @@ -2789,7 +2786,6 @@ public function placeBracketOrderAsync( { $_body = []; $this->setRequestBodyProperty($_body, "action", $action); - $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "instrument", $instrument); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); diff --git a/lib/Model/ManualTradeFormBracket.php b/lib/Model/ManualTradeFormBracket.php index 3a6831d..8b38b89 100644 --- a/lib/Model/ManualTradeFormBracket.php +++ b/lib/Model/ManualTradeFormBracket.php @@ -52,7 +52,6 @@ class ManualTradeFormBracket implements ModelInterface, ArrayAccess, \JsonSerial */ protected static $openAPITypes = [ 'action' => '\SnapTrade\Model\ActionStrictWithOptions', - 'symbol' => 'string', 'instrument' => '\SnapTrade\Model\TradingInstrument', 'order_type' => '\SnapTrade\Model\OrderTypeStrict', 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', @@ -72,7 +71,6 @@ class ManualTradeFormBracket implements ModelInterface, ArrayAccess, \JsonSerial */ protected static $openAPIFormats = [ 'action' => null, - 'symbol' => null, 'instrument' => null, 'order_type' => null, 'time_in_force' => null, @@ -90,7 +88,6 @@ class ManualTradeFormBracket implements ModelInterface, ArrayAccess, \JsonSerial */ protected static array $openAPINullables = [ 'action' => false, - 'symbol' => false, 'instrument' => false, 'order_type' => false, 'time_in_force' => false, @@ -188,7 +185,6 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'action' => 'action', - 'symbol' => 'symbol', 'instrument' => 'instrument', 'order_type' => 'order_type', 'time_in_force' => 'time_in_force', @@ -206,7 +202,6 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'action' => 'setAction', - 'symbol' => 'setSymbol', 'instrument' => 'setInstrument', 'order_type' => 'setOrderType', 'time_in_force' => 'setTimeInForce', @@ -224,7 +219,6 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'action' => 'getAction', - 'symbol' => 'getSymbol', 'instrument' => 'getInstrument', 'order_type' => 'getOrderType', 'time_in_force' => 'getTimeInForce', @@ -293,7 +287,6 @@ public function getModelName() public function __construct(array $data = null) { $this->setIfExists('action', $data ?? [], null); - $this->setIfExists('symbol', $data ?? [], null); $this->setIfExists('instrument', $data ?? [], null); $this->setIfExists('order_type', $data ?? [], null); $this->setIfExists('time_in_force', $data ?? [], null); @@ -393,35 +386,6 @@ public function setAction($action) return $this; } - /** - * Gets symbol - * - * @return string|null - */ - public function getSymbol() - { - return $this->container['symbol']; - } - - /** - * Sets symbol - * - * @param string|null $symbol The security's trading ticker symbol. - * - * @return self - */ - public function setSymbol($symbol) - { - - if (is_null($symbol)) { - throw new \InvalidArgumentException('non-nullable symbol cannot be null'); - } - - $this->container['symbol'] = $symbol; - - return $this; - } - /** * Gets instrument * diff --git a/test/Model/ManualTradeFormBracketTest.php b/test/Model/ManualTradeFormBracketTest.php index 1c8c52c..b30b06e 100644 --- a/test/Model/ManualTradeFormBracketTest.php +++ b/test/Model/ManualTradeFormBracketTest.php @@ -81,15 +81,6 @@ public function testPropertyAction() $this->markTestIncomplete('Not implemented'); } - /** - * Test attribute "symbol" - */ - public function testPropertySymbol() - { - // TODO: implement - $this->markTestIncomplete('Not implemented'); - } - /** * Test attribute "instrument" */ From f5910c91eb6e8d1b3bdedf9de1744ba3d7cb6d0d Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 19:12:34 +0000 Subject: [PATCH 195/252] Version Bump SDKs (#223) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index e7abe47..da4f9a3 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -5798ccf7-dae5-40c7-b22b-76c2e2216387 \ No newline at end of file +002e6c07-9a9b-4f5f-bb9c-b9ae6862b67d \ No newline at end of file diff --git a/README.md b/README.md index 90b37d5..e5ec7e7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.132-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.133-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.132" + "konfig/snaptrade-php-sdk": "2.0.133" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 2938e40..4c72f5f 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.132/PHP'; + protected $userAgent = 'Konfig/2.0.133/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.132' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.133' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 7b57a173278a3bc11700745e98c89536631290c2 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 19:46:34 +0000 Subject: [PATCH 196/252] Regenerate SDKs (#224) * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/Position.php | 55 +++++++++++++++++++++++++++++++++---- test/Model/PositionTest.php | 9 ++++++ 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index da4f9a3..8d971a4 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -002e6c07-9a9b-4f5f-bb9c-b9ae6862b67d \ No newline at end of file +355e0095-3383-4730-8ec9-7fcfb14ba0bf \ No newline at end of file diff --git a/lib/Model/Position.php b/lib/Model/Position.php index a75fc4f..e11b313 100644 --- a/lib/Model/Position.php +++ b/lib/Model/Position.php @@ -57,7 +57,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'open_pnl' => 'float', 'average_purchase_price' => 'float', 'fractional_units' => 'float', - 'currency' => '\SnapTrade\Model\PositionCurrency' + 'currency' => '\SnapTrade\Model\PositionCurrency', + 'cash_equivalent' => 'bool' ]; /** @@ -74,7 +75,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'open_pnl' => null, 'average_purchase_price' => null, 'fractional_units' => null, - 'currency' => null + 'currency' => null, + 'cash_equivalent' => null ]; /** @@ -89,7 +91,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'open_pnl' => true, 'average_purchase_price' => true, 'fractional_units' => true, - 'currency' => false + 'currency' => false, + 'cash_equivalent' => true ]; /** @@ -184,7 +187,8 @@ public function isNullableSetToNull(string $property): bool 'open_pnl' => 'open_pnl', 'average_purchase_price' => 'average_purchase_price', 'fractional_units' => 'fractional_units', - 'currency' => 'currency' + 'currency' => 'currency', + 'cash_equivalent' => 'cash_equivalent' ]; /** @@ -199,7 +203,8 @@ public function isNullableSetToNull(string $property): bool 'open_pnl' => 'setOpenPnl', 'average_purchase_price' => 'setAveragePurchasePrice', 'fractional_units' => 'setFractionalUnits', - 'currency' => 'setCurrency' + 'currency' => 'setCurrency', + 'cash_equivalent' => 'setCashEquivalent' ]; /** @@ -214,7 +219,8 @@ public function isNullableSetToNull(string $property): bool 'open_pnl' => 'getOpenPnl', 'average_purchase_price' => 'getAveragePurchasePrice', 'fractional_units' => 'getFractionalUnits', - 'currency' => 'getCurrency' + 'currency' => 'getCurrency', + 'cash_equivalent' => 'getCashEquivalent' ]; /** @@ -281,6 +287,7 @@ public function __construct(array $data = null) $this->setIfExists('average_purchase_price', $data ?? [], null); $this->setIfExists('fractional_units', $data ?? [], null); $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('cash_equivalent', $data ?? [], null); } /** @@ -564,6 +571,42 @@ public function setCurrency($currency) return $this; } + + /** + * Gets cash_equivalent + * + * @return bool|null + */ + public function getCashEquivalent() + { + return $this->container['cash_equivalent']; + } + + /** + * Sets cash_equivalent + * + * @param bool|null $cash_equivalent If the position is a cash equivalent (usually a money market fund) that is also counted in account cash balance and buying power + * + * @return self + */ + public function setCashEquivalent($cash_equivalent) + { + + if (is_null($cash_equivalent)) { + array_push($this->openAPINullablesSetToNull, 'cash_equivalent'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('cash_equivalent', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['cash_equivalent'] = $cash_equivalent; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/test/Model/PositionTest.php b/test/Model/PositionTest.php index 6d30436..9b9fb13 100644 --- a/test/Model/PositionTest.php +++ b/test/Model/PositionTest.php @@ -134,4 +134,13 @@ public function testPropertyCurrency() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "cash_equivalent" + */ + public function testPropertyCashEquivalent() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } From 743f116eda2fc9063a0d1d558d6d53acd7c79c3e Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 19:50:52 +0000 Subject: [PATCH 197/252] Version Bump SDKs (#225) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 8d971a4..b8fb80c 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -355e0095-3383-4730-8ec9-7fcfb14ba0bf \ No newline at end of file +a5ea87e5-f034-465a-b375-c9bba3a187a6 \ No newline at end of file diff --git a/README.md b/README.md index e5ec7e7..f74e334 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.133-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.134-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.133" + "konfig/snaptrade-php-sdk": "2.0.134" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 4c72f5f..73c8fba 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.133/PHP'; + protected $userAgent = 'Konfig/2.0.134/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.133' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.134' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 95323bb4a311040aee5e2979882e156e0768f9e0 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:55:58 +0000 Subject: [PATCH 198/252] Regenerate SDKs (#226) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/TradingApi.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b8fb80c..f2dfe75 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -a5ea87e5-f034-465a-b375-c9bba3a187a6 \ No newline at end of file +a14b4f0d-7dc7-491c-a6e8-b359af1e9d2c \ No newline at end of file diff --git a/README.md b/README.md index f74e334..a5e693a 100644 --- a/README.md +++ b/README.md @@ -2387,7 +2387,7 @@ The price at which a stop order is triggered for `Stop` and `StopLimit` orders. ### `snaptrade.trading.searchCryptocurrencyPairInstruments` -Searches cryptocurrency pairs instruments accessible to the specified account. +Searches cryptocurrency pairs instruments accessible to the specified account. Both `base` and `quote` are optional. Omit both for a full list of cryptocurrency pairs. diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 368d903..61863ce 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -5974,7 +5974,7 @@ public function replaceOrderRequest($account_id, $user_id, $user_secret, $manual * * Get crypto pairs * - * Searches cryptocurrency pairs instruments accessible to the specified account. + * Searches cryptocurrency pairs instruments accessible to the specified account. Both `base` and `quote` are optional. Omit both for a full list of cryptocurrency pairs. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -6007,7 +6007,7 @@ public function searchCryptocurrencyPairInstruments( * * Get crypto pairs * - * Searches cryptocurrency pairs instruments accessible to the specified account. + * Searches cryptocurrency pairs instruments accessible to the specified account. Both `base` and `quote` are optional. Omit both for a full list of cryptocurrency pairs. * * @param string $user_id (required) * @param string $user_secret (required) @@ -6155,7 +6155,7 @@ public function searchCryptocurrencyPairInstrumentsWithHttpInfo($user_id, $user_ * * Get crypto pairs * - * Searches cryptocurrency pairs instruments accessible to the specified account. + * Searches cryptocurrency pairs instruments accessible to the specified account. Both `base` and `quote` are optional. Omit both for a full list of cryptocurrency pairs. * * @param string $user_id (required) * @param string $user_secret (required) @@ -6191,7 +6191,7 @@ function ($response) { * * Get crypto pairs * - * Searches cryptocurrency pairs instruments accessible to the specified account. + * Searches cryptocurrency pairs instruments accessible to the specified account. Both `base` and `quote` are optional. Omit both for a full list of cryptocurrency pairs. * * @param string $user_id (required) * @param string $user_secret (required) From ea2d3a1e0f72c712afe1268aaf95cdb757362697 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 16:00:18 +0000 Subject: [PATCH 199/252] Version Bump SDKs (#227) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f2dfe75..1c27214 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -a14b4f0d-7dc7-491c-a6e8-b359af1e9d2c \ No newline at end of file +44d54d0f-e5c2-446a-ae8e-c7049fb511c8 \ No newline at end of file diff --git a/README.md b/README.md index a5e693a..d5c03a1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.134-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.135-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.134" + "konfig/snaptrade-php-sdk": "2.0.135" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 73c8fba..ff42d8a 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.134/PHP'; + protected $userAgent = 'Konfig/2.0.135/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.134' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.135' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 433a59a3485c0bce9ff4c01e8fe7bf885bab2c8c Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 16:13:00 +0000 Subject: [PATCH 200/252] Regenerate SDKs (#228) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/AccountOrderRecord.php | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 1c27214..a47b225 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -44d54d0f-e5c2-446a-ae8e-c7049fb511c8 \ No newline at end of file +98def0b5-7008-4186-b73a-6dd9ef4f7b92 \ No newline at end of file diff --git a/lib/Model/AccountOrderRecord.php b/lib/Model/AccountOrderRecord.php index 28f6fef..af5a04b 100644 --- a/lib/Model/AccountOrderRecord.php +++ b/lib/Model/AccountOrderRecord.php @@ -58,10 +58,10 @@ class AccountOrderRecord implements ModelInterface, ArrayAccess, \JsonSerializab 'quote_universal_symbol' => '\SnapTrade\Model\AccountOrderRecordQuoteUniversalSymbol', 'quote_currency' => '\SnapTrade\Model\AccountOrderRecordQuoteCurrency', 'action' => 'string', - 'total_quantity' => 'float', - 'open_quantity' => 'float', - 'canceled_quantity' => 'float', - 'filled_quantity' => 'float', + 'total_quantity' => 'string', + 'open_quantity' => 'string', + 'canceled_quantity' => 'string', + 'filled_quantity' => 'string', 'execution_price' => 'float', 'limit_price' => 'float', 'stop_price' => 'float', @@ -636,7 +636,7 @@ public function setAction($action) /** * Gets total_quantity * - * @return float|null + * @return string|null */ public function getTotalQuantity() { @@ -646,7 +646,7 @@ public function getTotalQuantity() /** * Sets total_quantity * - * @param float|null $total_quantity The total number of shares or contracts of the order. This should be the sum of the filled, canceled, and open quantities. Can be a decimal number for fractional shares. + * @param string|null $total_quantity The total number of shares or contracts of the order. This should be the sum of the filled, canceled, and open quantities. Can be a decimal number for fractional shares. * * @return self */ @@ -672,7 +672,7 @@ public function setTotalQuantity($total_quantity) /** * Gets open_quantity * - * @return float|null + * @return string|null */ public function getOpenQuantity() { @@ -682,7 +682,7 @@ public function getOpenQuantity() /** * Sets open_quantity * - * @param float|null $open_quantity The number of shares or contracts that are still open (waiting for execution). Can be a decimal number for fractional shares. + * @param string|null $open_quantity The number of shares or contracts that are still open (waiting for execution). Can be a decimal number for fractional shares. * * @return self */ @@ -708,7 +708,7 @@ public function setOpenQuantity($open_quantity) /** * Gets canceled_quantity * - * @return float|null + * @return string|null */ public function getCanceledQuantity() { @@ -718,7 +718,7 @@ public function getCanceledQuantity() /** * Sets canceled_quantity * - * @param float|null $canceled_quantity The number of shares or contracts that have been canceled. Can be a decimal number for fractional shares. + * @param string|null $canceled_quantity The number of shares or contracts that have been canceled. Can be a decimal number for fractional shares. * * @return self */ @@ -744,7 +744,7 @@ public function setCanceledQuantity($canceled_quantity) /** * Gets filled_quantity * - * @return float|null + * @return string|null */ public function getFilledQuantity() { @@ -754,7 +754,7 @@ public function getFilledQuantity() /** * Sets filled_quantity * - * @param float|null $filled_quantity The number of shares or contracts that have been filled. Can be a decimal number for fractional shares. + * @param string|null $filled_quantity The number of shares or contracts that have been filled. Can be a decimal number for fractional shares. * * @return self */ From edb22969cd17222cdb6b48d5dcef137850310649 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 16:17:21 +0000 Subject: [PATCH 201/252] Version Bump SDKs (#229) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a47b225..86d8026 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -98def0b5-7008-4186-b73a-6dd9ef4f7b92 \ No newline at end of file +fd8da240-8c6b-42d5-86b3-ea183bfe0aba \ No newline at end of file diff --git a/README.md b/README.md index d5c03a1..72724ad 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.135-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.136-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.135" + "konfig/snaptrade-php-sdk": "2.0.136" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index ff42d8a..5886edb 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.135/PHP'; + protected $userAgent = 'Konfig/2.0.136/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.135' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.136' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 806b8d148fcc643e4fc1ea4d57884e8169b74742 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 25 Sep 2025 23:01:22 +0000 Subject: [PATCH 202/252] Regenerate SDKs (#230) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Api/TradingApi.php | 8 ++++---- lib/Model/TradingInstrument.php | 4 +++- test/Api/TradingApiTest.php | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 86d8026..90f8bce 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -fd8da240-8c6b-42d5-86b3-ea183bfe0aba \ No newline at end of file +9cdba6c0-c60b-4f39-aa6a-cf8e2bd04e81 \ No newline at end of file diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 61863ce..8224e53 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -2535,7 +2535,7 @@ public function getUserAccountQuotesRequest($user_id, $user_secret, $symbols, $a /** * Operation placeBracketOrder * - * Place bracket equity order + * Place bracket order * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * @@ -2585,7 +2585,7 @@ public function placeBracketOrder( /** * Operation placeBracketOrderWithHttpInfo * - * Place bracket equity order + * Place bracket order * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * @@ -2754,7 +2754,7 @@ public function placeBracketOrderWithHttpInfo($account_id, $user_id, $user_secre /** * Operation placeBracketOrderAsync * - * Place bracket equity order + * Place bracket order * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * @@ -2807,7 +2807,7 @@ function ($response) { /** * Operation placeBracketOrderAsyncWithHttpInfo * - * Place bracket equity order + * Place bracket order * * Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages * diff --git a/lib/Model/TradingInstrument.php b/lib/Model/TradingInstrument.php index 2f2c5d1..6498dba 100644 --- a/lib/Model/TradingInstrument.php +++ b/lib/Model/TradingInstrument.php @@ -228,6 +228,7 @@ public function getModelName() } public const TYPE_EQUITY = 'EQUITY'; + public const TYPE_OPTION = 'OPTION'; public const TYPE_CRYPTOCURRENCY = 'CRYPTOCURRENCY'; public const TYPE_CRYPTOCURRENCY_PAIR = 'CRYPTOCURRENCY_PAIR'; @@ -240,6 +241,7 @@ public function getTypeAllowableValues() { return [ self::TYPE_EQUITY, + self::TYPE_OPTION, self::TYPE_CRYPTOCURRENCY, self::TYPE_CRYPTOCURRENCY_PAIR, ]; @@ -334,7 +336,7 @@ public function getSymbol() /** * Sets symbol * - * @param string $symbol The instrument's trading ticker symbol + * @param string $symbol The instrument's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example `AAPL 131124C00240000` represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format) * * @return self */ diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index 0cc29df..e0676cf 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -121,7 +121,7 @@ public function testGetUserAccountQuotes() /** * Test case for placeBracketOrder * - * Place bracket equity order. + * Place bracket order. * */ public function testPlaceBracketOrder() From 3700e1a4f920e03beaa6a7d3614334566b67ef48 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 25 Sep 2025 23:05:17 +0000 Subject: [PATCH 203/252] Version Bump SDKs (#231) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 90f8bce..7eb5ca6 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -9cdba6c0-c60b-4f39-aa6a-cf8e2bd04e81 \ No newline at end of file +f4823bfe-e250-40f1-8672-7d087bfdd8f5 \ No newline at end of file diff --git a/README.md b/README.md index 72724ad..0ef1c07 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.136-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.137-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.136" + "konfig/snaptrade-php-sdk": "2.0.137" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 5886edb..e453f65 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.136/PHP'; + protected $userAgent = 'Konfig/2.0.137/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.136' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.137' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From d6619172ae6bdba382cc37aed90f5e1e93d59b8a Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 12:25:58 +0000 Subject: [PATCH 204/252] Regenerate SDKs (#232) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Api/TradingApi.php | 8 ++++---- test/Api/TradingApiTest.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 7eb5ca6..f232f72 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f4823bfe-e250-40f1-8672-7d087bfdd8f5 \ No newline at end of file +ac4febc5-320c-4525-add6-2ea6d10ce30b \ No newline at end of file diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 8224e53..6f86532 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -3542,7 +3542,7 @@ public function placeCryptoOrderRequest($user_id, $user_secret, $account_id, $cr /** * Operation placeForceOrder * - * Place order + * Place equity order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -3592,7 +3592,7 @@ public function placeForceOrder( /** * Operation placeForceOrderWithHttpInfo * - * Place order + * Place equity order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -3759,7 +3759,7 @@ public function placeForceOrderWithHttpInfo($user_id, $user_secret, $manual_trad /** * Operation placeForceOrderAsync * - * Place order + * Place equity order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * @@ -3812,7 +3812,7 @@ function ($response) { /** * Operation placeForceOrderAsyncWithHttpInfo * - * Place order + * Place equity order * * Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds. This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this. * diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php index e0676cf..ff91b5b 100644 --- a/test/Api/TradingApiTest.php +++ b/test/Api/TradingApiTest.php @@ -145,7 +145,7 @@ public function testPlaceCryptoOrder() /** * Test case for placeForceOrder * - * Place order. + * Place equity order. * */ public function testPlaceForceOrder() From 805f7d84855d267c4c3928b3f07ee177fae82488 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 12:29:52 +0000 Subject: [PATCH 205/252] Version Bump SDKs (#233) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f232f72..98f86d3 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ac4febc5-320c-4525-add6-2ea6d10ce30b \ No newline at end of file +bb3cf50a-3d12-4924-a4e0-f09446fb91b5 \ No newline at end of file diff --git a/README.md b/README.md index 0ef1c07..b9c7e06 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.137-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.138-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.137" + "konfig/snaptrade-php-sdk": "2.0.138" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index e453f65..4c917e0 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.137/PHP'; + protected $userAgent = 'Konfig/2.0.138/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.137' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.138' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 64078c80f489972fa911de23fd66444565ab8ecc Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 14:50:52 +0000 Subject: [PATCH 206/252] Regenerate SDKs (#234) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 5 +++ lib/Api/AuthenticationApi.php | 4 +++ lib/Model/SnapTradeLoginUserRequestBody.php | 36 +++++++++++++++++++ .../SnapTradeLoginUserRequestBodyTest.php | 9 +++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 98f86d3..10f8801 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -bb3cf50a-3d12-4924-a4e0-f09446fb91b5 \ No newline at end of file +881edbbf-8a5b-4767-b66f-7d9bf6a54c88 \ No newline at end of file diff --git a/README.md b/README.md index b9c7e06..ca40448 100644 --- a/README.md +++ b/README.md @@ -773,6 +773,7 @@ $result = $snaptrade->authentication->loginSnapTradeUser( custom_redirect: "https://snaptrade.com", reconnect: "8b5f262d-4bb9-365d-888a-202bd3b15fa1", connection_type: "read", + show_close_button: True, connection_portal_version: "v4" ); ``` @@ -803,6 +804,10 @@ The UUID of the brokerage connection to be reconnected. This parameter should be Determines connection permissions (default: read) - `read`: Data access only. - `trade`: Data and trading access. - `trade-if-available`: Attempts to establish a trading connection if the brokerage supports it, otherwise falls back to read-only access automatically. +##### showCloseButton: `bool` + +Controls whether the close (X) button is displayed in the connection portal. When false, you control closing behavior from your app. Defaults to true. + ##### connectionPortalVersion: `string` Sets the connection portal version to render. Currently only v4 is supported and is the default. All other versions are deprecated and will automatically be set to v4. diff --git a/lib/Api/AuthenticationApi.php b/lib/Api/AuthenticationApi.php index 0da1226..a6dc59e 100644 --- a/lib/Api/AuthenticationApi.php +++ b/lib/Api/AuthenticationApi.php @@ -976,6 +976,7 @@ public function loginSnapTradeUser( $custom_redirect = SENTINEL_VALUE, $reconnect = SENTINEL_VALUE, $connection_type = 'read', + $show_close_button = SENTINEL_VALUE, $connection_portal_version = 'v4', string $contentType = self::contentTypes['loginSnapTradeUser'][0] @@ -987,6 +988,7 @@ public function loginSnapTradeUser( $this->setRequestBodyProperty($_body, "custom_redirect", $custom_redirect); $this->setRequestBodyProperty($_body, "reconnect", $reconnect); $this->setRequestBodyProperty($_body, "connection_type", $connection_type); + $this->setRequestBodyProperty($_body, "show_close_button", $show_close_button); $this->setRequestBodyProperty($_body, "connection_portal_version", $connection_portal_version); $snap_trade_login_user_request_body = $_body; @@ -1207,6 +1209,7 @@ public function loginSnapTradeUserAsync( $custom_redirect = SENTINEL_VALUE, $reconnect = SENTINEL_VALUE, $connection_type = 'read', + $show_close_button = SENTINEL_VALUE, $connection_portal_version = 'v4', string $contentType = self::contentTypes['loginSnapTradeUser'][0] @@ -1218,6 +1221,7 @@ public function loginSnapTradeUserAsync( $this->setRequestBodyProperty($_body, "custom_redirect", $custom_redirect); $this->setRequestBodyProperty($_body, "reconnect", $reconnect); $this->setRequestBodyProperty($_body, "connection_type", $connection_type); + $this->setRequestBodyProperty($_body, "show_close_button", $show_close_button); $this->setRequestBodyProperty($_body, "connection_portal_version", $connection_portal_version); $snap_trade_login_user_request_body = $_body; diff --git a/lib/Model/SnapTradeLoginUserRequestBody.php b/lib/Model/SnapTradeLoginUserRequestBody.php index ccd3611..f772d4b 100644 --- a/lib/Model/SnapTradeLoginUserRequestBody.php +++ b/lib/Model/SnapTradeLoginUserRequestBody.php @@ -56,6 +56,7 @@ class SnapTradeLoginUserRequestBody implements ModelInterface, ArrayAccess, \Jso 'custom_redirect' => 'string', 'reconnect' => 'string', 'connection_type' => 'string', + 'show_close_button' => 'bool', 'connection_portal_version' => 'string' ]; @@ -72,6 +73,7 @@ class SnapTradeLoginUserRequestBody implements ModelInterface, ArrayAccess, \Jso 'custom_redirect' => null, 'reconnect' => null, 'connection_type' => null, + 'show_close_button' => null, 'connection_portal_version' => null ]; @@ -86,6 +88,7 @@ class SnapTradeLoginUserRequestBody implements ModelInterface, ArrayAccess, \Jso 'custom_redirect' => false, 'reconnect' => false, 'connection_type' => false, + 'show_close_button' => false, 'connection_portal_version' => false ]; @@ -180,6 +183,7 @@ public function isNullableSetToNull(string $property): bool 'custom_redirect' => 'customRedirect', 'reconnect' => 'reconnect', 'connection_type' => 'connectionType', + 'show_close_button' => 'showCloseButton', 'connection_portal_version' => 'connectionPortalVersion' ]; @@ -194,6 +198,7 @@ public function isNullableSetToNull(string $property): bool 'custom_redirect' => 'setCustomRedirect', 'reconnect' => 'setReconnect', 'connection_type' => 'setConnectionType', + 'show_close_button' => 'setShowCloseButton', 'connection_portal_version' => 'setConnectionPortalVersion' ]; @@ -208,6 +213,7 @@ public function isNullableSetToNull(string $property): bool 'custom_redirect' => 'getCustomRedirect', 'reconnect' => 'getReconnect', 'connection_type' => 'getConnectionType', + 'show_close_button' => 'getShowCloseButton', 'connection_portal_version' => 'getConnectionPortalVersion' ]; @@ -307,6 +313,7 @@ public function __construct(array $data = null) $this->setIfExists('custom_redirect', $data ?? [], null); $this->setIfExists('reconnect', $data ?? [], null); $this->setIfExists('connection_type', $data ?? [], 'read'); + $this->setIfExists('show_close_button', $data ?? [], null); $this->setIfExists('connection_portal_version', $data ?? [], 'v4'); } @@ -525,6 +532,35 @@ public function setConnectionType($connection_type) return $this; } + /** + * Gets show_close_button + * + * @return bool|null + */ + public function getShowCloseButton() + { + return $this->container['show_close_button']; + } + + /** + * Sets show_close_button + * + * @param bool|null $show_close_button Controls whether the close (X) button is displayed in the connection portal. When false, you control closing behavior from your app. Defaults to true. + * + * @return self + */ + public function setShowCloseButton($show_close_button) + { + + if (is_null($show_close_button)) { + throw new \InvalidArgumentException('non-nullable show_close_button cannot be null'); + } + + $this->container['show_close_button'] = $show_close_button; + + return $this; + } + /** * Gets connection_portal_version * diff --git a/test/Model/SnapTradeLoginUserRequestBodyTest.php b/test/Model/SnapTradeLoginUserRequestBodyTest.php index fec0ffe..acb1300 100644 --- a/test/Model/SnapTradeLoginUserRequestBodyTest.php +++ b/test/Model/SnapTradeLoginUserRequestBodyTest.php @@ -117,6 +117,15 @@ public function testPropertyConnectionType() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "show_close_button" + */ + public function testPropertyShowCloseButton() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "connection_portal_version" */ From 4216e4be56b545ba0cbdcfae29b95c17551f6856 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 14:54:57 +0000 Subject: [PATCH 207/252] Version Bump SDKs (#235) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 10f8801..2ed20f5 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -881edbbf-8a5b-4767-b66f-7d9bf6a54c88 \ No newline at end of file +7a324b23-d254-4ddb-96a2-959dcd58c853 \ No newline at end of file diff --git a/README.md b/README.md index ca40448..b37e748 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.138-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.139-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.138" + "konfig/snaptrade-php-sdk": "2.0.139" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 4c917e0..dc15da5 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.138/PHP'; + protected $userAgent = 'Konfig/2.0.139/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.138' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.139' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 715504972245e5af998e5d44a756ab229c1184d7 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 8 Oct 2025 19:24:12 +0000 Subject: [PATCH 208/252] Regenerate SDKs (#236) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 ++ lib/Api/AccountInformationApi.php | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 2ed20f5..f235665 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -7a324b23-d254-4ddb-96a2-959dcd58c853 \ No newline at end of file +dd7f2dfe-6d99-4da2-b433-ea91e158f69a \ No newline at end of file diff --git a/README.md b/README.md index b37e748..5f7f3f8 100644 --- a/README.md +++ b/README.md @@ -563,6 +563,8 @@ Returns a list of balances, positions, and recent orders for the specified accou The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + #### πŸ› οΈ Usage diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 6e7919b..8c6fd62 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -4250,7 +4250,7 @@ public function getUserAccountReturnRatesRequest($user_id, $user_secret, $accoun * * List account holdings * - * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id account_id (required) * @param string $user_id user_id (required) @@ -4279,7 +4279,7 @@ public function getUserHoldings( * * List account holdings * - * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id (required) * @param string $user_id (required) @@ -4469,7 +4469,7 @@ public function getUserHoldingsWithHttpInfo($account_id, $user_id, $user_secret, * * List account holdings * - * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id (required) * @param string $user_id (required) @@ -4501,7 +4501,7 @@ function ($response) { * * List account holdings * - * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id (required) * @param string $user_id (required) From e11668af184ca52c2261920c10d41572fc56823a Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 8 Oct 2025 19:28:37 +0000 Subject: [PATCH 209/252] Version Bump SDKs (#237) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f235665..f69b8bf 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -dd7f2dfe-6d99-4da2-b433-ea91e158f69a \ No newline at end of file +d71ebab9-287f-4600-84bd-1b3c86b6250b \ No newline at end of file diff --git a/README.md b/README.md index 5f7f3f8..dcb5622 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.139-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.140-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.139" + "konfig/snaptrade-php-sdk": "2.0.140" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index dc15da5..a1ebf82 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.139/PHP'; + protected $userAgent = 'Konfig/2.0.140/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.139' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.140' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 4e8f8756756a066db3175da25da852449d61dfdf Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 21:01:00 +0000 Subject: [PATCH 210/252] Regenerate SDKs (#238) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 10 ++++++++ lib/Api/AccountInformationApi.php | 40 +++++++++++++++---------------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f69b8bf..c2e72c0 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d71ebab9-287f-4600-84bd-1b3c86b6250b \ No newline at end of file +de8eadc3-1468-4ec4-8edc-32ded4f699ca \ No newline at end of file diff --git a/README.md b/README.md index dcb5622..10663f0 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,8 @@ Transaction are returned in reverse chronological order, using the `trade_date` The data returned here is always cached and refreshed once a day. +If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + #### πŸ› οΈ Usage @@ -259,6 +261,8 @@ Returns a list of balances for the account. Each element of the list has a disti The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + #### πŸ› οΈ Usage @@ -299,6 +303,8 @@ Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + #### πŸ› οΈ Usage @@ -388,6 +394,8 @@ Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + #### πŸ› οΈ Usage @@ -438,6 +446,8 @@ Returns a list of stock/ETF/crypto/mutual fund positions in the specified accoun The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + #### πŸ› οΈ Usage diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 8c6fd62..3397182 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -173,7 +173,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id account_id (required) * @param string $user_id user_id (required) @@ -212,7 +212,7 @@ public function getAccountActivities( * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id (required) * @param string $user_id (required) @@ -343,7 +343,7 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id (required) * @param string $user_id (required) @@ -385,7 +385,7 @@ function ($response) { * * List account activities * - * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. + * Returns all historical transactions for the specified account. This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options. Transaction are returned in reverse chronological order, using the `trade_date` field. The data returned here is always cached and refreshed once a day. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id (required) * @param string $user_id (required) @@ -1153,7 +1153,7 @@ public function getAllUserHoldingsRequest($user_id, $user_secret, $brokerage_aut * * List account balances * - * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -1182,7 +1182,7 @@ public function getUserAccountBalance( * * List account balances * - * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1303,7 +1303,7 @@ public function getUserAccountBalanceWithHttpInfo($user_id, $user_secret, $accou * * List account balances * - * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1335,7 +1335,7 @@ function ($response) { * * List account balances * - * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1555,7 +1555,7 @@ public function getUserAccountBalanceRequest($user_id, $user_secret, $account_id * * Get account detail * - * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -1584,7 +1584,7 @@ public function getUserAccountDetails( * * Get account detail * - * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1705,7 +1705,7 @@ public function getUserAccountDetailsWithHttpInfo($user_id, $user_secret, $accou * * Get account detail * - * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1737,7 +1737,7 @@ function ($response) { * * Get account detail * - * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2463,7 +2463,7 @@ public function getUserAccountOrderDetailRequest($account_id, $user_id, $user_se * * List account orders * - * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -2496,7 +2496,7 @@ public function getUserAccountOrders( * * List account orders * - * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2644,7 +2644,7 @@ public function getUserAccountOrdersWithHttpInfo($user_id, $user_secret, $accoun * * List account orders * - * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2680,7 +2680,7 @@ function ($response) { * * List account orders * - * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2933,7 +2933,7 @@ public function getUserAccountOrdersRequest($user_id, $user_secret, $account_id, * * List account positions * - * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -2962,7 +2962,7 @@ public function getUserAccountPositions( * * List account positions * - * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -3083,7 +3083,7 @@ public function getUserAccountPositionsWithHttpInfo($user_id, $user_secret, $acc * * List account positions * - * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -3115,7 +3115,7 @@ function ($response) { * * List account positions * - * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) From 75eaa2de998835d21a7677b6f67a0d4324663148 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 21:05:28 +0000 Subject: [PATCH 211/252] Version Bump SDKs (#239) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index c2e72c0..cf847fc 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -de8eadc3-1468-4ec4-8edc-32ded4f699ca \ No newline at end of file +f05d0d33-a0f0-4cb6-a0f1-3929d7685872 \ No newline at end of file diff --git a/README.md b/README.md index 10663f0..ca26ad8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.140-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.141-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.140" + "konfig/snaptrade-php-sdk": "2.0.141" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index a1ebf82..1e05fc1 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.140/PHP'; + protected $userAgent = 'Konfig/2.0.141/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.140' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.141' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 06320a847cf94ad62a1693f33c0986c3e53b4473 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 24 Oct 2025 23:51:01 +0000 Subject: [PATCH 212/252] Regenerate SDKs (#240) * Regenerate SDKs * Regenerate SDKs --------- Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 3 + lib/Api/TradingApi.php | 4 + lib/Model/ManualTradeFormWithOptions.php | 36 +++++++++ lib/Model/TradingSession.php | 56 ++++++++++++++ test/Model/ManualTradeFormWithOptionsTest.php | 9 +++ test/Model/TradingSessionTest.php | 74 +++++++++++++++++++ 7 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 lib/Model/TradingSession.php create mode 100644 test/Model/TradingSessionTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index cf847fc..85dde00 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f05d0d33-a0f0-4cb6-a0f1-3929d7685872 \ No newline at end of file +d7394e1b-eb1f-47f2-98c8-a5ace7f12e02 \ No newline at end of file diff --git a/README.md b/README.md index ca26ad8..6acf01e 100644 --- a/README.md +++ b/README.md @@ -2071,6 +2071,7 @@ $result = $snaptrade->trading->placeForceOrder( user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", symbol: "AAPL", + trading_session: "REGULAR", price: 31.33, stop: 31.33, units: 10.5, @@ -2102,6 +2103,8 @@ The universal symbol ID of the security to trade. Must be 'null' if `symbol` is The security's trading ticker symbol. If 'symbol' is provided, then 'universal_symbol_id' must be 'null'. +##### trading_session: + ##### price: `float` The limit price for `Limit` and `StopLimit` orders. diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php index 6f86532..f795410 100644 --- a/lib/Api/TradingApi.php +++ b/lib/Api/TradingApi.php @@ -3565,6 +3565,7 @@ public function placeForceOrder( $user_secret, $universal_symbol_id = SENTINEL_VALUE, $symbol = SENTINEL_VALUE, + $trading_session = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, @@ -3579,6 +3580,7 @@ public function placeForceOrder( $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "trading_session", $trading_session); $this->setRequestBodyProperty($_body, "price", $price); $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); @@ -3781,6 +3783,7 @@ public function placeForceOrderAsync( $user_secret, $universal_symbol_id = SENTINEL_VALUE, $symbol = SENTINEL_VALUE, + $trading_session = SENTINEL_VALUE, $price = SENTINEL_VALUE, $stop = SENTINEL_VALUE, $units = SENTINEL_VALUE, @@ -3795,6 +3798,7 @@ public function placeForceOrderAsync( $this->setRequestBodyProperty($_body, "symbol", $symbol); $this->setRequestBodyProperty($_body, "order_type", $order_type); $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force); + $this->setRequestBodyProperty($_body, "trading_session", $trading_session); $this->setRequestBodyProperty($_body, "price", $price); $this->setRequestBodyProperty($_body, "stop", $stop); $this->setRequestBodyProperty($_body, "units", $units); diff --git a/lib/Model/ManualTradeFormWithOptions.php b/lib/Model/ManualTradeFormWithOptions.php index 91b1a0d..05760f4 100644 --- a/lib/Model/ManualTradeFormWithOptions.php +++ b/lib/Model/ManualTradeFormWithOptions.php @@ -57,6 +57,7 @@ class ManualTradeFormWithOptions implements ModelInterface, ArrayAccess, \JsonSe 'symbol' => 'string', 'order_type' => '\SnapTrade\Model\OrderTypeStrict', 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict', + 'trading_session' => '\SnapTrade\Model\TradingSession', 'price' => 'float', 'stop' => 'float', 'units' => 'float', @@ -77,6 +78,7 @@ class ManualTradeFormWithOptions implements ModelInterface, ArrayAccess, \JsonSe 'symbol' => null, 'order_type' => null, 'time_in_force' => null, + 'trading_session' => null, 'price' => null, 'stop' => null, 'units' => null, @@ -95,6 +97,7 @@ class ManualTradeFormWithOptions implements ModelInterface, ArrayAccess, \JsonSe 'symbol' => true, 'order_type' => false, 'time_in_force' => false, + 'trading_session' => false, 'price' => true, 'stop' => true, 'units' => true, @@ -193,6 +196,7 @@ public function isNullableSetToNull(string $property): bool 'symbol' => 'symbol', 'order_type' => 'order_type', 'time_in_force' => 'time_in_force', + 'trading_session' => 'trading_session', 'price' => 'price', 'stop' => 'stop', 'units' => 'units', @@ -211,6 +215,7 @@ public function isNullableSetToNull(string $property): bool 'symbol' => 'setSymbol', 'order_type' => 'setOrderType', 'time_in_force' => 'setTimeInForce', + 'trading_session' => 'setTradingSession', 'price' => 'setPrice', 'stop' => 'setStop', 'units' => 'setUnits', @@ -229,6 +234,7 @@ public function isNullableSetToNull(string $property): bool 'symbol' => 'getSymbol', 'order_type' => 'getOrderType', 'time_in_force' => 'getTimeInForce', + 'trading_session' => 'getTradingSession', 'price' => 'getPrice', 'stop' => 'getStop', 'units' => 'getUnits', @@ -298,6 +304,7 @@ public function __construct(array $data = null) $this->setIfExists('symbol', $data ?? [], null); $this->setIfExists('order_type', $data ?? [], null); $this->setIfExists('time_in_force', $data ?? [], null); + $this->setIfExists('trading_session', $data ?? [], null); $this->setIfExists('price', $data ?? [], null); $this->setIfExists('stop', $data ?? [], null); $this->setIfExists('units', $data ?? [], null); @@ -546,6 +553,35 @@ public function setTimeInForce($time_in_force) return $this; } + /** + * Gets trading_session + * + * @return \SnapTrade\Model\TradingSession|null + */ + public function getTradingSession() + { + return $this->container['trading_session']; + } + + /** + * Sets trading_session + * + * @param \SnapTrade\Model\TradingSession|null $trading_session trading_session + * + * @return self + */ + public function setTradingSession($trading_session) + { + + if (is_null($trading_session)) { + throw new \InvalidArgumentException('non-nullable trading_session cannot be null'); + } + + $this->container['trading_session'] = $trading_session; + + return $this; + } + /** * Gets price * diff --git a/lib/Model/TradingSession.php b/lib/Model/TradingSession.php new file mode 100644 index 0000000..c5cea42 --- /dev/null +++ b/lib/Model/TradingSession.php @@ -0,0 +1,56 @@ +markTestIncomplete('Not implemented'); } + /** + * Test attribute "trading_session" + */ + public function testPropertyTradingSession() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "price" */ diff --git a/test/Model/TradingSessionTest.php b/test/Model/TradingSessionTest.php new file mode 100644 index 0000000..2bd37fe --- /dev/null +++ b/test/Model/TradingSessionTest.php @@ -0,0 +1,74 @@ +markTestIncomplete('Not implemented'); + } +} From 10c44d67de11ca9c737a118774277d26887e86c8 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 24 Oct 2025 23:55:42 +0000 Subject: [PATCH 213/252] Version Bump SDKs (#241) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 85dde00..6543e60 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -d7394e1b-eb1f-47f2-98c8-a5ace7f12e02 \ No newline at end of file +61d27bf9-804b-4fd2-89a5-7e258c1c6c88 \ No newline at end of file diff --git a/README.md b/README.md index 6acf01e..5c585b2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.141-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.142-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.141" + "konfig/snaptrade-php-sdk": "2.0.142" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 1e05fc1..0fb28f5 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.141/PHP'; + protected $userAgent = 'Konfig/2.0.142/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.141' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.142' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From fc2af642461ad1295d9d04ff20a7631df3307515 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 4 Nov 2025 12:57:29 +0000 Subject: [PATCH 214/252] Regenerate SDKs (#242) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/AccountInformationApi.php | 10 +++++----- lib/Model/AccountOrderRecordStatus.php | 2 +- lib/Model/AccountUniversalActivity.php | 2 +- test/Model/AccountOrderRecordStatusTest.php | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 6543e60..170f810 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -61d27bf9-804b-4fd2-89a5-7e258c1c6c88 \ No newline at end of file +e216d59f-98f9-43b2-bb66-8945f4d1e0b5 \ No newline at end of file diff --git a/README.md b/README.md index 5c585b2..49cf794 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ An integer that specifies the maximum number of transactions to return. Default ##### type: `string` -Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another +Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. #### πŸ”„ Return diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 3397182..622b146 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -182,7 +182,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -221,7 +221,7 @@ public function getAccountActivities( * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -352,7 +352,7 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -394,7 +394,7 @@ function ($response) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -454,7 +454,7 @@ function ($exception) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/lib/Model/AccountOrderRecordStatus.php b/lib/Model/AccountOrderRecordStatus.php index d54bc28..37917f4 100644 --- a/lib/Model/AccountOrderRecordStatus.php +++ b/lib/Model/AccountOrderRecordStatus.php @@ -28,7 +28,7 @@ * AccountOrderRecordStatus Class Doc Comment * * @category Class - * @description Indicates the status of an order. SnapTrade does a best effort to map brokerage statuses to statuses in this enum. + * @description Indicates the status of an order. SnapTrade does a best effort to map brokerage statuses to statuses in this enum. Possible values include: - NONE - PENDING - ACCEPTED - FAILED - REJECTED - CANCELED - PARTIAL_CANCELED - CANCEL_PENDING - EXECUTED - PARTIAL - REPLACE_PENDING - REPLACED - EXPIRED - QUEUED - TRIGGERED - ACTIVATED * @package SnapTrade */ class AccountOrderRecordStatus diff --git a/lib/Model/AccountUniversalActivity.php b/lib/Model/AccountUniversalActivity.php index b6519e7..87f1efa 100644 --- a/lib/Model/AccountUniversalActivity.php +++ b/lib/Model/AccountUniversalActivity.php @@ -625,7 +625,7 @@ public function getType() /** * Sets type * - * @param string|null $type A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. `option_symbol` contains the related option contract info. - `OPTIONASSIGNMENT` - Option assignment event. `option_symbol` contains the related option contract info. - `OPTIONEXERCISE` - Option exercise event. `option_symbol` contains the related option contract info. + * @param string|null $type A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. * * @return self */ diff --git a/test/Model/AccountOrderRecordStatusTest.php b/test/Model/AccountOrderRecordStatusTest.php index 003e9be..c969bb4 100644 --- a/test/Model/AccountOrderRecordStatusTest.php +++ b/test/Model/AccountOrderRecordStatusTest.php @@ -29,7 +29,7 @@ * AccountOrderRecordStatusTest Class Doc Comment * * @category Class - * @description Indicates the status of an order. SnapTrade does a best effort to map brokerage statuses to statuses in this enum. + * @description Indicates the status of an order. SnapTrade does a best effort to map brokerage statuses to statuses in this enum. Possible values include: - NONE - PENDING - ACCEPTED - FAILED - REJECTED - CANCELED - PARTIAL_CANCELED - CANCEL_PENDING - EXECUTED - PARTIAL - REPLACE_PENDING - REPLACED - EXPIRED - QUEUED - TRIGGERED - ACTIVATED * @package SnapTrade */ class AccountOrderRecordStatusTest extends TestCase From 691ebc0bd6ddc2254e79237de1a021df89bf1a7a Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 4 Nov 2025 13:02:03 +0000 Subject: [PATCH 215/252] Version Bump SDKs (#243) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 170f810..8a9fadc 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -e216d59f-98f9-43b2-bb66-8945f4d1e0b5 \ No newline at end of file +44ee0dff-4416-4311-8e55-469b27c84d1b \ No newline at end of file diff --git a/README.md b/README.md index 49cf794..7852209 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.142-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.143-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -97,7 +97,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.142" + "konfig/snaptrade-php-sdk": "2.0.143" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 0fb28f5..7a9227e 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.142/PHP'; + protected $userAgent = 'Konfig/2.0.143/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.142' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.143' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 06280880079cd7975df6a0fe5b8059069c1c9c70 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 6 Nov 2025 00:21:12 +0000 Subject: [PATCH 216/252] Regenerate SDKs (#244) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 101 ++ lib/Api/ExperimentalEndpointsApi.php | 1096 +++++++++++++++++ lib/Client.php | 3 + lib/Model/AccountOrderRecordLeg.php | 699 +++++++++++ lib/Model/AccountOrderRecordLegInstrument.php | 556 +++++++++ lib/Model/AccountOrderRecordStatusV2.php | 80 ++ lib/Model/AccountOrderRecordV2.php | 800 ++++++++++++ lib/Model/AccountOrdersV2Response.php | 408 ++++++ test/Api/ExperimentalEndpointsApiTest.php | 84 ++ .../AccountOrderRecordLegInstrumentTest.php | 119 ++ test/Model/AccountOrderRecordLegTest.php | 146 +++ test/Model/AccountOrderRecordStatusV2Test.php | 74 ++ test/Model/AccountOrderRecordV2Test.php | 173 +++ test/Model/AccountOrdersV2ResponseTest.php | 83 ++ 15 files changed, 4423 insertions(+), 1 deletion(-) create mode 100644 lib/Api/ExperimentalEndpointsApi.php create mode 100644 lib/Model/AccountOrderRecordLeg.php create mode 100644 lib/Model/AccountOrderRecordLegInstrument.php create mode 100644 lib/Model/AccountOrderRecordStatusV2.php create mode 100644 lib/Model/AccountOrderRecordV2.php create mode 100644 lib/Model/AccountOrdersV2Response.php create mode 100644 test/Api/ExperimentalEndpointsApiTest.php create mode 100644 test/Model/AccountOrderRecordLegInstrumentTest.php create mode 100644 test/Model/AccountOrderRecordLegTest.php create mode 100644 test/Model/AccountOrderRecordStatusV2Test.php create mode 100644 test/Model/AccountOrderRecordV2Test.php create mode 100644 test/Model/AccountOrdersV2ResponseTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 8a9fadc..1300d5a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -44ee0dff-4416-4311-8e55-469b27c84d1b \ No newline at end of file +99ba219d-4d6d-4a86-ba2e-d3e3c054cdc6 \ No newline at end of file diff --git a/README.md b/README.md index 7852209..67fbc33 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.connections.removeBrokerageAuthorization`](#snaptradeconnectionsremovebrokerageauthorization) * [`snaptrade.connections.returnRates`](#snaptradeconnectionsreturnrates) * [`snaptrade.connections.sessionEvents`](#snaptradeconnectionssessionevents) + * [`snaptrade.experimentalEndpoints.getUserAccountOrdersV2`](#snaptradeexperimentalendpointsgetuseraccountordersv2) + * [`snaptrade.experimentalEndpoints.getUserAccountRecentOrdersV2`](#snaptradeexperimentalendpointsgetuseraccountrecentordersv2) * [`snaptrade.options.getOptionsChain`](#snaptradeoptionsgetoptionschain) * [`snaptrade.options.listOptionHoldings`](#snaptradeoptionslistoptionholdings) * [`snaptrade.referenceData.getCurrencyExchangeRatePair`](#snaptradereferencedatagetcurrencyexchangeratepair) @@ -1186,6 +1188,105 @@ Optional comma separated list of session IDs used to filter the request on speci --- +### `snaptrade.experimentalEndpoints.getUserAccountOrdersV2` + +Returns a list of recent orders in the specified account. + +The V2 order response format will include all legs of each order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. + +If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->experimentalEndpoints->getUserAccountOrdersV2( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + state: "all", + days: 30 +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### state: `string` + +defaults value is set to \"all\" + +##### days: `int` + +Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in. + + +#### πŸ”„ Return + +[**AccountOrdersV2Response**](./lib/Model/AccountOrdersV2Response.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/orders/v2` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + +### `snaptrade.experimentalEndpoints.getUserAccountRecentOrdersV2` + +A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. +This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. +Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days. +By default only returns executed orders, but that can be changed by setting *only_executed* to false. +**Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->experimentalEndpoints->getUserAccountRecentOrdersV2( + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + only_executed: True +); +``` + +#### βš™οΈ Parameters + +##### user_id: `string` + +##### user_secret: `string` + +##### account_id: `string` + +##### only_executed: `bool` + +Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well + + +#### πŸ”„ Return + +[**AccountOrdersV2Response**](./lib/Model/AccountOrdersV2Response.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/recentOrders/v2` `GET` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.options.getOptionsChain` Returns the option chain for the specified symbol in the specified account. diff --git a/lib/Api/ExperimentalEndpointsApi.php b/lib/Api/ExperimentalEndpointsApi.php new file mode 100644 index 0000000..57b2ae6 --- /dev/null +++ b/lib/Api/ExperimentalEndpointsApi.php @@ -0,0 +1,1096 @@ + [ + 'application/json', + ], + 'getUserAccountRecentOrdersV2' => [ + 'application/json', + ], + ]; + +/** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + Configuration $config = null, + ClientInterface $client = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $clientOptions = []; + if (!$config->getVerifySsl()) $clientOptions["verify"] = false; + + // Do not truncate error messages + // https://github.com/guzzle/guzzle/issues/2185#issuecomment-800293420 + $stack = new HandlerStack(Utils::chooseHandler()); + $stack->push(Middleware::httpErrors(new BodySummarizer(10000)), 'http_errors'); + $stack->push(Middleware::redirect(), 'allow_redirects'); + $stack->push(Middleware::cookies(), 'cookies'); + $stack->push(Middleware::prepareBody(), 'prepare_body'); + $clientOptions["handler"] = $stack; + + $this->client = $client ?: new Client($clientOptions); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * For initializing request body parameter + */ + private function setRequestBodyProperty(&$body, $property, $value) { + if ($body === null) $body = []; + // user did not pass in a value for this parameter + if ($value === SENTINEL_VALUE) return; + $body[$property] = $value; + } + + /** + * Operation getUserAccountOrdersV2 + * + * List account orders v2 + * + * Returns a list of recent orders in the specified account. The V2 order response format will include all legs of each order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param string $state defaults value is set to \"all\" (optional) + * @param int $days Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrdersV2'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrdersV2Response|\SnapTrade\Model\Model500UnexpectedExceptionResponse + */ + public function getUserAccountOrdersV2( + $user_id, + $user_secret, + $account_id, + $state = SENTINEL_VALUE, + $days = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getUserAccountOrdersV2'][0] + ) + { + + list($response) = $this->getUserAccountOrdersV2WithHttpInfo($user_id, $user_secret, $account_id, $state, $days, $contentType); + return $response; + } + + /** + * Operation getUserAccountOrdersV2WithHttpInfo + * + * List account orders v2 + * + * Returns a list of recent orders in the specified account. The V2 order response format will include all legs of each order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $state defaults value is set to \"all\" (optional) + * @param int $days Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrdersV2'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrdersV2Response|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getUserAccountOrdersV2WithHttpInfo($user_id, $user_secret, $account_id, $state = null, $days = null, string $contentType = self::contentTypes['getUserAccountOrdersV2'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrdersV2Request($user_id, $user_secret, $account_id, $state, $days, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->getUserAccountOrdersV2WithHttpInfo( + $user_id, + $user_secret, + $account_id, + $state, + $days, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrdersV2Response' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrdersV2Response' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrdersV2Response', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrdersV2Response'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrdersV2Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getUserAccountOrdersV2Async + * + * List account orders v2 + * + * Returns a list of recent orders in the specified account. The V2 order response format will include all legs of each order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $state defaults value is set to \"all\" (optional) + * @param int $days Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrdersV2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountOrdersV2Async( + $user_id, + $user_secret, + $account_id, + $state = SENTINEL_VALUE, + $days = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getUserAccountOrdersV2'][0] + ) + { + + return $this->getUserAccountOrdersV2AsyncWithHttpInfo($user_id, $user_secret, $account_id, $state, $days, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getUserAccountOrdersV2AsyncWithHttpInfo + * + * List account orders v2 + * + * Returns a list of recent orders in the specified account. The V2 order response format will include all legs of each order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $state defaults value is set to \"all\" (optional) + * @param int $days Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrdersV2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountOrdersV2AsyncWithHttpInfo($user_id, $user_secret, $account_id, $state = null, $days = null, string $contentType = self::contentTypes['getUserAccountOrdersV2'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrdersV2Response'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrdersV2Request($user_id, $user_secret, $account_id, $state, $days, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getUserAccountOrdersV2' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param string $state defaults value is set to \"all\" (optional) + * @param int $days Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrdersV2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getUserAccountOrdersV2Request($user_id, $user_secret, $account_id, $state = SENTINEL_VALUE, $days = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountOrdersV2'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getUserAccountOrdersV2' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getUserAccountOrdersV2' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getUserAccountOrdersV2' + ); + } + // Check if $state is a string + if ($state !== SENTINEL_VALUE && !is_string($state)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($state, true), gettype($state))); + } + if ($days !== SENTINEL_VALUE && $days < 1) { + throw new \InvalidArgumentException('invalid value for "days" when calling ExperimentalEndpointsApi.getUserAccountOrdersV2, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/accounts/{accountId}/orders/v2'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($state !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $state, + 'state', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + if ($days !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $days, + 'days', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Operation getUserAccountRecentOrdersV2 + * + * List account recent orders (V2, last 24 hours only) + * + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param string $account_id account_id (required) + * @param bool $only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrdersV2'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrdersV2Response|\SnapTrade\Model\Model403FeatureNotEnabledResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse + */ + public function getUserAccountRecentOrdersV2( + $user_id, + $user_secret, + $account_id, + $only_executed = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getUserAccountRecentOrdersV2'][0] + ) + { + + list($response) = $this->getUserAccountRecentOrdersV2WithHttpInfo($user_id, $user_secret, $account_id, $only_executed, $contentType); + return $response; + } + + /** + * Operation getUserAccountRecentOrdersV2WithHttpInfo + * + * List account recent orders (V2, last 24 hours only) + * + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param bool $only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrdersV2'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrdersV2Response|\SnapTrade\Model\Model403FeatureNotEnabledResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getUserAccountRecentOrdersV2WithHttpInfo($user_id, $user_secret, $account_id, $only_executed = null, string $contentType = self::contentTypes['getUserAccountRecentOrdersV2'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountRecentOrdersV2Request($user_id, $user_secret, $account_id, $only_executed, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->getUserAccountRecentOrdersV2WithHttpInfo( + $user_id, + $user_secret, + $account_id, + $only_executed, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrdersV2Response' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrdersV2Response' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrdersV2Response', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\SnapTrade\Model\Model403FeatureNotEnabledResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model403FeatureNotEnabledResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model403FeatureNotEnabledResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrdersV2Response'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrdersV2Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model403FeatureNotEnabledResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getUserAccountRecentOrdersV2Async + * + * List account recent orders (V2, last 24 hours only) + * + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param bool $only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrdersV2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountRecentOrdersV2Async( + $user_id, + $user_secret, + $account_id, + $only_executed = SENTINEL_VALUE, + + string $contentType = self::contentTypes['getUserAccountRecentOrdersV2'][0] + ) + { + + return $this->getUserAccountRecentOrdersV2AsyncWithHttpInfo($user_id, $user_secret, $account_id, $only_executed, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getUserAccountRecentOrdersV2AsyncWithHttpInfo + * + * List account recent orders (V2, last 24 hours only) + * + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param bool $only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrdersV2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountRecentOrdersV2AsyncWithHttpInfo($user_id, $user_secret, $account_id, $only_executed = null, string $contentType = self::contentTypes['getUserAccountRecentOrdersV2'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrdersV2Response'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountRecentOrdersV2Request($user_id, $user_secret, $account_id, $only_executed, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getUserAccountRecentOrdersV2' + * + * @param string $user_id (required) + * @param string $user_secret (required) + * @param string $account_id (required) + * @param bool $only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountRecentOrdersV2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getUserAccountRecentOrdersV2Request($user_id, $user_secret, $account_id, $only_executed = SENTINEL_VALUE, string $contentType = self::contentTypes['getUserAccountRecentOrdersV2'][0]) + { + + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getUserAccountRecentOrdersV2' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getUserAccountRecentOrdersV2' + ); + } + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getUserAccountRecentOrdersV2' + ); + } + + + $resourcePath = '/accounts/{accountId}/recentOrders/v2'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($only_executed !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_executed, + 'only_executed', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'GET'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/Client.php b/lib/Client.php index b8de060..dd3cd18 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -13,6 +13,8 @@ class Client public readonly \SnapTrade\Api\ConnectionsApi $connections; + public readonly \SnapTrade\Api\ExperimentalEndpointsApi $experimentalEndpoints; + public readonly \SnapTrade\Api\OptionsApi $options; public readonly \SnapTrade\Api\ReferenceDataApi $referenceData; @@ -48,6 +50,7 @@ public function __construct( $this->apiStatus = new \SnapTrade\Api\ApiStatusApi($config); $this->authentication = new \SnapTrade\Api\AuthenticationApi($config); $this->connections = new \SnapTrade\Api\ConnectionsApi($config); + $this->experimentalEndpoints = new \SnapTrade\Api\ExperimentalEndpointsApi($config); $this->options = new \SnapTrade\Api\OptionsApi($config); $this->referenceData = new \SnapTrade\Api\ReferenceDataApi($config); $this->trading = new \SnapTrade\Api\TradingApi($config); diff --git a/lib/Model/AccountOrderRecordLeg.php b/lib/Model/AccountOrderRecordLeg.php new file mode 100644 index 0000000..c27f223 --- /dev/null +++ b/lib/Model/AccountOrderRecordLeg.php @@ -0,0 +1,699 @@ + + */ +class AccountOrderRecordLeg implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AccountOrderRecordLeg'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'leg_id' => 'string', + 'instrument' => '\SnapTrade\Model\AccountOrderRecordLegInstrument', + 'action' => 'string', + 'execution_price' => 'float', + 'total_quantity' => 'string', + 'canceled_quantity' => 'string', + 'filled_quantity' => 'string', + 'status' => 'AccountOrderRecordStatusV2' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'leg_id' => null, + 'instrument' => null, + 'action' => null, + 'execution_price' => null, + 'total_quantity' => null, + 'canceled_quantity' => null, + 'filled_quantity' => null, + 'status' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'leg_id' => true, + 'instrument' => false, + 'action' => false, + 'execution_price' => true, + 'total_quantity' => true, + 'canceled_quantity' => true, + 'filled_quantity' => true, + 'status' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'leg_id' => 'leg_id', + 'instrument' => 'instrument', + 'action' => 'action', + 'execution_price' => 'execution_price', + 'total_quantity' => 'total_quantity', + 'canceled_quantity' => 'canceled_quantity', + 'filled_quantity' => 'filled_quantity', + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'leg_id' => 'setLegId', + 'instrument' => 'setInstrument', + 'action' => 'setAction', + 'execution_price' => 'setExecutionPrice', + 'total_quantity' => 'setTotalQuantity', + 'canceled_quantity' => 'setCanceledQuantity', + 'filled_quantity' => 'setFilledQuantity', + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'leg_id' => 'getLegId', + 'instrument' => 'getInstrument', + 'action' => 'getAction', + 'execution_price' => 'getExecutionPrice', + 'total_quantity' => 'getTotalQuantity', + 'canceled_quantity' => 'getCanceledQuantity', + 'filled_quantity' => 'getFilledQuantity', + 'status' => 'getStatus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('leg_id', $data ?? [], null); + $this->setIfExists('instrument', $data ?? [], null); + $this->setIfExists('action', $data ?? [], null); + $this->setIfExists('execution_price', $data ?? [], null); + $this->setIfExists('total_quantity', $data ?? [], null); + $this->setIfExists('canceled_quantity', $data ?? [], null); + $this->setIfExists('filled_quantity', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets leg_id + * + * @return string|null + */ + public function getLegId() + { + return $this->container['leg_id']; + } + + /** + * Sets leg_id + * + * @param string|null $leg_id Brokerage order identifier for this leg, if available. + * + * @return self + */ + public function setLegId($leg_id) + { + + if (is_null($leg_id)) { + array_push($this->openAPINullablesSetToNull, 'leg_id'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('leg_id', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['leg_id'] = $leg_id; + + return $this; + } + + /** + * Gets instrument + * + * @return \SnapTrade\Model\AccountOrderRecordLegInstrument|null + */ + public function getInstrument() + { + return $this->container['instrument']; + } + + /** + * Sets instrument + * + * @param \SnapTrade\Model\AccountOrderRecordLegInstrument|null $instrument instrument + * + * @return self + */ + public function setInstrument($instrument) + { + + if (is_null($instrument)) { + throw new \InvalidArgumentException('non-nullable instrument cannot be null'); + } + + $this->container['instrument'] = $instrument; + + return $this; + } + + /** + * Gets action + * + * @return string|null + */ + public function getAction() + { + return $this->container['action']; + } + + /** + * Sets action + * + * @param string|null $action The action describes the intent or side of a trade. - BUY - SELL - BUY_COVER - SELL_SHORT - BUY_TO_OPEN - BUY_TO_CLOSE - SELL_TO_OPEN - SELL_TO_CLOSE + * + * @return self + */ + public function setAction($action) + { + + if (is_null($action)) { + throw new \InvalidArgumentException('non-nullable action cannot be null'); + } + + $this->container['action'] = $action; + + return $this; + } + + /** + * Gets execution_price + * + * @return float|null + */ + public function getExecutionPrice() + { + return $this->container['execution_price']; + } + + /** + * Sets execution_price + * + * @param float|null $execution_price Execution price for this leg, if available. + * + * @return self + */ + public function setExecutionPrice($execution_price) + { + + if (is_null($execution_price)) { + array_push($this->openAPINullablesSetToNull, 'execution_price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('execution_price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['execution_price'] = $execution_price; + + return $this; + } + + /** + * Gets total_quantity + * + * @return string|null + */ + public function getTotalQuantity() + { + return $this->container['total_quantity']; + } + + /** + * Sets total_quantity + * + * @param string|null $total_quantity The total number of shares or contracts associated with this leg. Can be a decimal number for fractional shares. + * + * @return self + */ + public function setTotalQuantity($total_quantity) + { + + if (is_null($total_quantity)) { + array_push($this->openAPINullablesSetToNull, 'total_quantity'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('total_quantity', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['total_quantity'] = $total_quantity; + + return $this; + } + + /** + * Gets canceled_quantity + * + * @return string|null + */ + public function getCanceledQuantity() + { + return $this->container['canceled_quantity']; + } + + /** + * Sets canceled_quantity + * + * @param string|null $canceled_quantity The number of shares or contracts that have been canceled for this leg. + * + * @return self + */ + public function setCanceledQuantity($canceled_quantity) + { + + if (is_null($canceled_quantity)) { + array_push($this->openAPINullablesSetToNull, 'canceled_quantity'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('canceled_quantity', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['canceled_quantity'] = $canceled_quantity; + + return $this; + } + + /** + * Gets filled_quantity + * + * @return string|null + */ + public function getFilledQuantity() + { + return $this->container['filled_quantity']; + } + + /** + * Sets filled_quantity + * + * @param string|null $filled_quantity The number of shares or contracts that have been filled for this leg. + * + * @return self + */ + public function setFilledQuantity($filled_quantity) + { + + if (is_null($filled_quantity)) { + array_push($this->openAPINullablesSetToNull, 'filled_quantity'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('filled_quantity', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['filled_quantity'] = $filled_quantity; + + return $this; + } + + /** + * Gets status + * + * @return AccountOrderRecordStatusV2|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param AccountOrderRecordStatusV2|null $status status + * + * @return self + */ + public function setStatus($status) + { + + if (is_null($status)) { + array_push($this->openAPINullablesSetToNull, 'status'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('status', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['status'] = $status; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/AccountOrderRecordLegInstrument.php b/lib/Model/AccountOrderRecordLegInstrument.php new file mode 100644 index 0000000..24025a5 --- /dev/null +++ b/lib/Model/AccountOrderRecordLegInstrument.php @@ -0,0 +1,556 @@ + + */ +class AccountOrderRecordLegInstrument implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AccountOrderRecordLegInstrument'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'symbol' => 'string', + 'description' => 'string', + 'asset_type' => 'string', + 'exchange_mic_code' => 'string', + 'figi_code' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'symbol' => null, + 'description' => null, + 'asset_type' => null, + 'exchange_mic_code' => null, + 'figi_code' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'symbol' => false, + 'description' => false, + 'asset_type' => false, + 'exchange_mic_code' => false, + 'figi_code' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'symbol' => 'symbol', + 'description' => 'description', + 'asset_type' => 'asset_type', + 'exchange_mic_code' => 'exchange_mic_code', + 'figi_code' => 'figi_code' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'symbol' => 'setSymbol', + 'description' => 'setDescription', + 'asset_type' => 'setAssetType', + 'exchange_mic_code' => 'setExchangeMicCode', + 'figi_code' => 'setFigiCode' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'symbol' => 'getSymbol', + 'description' => 'getDescription', + 'asset_type' => 'getAssetType', + 'exchange_mic_code' => 'getExchangeMicCode', + 'figi_code' => 'getFigiCode' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('asset_type', $data ?? [], null); + $this->setIfExists('exchange_mic_code', $data ?? [], null); + $this->setIfExists('figi_code', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets symbol + * + * @return string|null + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string|null $symbol The symbol or ticker for the security. + * + * @return self + */ + public function setSymbol($symbol) + { + + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Human-readable description of the security. + * + * @return self + */ + public function setDescription($description) + { + + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets asset_type + * + * @return string|null + */ + public function getAssetType() + { + return $this->container['asset_type']; + } + + /** + * Sets asset_type + * + * @param string|null $asset_type Type of instrument for the leg. - EQUITY - OPTION - CRYPTO + * + * @return self + */ + public function setAssetType($asset_type) + { + + if (is_null($asset_type)) { + throw new \InvalidArgumentException('non-nullable asset_type cannot be null'); + } + + $this->container['asset_type'] = $asset_type; + + return $this; + } + + /** + * Gets exchange_mic_code + * + * @return string|null + */ + public function getExchangeMicCode() + { + return $this->container['exchange_mic_code']; + } + + /** + * Sets exchange_mic_code + * + * @param string|null $exchange_mic_code Market Identifier Code (MIC) for the exchange on which the instrument trades. + * + * @return self + */ + public function setExchangeMicCode($exchange_mic_code) + { + + if (is_null($exchange_mic_code)) { + throw new \InvalidArgumentException('non-nullable exchange_mic_code cannot be null'); + } + + $this->container['exchange_mic_code'] = $exchange_mic_code; + + return $this; + } + + /** + * Gets figi_code + * + * @return string|null + */ + public function getFigiCode() + { + return $this->container['figi_code']; + } + + /** + * Sets figi_code + * + * @param string|null $figi_code Financial Instrument Global Identifier (FIGI) if available. + * + * @return self + */ + public function setFigiCode($figi_code) + { + + if (is_null($figi_code)) { + array_push($this->openAPINullablesSetToNull, 'figi_code'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('figi_code', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['figi_code'] = $figi_code; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/AccountOrderRecordStatusV2.php b/lib/Model/AccountOrderRecordStatusV2.php new file mode 100644 index 0000000..0d33d07 --- /dev/null +++ b/lib/Model/AccountOrderRecordStatusV2.php @@ -0,0 +1,80 @@ + + */ +class AccountOrderRecordV2 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AccountOrderRecordV2'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'brokerage_order_id' => 'string', + 'status' => '\SnapTrade\Model\AccountOrderRecordStatus', + 'order_type' => 'string', + 'time_in_force' => 'string', + 'time_placed' => '\DateTime', + 'time_executed' => '\DateTime', + 'quote_currency' => 'string', + 'execution_price' => 'float', + 'limit_price' => 'float', + 'stop_price' => 'float', + 'legs' => '\SnapTrade\Model\AccountOrderRecordLeg[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'brokerage_order_id' => null, + 'status' => null, + 'order_type' => null, + 'time_in_force' => null, + 'time_placed' => 'date-time', + 'time_executed' => 'date-time', + 'quote_currency' => null, + 'execution_price' => null, + 'limit_price' => null, + 'stop_price' => null, + 'legs' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'brokerage_order_id' => false, + 'status' => false, + 'order_type' => true, + 'time_in_force' => false, + 'time_placed' => false, + 'time_executed' => true, + 'quote_currency' => false, + 'execution_price' => true, + 'limit_price' => true, + 'stop_price' => true, + 'legs' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'brokerage_order_id' => 'brokerage_order_id', + 'status' => 'status', + 'order_type' => 'order_type', + 'time_in_force' => 'time_in_force', + 'time_placed' => 'time_placed', + 'time_executed' => 'time_executed', + 'quote_currency' => 'quote_currency', + 'execution_price' => 'execution_price', + 'limit_price' => 'limit_price', + 'stop_price' => 'stop_price', + 'legs' => 'legs' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'brokerage_order_id' => 'setBrokerageOrderId', + 'status' => 'setStatus', + 'order_type' => 'setOrderType', + 'time_in_force' => 'setTimeInForce', + 'time_placed' => 'setTimePlaced', + 'time_executed' => 'setTimeExecuted', + 'quote_currency' => 'setQuoteCurrency', + 'execution_price' => 'setExecutionPrice', + 'limit_price' => 'setLimitPrice', + 'stop_price' => 'setStopPrice', + 'legs' => 'setLegs' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'brokerage_order_id' => 'getBrokerageOrderId', + 'status' => 'getStatus', + 'order_type' => 'getOrderType', + 'time_in_force' => 'getTimeInForce', + 'time_placed' => 'getTimePlaced', + 'time_executed' => 'getTimeExecuted', + 'quote_currency' => 'getQuoteCurrency', + 'execution_price' => 'getExecutionPrice', + 'limit_price' => 'getLimitPrice', + 'stop_price' => 'getStopPrice', + 'legs' => 'getLegs' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('brokerage_order_id', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('order_type', $data ?? [], null); + $this->setIfExists('time_in_force', $data ?? [], null); + $this->setIfExists('time_placed', $data ?? [], null); + $this->setIfExists('time_executed', $data ?? [], null); + $this->setIfExists('quote_currency', $data ?? [], null); + $this->setIfExists('execution_price', $data ?? [], null); + $this->setIfExists('limit_price', $data ?? [], null); + $this->setIfExists('stop_price', $data ?? [], null); + $this->setIfExists('legs', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets brokerage_order_id + * + * @return string|null + */ + public function getBrokerageOrderId() + { + return $this->container['brokerage_order_id']; + } + + /** + * Sets brokerage_order_id + * + * @param string|null $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + * + * @return self + */ + public function setBrokerageOrderId($brokerage_order_id) + { + + if (is_null($brokerage_order_id)) { + throw new \InvalidArgumentException('non-nullable brokerage_order_id cannot be null'); + } + + $this->container['brokerage_order_id'] = $brokerage_order_id; + + return $this; + } + + /** + * Gets status + * + * @return \SnapTrade\Model\AccountOrderRecordStatus|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \SnapTrade\Model\AccountOrderRecordStatus|null $status status + * + * @return self + */ + public function setStatus($status) + { + + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets order_type + * + * @return string|null + */ + public function getOrderType() + { + return $this->container['order_type']; + } + + /** + * Sets order_type + * + * @param string|null $order_type The type of order placed. - `MARKET` - `LIMIT` - `STOP` - `STOP_LIMIT` + * + * @return self + */ + public function setOrderType($order_type) + { + + if (is_null($order_type)) { + array_push($this->openAPINullablesSetToNull, 'order_type'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('order_type', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['order_type'] = $order_type; + + return $this; + } + + /** + * Gets time_in_force + * + * @return string|null + */ + public function getTimeInForce() + { + return $this->container['time_in_force']; + } + + /** + * Sets time_in_force + * + * @param string|null $time_in_force The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. We try our best to map brokerage time in force values to the following. When mapping fails, we will return the brokerage's time in force value. - `DAY` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. - `MOO` - Market On Open. The order is to be executed at the day's opening price. - `EHP` - Extended Hours P.M. The order is to be placed during extended hour trading, after markets close. + * + * @return self + */ + public function setTimeInForce($time_in_force) + { + + if (is_null($time_in_force)) { + throw new \InvalidArgumentException('non-nullable time_in_force cannot be null'); + } + + $this->container['time_in_force'] = $time_in_force; + + return $this; + } + + /** + * Gets time_placed + * + * @return \DateTime|null + */ + public function getTimePlaced() + { + return $this->container['time_placed']; + } + + /** + * Sets time_placed + * + * @param \DateTime|null $time_placed The time the order was placed. This is the time the order was submitted to the brokerage. + * + * @return self + */ + public function setTimePlaced($time_placed) + { + + if (is_null($time_placed)) { + throw new \InvalidArgumentException('non-nullable time_placed cannot be null'); + } + + $this->container['time_placed'] = $time_placed; + + return $this; + } + + /** + * Gets time_executed + * + * @return \DateTime|null + */ + public function getTimeExecuted() + { + return $this->container['time_executed']; + } + + /** + * Sets time_executed + * + * @param \DateTime|null $time_executed The time the order was executed in the brokerage system. This value is not always available from the brokerage. + * + * @return self + */ + public function setTimeExecuted($time_executed) + { + + if (is_null($time_executed)) { + array_push($this->openAPINullablesSetToNull, 'time_executed'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('time_executed', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['time_executed'] = $time_executed; + + return $this; + } + + /** + * Gets quote_currency + * + * @return string|null + */ + public function getQuoteCurrency() + { + return $this->container['quote_currency']; + } + + /** + * Sets quote_currency + * + * @param string|null $quote_currency Quote currency code for the order. + * + * @return self + */ + public function setQuoteCurrency($quote_currency) + { + + if (is_null($quote_currency)) { + throw new \InvalidArgumentException('non-nullable quote_currency cannot be null'); + } + + $this->container['quote_currency'] = $quote_currency; + + return $this; + } + + /** + * Gets execution_price + * + * @return float|null + */ + public function getExecutionPrice() + { + return $this->container['execution_price']; + } + + /** + * Sets execution_price + * + * @param float|null $execution_price The price at which the order was executed. + * + * @return self + */ + public function setExecutionPrice($execution_price) + { + + if (is_null($execution_price)) { + array_push($this->openAPINullablesSetToNull, 'execution_price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('execution_price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['execution_price'] = $execution_price; + + return $this; + } + + /** + * Gets limit_price + * + * @return float|null + */ + public function getLimitPrice() + { + return $this->container['limit_price']; + } + + /** + * Sets limit_price + * + * @param float|null $limit_price The limit price is maximum price one is willing to pay for a buy order or the minimum price one is willing to accept for a sell order. Should only apply to `Limit` and `StopLimit` orders. + * + * @return self + */ + public function setLimitPrice($limit_price) + { + + if (is_null($limit_price)) { + array_push($this->openAPINullablesSetToNull, 'limit_price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('limit_price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['limit_price'] = $limit_price; + + return $this; + } + + /** + * Gets stop_price + * + * @return float|null + */ + public function getStopPrice() + { + return $this->container['stop_price']; + } + + /** + * Sets stop_price + * + * @param float|null $stop_price The stop price is the price at which a stop order is triggered. Should only apply to `Stop` and `StopLimit` orders. + * + * @return self + */ + public function setStopPrice($stop_price) + { + + if (is_null($stop_price)) { + array_push($this->openAPINullablesSetToNull, 'stop_price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('stop_price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['stop_price'] = $stop_price; + + return $this; + } + + /** + * Gets legs + * + * @return \SnapTrade\Model\AccountOrderRecordLeg[]|null + */ + public function getLegs() + { + return $this->container['legs']; + } + + /** + * Sets legs + * + * @param \SnapTrade\Model\AccountOrderRecordLeg[]|null $legs List of legs that make up the order. + * + * @return self + */ + public function setLegs($legs) + { + + if (is_null($legs)) { + throw new \InvalidArgumentException('non-nullable legs cannot be null'); + } + + $this->container['legs'] = $legs; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/AccountOrdersV2Response.php b/lib/Model/AccountOrdersV2Response.php new file mode 100644 index 0000000..4f2737d --- /dev/null +++ b/lib/Model/AccountOrdersV2Response.php @@ -0,0 +1,408 @@ + + */ +class AccountOrdersV2Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AccountOrdersV2Response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'orders' => '\SnapTrade\Model\AccountOrderRecordV2[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'orders' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'orders' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'orders' => 'orders' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'orders' => 'setOrders' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'orders' => 'getOrders' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('orders', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['orders'] === null) { + $invalidProperties[] = "'orders' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets orders + * + * @return \SnapTrade\Model\AccountOrderRecordV2[] + */ + public function getOrders() + { + return $this->container['orders']; + } + + /** + * Sets orders + * + * @param \SnapTrade\Model\AccountOrderRecordV2[] $orders List of orders returned by the endpoint. + * + * @return self + */ + public function setOrders($orders) + { + + if (is_null($orders)) { + throw new \InvalidArgumentException('non-nullable orders cannot be null'); + } + + $this->container['orders'] = $orders; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/ExperimentalEndpointsApiTest.php b/test/Api/ExperimentalEndpointsApiTest.php new file mode 100644 index 0000000..ea385e6 --- /dev/null +++ b/test/Api/ExperimentalEndpointsApiTest.php @@ -0,0 +1,84 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test case for getUserAccountRecentOrdersV2 + * + * List account recent orders (V2, last 24 hours only). + * + */ + public function testGetUserAccountRecentOrdersV2() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/AccountOrderRecordLegInstrumentTest.php b/test/Model/AccountOrderRecordLegInstrumentTest.php new file mode 100644 index 0000000..dca9f3a --- /dev/null +++ b/test/Model/AccountOrderRecordLegInstrumentTest.php @@ -0,0 +1,119 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "symbol" + */ + public function testPropertySymbol() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "description" + */ + public function testPropertyDescription() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "asset_type" + */ + public function testPropertyAssetType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "exchange_mic_code" + */ + public function testPropertyExchangeMicCode() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "figi_code" + */ + public function testPropertyFigiCode() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/AccountOrderRecordLegTest.php b/test/Model/AccountOrderRecordLegTest.php new file mode 100644 index 0000000..4881b9e --- /dev/null +++ b/test/Model/AccountOrderRecordLegTest.php @@ -0,0 +1,146 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "leg_id" + */ + public function testPropertyLegId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "instrument" + */ + public function testPropertyInstrument() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "action" + */ + public function testPropertyAction() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "execution_price" + */ + public function testPropertyExecutionPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "total_quantity" + */ + public function testPropertyTotalQuantity() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "canceled_quantity" + */ + public function testPropertyCanceledQuantity() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "filled_quantity" + */ + public function testPropertyFilledQuantity() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "status" + */ + public function testPropertyStatus() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/AccountOrderRecordStatusV2Test.php b/test/Model/AccountOrderRecordStatusV2Test.php new file mode 100644 index 0000000..a03a61c --- /dev/null +++ b/test/Model/AccountOrderRecordStatusV2Test.php @@ -0,0 +1,74 @@ +markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/AccountOrderRecordV2Test.php b/test/Model/AccountOrderRecordV2Test.php new file mode 100644 index 0000000..96785f2 --- /dev/null +++ b/test/Model/AccountOrderRecordV2Test.php @@ -0,0 +1,173 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "brokerage_order_id" + */ + public function testPropertyBrokerageOrderId() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "status" + */ + public function testPropertyStatus() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "order_type" + */ + public function testPropertyOrderType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "time_in_force" + */ + public function testPropertyTimeInForce() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "time_placed" + */ + public function testPropertyTimePlaced() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "time_executed" + */ + public function testPropertyTimeExecuted() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "quote_currency" + */ + public function testPropertyQuoteCurrency() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "execution_price" + */ + public function testPropertyExecutionPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "limit_price" + */ + public function testPropertyLimitPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "stop_price" + */ + public function testPropertyStopPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "legs" + */ + public function testPropertyLegs() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/test/Model/AccountOrdersV2ResponseTest.php b/test/Model/AccountOrdersV2ResponseTest.php new file mode 100644 index 0000000..5b665cc --- /dev/null +++ b/test/Model/AccountOrdersV2ResponseTest.php @@ -0,0 +1,83 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "orders" + */ + public function testPropertyOrders() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From c6eeda056cbdc3291ef31dbc4b5c3e648c7a1af9 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 6 Nov 2025 00:25:20 +0000 Subject: [PATCH 217/252] Version Bump SDKs (#245) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 1300d5a..487adf9 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -99ba219d-4d6d-4a86-ba2e-d3e3c054cdc6 \ No newline at end of file +2026f092-efbe-4bde-aed1-b7d05294d6cc \ No newline at end of file diff --git a/README.md b/README.md index 67fbc33..6ba6d05 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.143-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.144-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.143" + "konfig/snaptrade-php-sdk": "2.0.144" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 7a9227e..6220232 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.143/PHP'; + protected $userAgent = 'Konfig/2.0.144/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.143' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.144' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 06ac38471f299aa1d444fbc0f676b29e6068b635 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 7 Nov 2025 23:37:21 +0000 Subject: [PATCH 218/252] Regenerate SDKs (#246) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 30 +++++++++++++------ lib/Api/AccountInformationApi.php | 48 +++++++++++++++---------------- lib/Api/ConnectionsApi.php | 8 +++--- lib/Api/OptionsApi.php | 8 +++--- 5 files changed, 55 insertions(+), 41 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 487adf9..4e98dff 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2026f092-efbe-4bde-aed1-b7d05294d6cc \ No newline at end of file +3c93813b-9c43-4421-96d1-d972ccb22f11 \ No newline at end of file diff --git a/README.md b/README.md index 6ba6d05..52c4228 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,9 @@ Optional. Comma separated list of authorization IDs (only use if filtering is ne Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). -The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: + - If you do, this endpoint returns real-time data. + - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. @@ -303,7 +305,9 @@ $result = $snaptrade->accountInformation->getUserAccountBalance( Returns account detail known to SnapTrade for the specified account. -The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: + - If you do, this endpoint returns real-time data. + - If you don't, the data is cached and refreshed once a day. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. @@ -394,7 +398,9 @@ Order ID returned by brokerage. This is the unique identifier for the order in t Returns a list of recent orders in the specified account. -The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: + - If you do, this endpoint returns real-time data. + - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. @@ -446,7 +452,9 @@ Number of days in the past to fetch the most recent orders. Defaults to the last Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). -The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: + - If you do, this endpoint returns real-time data. + - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. @@ -573,7 +581,9 @@ $result = $snaptrade->accountInformation->getUserAccountReturnRates( Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ -The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: + - If you do, this endpoint returns real-time data. + - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. @@ -615,7 +625,9 @@ $result = $snaptrade->accountInformation->getUserHoldings( Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. -The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: + - If you do, this endpoint returns real-time data. + - If you don't, the data is cached and refreshed once a day. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. @@ -1036,7 +1048,7 @@ $result = $snaptrade->connections->listBrokerageAuthorizations( Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. -**Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** +**Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** @@ -1335,7 +1347,9 @@ Universal symbol ID if symbol Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). -The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. +Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: + - If you do, this endpoint returns real-time data. + - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 622b146..c762ac2 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -1153,7 +1153,7 @@ public function getAllUserHoldingsRequest($user_id, $user_secret, $brokerage_aut * * List account balances * - * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -1182,7 +1182,7 @@ public function getUserAccountBalance( * * List account balances * - * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1303,7 +1303,7 @@ public function getUserAccountBalanceWithHttpInfo($user_id, $user_secret, $accou * * List account balances * - * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1335,7 +1335,7 @@ function ($response) { * * List account balances * - * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1555,7 +1555,7 @@ public function getUserAccountBalanceRequest($user_id, $user_secret, $account_id * * Get account detail * - * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns account detail known to SnapTrade for the specified account. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -1584,7 +1584,7 @@ public function getUserAccountDetails( * * Get account detail * - * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns account detail known to SnapTrade for the specified account. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1705,7 +1705,7 @@ public function getUserAccountDetailsWithHttpInfo($user_id, $user_secret, $accou * * Get account detail * - * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns account detail known to SnapTrade for the specified account. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -1737,7 +1737,7 @@ function ($response) { * * Get account detail * - * Returns account detail known to SnapTrade for the specified account. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns account detail known to SnapTrade for the specified account. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2463,7 +2463,7 @@ public function getUserAccountOrderDetailRequest($account_id, $user_id, $user_se * * List account orders * - * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of recent orders in the specified account. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -2496,7 +2496,7 @@ public function getUserAccountOrders( * * List account orders * - * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of recent orders in the specified account. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2644,7 +2644,7 @@ public function getUserAccountOrdersWithHttpInfo($user_id, $user_secret, $accoun * * List account orders * - * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of recent orders in the specified account. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2680,7 +2680,7 @@ function ($response) { * * List account orders * - * Returns a list of recent orders in the specified account. The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of recent orders in the specified account. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -2933,7 +2933,7 @@ public function getUserAccountOrdersRequest($user_id, $user_secret, $account_id, * * List account positions * - * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -2962,7 +2962,7 @@ public function getUserAccountPositions( * * List account positions * - * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -3083,7 +3083,7 @@ public function getUserAccountPositionsWithHttpInfo($user_id, $user_secret, $acc * * List account positions * - * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -3115,7 +3115,7 @@ function ($response) { * * List account positions * - * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $user_id (required) * @param string $user_secret (required) @@ -4250,7 +4250,7 @@ public function getUserAccountReturnRatesRequest($user_id, $user_secret, $accoun * * List account holdings * - * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id account_id (required) * @param string $user_id user_id (required) @@ -4279,7 +4279,7 @@ public function getUserHoldings( * * List account holdings * - * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id (required) * @param string $user_id (required) @@ -4469,7 +4469,7 @@ public function getUserHoldingsWithHttpInfo($account_id, $user_id, $user_secret, * * List account holdings * - * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id (required) * @param string $user_id (required) @@ -4501,7 +4501,7 @@ function ($response) { * * List account holdings * - * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. + * Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) endpoints. __The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.__ Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection. * * @param string $account_id (required) * @param string $user_id (required) @@ -4721,7 +4721,7 @@ public function getUserHoldingsRequest($account_id, $user_id, $user_secret, stri * * List accounts * - * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -4748,7 +4748,7 @@ public function listUserAccounts( * * List accounts * - * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. * * @param string $user_id (required) * @param string $user_secret (required) @@ -4867,7 +4867,7 @@ public function listUserAccountsWithHttpInfo($user_id, $user_secret, string $con * * List accounts * - * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. * * @param string $user_id (required) * @param string $user_secret (required) @@ -4897,7 +4897,7 @@ function ($response) { * * List accounts * - * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. * * @param string $user_id (required) * @param string $user_secret (required) diff --git a/lib/Api/ConnectionsApi.php b/lib/Api/ConnectionsApi.php index b5305a2..dd07a41 100644 --- a/lib/Api/ConnectionsApi.php +++ b/lib/Api/ConnectionsApi.php @@ -1430,7 +1430,7 @@ public function listBrokerageAuthorizationsRequest($user_id, $user_secret, strin * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) @@ -1459,7 +1459,7 @@ public function refreshBrokerageAuthorization( * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1672,7 +1672,7 @@ public function refreshBrokerageAuthorizationWithHttpInfo($authorization_id, $us * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $authorization_id (required) * @param string $user_id (required) @@ -1704,7 +1704,7 @@ function ($response) { * * Refresh holdings for a connection * - * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Please contact support before use. Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** * * @param string $authorization_id (required) * @param string $user_id (required) diff --git a/lib/Api/OptionsApi.php b/lib/Api/OptionsApi.php index 5238a08..dcf363d 100644 --- a/lib/Api/OptionsApi.php +++ b/lib/Api/OptionsApi.php @@ -597,7 +597,7 @@ public function getOptionsChainRequest($user_id, $user_secret, $account_id, $sym * * List account option positions * - * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -626,7 +626,7 @@ public function listOptionHoldings( * * List account option positions * - * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. * * @param string $user_id (required) * @param string $user_secret (required) @@ -770,7 +770,7 @@ public function listOptionHoldingsWithHttpInfo($user_id, $user_secret, $account_ * * List account option positions * - * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. * * @param string $user_id (required) * @param string $user_secret (required) @@ -802,7 +802,7 @@ function ($response) { * * List account option positions * - * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. + * Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. * * @param string $user_id (required) * @param string $user_secret (required) From ab3892891124007a44974330ad679124fe33539a Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 7 Nov 2025 23:42:11 +0000 Subject: [PATCH 219/252] Version Bump SDKs (#247) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 4e98dff..b0dbc08 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -3c93813b-9c43-4421-96d1-d972ccb22f11 \ No newline at end of file +6c14a99e-7c60-4527-bbad-5055348f464b \ No newline at end of file diff --git a/README.md b/README.md index 52c4228..77ffbdb 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.144-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.145-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.144" + "konfig/snaptrade-php-sdk": "2.0.145" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 6220232..9e59f03 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.144/PHP'; + protected $userAgent = 'Konfig/2.0.145/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.144' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.145' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 19e6679f91ba1b502379143e3e588ca060b283d6 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 00:16:40 +0000 Subject: [PATCH 220/252] Regenerate SDKs (#248) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/CryptocurrencyPair.php | 55 ++++++++++++++++++++++++--- test/Model/CryptocurrencyPairTest.php | 9 +++++ 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index b0dbc08..baee4d9 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -6c14a99e-7c60-4527-bbad-5055348f464b \ No newline at end of file +480f3a06-234b-4cb3-85a4-4bea67b3815f \ No newline at end of file diff --git a/lib/Model/CryptocurrencyPair.php b/lib/Model/CryptocurrencyPair.php index b46986b..7e8d773 100644 --- a/lib/Model/CryptocurrencyPair.php +++ b/lib/Model/CryptocurrencyPair.php @@ -53,7 +53,8 @@ class CryptocurrencyPair implements ModelInterface, ArrayAccess, \JsonSerializab protected static $openAPITypes = [ 'symbol' => 'string', 'base' => 'string', - 'quote' => 'string' + 'quote' => 'string', + 'increment' => 'string' ]; /** @@ -66,7 +67,8 @@ class CryptocurrencyPair implements ModelInterface, ArrayAccess, \JsonSerializab protected static $openAPIFormats = [ 'symbol' => null, 'base' => null, - 'quote' => null + 'quote' => null, + 'increment' => null ]; /** @@ -77,7 +79,8 @@ class CryptocurrencyPair implements ModelInterface, ArrayAccess, \JsonSerializab protected static array $openAPINullables = [ 'symbol' => false, 'base' => false, - 'quote' => false + 'quote' => false, + 'increment' => true ]; /** @@ -168,7 +171,8 @@ public function isNullableSetToNull(string $property): bool protected static $attributeMap = [ 'symbol' => 'symbol', 'base' => 'base', - 'quote' => 'quote' + 'quote' => 'quote', + 'increment' => 'increment' ]; /** @@ -179,7 +183,8 @@ public function isNullableSetToNull(string $property): bool protected static $setters = [ 'symbol' => 'setSymbol', 'base' => 'setBase', - 'quote' => 'setQuote' + 'quote' => 'setQuote', + 'increment' => 'setIncrement' ]; /** @@ -190,7 +195,8 @@ public function isNullableSetToNull(string $property): bool protected static $getters = [ 'symbol' => 'getSymbol', 'base' => 'getBase', - 'quote' => 'getQuote' + 'quote' => 'getQuote', + 'increment' => 'getIncrement' ]; /** @@ -253,6 +259,7 @@ public function __construct(array $data = null) $this->setIfExists('symbol', $data ?? [], null); $this->setIfExists('base', $data ?? [], null); $this->setIfExists('quote', $data ?? [], null); + $this->setIfExists('increment', $data ?? [], null); } /** @@ -389,6 +396,42 @@ public function setQuote($quote) return $this; } + + /** + * Gets increment + * + * @return string|null + */ + public function getIncrement() + { + return $this->container['increment']; + } + + /** + * Sets increment + * + * @param string|null $increment increment + * + * @return self + */ + public function setIncrement($increment) + { + + if (is_null($increment)) { + array_push($this->openAPINullablesSetToNull, 'increment'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('increment', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['increment'] = $increment; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/test/Model/CryptocurrencyPairTest.php b/test/Model/CryptocurrencyPairTest.php index ddc9d6c..06f92f3 100644 --- a/test/Model/CryptocurrencyPairTest.php +++ b/test/Model/CryptocurrencyPairTest.php @@ -98,4 +98,13 @@ public function testPropertyQuote() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "increment" + */ + public function testPropertyIncrement() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } From 8a06d6ff43f727bac7d56470b89eed69f67b2e9e Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 00:20:58 +0000 Subject: [PATCH 221/252] Version Bump SDKs (#249) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index baee4d9..ba8affc 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -480f3a06-234b-4cb3-85a4-4bea67b3815f \ No newline at end of file +ff664431-dbff-4966-adc1-088258f17f01 \ No newline at end of file diff --git a/README.md b/README.md index 77ffbdb..1d23928 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.145-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.146-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.145" + "konfig/snaptrade-php-sdk": "2.0.146" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 9e59f03..3e63de5 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.145/PHP'; + protected $userAgent = 'Konfig/2.0.146/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.145' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.146' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From e6bd6272489906fbeafa4866afb95f9eff81a86a Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:17:28 +0000 Subject: [PATCH 222/252] Regenerate SDKs (#250) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 5 +++ lib/Api/AuthenticationApi.php | 4 +++ lib/Model/SnapTradeLoginUserRequestBody.php | 36 +++++++++++++++++++ .../SnapTradeLoginUserRequestBodyTest.php | 9 +++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index ba8affc..90c15f0 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ff664431-dbff-4966-adc1-088258f17f01 \ No newline at end of file +bd8cec7b-c626-418e-955b-449ac412366a \ No newline at end of file diff --git a/README.md b/README.md index 1d23928..e6079ba 100644 --- a/README.md +++ b/README.md @@ -800,6 +800,7 @@ $result = $snaptrade->authentication->loginSnapTradeUser( reconnect: "8b5f262d-4bb9-365d-888a-202bd3b15fa1", connection_type: "read", show_close_button: True, + dark_mode: True, connection_portal_version: "v4" ); ``` @@ -834,6 +835,10 @@ Determines connection permissions (default: read) - `read`: Data access only. - Controls whether the close (X) button is displayed in the connection portal. When false, you control closing behavior from your app. Defaults to true. +##### darkMode: `bool` + +Enable dark mode for the connection portal. Defaults to false. + ##### connectionPortalVersion: `string` Sets the connection portal version to render. Currently only v4 is supported and is the default. All other versions are deprecated and will automatically be set to v4. diff --git a/lib/Api/AuthenticationApi.php b/lib/Api/AuthenticationApi.php index a6dc59e..7bd7dd4 100644 --- a/lib/Api/AuthenticationApi.php +++ b/lib/Api/AuthenticationApi.php @@ -977,6 +977,7 @@ public function loginSnapTradeUser( $reconnect = SENTINEL_VALUE, $connection_type = 'read', $show_close_button = SENTINEL_VALUE, + $dark_mode = SENTINEL_VALUE, $connection_portal_version = 'v4', string $contentType = self::contentTypes['loginSnapTradeUser'][0] @@ -989,6 +990,7 @@ public function loginSnapTradeUser( $this->setRequestBodyProperty($_body, "reconnect", $reconnect); $this->setRequestBodyProperty($_body, "connection_type", $connection_type); $this->setRequestBodyProperty($_body, "show_close_button", $show_close_button); + $this->setRequestBodyProperty($_body, "dark_mode", $dark_mode); $this->setRequestBodyProperty($_body, "connection_portal_version", $connection_portal_version); $snap_trade_login_user_request_body = $_body; @@ -1210,6 +1212,7 @@ public function loginSnapTradeUserAsync( $reconnect = SENTINEL_VALUE, $connection_type = 'read', $show_close_button = SENTINEL_VALUE, + $dark_mode = SENTINEL_VALUE, $connection_portal_version = 'v4', string $contentType = self::contentTypes['loginSnapTradeUser'][0] @@ -1222,6 +1225,7 @@ public function loginSnapTradeUserAsync( $this->setRequestBodyProperty($_body, "reconnect", $reconnect); $this->setRequestBodyProperty($_body, "connection_type", $connection_type); $this->setRequestBodyProperty($_body, "show_close_button", $show_close_button); + $this->setRequestBodyProperty($_body, "dark_mode", $dark_mode); $this->setRequestBodyProperty($_body, "connection_portal_version", $connection_portal_version); $snap_trade_login_user_request_body = $_body; diff --git a/lib/Model/SnapTradeLoginUserRequestBody.php b/lib/Model/SnapTradeLoginUserRequestBody.php index f772d4b..64f02ad 100644 --- a/lib/Model/SnapTradeLoginUserRequestBody.php +++ b/lib/Model/SnapTradeLoginUserRequestBody.php @@ -57,6 +57,7 @@ class SnapTradeLoginUserRequestBody implements ModelInterface, ArrayAccess, \Jso 'reconnect' => 'string', 'connection_type' => 'string', 'show_close_button' => 'bool', + 'dark_mode' => 'bool', 'connection_portal_version' => 'string' ]; @@ -74,6 +75,7 @@ class SnapTradeLoginUserRequestBody implements ModelInterface, ArrayAccess, \Jso 'reconnect' => null, 'connection_type' => null, 'show_close_button' => null, + 'dark_mode' => null, 'connection_portal_version' => null ]; @@ -89,6 +91,7 @@ class SnapTradeLoginUserRequestBody implements ModelInterface, ArrayAccess, \Jso 'reconnect' => false, 'connection_type' => false, 'show_close_button' => false, + 'dark_mode' => false, 'connection_portal_version' => false ]; @@ -184,6 +187,7 @@ public function isNullableSetToNull(string $property): bool 'reconnect' => 'reconnect', 'connection_type' => 'connectionType', 'show_close_button' => 'showCloseButton', + 'dark_mode' => 'darkMode', 'connection_portal_version' => 'connectionPortalVersion' ]; @@ -199,6 +203,7 @@ public function isNullableSetToNull(string $property): bool 'reconnect' => 'setReconnect', 'connection_type' => 'setConnectionType', 'show_close_button' => 'setShowCloseButton', + 'dark_mode' => 'setDarkMode', 'connection_portal_version' => 'setConnectionPortalVersion' ]; @@ -214,6 +219,7 @@ public function isNullableSetToNull(string $property): bool 'reconnect' => 'getReconnect', 'connection_type' => 'getConnectionType', 'show_close_button' => 'getShowCloseButton', + 'dark_mode' => 'getDarkMode', 'connection_portal_version' => 'getConnectionPortalVersion' ]; @@ -314,6 +320,7 @@ public function __construct(array $data = null) $this->setIfExists('reconnect', $data ?? [], null); $this->setIfExists('connection_type', $data ?? [], 'read'); $this->setIfExists('show_close_button', $data ?? [], null); + $this->setIfExists('dark_mode', $data ?? [], null); $this->setIfExists('connection_portal_version', $data ?? [], 'v4'); } @@ -561,6 +568,35 @@ public function setShowCloseButton($show_close_button) return $this; } + /** + * Gets dark_mode + * + * @return bool|null + */ + public function getDarkMode() + { + return $this->container['dark_mode']; + } + + /** + * Sets dark_mode + * + * @param bool|null $dark_mode Enable dark mode for the connection portal. Defaults to false. + * + * @return self + */ + public function setDarkMode($dark_mode) + { + + if (is_null($dark_mode)) { + throw new \InvalidArgumentException('non-nullable dark_mode cannot be null'); + } + + $this->container['dark_mode'] = $dark_mode; + + return $this; + } + /** * Gets connection_portal_version * diff --git a/test/Model/SnapTradeLoginUserRequestBodyTest.php b/test/Model/SnapTradeLoginUserRequestBodyTest.php index acb1300..2ca48b2 100644 --- a/test/Model/SnapTradeLoginUserRequestBodyTest.php +++ b/test/Model/SnapTradeLoginUserRequestBodyTest.php @@ -126,6 +126,15 @@ public function testPropertyShowCloseButton() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "dark_mode" + */ + public function testPropertyDarkMode() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "connection_portal_version" */ From 86b7cc54c2959d2008c8e45bf1d142e366c5ba99 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:25:41 +0000 Subject: [PATCH 223/252] Version Bump SDKs (#251) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 90c15f0..53fb4b7 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -bd8cec7b-c626-418e-955b-449ac412366a \ No newline at end of file +7f7ee29c-1d69-4217-8f9c-95f6b19bc087 \ No newline at end of file diff --git a/README.md b/README.md index e6079ba..fdfbf35 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.146-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.147-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.146" + "konfig/snaptrade-php-sdk": "2.0.147" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 3e63de5..bcfd856 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.146/PHP'; + protected $userAgent = 'Konfig/2.0.147/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.146' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.147' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 2090540832a01468c776f0c227e9fc29187a20e8 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 21 Nov 2025 12:14:21 +0000 Subject: [PATCH 224/252] Regenerate SDKs (#252) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/Account.php | 51 +++++++++++++++++++++++++++++++++----- test/Model/AccountTest.php | 9 +++++++ 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 53fb4b7..75d8eb0 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -7f7ee29c-1d69-4217-8f9c-95f6b19bc087 \ No newline at end of file +acac1f9a-2b3f-4f72-ae46-ce195095ec23 \ No newline at end of file diff --git a/lib/Model/Account.php b/lib/Model/Account.php index b4ee693..d139b97 100644 --- a/lib/Model/Account.php +++ b/lib/Model/Account.php @@ -63,7 +63,8 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'raw_type' => 'string', 'meta' => 'array', 'portfolio_group' => 'string', - 'cash_restrictions' => 'string[]' + 'cash_restrictions' => 'string[]', + 'is_paper' => 'bool' ]; /** @@ -86,7 +87,8 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'raw_type' => null, 'meta' => null, 'portfolio_group' => 'uuid', - 'cash_restrictions' => null + 'cash_restrictions' => null, + 'is_paper' => null ]; /** @@ -107,7 +109,8 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'raw_type' => true, 'meta' => false, 'portfolio_group' => false, - 'cash_restrictions' => false + 'cash_restrictions' => false, + 'is_paper' => false ]; /** @@ -208,7 +211,8 @@ public function isNullableSetToNull(string $property): bool 'raw_type' => 'raw_type', 'meta' => 'meta', 'portfolio_group' => 'portfolio_group', - 'cash_restrictions' => 'cash_restrictions' + 'cash_restrictions' => 'cash_restrictions', + 'is_paper' => 'is_paper' ]; /** @@ -229,7 +233,8 @@ public function isNullableSetToNull(string $property): bool 'raw_type' => 'setRawType', 'meta' => 'setMeta', 'portfolio_group' => 'setPortfolioGroup', - 'cash_restrictions' => 'setCashRestrictions' + 'cash_restrictions' => 'setCashRestrictions', + 'is_paper' => 'setIsPaper' ]; /** @@ -250,7 +255,8 @@ public function isNullableSetToNull(string $property): bool 'raw_type' => 'getRawType', 'meta' => 'getMeta', 'portfolio_group' => 'getPortfolioGroup', - 'cash_restrictions' => 'getCashRestrictions' + 'cash_restrictions' => 'getCashRestrictions', + 'is_paper' => 'getIsPaper' ]; /** @@ -342,6 +348,7 @@ public function __construct(array $data = null) $this->setIfExists('meta', $data ?? [], null); $this->setIfExists('portfolio_group', $data ?? [], null); $this->setIfExists('cash_restrictions', $data ?? [], null); + $this->setIfExists('is_paper', $data ?? [], null); } /** @@ -404,6 +411,9 @@ public function listInvalidProperties() ); } + if ($this->container['is_paper'] === null) { + $invalidProperties[] = "'is_paper' can't be null"; + } return $invalidProperties; } @@ -832,6 +842,35 @@ public function setCashRestrictions($cash_restrictions) return $this; } + + /** + * Gets is_paper + * + * @return bool + */ + public function getIsPaper() + { + return $this->container['is_paper']; + } + + /** + * Sets is_paper + * + * @param bool $is_paper Indicates whether the account is a paper (simulated) trading account. + * + * @return self + */ + public function setIsPaper($is_paper) + { + + if (is_null($is_paper)) { + throw new \InvalidArgumentException('non-nullable is_paper cannot be null'); + } + + $this->container['is_paper'] = $is_paper; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/test/Model/AccountTest.php b/test/Model/AccountTest.php index 426b0f6..f6f2338 100644 --- a/test/Model/AccountTest.php +++ b/test/Model/AccountTest.php @@ -188,4 +188,13 @@ public function testPropertyCashRestrictions() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "is_paper" + */ + public function testPropertyIsPaper() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } From 84ff65ecc758820ecfe3ef33c761a380fc7970a3 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 21 Nov 2025 12:18:22 +0000 Subject: [PATCH 225/252] Version Bump SDKs (#253) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 75d8eb0..2400f9a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -acac1f9a-2b3f-4f72-ae46-ce195095ec23 \ No newline at end of file +2e7c3d33-0ebf-4741-a5cc-677ae421c6b7 \ No newline at end of file diff --git a/README.md b/README.md index fdfbf35..ec4e823 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.147-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.148-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.147" + "konfig/snaptrade-php-sdk": "2.0.148" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index bcfd856..2d0727e 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.147/PHP'; + protected $userAgent = 'Konfig/2.0.148/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.147' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.148' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 10ff6603f8495a1288664e839192c80c5cf9e8fe Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 24 Nov 2025 16:12:26 +0000 Subject: [PATCH 226/252] Regenerate SDKs (#254) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/MlegPriceEffectStrict.php | 2 +- test/Model/MlegPriceEffectStrictTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 2400f9a..0d7e3da 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2e7c3d33-0ebf-4741-a5cc-677ae421c6b7 \ No newline at end of file +96002270-1a84-4b1e-b3f1-4c901fbbf3cc \ No newline at end of file diff --git a/lib/Model/MlegPriceEffectStrict.php b/lib/Model/MlegPriceEffectStrict.php index 81a16de..e75c2a0 100644 --- a/lib/Model/MlegPriceEffectStrict.php +++ b/lib/Model/MlegPriceEffectStrict.php @@ -28,7 +28,7 @@ * MlegPriceEffectStrict Class Doc Comment * * @category Class - * @description The desired price_effect for LIMIT and STOP_LOSS_LIMIT orders + * @description The desired price_effect for LIMIT and STOP_LOSS_LIMIT orders. Values are CREDIT, DEBIT, EVEN * @package SnapTrade */ class MlegPriceEffectStrict diff --git a/test/Model/MlegPriceEffectStrictTest.php b/test/Model/MlegPriceEffectStrictTest.php index 9217146..f57c98b 100644 --- a/test/Model/MlegPriceEffectStrictTest.php +++ b/test/Model/MlegPriceEffectStrictTest.php @@ -29,7 +29,7 @@ * MlegPriceEffectStrictTest Class Doc Comment * * @category Class - * @description The desired price_effect for LIMIT and STOP_LOSS_LIMIT orders + * @description The desired price_effect for LIMIT and STOP_LOSS_LIMIT orders. Values are CREDIT, DEBIT, EVEN * @package SnapTrade */ class MlegPriceEffectStrictTest extends TestCase From e95996de75ba8ca7b0094679dbf662e4540e8d8a Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Mon, 24 Nov 2025 16:17:00 +0000 Subject: [PATCH 227/252] Version Bump SDKs (#255) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0d7e3da..bab2397 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -96002270-1a84-4b1e-b3f1-4c901fbbf3cc \ No newline at end of file +f3431f86-727c-47c0-9c6b-9b5791d1696c \ No newline at end of file diff --git a/README.md b/README.md index ec4e823..06874ff 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.148-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.149-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.148" + "konfig/snaptrade-php-sdk": "2.0.149" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 2d0727e..0ced251 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.148/PHP'; + protected $userAgent = 'Konfig/2.0.149/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.148' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.149' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 74d90deaaa86d9a0f404188f4777ea261a109000 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 02:03:19 +0000 Subject: [PATCH 228/252] Regenerate SDKs (#256) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/BrokerageAuthorization.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index bab2397..f3ec1bc 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f3431f86-727c-47c0-9c6b-9b5791d1696c \ No newline at end of file +5d45b40e-8c2c-4452-9e98-73f22056d228 \ No newline at end of file diff --git a/lib/Model/BrokerageAuthorization.php b/lib/Model/BrokerageAuthorization.php index 4886669..3a015c2 100644 --- a/lib/Model/BrokerageAuthorization.php +++ b/lib/Model/BrokerageAuthorization.php @@ -631,7 +631,7 @@ public function getIsEligibleForPayout() /** * Sets is_eligible_for_payout * - * @param bool|null $is_eligible_for_payout Whether the connection is eligible for a payout. + * @param bool|null $is_eligible_for_payout Whether the connection is eligible for a payout. This is an experimental field that is NOT generally available for all partners. Do not use in production without speaking to the SnapTrade team. * * @return self */ From ee3b57a2c6d09e3760af2d25f3fc9695937f3f2c Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 02:07:34 +0000 Subject: [PATCH 229/252] Version Bump SDKs (#257) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index f3ec1bc..1ebd39d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -5d45b40e-8c2c-4452-9e98-73f22056d228 \ No newline at end of file +ba3e7f0c-bca4-4480-b6fb-7124180227e0 \ No newline at end of file diff --git a/README.md b/README.md index 06874ff..7fd3f27 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.149-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.150-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.149" + "konfig/snaptrade-php-sdk": "2.0.150" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 0ced251..ceffa1e 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.149/PHP'; + protected $userAgent = 'Konfig/2.0.150/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.149' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.150' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From e736c11da8a83f2dee42252a014b6648a8af4bd2 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 14:15:19 +0000 Subject: [PATCH 230/252] Regenerate SDKs (#258) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/SecurityType.php | 2 +- lib/Model/UnderlyingSymbolType.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 1ebd39d..42dbce3 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ba3e7f0c-bca4-4480-b6fb-7124180227e0 \ No newline at end of file +83e19c0a-e44e-4b94-abf5-56b74ce5b7e5 \ No newline at end of file diff --git a/lib/Model/SecurityType.php b/lib/Model/SecurityType.php index d6c69b4..29c3f31 100644 --- a/lib/Model/SecurityType.php +++ b/lib/Model/SecurityType.php @@ -346,7 +346,7 @@ public function getCode() /** * Sets code * - * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: - `ad` - ADR - `bnd` - Bond - `cs` - Common Stock - `cef` - Closed End Fund - `crypto` - Cryptocurrency - `et` - ETF - `oef` - Open Ended Fund - `ps` - Preferred Stock - `rt` - Right - `struct` - Structured Product - `ut` - Unit - `wi` - When Issued - `wt` - Warrant + * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: - `ad` - ADR - `bnd` - Bond - `cs` - Common Stock - `cef` - Closed End Fund - `crypto` - Cryptocurrency - `et` - ETF - `oef` - Open Ended Fund - `pm` - Precious Metals - `ps` - Preferred Stock - `rt` - Right - `struct` - Structured Product - `ut` - Unit - `wi` - When Issued - `wt` - Warrant * * @return self */ diff --git a/lib/Model/UnderlyingSymbolType.php b/lib/Model/UnderlyingSymbolType.php index 4b22b9d..ff991a3 100644 --- a/lib/Model/UnderlyingSymbolType.php +++ b/lib/Model/UnderlyingSymbolType.php @@ -346,7 +346,7 @@ public function getCode() /** * Sets code * - * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: - `ad` - ADR - `bnd` - Bond - `cs` - Common Stock - `cef` - Closed End Fund - `crypto` - Cryptocurrency - `et` - ETF - `oef` - Open Ended Fund - `ps` - Preferred Stock - `rt` - Right - `struct` - Structured Product - `ut` - Unit - `wi` - When Issued - `wt` - Warrant + * @param string|null $code A short code representing the security type. For example, \"cs\" for Common Stock. Here are some common values: - `ad` - ADR - `bnd` - Bond - `cs` - Common Stock - `cef` - Closed End Fund - `crypto` - Cryptocurrency - `et` - ETF - `oef` - Open Ended Fund - `pm` - Precious Metals - `ps` - Preferred Stock - `rt` - Right - `struct` - Structured Product - `ut` - Unit - `wi` - When Issued - `wt` - Warrant * * @return self */ From e687c8e20dc3fecc0ce21320454fc975531b1926 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 14:19:43 +0000 Subject: [PATCH 231/252] Version Bump SDKs (#259) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 42dbce3..3fa2b95 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -83e19c0a-e44e-4b94-abf5-56b74ce5b7e5 \ No newline at end of file +43c3d599-6bf1-4171-adca-553345e9831f \ No newline at end of file diff --git a/README.md b/README.md index 7fd3f27..c8d28ea 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.150-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.151-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.150" + "konfig/snaptrade-php-sdk": "2.0.151" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index ceffa1e..e9fb4d6 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.150/PHP'; + protected $userAgent = 'Konfig/2.0.151/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.150' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.151' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From f2c97ab901892858bee03f6ccd7f5d703def7acb Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Sat, 29 Nov 2025 01:27:58 +0000 Subject: [PATCH 232/252] Regenerate SDKs (#260) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/AccountUniversalActivity.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 3fa2b95..9c52b2d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -43c3d599-6bf1-4171-adca-553345e9831f \ No newline at end of file +9821b459-8813-40ed-bb77-b7ade3684837 \ No newline at end of file diff --git a/lib/Model/AccountUniversalActivity.php b/lib/Model/AccountUniversalActivity.php index 87f1efa..98d04d1 100644 --- a/lib/Model/AccountUniversalActivity.php +++ b/lib/Model/AccountUniversalActivity.php @@ -625,7 +625,7 @@ public function getType() /** * Sets type * - * @param string|null $type A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. + * @param string|null $type A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of asset(s) from one account to another. - `EXTERNAL_ASSET_TRANSFER_IN` - Incoming transfer of an asset from an external account to this account. - `EXTERNAL_ASSET_TRANSFER_OUT` - Outgoing transfer of an asset from this account to an external account. - `SPLIT` - A stock share split. - `ADJUSTMENT` - A one time adjustment of the account's cash balance or shares of an asset * * @return self */ From c5041e6a27854779289c58d409ad98f8c820a4e3 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Sat, 29 Nov 2025 01:32:28 +0000 Subject: [PATCH 233/252] Version Bump SDKs (#261) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 9c52b2d..8645dbb 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -9821b459-8813-40ed-bb77-b7ade3684837 \ No newline at end of file +ddeca13a-214b-42fa-8253-6be1ceeae325 \ No newline at end of file diff --git a/README.md b/README.md index c8d28ea..b3ce3a4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.151-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.152-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.151" + "konfig/snaptrade-php-sdk": "2.0.152" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index e9fb4d6..961e2eb 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.151/PHP'; + protected $userAgent = 'Konfig/2.0.152/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.151' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.152' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From f1f5696297036e3894eedde7de6b01cd701615ff Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 18:39:50 +0000 Subject: [PATCH 234/252] Regenerate SDKs (#262) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 1 - lib/Api/AccountInformationApi.php | 8 ++++---- lib/Model/MlegTradingInstrument.php | 2 +- lib/Model/TradingInstrument.php | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 8645dbb..95f9aa8 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -ddeca13a-214b-42fa-8253-6be1ceeae325 \ No newline at end of file +444451ff-abd2-44cf-8b2c-6a92353335a8 \ No newline at end of file diff --git a/README.md b/README.md index b3ce3a4..92059b5 100644 --- a/README.md +++ b/README.md @@ -498,7 +498,6 @@ A lightweight endpoint that returns a list of orders executed in the last 24 hou This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false -**Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index c762ac2..62f97db 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -3335,7 +3335,7 @@ public function getUserAccountPositionsRequest($user_id, $user_secret, $account_ * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -3366,7 +3366,7 @@ public function getUserAccountRecentOrders( * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false * * @param string $user_id (required) * @param string $user_secret (required) @@ -3535,7 +3535,7 @@ public function getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $ * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false * * @param string $user_id (required) * @param string $user_secret (required) @@ -3569,7 +3569,7 @@ function ($response) { * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** + * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false * * @param string $user_id (required) * @param string $user_secret (required) diff --git a/lib/Model/MlegTradingInstrument.php b/lib/Model/MlegTradingInstrument.php index 6b553a1..88fb851 100644 --- a/lib/Model/MlegTradingInstrument.php +++ b/lib/Model/MlegTradingInstrument.php @@ -308,7 +308,7 @@ public function getSymbol() /** * Sets symbol * - * @param string $symbol The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example `AAPL 131124C00240000` represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format) + * @param string $symbol The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example `AAPL 251114C00240000` represents a call option on AAPL expiring on 2025-11-14 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format) * * @return self */ diff --git a/lib/Model/TradingInstrument.php b/lib/Model/TradingInstrument.php index 6498dba..ce489b3 100644 --- a/lib/Model/TradingInstrument.php +++ b/lib/Model/TradingInstrument.php @@ -336,7 +336,7 @@ public function getSymbol() /** * Sets symbol * - * @param string $symbol The instrument's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example `AAPL 131124C00240000` represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format) + * @param string $symbol The instrument's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example `AAPL 251114C00240000` represents a call option on AAPL expiring on 2025-11-14 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format) * * @return self */ From 7ae22fac152c46f59f325dac5742f9c7d437e074 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 18:44:26 +0000 Subject: [PATCH 235/252] Version Bump SDKs (#263) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 95f9aa8..9950245 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -444451ff-abd2-44cf-8b2c-6a92353335a8 \ No newline at end of file +89e3db9b-79e8-4871-8e7f-7a695e3e9512 \ No newline at end of file diff --git a/README.md b/README.md index 92059b5..ae87e65 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.152-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.153-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.152" + "konfig/snaptrade-php-sdk": "2.0.153" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 961e2eb..5b53b06 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.152/PHP'; + protected $userAgent = 'Konfig/2.0.153/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.152' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.153' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From e7e31c3a3a3b8db09c455573beb3a58c38169223 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 5 Dec 2025 01:54:29 +0000 Subject: [PATCH 236/252] Regenerate SDKs (#264) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/ConnectionsApi.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 9950245..a3c0fcc 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -89e3db9b-79e8-4871-8e7f-7a695e3e9512 \ No newline at end of file +269f4b30-f4b3-405d-9030-dbbfd94f0688 \ No newline at end of file diff --git a/README.md b/README.md index ae87e65..e17234f 100644 --- a/README.md +++ b/README.md @@ -1090,7 +1090,7 @@ $result = $snaptrade->connections->refreshBrokerageAuthorization( ### `snaptrade.connections.removeBrokerageAuthorization` -Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted. +Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the data has been successfully deleted. #### πŸ› οΈ Usage diff --git a/lib/Api/ConnectionsApi.php b/lib/Api/ConnectionsApi.php index dd07a41..c6482bd 100644 --- a/lib/Api/ConnectionsApi.php +++ b/lib/Api/ConnectionsApi.php @@ -1924,7 +1924,7 @@ public function refreshBrokerageAuthorizationRequest($authorization_id, $user_id * * Delete connection * - * Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted. + * Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the data has been successfully deleted. * * @param string $authorization_id authorization_id (required) * @param string $user_id user_id (required) @@ -1952,7 +1952,7 @@ public function removeBrokerageAuthorization( * * Delete connection * - * Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted. + * Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the data has been successfully deleted. * * @param string $authorization_id (required) * @param string $user_id (required) @@ -2033,7 +2033,7 @@ public function removeBrokerageAuthorizationWithHttpInfo($authorization_id, $use * * Delete connection * - * Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted. + * Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the data has been successfully deleted. * * @param string $authorization_id (required) * @param string $user_id (required) @@ -2065,7 +2065,7 @@ function ($response) { * * Delete connection * - * Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted. + * Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the data has been successfully deleted. * * @param string $authorization_id (required) * @param string $user_id (required) From c75d213e37bf5212ca06f5ec1e20586400705cbe Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 5 Dec 2025 01:58:41 +0000 Subject: [PATCH 237/252] Version Bump SDKs (#265) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a3c0fcc..0d7d7ae 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -269f4b30-f4b3-405d-9030-dbbfd94f0688 \ No newline at end of file +63b3cdad-8888-438e-8ba5-ffc552d0dcab \ No newline at end of file diff --git a/README.md b/README.md index e17234f..0855dda 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.153-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.154-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.153" + "konfig/snaptrade-php-sdk": "2.0.154" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 5b53b06..264e634 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.153/PHP'; + protected $userAgent = 'Konfig/2.0.154/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.153' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.154' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 0c0f368c020990eee2326c6241b05ffecbb5b8b6 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:38:11 +0000 Subject: [PATCH 238/252] Version Bump SDKs (#266) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0d7d7ae..0ce59de 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -63b3cdad-8888-438e-8ba5-ffc552d0dcab \ No newline at end of file +824ee686-aea7-4fa9-95b5-c3d9e6aa8887 \ No newline at end of file From 9069e02c843b3cf1a07747c42e8abf39fb18f798 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 17:28:23 +0000 Subject: [PATCH 239/252] Version Bump SDKs (#267) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0ce59de..10878fc 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -824ee686-aea7-4fa9-95b5-c3d9e6aa8887 \ No newline at end of file +0a3c8b67-e78c-4765-ac04-607455f38a14 \ No newline at end of file From 763e9d3c7d28e5d82ac0de92d9f614b5131db87f Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 18:51:33 +0000 Subject: [PATCH 240/252] Version Bump SDKs (#268) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 10878fc..604f41d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -0a3c8b67-e78c-4765-ac04-607455f38a14 \ No newline at end of file +2c05b995-541d-4840-a4b4-87abdb99dc35 \ No newline at end of file From ff46550ef2cdaae19f4afb37b052fbb913225e88 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 00:21:00 +0000 Subject: [PATCH 241/252] Regenerate SDKs (#269) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/Position.php | 48 ++- lib/Model/TaxLot.php | 627 ++++++++++++++++++++++++++++++++++++ test/Model/PositionTest.php | 9 + test/Model/TaxLotTest.php | 128 ++++++++ 5 files changed, 807 insertions(+), 7 deletions(-) create mode 100644 lib/Model/TaxLot.php create mode 100644 test/Model/TaxLotTest.php diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 604f41d..68f2b43 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -2c05b995-541d-4840-a4b4-87abdb99dc35 \ No newline at end of file +f4d3a006-5749-4f23-9e0f-203a95228965 \ No newline at end of file diff --git a/lib/Model/Position.php b/lib/Model/Position.php index e11b313..a5911d1 100644 --- a/lib/Model/Position.php +++ b/lib/Model/Position.php @@ -58,7 +58,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'average_purchase_price' => 'float', 'fractional_units' => 'float', 'currency' => '\SnapTrade\Model\PositionCurrency', - 'cash_equivalent' => 'bool' + 'cash_equivalent' => 'bool', + 'tax_lots' => '\SnapTrade\Model\TaxLot[]' ]; /** @@ -76,7 +77,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'average_purchase_price' => null, 'fractional_units' => null, 'currency' => null, - 'cash_equivalent' => null + 'cash_equivalent' => null, + 'tax_lots' => null ]; /** @@ -92,7 +94,8 @@ class Position implements ModelInterface, ArrayAccess, \JsonSerializable 'average_purchase_price' => true, 'fractional_units' => true, 'currency' => false, - 'cash_equivalent' => true + 'cash_equivalent' => true, + 'tax_lots' => false ]; /** @@ -188,7 +191,8 @@ public function isNullableSetToNull(string $property): bool 'average_purchase_price' => 'average_purchase_price', 'fractional_units' => 'fractional_units', 'currency' => 'currency', - 'cash_equivalent' => 'cash_equivalent' + 'cash_equivalent' => 'cash_equivalent', + 'tax_lots' => 'tax_lots' ]; /** @@ -204,7 +208,8 @@ public function isNullableSetToNull(string $property): bool 'average_purchase_price' => 'setAveragePurchasePrice', 'fractional_units' => 'setFractionalUnits', 'currency' => 'setCurrency', - 'cash_equivalent' => 'setCashEquivalent' + 'cash_equivalent' => 'setCashEquivalent', + 'tax_lots' => 'setTaxLots' ]; /** @@ -220,7 +225,8 @@ public function isNullableSetToNull(string $property): bool 'average_purchase_price' => 'getAveragePurchasePrice', 'fractional_units' => 'getFractionalUnits', 'currency' => 'getCurrency', - 'cash_equivalent' => 'getCashEquivalent' + 'cash_equivalent' => 'getCashEquivalent', + 'tax_lots' => 'getTaxLots' ]; /** @@ -288,6 +294,7 @@ public function __construct(array $data = null) $this->setIfExists('fractional_units', $data ?? [], null); $this->setIfExists('currency', $data ?? [], null); $this->setIfExists('cash_equivalent', $data ?? [], null); + $this->setIfExists('tax_lots', $data ?? [], null); } /** @@ -607,6 +614,35 @@ public function setCashEquivalent($cash_equivalent) return $this; } + + /** + * Gets tax_lots + * + * @return \SnapTrade\Model\TaxLot[]|null + */ + public function getTaxLots() + { + return $this->container['tax_lots']; + } + + /** + * Sets tax_lots + * + * @param \SnapTrade\Model\TaxLot[]|null $tax_lots List of tax lots for the given position (disabled by default, contact support if needed) + * + * @return self + */ + public function setTaxLots($tax_lots) + { + + if (is_null($tax_lots)) { + throw new \InvalidArgumentException('non-nullable tax_lots cannot be null'); + } + + $this->container['tax_lots'] = $tax_lots; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/lib/Model/TaxLot.php b/lib/Model/TaxLot.php new file mode 100644 index 0000000..b11b86b --- /dev/null +++ b/lib/Model/TaxLot.php @@ -0,0 +1,627 @@ + + */ +class TaxLot implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TaxLot'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'original_purchase_date' => '\DateTime', + 'quantity' => 'string', + 'purchased_price' => 'string', + 'cost_basis' => 'string', + 'current_value' => 'string', + 'position_type' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'original_purchase_date' => 'date-time', + 'quantity' => null, + 'purchased_price' => null, + 'cost_basis' => null, + 'current_value' => null, + 'position_type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'original_purchase_date' => true, + 'quantity' => true, + 'purchased_price' => true, + 'cost_basis' => true, + 'current_value' => true, + 'position_type' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'original_purchase_date' => 'original_purchase_date', + 'quantity' => 'quantity', + 'purchased_price' => 'purchased_price', + 'cost_basis' => 'cost_basis', + 'current_value' => 'current_value', + 'position_type' => 'position_type' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'original_purchase_date' => 'setOriginalPurchaseDate', + 'quantity' => 'setQuantity', + 'purchased_price' => 'setPurchasedPrice', + 'cost_basis' => 'setCostBasis', + 'current_value' => 'setCurrentValue', + 'position_type' => 'setPositionType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'original_purchase_date' => 'getOriginalPurchaseDate', + 'quantity' => 'getQuantity', + 'purchased_price' => 'getPurchasedPrice', + 'cost_basis' => 'getCostBasis', + 'current_value' => 'getCurrentValue', + 'position_type' => 'getPositionType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('original_purchase_date', $data ?? [], null); + $this->setIfExists('quantity', $data ?? [], null); + $this->setIfExists('purchased_price', $data ?? [], null); + $this->setIfExists('cost_basis', $data ?? [], null); + $this->setIfExists('current_value', $data ?? [], null); + $this->setIfExists('position_type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets original_purchase_date + * + * @return \DateTime|null + */ + public function getOriginalPurchaseDate() + { + return $this->container['original_purchase_date']; + } + + /** + * Sets original_purchase_date + * + * @param \DateTime|null $original_purchase_date The date and time of the purchase. + * + * @return self + */ + public function setOriginalPurchaseDate($original_purchase_date) + { + + if (is_null($original_purchase_date)) { + array_push($this->openAPINullablesSetToNull, 'original_purchase_date'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('original_purchase_date', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['original_purchase_date'] = $original_purchase_date; + + return $this; + } + + /** + * Gets quantity + * + * @return string|null + */ + public function getQuantity() + { + return $this->container['quantity']; + } + + /** + * Sets quantity + * + * @param string|null $quantity The number of shares in the tax lot. This can be fractional or integer units. + * + * @return self + */ + public function setQuantity($quantity) + { + + if (is_null($quantity)) { + array_push($this->openAPINullablesSetToNull, 'quantity'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('quantity', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['quantity'] = $quantity; + + return $this; + } + + /** + * Gets purchased_price + * + * @return string|null + */ + public function getPurchasedPrice() + { + return $this->container['purchased_price']; + } + + /** + * Sets purchased_price + * + * @param string|null $purchased_price The purchase price per share for the tax lot. + * + * @return self + */ + public function setPurchasedPrice($purchased_price) + { + + if (is_null($purchased_price)) { + array_push($this->openAPINullablesSetToNull, 'purchased_price'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('purchased_price', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['purchased_price'] = $purchased_price; + + return $this; + } + + /** + * Gets cost_basis + * + * @return string|null + */ + public function getCostBasis() + { + return $this->container['cost_basis']; + } + + /** + * Sets cost_basis + * + * @param string|null $cost_basis The cost basis of the entire lot. + * + * @return self + */ + public function setCostBasis($cost_basis) + { + + if (is_null($cost_basis)) { + array_push($this->openAPINullablesSetToNull, 'cost_basis'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('cost_basis', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['cost_basis'] = $cost_basis; + + return $this; + } + + /** + * Gets current_value + * + * @return string|null + */ + public function getCurrentValue() + { + return $this->container['current_value']; + } + + /** + * Sets current_value + * + * @param string|null $current_value The current market value of the entire lot. + * + * @return self + */ + public function setCurrentValue($current_value) + { + + if (is_null($current_value)) { + array_push($this->openAPINullablesSetToNull, 'current_value'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('current_value', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['current_value'] = $current_value; + + return $this; + } + + /** + * Gets position_type + * + * @return string|null + */ + public function getPositionType() + { + return $this->container['position_type']; + } + + /** + * Sets position_type + * + * @param string|null $position_type The type of position for the tax lot (e.g., LONG, SHORT). + * + * @return self + */ + public function setPositionType($position_type) + { + + if (is_null($position_type)) { + array_push($this->openAPINullablesSetToNull, 'position_type'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('position_type', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['position_type'] = $position_type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Model/PositionTest.php b/test/Model/PositionTest.php index 9b9fb13..05acb88 100644 --- a/test/Model/PositionTest.php +++ b/test/Model/PositionTest.php @@ -143,4 +143,13 @@ public function testPropertyCashEquivalent() // TODO: implement $this->markTestIncomplete('Not implemented'); } + + /** + * Test attribute "tax_lots" + */ + public function testPropertyTaxLots() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } } diff --git a/test/Model/TaxLotTest.php b/test/Model/TaxLotTest.php new file mode 100644 index 0000000..f5a9059 --- /dev/null +++ b/test/Model/TaxLotTest.php @@ -0,0 +1,128 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "original_purchase_date" + */ + public function testPropertyOriginalPurchaseDate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "quantity" + */ + public function testPropertyQuantity() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "purchased_price" + */ + public function testPropertyPurchasedPrice() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "cost_basis" + */ + public function testPropertyCostBasis() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "current_value" + */ + public function testPropertyCurrentValue() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "position_type" + */ + public function testPropertyPositionType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} From 5fb72c104bcfa1fb22b0b5aa8c046536ed94609c Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 00:25:09 +0000 Subject: [PATCH 242/252] Version Bump SDKs (#270) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 68f2b43..d7b7ead 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f4d3a006-5749-4f23-9e0f-203a95228965 \ No newline at end of file +fa4d6f3b-6088-4f34-af12-7968eeef694d \ No newline at end of file diff --git a/README.md b/README.md index 0855dda..06e1606 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.154-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.155-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.154" + "konfig/snaptrade-php-sdk": "2.0.155" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 264e634..5fac98a 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.154/PHP'; + protected $userAgent = 'Konfig/2.0.155/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.154' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.155' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 9c84da8118f6769cd0dbaaf63fe3537529fb9583 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 08:21:02 +0000 Subject: [PATCH 243/252] Regenerate SDKs (#271) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 2 +- lib/Api/AccountInformationApi.php | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index d7b7ead..0d1ea3d 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -fa4d6f3b-6088-4f34-af12-7968eeef694d \ No newline at end of file +0a142f9b-d5c2-4c93-acc9-4408579954b8 \ No newline at end of file diff --git a/README.md b/README.md index 06e1606..311f461 100644 --- a/README.md +++ b/README.md @@ -197,7 +197,7 @@ An integer that specifies the maximum number of transactions to return. Default ##### type: `string` -Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. +Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. #### πŸ”„ Return diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index 62f97db..cdef8be 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -182,7 +182,7 @@ private function setRequestBodyProperty(&$body, $property, $value) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -221,7 +221,7 @@ public function getAccountActivities( * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response @@ -352,7 +352,7 @@ public function getAccountActivitiesWithHttpInfo($account_id, $user_id, $user_se * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -394,7 +394,7 @@ function ($response) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -454,7 +454,7 @@ function ($exception) { * @param \DateTime $end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional) * @param int $offset An integer that specifies the starting point of the paginated results. Default is 0. (optional) * @param int $limit An integer that specifies the maximum number of transactions to return. Default of 1000. (optional) - * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX`` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) + * @param string $type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAccountActivities'] to see the possible values for this operation * * @throws \InvalidArgumentException From 5a02c99e1e4f9bf401f44451eebaccb19aa83219 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 08:25:12 +0000 Subject: [PATCH 244/252] Version Bump SDKs (#272) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 0d1ea3d..3cd334a 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -0a142f9b-d5c2-4c93-acc9-4408579954b8 \ No newline at end of file +4d19dfcf-f6b1-4b98-8a72-96c8989effd0 \ No newline at end of file diff --git a/README.md b/README.md index 311f461..7d78b35 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.155-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.156-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.155" + "konfig/snaptrade-php-sdk": "2.0.156" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 5fac98a..621bd1f 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.155/PHP'; + protected $userAgent = 'Konfig/2.0.156/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.155' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.156' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From f49e2d15734d7ecec3928024238c71a1d4a2e2fd Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 23:29:23 +0000 Subject: [PATCH 245/252] Regenerate SDKs (#273) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- lib/Model/Account.php | 86 ++++++++++++++++++++++++++++++++++++++ test/Model/AccountTest.php | 18 ++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 3cd334a..9619070 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -4d19dfcf-f6b1-4b98-8a72-96c8989effd0 \ No newline at end of file +f3b544d6-6d7a-40ba-b437-20e89ca018a0 \ No newline at end of file diff --git a/lib/Model/Account.php b/lib/Model/Account.php index d139b97..2196b23 100644 --- a/lib/Model/Account.php +++ b/lib/Model/Account.php @@ -57,6 +57,8 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'number' => 'string', 'institution_name' => 'string', 'created_date' => '\DateTime', + 'funding_date' => '\DateTime', + 'opening_date' => '\DateTime', 'sync_status' => '\SnapTrade\Model\AccountSyncStatus', 'balance' => '\SnapTrade\Model\AccountBalance', 'status' => 'string', @@ -81,6 +83,8 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'number' => null, 'institution_name' => null, 'created_date' => 'date-time', + 'funding_date' => 'date-time', + 'opening_date' => 'date-time', 'sync_status' => null, 'balance' => null, 'status' => null, @@ -103,6 +107,8 @@ class Account implements ModelInterface, ArrayAccess, \JsonSerializable 'number' => false, 'institution_name' => false, 'created_date' => false, + 'funding_date' => true, + 'opening_date' => true, 'sync_status' => false, 'balance' => false, 'status' => true, @@ -205,6 +211,8 @@ public function isNullableSetToNull(string $property): bool 'number' => 'number', 'institution_name' => 'institution_name', 'created_date' => 'created_date', + 'funding_date' => 'funding_date', + 'opening_date' => 'opening_date', 'sync_status' => 'sync_status', 'balance' => 'balance', 'status' => 'status', @@ -227,6 +235,8 @@ public function isNullableSetToNull(string $property): bool 'number' => 'setNumber', 'institution_name' => 'setInstitutionName', 'created_date' => 'setCreatedDate', + 'funding_date' => 'setFundingDate', + 'opening_date' => 'setOpeningDate', 'sync_status' => 'setSyncStatus', 'balance' => 'setBalance', 'status' => 'setStatus', @@ -249,6 +259,8 @@ public function isNullableSetToNull(string $property): bool 'number' => 'getNumber', 'institution_name' => 'getInstitutionName', 'created_date' => 'getCreatedDate', + 'funding_date' => 'getFundingDate', + 'opening_date' => 'getOpeningDate', 'sync_status' => 'getSyncStatus', 'balance' => 'getBalance', 'status' => 'getStatus', @@ -341,6 +353,8 @@ public function __construct(array $data = null) $this->setIfExists('number', $data ?? [], null); $this->setIfExists('institution_name', $data ?? [], null); $this->setIfExists('created_date', $data ?? [], null); + $this->setIfExists('funding_date', $data ?? [], null); + $this->setIfExists('opening_date', $data ?? [], null); $this->setIfExists('sync_status', $data ?? [], null); $this->setIfExists('balance', $data ?? [], null); $this->setIfExists('status', $data ?? [], null); @@ -610,6 +624,78 @@ public function setCreatedDate($created_date) return $this; } + /** + * Gets funding_date + * + * @return \DateTime|null + */ + public function getFundingDate() + { + return $this->container['funding_date']; + } + + /** + * Sets funding_date + * + * @param \DateTime|null $funding_date Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the account was funded. + * + * @return self + */ + public function setFundingDate($funding_date) + { + + if (is_null($funding_date)) { + array_push($this->openAPINullablesSetToNull, 'funding_date'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('funding_date', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['funding_date'] = $funding_date; + + return $this; + } + + /** + * Gets opening_date + * + * @return \DateTime|null + */ + public function getOpeningDate() + { + return $this->container['opening_date']; + } + + /** + * Sets opening_date + * + * @param \DateTime|null $opening_date Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the account was opened at the brokerage. + * + * @return self + */ + public function setOpeningDate($opening_date) + { + + if (is_null($opening_date)) { + array_push($this->openAPINullablesSetToNull, 'opening_date'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('opening_date', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + $this->container['opening_date'] = $opening_date; + + return $this; + } + /** * Gets sync_status * diff --git a/test/Model/AccountTest.php b/test/Model/AccountTest.php index f6f2338..73eac59 100644 --- a/test/Model/AccountTest.php +++ b/test/Model/AccountTest.php @@ -126,6 +126,24 @@ public function testPropertyCreatedDate() $this->markTestIncomplete('Not implemented'); } + /** + * Test attribute "funding_date" + */ + public function testPropertyFundingDate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "opening_date" + */ + public function testPropertyOpeningDate() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test attribute "sync_status" */ From 43576daf0870dcdcf8432eb0c0392d941d5cfad3 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 23:33:30 +0000 Subject: [PATCH 246/252] Version Bump SDKs (#274) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 9619070..e727ba1 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -f3b544d6-6d7a-40ba-b437-20e89ca018a0 \ No newline at end of file +1408db1c-8d39-4637-988f-991035547949 \ No newline at end of file diff --git a/README.md b/README.md index 7d78b35..a56b689 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.156-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.157-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -99,7 +99,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.156" + "konfig/snaptrade-php-sdk": "2.0.157" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 621bd1f..ccb0949 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.156/PHP'; + protected $userAgent = 'Konfig/2.0.157/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.156' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.157' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 4883a1bcb415269d2f4c09ecac90dcdbf6c816be Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 12:49:59 +0000 Subject: [PATCH 247/252] Regenerate SDKs (#275) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 51 +++ lib/Api/ExperimentalEndpointsApi.php | 509 ++++++++++++++++++++++ test/Api/ExperimentalEndpointsApiTest.php | 12 + 4 files changed, 573 insertions(+), 1 deletion(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index e727ba1..afa23fd 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -1408db1c-8d39-4637-988f-991035547949 \ No newline at end of file +b76e98b0-418b-4cc6-b9de-f96d4f6a9f7b \ No newline at end of file diff --git a/README.md b/README.md index a56b689..5c50754 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Connect brokerage accounts to your app for live positions and trading * [`snaptrade.connections.removeBrokerageAuthorization`](#snaptradeconnectionsremovebrokerageauthorization) * [`snaptrade.connections.returnRates`](#snaptradeconnectionsreturnrates) * [`snaptrade.connections.sessionEvents`](#snaptradeconnectionssessionevents) + * [`snaptrade.experimentalEndpoints.getUserAccountOrderDetailV2`](#snaptradeexperimentalendpointsgetuseraccountorderdetailv2) * [`snaptrade.experimentalEndpoints.getUserAccountOrdersV2`](#snaptradeexperimentalendpointsgetuseraccountordersv2) * [`snaptrade.experimentalEndpoints.getUserAccountRecentOrdersV2`](#snaptradeexperimentalendpointsgetuseraccountrecentordersv2) * [`snaptrade.options.getOptionsChain`](#snaptradeoptionsgetoptionschain) @@ -1204,6 +1205,56 @@ Optional comma separated list of session IDs used to filter the request on speci --- +### `snaptrade.experimentalEndpoints.getUserAccountOrderDetailV2` + +Returns the detail of a single order using the external order ID provided in the request body. + +The V2 order response format includes all legs of the order in the `legs` list field. +If the order is single legged, `legs` will be a list of one leg. + +This endpoint is always realtime and does not rely on cached data. + +This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + + + +#### πŸ› οΈ Usage + +```php +$result = $snaptrade->experimentalEndpoints->getUserAccountOrderDetailV2( + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", + account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + user_id: "snaptrade-user-123", + user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" +); +``` + +#### βš™οΈ Parameters + +##### brokerage_order_id: `string` + +Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. + +##### account_id: `string` + +##### user_id: `string` + +##### user_secret: `string` + + +#### πŸ”„ Return + +[**AccountOrderRecordV2**](./lib/Model/AccountOrderRecordV2.php) + +#### 🌐 Endpoint + +`/accounts/{accountId}/orders/details/v2` `POST` + +[πŸ”™ **Back to Table of Contents**](#table-of-contents) + +--- + + ### `snaptrade.experimentalEndpoints.getUserAccountOrdersV2` Returns a list of recent orders in the specified account. diff --git a/lib/Api/ExperimentalEndpointsApi.php b/lib/Api/ExperimentalEndpointsApi.php index 57b2ae6..ce7999f 100644 --- a/lib/Api/ExperimentalEndpointsApi.php +++ b/lib/Api/ExperimentalEndpointsApi.php @@ -62,6 +62,9 @@ class ExperimentalEndpointsApi extends \SnapTrade\CustomApi /** @var string[] $contentTypes **/ public const contentTypes = [ + 'getUserAccountOrderDetailV2' => [ + 'application/json', + ], 'getUserAccountOrdersV2' => [ 'application/json', ], @@ -138,6 +141,512 @@ private function setRequestBodyProperty(&$body, $property, $value) { $body[$property] = $value; } + /** + * Operation getUserAccountOrderDetailV2 + * + * Get account order detail (V2) + * + * Returns the detail of a single order using the external order ID provided in the request body. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * + * @param string $account_id account_id (required) + * @param string $user_id user_id (required) + * @param string $user_secret user_secret (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request account_information_get_user_account_order_detail_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetailV2'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \SnapTrade\Model\AccountOrderRecordV2|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse + */ + public function getUserAccountOrderDetailV2( + + $brokerage_order_id, + $account_id, + $user_id, + $user_secret, + string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); + $account_information_get_user_account_order_detail_request = $_body; + + list($response) = $this->getUserAccountOrderDetailV2WithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType); + return $response; + } + + /** + * Operation getUserAccountOrderDetailV2WithHttpInfo + * + * Get account order detail (V2) + * + * Returns the detail of a single order using the external order ID provided in the request body. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * + * @param string $account_id (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetailV2'] to see the possible values for this operation + * + * @throws \SnapTrade\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \SnapTrade\Model\AccountOrderRecordV2|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getUserAccountOrderDetailV2WithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailV2Request($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + if ( + ($e->getCode() == 401 || $e->getCode() == 403) && + !empty($this->getConfig()->getAccessToken()) && + $requestOptions->shouldRetryOAuth() + ) { + return $this->getUserAccountOrderDetailV2WithHttpInfo( + $account_id, + $user_id, + $user_secret, + $account_information_get_user_account_order_detail_request, + $contentType, + $requestOptions->setRetryOAuth(false) + ); + } + + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SnapTrade\Model\AccountOrderRecordV2' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\AccountOrderRecordV2' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\AccountOrderRecordV2', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\SnapTrade\Model\Model404FailedRequestResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model404FailedRequestResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model404FailedRequestResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SnapTrade\Model\Model500UnexpectedExceptionResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model500UnexpectedExceptionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SnapTrade\Model\AccountOrderRecordV2'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\AccountOrderRecordV2', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model400FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model404FailedRequestResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SnapTrade\Model\Model500UnexpectedExceptionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getUserAccountOrderDetailV2Async + * + * Get account order detail (V2) + * + * Returns the detail of a single order using the external order ID provided in the request body. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * + * @param string $account_id (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetailV2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountOrderDetailV2Async( + + $brokerage_order_id, + $account_id, + $user_id, + $user_secret, + string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0] + ) + { + $_body = []; + $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); + $account_information_get_user_account_order_detail_request = $_body; + + return $this->getUserAccountOrderDetailV2AsyncWithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getUserAccountOrderDetailV2AsyncWithHttpInfo + * + * Get account order detail (V2) + * + * Returns the detail of a single order using the external order ID provided in the request body. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * + * @param string $account_id (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetailV2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserAccountOrderDetailV2AsyncWithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + { + $returnType = '\SnapTrade\Model\AccountOrderRecordV2'; + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailV2Request($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType); + + // Customization hook + $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getUserAccountOrderDetailV2' + * + * @param string $account_id (required) + * @param string $user_id (required) + * @param string $user_secret (required) + * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetailV2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getUserAccountOrderDetailV2Request($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0]) + { + + // Check if $account_id is a string + if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id))); + } + // verify the required parameter 'account_id' is set + if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_id when calling getUserAccountOrderDetailV2' + ); + } + // Check if $user_id is a string + if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); + } + // verify the required parameter 'user_id' is set + if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_id when calling getUserAccountOrderDetailV2' + ); + } + // Check if $user_secret is a string + if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret))); + } + // verify the required parameter 'user_secret' is set + if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter user_secret when calling getUserAccountOrderDetailV2' + ); + } + if ($account_information_get_user_account_order_detail_request !== SENTINEL_VALUE) { + if (!($account_information_get_user_account_order_detail_request instanceof \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest)) { + if (!is_array($account_information_get_user_account_order_detail_request)) + throw new \InvalidArgumentException('"account_information_get_user_account_order_detail_request" must be associative array or an instance of \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest ExperimentalEndpointsApi.getUserAccountOrderDetailV2.'); + else + $account_information_get_user_account_order_detail_request = new \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest($account_information_get_user_account_order_detail_request); + } + } + // verify the required parameter 'account_information_get_user_account_order_detail_request' is set + if ($account_information_get_user_account_order_detail_request === SENTINEL_VALUE || (is_array($account_information_get_user_account_order_detail_request) && count($account_information_get_user_account_order_detail_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter account_information_get_user_account_order_detail_request when calling getUserAccountOrderDetailV2' + ); + } + + + $resourcePath = '/accounts/{accountId}/orders/details/v2'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + if ($user_id !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_id, + 'userId', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + if ($user_secret !== SENTINEL_VALUE) { + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $user_secret, + 'userSecret', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + } + + + // path params + if ($account_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'accountId' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($account_information_get_user_account_order_detail_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($account_information_get_user_account_order_detail_request)); + } else { + $httpBody = $account_information_get_user_account_order_detail_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\json_encode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('clientId'); + if ($apiKey !== null) { + $queryParams['clientId'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Signature'); + if ($apiKey !== null) { + $headers['Signature'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('timestamp'); + if ($apiKey !== null) { + $queryParams['timestamp'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $method = 'POST'; + $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return [ + "request" => new Request( + $method, + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ), + "serializedBody" => $httpBody + ]; + } + /** * Operation getUserAccountOrdersV2 * diff --git a/test/Api/ExperimentalEndpointsApiTest.php b/test/Api/ExperimentalEndpointsApiTest.php index ea385e6..26c1cc0 100644 --- a/test/Api/ExperimentalEndpointsApiTest.php +++ b/test/Api/ExperimentalEndpointsApiTest.php @@ -58,6 +58,18 @@ public static function tearDownAfterClass(): void { } + /** + * Test case for getUserAccountOrderDetailV2 + * + * Get account order detail (V2). + * + */ + public function testGetUserAccountOrderDetailV2() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + /** * Test case for getUserAccountOrdersV2 * From 6056f5c6d498cbcdd4845a5dc56230a10bb090a8 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 12:54:17 +0000 Subject: [PATCH 248/252] Version Bump SDKs (#276) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index afa23fd..a070bb0 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -b76e98b0-418b-4cc6-b9de-f96d4f6a9f7b \ No newline at end of file +05decdc3-71bb-4f5f-9d3a-b42c2ba38b16 \ No newline at end of file diff --git a/README.md b/README.md index 5c50754..39829cc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.157-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.158-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -100,7 +100,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.157" + "konfig/snaptrade-php-sdk": "2.0.158" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index ccb0949..986e128 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.157/PHP'; + protected $userAgent = 'Konfig/2.0.158/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.157' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.158' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From 8a12983d0077d9a7b3ed3da33689a0cd6633b23f Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Wed, 4 Feb 2026 23:56:25 +0000 Subject: [PATCH 249/252] Regenerate SDKs (#277) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Api/AccountInformationApi.php | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index a070bb0..c2ff2c5 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -05decdc3-71bb-4f5f-9d3a-b42c2ba38b16 \ No newline at end of file +e7efadd1-1429-4205-8ae1-017064044500 \ No newline at end of file diff --git a/README.md b/README.md index 39829cc..e01158f 100644 --- a/README.md +++ b/README.md @@ -495,9 +495,9 @@ $result = $snaptrade->accountInformation->getUserAccountPositions( ### `snaptrade.accountInformation.getUserAccountRecentOrders` -A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. +A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account. For most brokerages, the default page size is 100 meaning the endpoint will return a max of 100 orders. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders -Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days +Differs from /orders in that it is always realtime, and only checks the last 24 hours By default only returns executed orders, but that can be changed by setting *only_executed* to false diff --git a/lib/Api/AccountInformationApi.php b/lib/Api/AccountInformationApi.php index cdef8be..1c48660 100644 --- a/lib/Api/AccountInformationApi.php +++ b/lib/Api/AccountInformationApi.php @@ -3335,7 +3335,7 @@ public function getUserAccountPositionsRequest($user_id, $user_secret, $account_ * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false + * A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account. For most brokerages, the default page size is 100 meaning the endpoint will return a max of 100 orders. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is always realtime, and only checks the last 24 hours By default only returns executed orders, but that can be changed by setting *only_executed* to false * * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) @@ -3366,7 +3366,7 @@ public function getUserAccountRecentOrders( * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false + * A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account. For most brokerages, the default page size is 100 meaning the endpoint will return a max of 100 orders. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is always realtime, and only checks the last 24 hours By default only returns executed orders, but that can be changed by setting *only_executed* to false * * @param string $user_id (required) * @param string $user_secret (required) @@ -3535,7 +3535,7 @@ public function getUserAccountRecentOrdersWithHttpInfo($user_id, $user_secret, $ * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false + * A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account. For most brokerages, the default page size is 100 meaning the endpoint will return a max of 100 orders. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is always realtime, and only checks the last 24 hours By default only returns executed orders, but that can be changed by setting *only_executed* to false * * @param string $user_id (required) * @param string $user_secret (required) @@ -3569,7 +3569,7 @@ function ($response) { * * List account recent orders (last 24 hours only) * - * A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days By default only returns executed orders, but that can be changed by setting *only_executed* to false + * A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account. For most brokerages, the default page size is 100 meaning the endpoint will return a max of 100 orders. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is always realtime, and only checks the last 24 hours By default only returns executed orders, but that can be changed by setting *only_executed* to false * * @param string $user_id (required) * @param string $user_secret (required) From 1974d501a0f00349ed95045e8388a2c393197b32 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 00:00:40 +0000 Subject: [PATCH 250/252] Version Bump SDKs (#278) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index c2ff2c5..c58f058 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -e7efadd1-1429-4205-8ae1-017064044500 \ No newline at end of file +3ebd072e-0fdc-46de-abf5-367eefa59297 \ No newline at end of file diff --git a/README.md b/README.md index e01158f..92a4730 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.158-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.159-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -100,7 +100,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.158" + "konfig/snaptrade-php-sdk": "2.0.159" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 986e128..6d246c1 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.158/PHP'; + protected $userAgent = 'Konfig/2.0.159/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.158' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.159' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; From bc440b670e0c05031800d904bc620a1e953a2630 Mon Sep 17 00:00:00 2001 From: "snaptrade-sdks[bot]" <193628122+snaptrade-sdks[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 22:05:33 +0000 Subject: [PATCH 251/252] Regenerate SDKs (#279) Co-authored-by: Passiv Ops --- .konfig/generate-id.txt | 2 +- README.md | 12 ++- lib/Api/ExperimentalEndpointsApi.php | 124 ++++++++++----------------- 3 files changed, 52 insertions(+), 86 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index c58f058..7f907cf 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -3ebd072e-0fdc-46de-abf5-367eefa59297 \ No newline at end of file +c103f026-5883-4300-979d-1aaab9768647 \ No newline at end of file diff --git a/README.md b/README.md index 92a4730..633fbae 100644 --- a/README.md +++ b/README.md @@ -1207,7 +1207,7 @@ Optional comma separated list of session IDs used to filter the request on speci ### `snaptrade.experimentalEndpoints.getUserAccountOrderDetailV2` -Returns the detail of a single order using the external order ID provided in the request body. +Returns the detail of a single order using the brokerage order ID provided as a path parameter. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. @@ -1222,8 +1222,8 @@ This endpoint only returns orders placed through SnapTrade. In other words, orde ```php $result = $snaptrade->experimentalEndpoints->getUserAccountOrderDetailV2( - brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", + brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" ); @@ -1231,12 +1231,10 @@ $result = $snaptrade->experimentalEndpoints->getUserAccountOrderDetailV2( #### βš™οΈ Parameters -##### brokerage_order_id: `string` - -Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system. - ##### account_id: `string` +##### brokerage_order_id: `string` + ##### user_id: `string` ##### user_secret: `string` @@ -1248,7 +1246,7 @@ Order ID returned by brokerage. This is the unique identifier for the order in t #### 🌐 Endpoint -`/accounts/{accountId}/orders/details/v2` `POST` +`/accounts/{accountId}/orders/details/v2/{brokerageOrderId}` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) diff --git a/lib/Api/ExperimentalEndpointsApi.php b/lib/Api/ExperimentalEndpointsApi.php index ce7999f..07f70b8 100644 --- a/lib/Api/ExperimentalEndpointsApi.php +++ b/lib/Api/ExperimentalEndpointsApi.php @@ -146,32 +146,29 @@ private function setRequestBodyProperty(&$body, $property, $value) { * * Get account order detail (V2) * - * Returns the detail of a single order using the external order ID provided in the request body. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the brokerage order ID provided as a path parameter. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $account_id account_id (required) + * @param string $brokerage_order_id brokerage_order_id (required) * @param string $user_id user_id (required) * @param string $user_secret user_secret (required) - * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetailV2'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return \SnapTrade\Model\AccountOrderRecordV2|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse + * @return \SnapTrade\Model\AccountOrderRecordV2|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse */ public function getUserAccountOrderDetailV2( - - $brokerage_order_id, $account_id, + $brokerage_order_id, $user_id, $user_secret, + string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); - $account_information_get_user_account_order_detail_request = $_body; - list($response) = $this->getUserAccountOrderDetailV2WithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType); + list($response) = $this->getUserAccountOrderDetailV2WithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $contentType); return $response; } @@ -180,24 +177,24 @@ public function getUserAccountOrderDetailV2( * * Get account order detail (V2) * - * Returns the detail of a single order using the external order ID provided in the request body. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the brokerage order ID provided as a path parameter. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $account_id (required) + * @param string $brokerage_order_id (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetailV2'] to see the possible values for this operation * * @throws \SnapTrade\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of \SnapTrade\Model\AccountOrderRecordV2|\SnapTrade\Model\Model400FailedRequestResponse|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \SnapTrade\Model\AccountOrderRecordV2|\SnapTrade\Model\Model404FailedRequestResponse|\SnapTrade\Model\Model500UnexpectedExceptionResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getUserAccountOrderDetailV2WithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getUserAccountOrderDetailV2WithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailV2Request($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailV2Request($account_id, $brokerage_order_id, $user_id, $user_secret, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); try { $options = $this->createHttpClientOption(); @@ -211,9 +208,9 @@ public function getUserAccountOrderDetailV2WithHttpInfo($account_id, $user_id, $ ) { return $this->getUserAccountOrderDetailV2WithHttpInfo( $account_id, + $brokerage_order_id, $user_id, $user_secret, - $account_information_get_user_account_order_detail_request, $contentType, $requestOptions->setRetryOAuth(false) ); @@ -265,21 +262,6 @@ public function getUserAccountOrderDetailV2WithHttpInfo($account_id, $user_id, $ $response->getStatusCode(), $response->getHeaders() ]; - case 400: - if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; case 404: if ('\SnapTrade\Model\Model404FailedRequestResponse' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -338,14 +320,6 @@ public function getUserAccountOrderDetailV2WithHttpInfo($account_id, $user_id, $ ); $e->setResponseObject($data); break; - case 400: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\SnapTrade\Model\Model400FailedRequestResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; case 404: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -372,31 +346,28 @@ public function getUserAccountOrderDetailV2WithHttpInfo($account_id, $user_id, $ * * Get account order detail (V2) * - * Returns the detail of a single order using the external order ID provided in the request body. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the brokerage order ID provided as a path parameter. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $account_id (required) + * @param string $brokerage_order_id (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetailV2'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getUserAccountOrderDetailV2Async( - - $brokerage_order_id, $account_id, + $brokerage_order_id, $user_id, $user_secret, + string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0] ) { - $_body = []; - $this->setRequestBodyProperty($_body, "brokerage_order_id", $brokerage_order_id); - $account_information_get_user_account_order_detail_request = $_body; - return $this->getUserAccountOrderDetailV2AsyncWithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType) + return $this->getUserAccountOrderDetailV2AsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, $contentType) ->then( function ($response) { return $response[0]; @@ -409,24 +380,24 @@ function ($response) { * * Get account order detail (V2) * - * Returns the detail of a single order using the external order ID provided in the request body. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. + * Returns the detail of a single order using the brokerage order ID provided as a path parameter. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. * * @param string $account_id (required) + * @param string $brokerage_order_id (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetailV2'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getUserAccountOrderDetailV2AsyncWithHttpInfo($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) + public function getUserAccountOrderDetailV2AsyncWithHttpInfo($account_id, $brokerage_order_id, $user_id, $user_secret, string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions()) { $returnType = '\SnapTrade\Model\AccountOrderRecordV2'; - ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailV2Request($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, $contentType); + ["request" => $request, "serializedBody" => $serializedBody] = $this->getUserAccountOrderDetailV2Request($account_id, $brokerage_order_id, $user_id, $user_secret, $contentType); // Customization hook - $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody); + $this->beforeSendHook($request, $requestOptions, $this->config); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -468,15 +439,15 @@ function ($exception) { * Create request for operation 'getUserAccountOrderDetailV2' * * @param string $account_id (required) + * @param string $brokerage_order_id (required) * @param string $user_id (required) * @param string $user_secret (required) - * @param \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest $account_information_get_user_account_order_detail_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserAccountOrderDetailV2'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getUserAccountOrderDetailV2Request($account_id, $user_id, $user_secret, $account_information_get_user_account_order_detail_request, string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0]) + public function getUserAccountOrderDetailV2Request($account_id, $brokerage_order_id, $user_id, $user_secret, string $contentType = self::contentTypes['getUserAccountOrderDetailV2'][0]) { // Check if $account_id is a string @@ -489,6 +460,16 @@ public function getUserAccountOrderDetailV2Request($account_id, $user_id, $user_ 'Missing the required parameter account_id when calling getUserAccountOrderDetailV2' ); } + // Check if $brokerage_order_id is a string + if ($brokerage_order_id !== SENTINEL_VALUE && !is_string($brokerage_order_id)) { + throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($brokerage_order_id, true), gettype($brokerage_order_id))); + } + // verify the required parameter 'brokerage_order_id' is set + if ($brokerage_order_id === SENTINEL_VALUE || (is_array($brokerage_order_id) && count($brokerage_order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter brokerage_order_id when calling getUserAccountOrderDetailV2' + ); + } // Check if $user_id is a string if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) { throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id))); @@ -509,23 +490,9 @@ public function getUserAccountOrderDetailV2Request($account_id, $user_id, $user_ 'Missing the required parameter user_secret when calling getUserAccountOrderDetailV2' ); } - if ($account_information_get_user_account_order_detail_request !== SENTINEL_VALUE) { - if (!($account_information_get_user_account_order_detail_request instanceof \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest)) { - if (!is_array($account_information_get_user_account_order_detail_request)) - throw new \InvalidArgumentException('"account_information_get_user_account_order_detail_request" must be associative array or an instance of \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest ExperimentalEndpointsApi.getUserAccountOrderDetailV2.'); - else - $account_information_get_user_account_order_detail_request = new \SnapTrade\Model\AccountInformationGetUserAccountOrderDetailRequest($account_information_get_user_account_order_detail_request); - } - } - // verify the required parameter 'account_information_get_user_account_order_detail_request' is set - if ($account_information_get_user_account_order_detail_request === SENTINEL_VALUE || (is_array($account_information_get_user_account_order_detail_request) && count($account_information_get_user_account_order_detail_request) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter account_information_get_user_account_order_detail_request when calling getUserAccountOrderDetailV2' - ); - } - $resourcePath = '/accounts/{accountId}/orders/details/v2'; + $resourcePath = '/accounts/{accountId}/orders/details/v2/{brokerageOrderId}'; $formParams = []; $queryParams = []; $headerParams = []; @@ -564,6 +531,14 @@ public function getUserAccountOrderDetailV2Request($account_id, $user_id, $user_ $resourcePath ); } + // path params + if ($brokerage_order_id !== SENTINEL_VALUE) { + $resourcePath = str_replace( + '{' . 'brokerageOrderId' . '}', + ObjectSerializer::toPathValue($brokerage_order_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -573,14 +548,7 @@ public function getUserAccountOrderDetailV2Request($account_id, $user_id, $user_ ); // for model (json/xml) - if (isset($account_information_get_user_account_order_detail_request)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($account_information_get_user_account_order_detail_request)); - } else { - $httpBody = $account_information_get_user_account_order_detail_request; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -631,7 +599,7 @@ public function getUserAccountOrderDetailV2Request($account_id, $user_id, $user_ $headers ); - $method = 'POST'; + $method = 'GET'; $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody); $operationHost = $this->config->getHost(); From 9d8233429fcb638314b5e519dead31f6a6d15fda Mon Sep 17 00:00:00 2001 From: Passiv Ops Date: Fri, 6 Feb 2026 22:08:55 +0000 Subject: [PATCH 252/252] Version Bump SDKs --- .konfig/generate-id.txt | 2 +- README.md | 4 ++-- lib/Configuration.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt index 7f907cf..00ec457 100644 --- a/.konfig/generate-id.txt +++ b/.konfig/generate-id.txt @@ -1 +1 @@ -c103f026-5883-4300-979d-1aaab9768647 \ No newline at end of file +c543538a-5735-46ae-91fa-72ebb0c872ef \ No newline at end of file diff --git a/README.md b/README.md index 633fbae..3bd75db 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Connect brokerage accounts to your app for live positions and trading -[![Packagist](https://img.shields.io/badge/Packagist-v2.0.159-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) +[![Packagist](https://img.shields.io/badge/Packagist-v2.0.160-blue)](https://packagist.org/packages/konfig/snaptrade-php-sdk) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/) @@ -100,7 +100,7 @@ To install the bindings via [Composer](https://getcomposer.org/), add the follow } ], "require": { - "konfig/snaptrade-php-sdk": "2.0.159" + "konfig/snaptrade-php-sdk": "2.0.160" } } ``` diff --git a/lib/Configuration.php b/lib/Configuration.php index 6d246c1..a6934b4 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -97,7 +97,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Konfig/2.0.159/PHP'; + protected $userAgent = 'Konfig/2.0.160/PHP'; /** * Debug switch (default set to false) @@ -487,7 +487,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 2.0.159' . PHP_EOL; + $report .= ' SDK Package Version: 2.0.160' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report;