diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt
index 8da717e..dd7b510 100644
--- a/.konfig/generate-id.txt
+++ b/.konfig/generate-id.txt
@@ -1 +1 @@
-74fcea5c-8629-433c-aadb-0be37b3ff930
\ No newline at end of file
+f827227f-1f55-4911-b92d-df62055a4b8d
\ No newline at end of file
diff --git a/README.md b/README.md
index 067c621..7bcf1c3 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.
@@ -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`

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..0edd92b 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',
- ],
];
/**
@@ -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');
- }
}