tinkoff_invest_client 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +169 -0
  4. data/Rakefile +10 -0
  5. data/docs/BrokerAccountType.md +15 -0
  6. data/docs/Candle.md +32 -0
  7. data/docs/CandleResolution.md +15 -0
  8. data/docs/Candles.md +22 -0
  9. data/docs/CandlesResponse.md +22 -0
  10. data/docs/Currencies.md +18 -0
  11. data/docs/Currency.md +15 -0
  12. data/docs/CurrencyPosition.md +22 -0
  13. data/docs/Empty.md +22 -0
  14. data/docs/Error.md +22 -0
  15. data/docs/ErrorPayload.md +20 -0
  16. data/docs/InstrumentType.md +15 -0
  17. data/docs/LimitOrderRequest.md +22 -0
  18. data/docs/LimitOrderResponse.md +22 -0
  19. data/docs/MarketApi.md +547 -0
  20. data/docs/MarketInstrument.md +34 -0
  21. data/docs/MarketInstrumentList.md +20 -0
  22. data/docs/MarketInstrumentListResponse.md +22 -0
  23. data/docs/MarketInstrumentResponse.md +22 -0
  24. data/docs/MarketOrderRequest.md +20 -0
  25. data/docs/MarketOrderResponse.md +22 -0
  26. data/docs/MoneyAmount.md +20 -0
  27. data/docs/Operation.md +44 -0
  28. data/docs/OperationStatus.md +15 -0
  29. data/docs/OperationTrade.md +24 -0
  30. data/docs/OperationType.md +15 -0
  31. data/docs/OperationTypeWithCommission.md +15 -0
  32. data/docs/Operations.md +18 -0
  33. data/docs/OperationsApi.md +83 -0
  34. data/docs/OperationsResponse.md +22 -0
  35. data/docs/Order.md +32 -0
  36. data/docs/OrderResponse.md +20 -0
  37. data/docs/OrderStatus.md +15 -0
  38. data/docs/OrderType.md +15 -0
  39. data/docs/Orderbook.md +38 -0
  40. data/docs/OrderbookResponse.md +22 -0
  41. data/docs/OrdersApi.md +297 -0
  42. data/docs/OrdersResponse.md +22 -0
  43. data/docs/PlacedLimitOrder.md +32 -0
  44. data/docs/PlacedMarketOrder.md +32 -0
  45. data/docs/Portfolio.md +18 -0
  46. data/docs/PortfolioApi.md +147 -0
  47. data/docs/PortfolioCurrenciesResponse.md +22 -0
  48. data/docs/PortfolioPosition.md +38 -0
  49. data/docs/PortfolioResponse.md +22 -0
  50. data/docs/SandboxAccount.md +20 -0
  51. data/docs/SandboxApi.md +367 -0
  52. data/docs/SandboxCurrency.md +15 -0
  53. data/docs/SandboxRegisterRequest.md +18 -0
  54. data/docs/SandboxRegisterResponse.md +22 -0
  55. data/docs/SandboxSetCurrencyBalanceRequest.md +20 -0
  56. data/docs/SandboxSetPositionBalanceRequest.md +20 -0
  57. data/docs/SearchMarketInstrument.md +32 -0
  58. data/docs/SearchMarketInstrumentResponse.md +22 -0
  59. data/docs/TradeStatus.md +15 -0
  60. data/docs/UserAccount.md +20 -0
  61. data/docs/UserAccounts.md +18 -0
  62. data/docs/UserAccountsResponse.md +22 -0
  63. data/docs/UserApi.md +72 -0
  64. data/generator_options.md +1 -0
  65. data/git_push.sh +58 -0
  66. data/lib/tinkoff_invest_client.rb +98 -0
  67. data/lib/tinkoff_invest_client/api/market_api.rb +518 -0
  68. data/lib/tinkoff_invest_client/api/operations_api.rb +97 -0
  69. data/lib/tinkoff_invest_client/api/orders_api.rb +291 -0
  70. data/lib/tinkoff_invest_client/api/portfolio_api.rb +138 -0
  71. data/lib/tinkoff_invest_client/api/sandbox_api.rb +335 -0
  72. data/lib/tinkoff_invest_client/api/user_api.rb +77 -0
  73. data/lib/tinkoff_invest_client/api_client.rb +390 -0
  74. data/lib/tinkoff_invest_client/api_error.rb +57 -0
  75. data/lib/tinkoff_invest_client/configuration.rb +281 -0
  76. data/lib/tinkoff_invest_client/models/broker_account_type.rb +37 -0
  77. data/lib/tinkoff_invest_client/models/candle.rb +322 -0
  78. data/lib/tinkoff_invest_client/models/candle_resolution.rb +46 -0
  79. data/lib/tinkoff_invest_client/models/candles.rb +253 -0
  80. data/lib/tinkoff_invest_client/models/candles_response.rb +253 -0
  81. data/lib/tinkoff_invest_client/models/currencies.rb +225 -0
  82. data/lib/tinkoff_invest_client/models/currency.rb +44 -0
  83. data/lib/tinkoff_invest_client/models/currency_position.rb +246 -0
  84. data/lib/tinkoff_invest_client/models/empty.rb +253 -0
  85. data/lib/tinkoff_invest_client/models/error.rb +253 -0
  86. data/lib/tinkoff_invest_client/models/error_payload.rb +227 -0
  87. data/lib/tinkoff_invest_client/models/instrument_type.rb +39 -0
  88. data/lib/tinkoff_invest_client/models/limit_order_request.rb +251 -0
  89. data/lib/tinkoff_invest_client/models/limit_order_response.rb +253 -0
  90. data/lib/tinkoff_invest_client/models/market_instrument.rb +317 -0
  91. data/lib/tinkoff_invest_client/models/market_instrument_list.rb +239 -0
  92. data/lib/tinkoff_invest_client/models/market_instrument_list_response.rb +253 -0
  93. data/lib/tinkoff_invest_client/models/market_instrument_response.rb +253 -0
  94. data/lib/tinkoff_invest_client/models/market_order_request.rb +237 -0
  95. data/lib/tinkoff_invest_client/models/market_order_response.rb +253 -0
  96. data/lib/tinkoff_invest_client/models/money_amount.rb +237 -0
  97. data/lib/tinkoff_invest_client/models/operation.rb +370 -0
  98. data/lib/tinkoff_invest_client/models/operation_status.rb +38 -0
  99. data/lib/tinkoff_invest_client/models/operation_trade.rb +266 -0
  100. data/lib/tinkoff_invest_client/models/operation_type.rb +37 -0
  101. data/lib/tinkoff_invest_client/models/operation_type_with_commission.rb +56 -0
  102. data/lib/tinkoff_invest_client/models/operations.rb +225 -0
  103. data/lib/tinkoff_invest_client/models/operations_response.rb +253 -0
  104. data/lib/tinkoff_invest_client/models/order.rb +321 -0
  105. data/lib/tinkoff_invest_client/models/order_response.rb +237 -0
  106. data/lib/tinkoff_invest_client/models/order_status.rb +44 -0
  107. data/lib/tinkoff_invest_client/models/order_type.rb +37 -0
  108. data/lib/tinkoff_invest_client/models/orderbook.rb +346 -0
  109. data/lib/tinkoff_invest_client/models/orderbook_response.rb +253 -0
  110. data/lib/tinkoff_invest_client/models/orders_response.rb +255 -0
  111. data/lib/tinkoff_invest_client/models/placed_limit_order.rb +307 -0
  112. data/lib/tinkoff_invest_client/models/placed_market_order.rb +307 -0
  113. data/lib/tinkoff_invest_client/models/portfolio.rb +225 -0
  114. data/lib/tinkoff_invest_client/models/portfolio_currencies_response.rb +253 -0
  115. data/lib/tinkoff_invest_client/models/portfolio_position.rb +333 -0
  116. data/lib/tinkoff_invest_client/models/portfolio_response.rb +253 -0
  117. data/lib/tinkoff_invest_client/models/sandbox_account.rb +237 -0
  118. data/lib/tinkoff_invest_client/models/sandbox_currency.rb +44 -0
  119. data/lib/tinkoff_invest_client/models/sandbox_register_request.rb +218 -0
  120. data/lib/tinkoff_invest_client/models/sandbox_register_response.rb +253 -0
  121. data/lib/tinkoff_invest_client/models/sandbox_set_currency_balance_request.rb +237 -0
  122. data/lib/tinkoff_invest_client/models/sandbox_set_position_balance_request.rb +232 -0
  123. data/lib/tinkoff_invest_client/models/search_market_instrument.rb +307 -0
  124. data/lib/tinkoff_invest_client/models/search_market_instrument_response.rb +253 -0
  125. data/lib/tinkoff_invest_client/models/trade_status.rb +37 -0
  126. data/lib/tinkoff_invest_client/models/user_account.rb +237 -0
  127. data/lib/tinkoff_invest_client/models/user_accounts.rb +225 -0
  128. data/lib/tinkoff_invest_client/models/user_accounts_response.rb +253 -0
  129. data/lib/tinkoff_invest_client/version.rb +15 -0
  130. data/spec/api/market_api_spec.rb +123 -0
  131. data/spec/api/operations_api_spec.rb +49 -0
  132. data/spec/api/orders_api_spec.rb +84 -0
  133. data/spec/api/portfolio_api_spec.rb +57 -0
  134. data/spec/api/sandbox_api_spec.rb +95 -0
  135. data/spec/api/user_api_spec.rb +45 -0
  136. data/spec/api_client_spec.rb +226 -0
  137. data/spec/configuration_spec.rb +42 -0
  138. data/spec/models/broker_account_type_spec.rb +28 -0
  139. data/spec/models/candle_resolution_spec.rb +28 -0
  140. data/spec/models/candle_spec.rb +76 -0
  141. data/spec/models/candles_response_spec.rb +46 -0
  142. data/spec/models/candles_spec.rb +46 -0
  143. data/spec/models/currencies_spec.rb +34 -0
  144. data/spec/models/currency_position_spec.rb +46 -0
  145. data/spec/models/currency_spec.rb +28 -0
  146. data/spec/models/empty_spec.rb +46 -0
  147. data/spec/models/error_payload_spec.rb +40 -0
  148. data/spec/models/error_spec.rb +46 -0
  149. data/spec/models/instrument_type_spec.rb +28 -0
  150. data/spec/models/limit_order_request_spec.rb +46 -0
  151. data/spec/models/limit_order_response_spec.rb +46 -0
  152. data/spec/models/market_instrument_list_response_spec.rb +46 -0
  153. data/spec/models/market_instrument_list_spec.rb +40 -0
  154. data/spec/models/market_instrument_response_spec.rb +46 -0
  155. data/spec/models/market_instrument_spec.rb +82 -0
  156. data/spec/models/market_order_request_spec.rb +40 -0
  157. data/spec/models/market_order_response_spec.rb +46 -0
  158. data/spec/models/money_amount_spec.rb +40 -0
  159. data/spec/models/operation_spec.rb +112 -0
  160. data/spec/models/operation_status_spec.rb +28 -0
  161. data/spec/models/operation_trade_spec.rb +52 -0
  162. data/spec/models/operation_type_spec.rb +28 -0
  163. data/spec/models/operation_type_with_commission_spec.rb +28 -0
  164. data/spec/models/operations_response_spec.rb +46 -0
  165. data/spec/models/operations_spec.rb +34 -0
  166. data/spec/models/order_response_spec.rb +40 -0
  167. data/spec/models/order_spec.rb +76 -0
  168. data/spec/models/order_status_spec.rb +28 -0
  169. data/spec/models/order_type_spec.rb +28 -0
  170. data/spec/models/orderbook_response_spec.rb +46 -0
  171. data/spec/models/orderbook_spec.rb +94 -0
  172. data/spec/models/orders_response_spec.rb +46 -0
  173. data/spec/models/placed_limit_order_spec.rb +76 -0
  174. data/spec/models/placed_market_order_spec.rb +76 -0
  175. data/spec/models/portfolio_currencies_response_spec.rb +46 -0
  176. data/spec/models/portfolio_position_spec.rb +94 -0
  177. data/spec/models/portfolio_response_spec.rb +46 -0
  178. data/spec/models/portfolio_spec.rb +34 -0
  179. data/spec/models/sandbox_account_spec.rb +40 -0
  180. data/spec/models/sandbox_currency_spec.rb +28 -0
  181. data/spec/models/sandbox_register_request_spec.rb +34 -0
  182. data/spec/models/sandbox_register_response_spec.rb +46 -0
  183. data/spec/models/sandbox_set_currency_balance_request_spec.rb +40 -0
  184. data/spec/models/sandbox_set_position_balance_request_spec.rb +40 -0
  185. data/spec/models/search_market_instrument_response_spec.rb +46 -0
  186. data/spec/models/search_market_instrument_spec.rb +76 -0
  187. data/spec/models/trade_status_spec.rb +28 -0
  188. data/spec/models/user_account_spec.rb +40 -0
  189. data/spec/models/user_accounts_response_spec.rb +46 -0
  190. data/spec/models/user_accounts_spec.rb +34 -0
  191. data/spec/spec_helper.rb +111 -0
  192. data/tinkoff_invest_client.gemspec +38 -0
  193. metadata +336 -0
@@ -0,0 +1,57 @@
1
+ =begin
2
+ #OpenAPI
3
+
4
+ #tinkoff.ru/invest OpenAPI.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: al.a.volkov@tinkoff.ru
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ module TinkoffInvestClient
14
+ class ApiError < StandardError
15
+ attr_reader :code, :response_headers, :response_body
16
+
17
+ # Usage examples:
18
+ # ApiError.new
19
+ # ApiError.new("message")
20
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
21
+ # ApiError.new(:code => 404, :message => "Not Found")
22
+ def initialize(arg = nil)
23
+ if arg.is_a? Hash
24
+ if arg.key?(:message) || arg.key?('message')
25
+ super(arg[:message] || arg['message'])
26
+ else
27
+ super arg
28
+ end
29
+
30
+ arg.each do |k, v|
31
+ instance_variable_set "@#{k}", v
32
+ end
33
+ else
34
+ super arg
35
+ end
36
+ end
37
+
38
+ # Override to_s to display a friendly error message
39
+ def to_s
40
+ message
41
+ end
42
+
43
+ def message
44
+ if @message.nil?
45
+ msg = "Error message: the server returns an error"
46
+ else
47
+ msg = @message
48
+ end
49
+
50
+ msg += "\nHTTP status code: #{code}" if code
51
+ msg += "\nResponse headers: #{response_headers}" if response_headers
52
+ msg += "\nResponse body: #{response_body}" if response_body
53
+
54
+ msg
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,281 @@
1
+ =begin
2
+ #OpenAPI
3
+
4
+ #tinkoff.ru/invest OpenAPI.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: al.a.volkov@tinkoff.ru
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ module TinkoffInvestClient
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the access token (Bearer) used with OAuth2.
63
+ attr_accessor :access_token
64
+
65
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
66
+ # details will be logged with `logger.debug` (see the `logger` attribute).
67
+ # Default to false.
68
+ #
69
+ # @return [true, false]
70
+ attr_accessor :debugging
71
+
72
+ # Defines the logger used for debugging.
73
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
74
+ #
75
+ # @return [#debug]
76
+ attr_accessor :logger
77
+
78
+ # Defines the temporary folder to store downloaded files
79
+ # (for API endpoints that have file response).
80
+ # Default to use `Tempfile`.
81
+ #
82
+ # @return [String]
83
+ attr_accessor :temp_folder_path
84
+
85
+ # The time limit for HTTP request in seconds.
86
+ # Default to 0 (never times out).
87
+ attr_accessor :timeout
88
+
89
+ # Set this to false to skip client side validation in the operation.
90
+ # Default to true.
91
+ # @return [true, false]
92
+ attr_accessor :client_side_validation
93
+
94
+ ### TLS/SSL setting
95
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
96
+ # Default to true.
97
+ #
98
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
99
+ #
100
+ # @return [true, false]
101
+ attr_accessor :verify_ssl
102
+
103
+ ### TLS/SSL setting
104
+ # Set this to false to skip verifying SSL host name
105
+ # Default to true.
106
+ #
107
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
108
+ #
109
+ # @return [true, false]
110
+ attr_accessor :verify_ssl_host
111
+
112
+ ### TLS/SSL setting
113
+ # Set this to customize the certificate file to verify the peer.
114
+ #
115
+ # @return [String] the path to the certificate file
116
+ #
117
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
118
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
119
+ attr_accessor :ssl_ca_cert
120
+
121
+ ### TLS/SSL setting
122
+ # Client certificate file (for client certificate)
123
+ attr_accessor :cert_file
124
+
125
+ ### TLS/SSL setting
126
+ # Client private key file (for client certificate)
127
+ attr_accessor :key_file
128
+
129
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
130
+ # Default to nil.
131
+ #
132
+ # @see The params_encoding option of Ethon. Related source code:
133
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
134
+ attr_accessor :params_encoding
135
+
136
+ attr_accessor :inject_format
137
+
138
+ attr_accessor :force_ending_format
139
+
140
+ def initialize
141
+ @scheme = 'https'
142
+ @host = 'api-invest.tinkoff.ru'
143
+ @base_path = '/openapi'
144
+ @server_index = 0
145
+ @server_operation_index = {}
146
+ @server_variables = {}
147
+ @server_operation_variables = {}
148
+ @api_key = {}
149
+ @api_key_prefix = {}
150
+ @timeout = 0
151
+ @client_side_validation = true
152
+ @verify_ssl = true
153
+ @verify_ssl_host = true
154
+ @params_encoding = nil
155
+ @cert_file = nil
156
+ @key_file = nil
157
+ @debugging = false
158
+ @inject_format = false
159
+ @force_ending_format = false
160
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
161
+
162
+ yield(self) if block_given?
163
+ end
164
+
165
+ # The default Configuration object.
166
+ def self.default
167
+ @@default ||= Configuration.new
168
+ end
169
+
170
+ def configure
171
+ yield(self) if block_given?
172
+ end
173
+
174
+ def scheme=(scheme)
175
+ # remove :// from scheme
176
+ @scheme = scheme.sub(/:\/\//, '')
177
+ end
178
+
179
+ def host=(host)
180
+ # remove http(s):// and anything after a slash
181
+ @host = host.sub(/https?:\/\//, '').split('/').first
182
+ end
183
+
184
+ def base_path=(base_path)
185
+ # Add leading and trailing slashes to base_path
186
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
187
+ @base_path = '' if @base_path == '/'
188
+ end
189
+
190
+ # Returns base URL for specified operation based on server settings
191
+ def base_url(operation = nil)
192
+ index = server_operation_index.fetch(operation, server_index)
193
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
194
+
195
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
196
+ end
197
+
198
+ # Gets API key (with prefix if set).
199
+ # @param [String] param_name the parameter name of API key auth
200
+ def api_key_with_prefix(param_name, param_alias = nil)
201
+ key = @api_key[param_name]
202
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
203
+ if @api_key_prefix[param_name]
204
+ "#{@api_key_prefix[param_name]} #{key}"
205
+ else
206
+ key
207
+ end
208
+ end
209
+
210
+ # Gets Basic Auth token string
211
+ def basic_auth_token
212
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
213
+ end
214
+
215
+ # Returns Auth Settings hash for api client.
216
+ def auth_settings
217
+ {
218
+ 'sso_auth' =>
219
+ {
220
+ type: 'bearer',
221
+ in: 'header',
222
+ key: 'Authorization',
223
+ value: "Bearer #{access_token}"
224
+ },
225
+ }
226
+ end
227
+
228
+ # Returns an array of Server setting
229
+ def server_settings
230
+ [
231
+ {
232
+ url: "https://api-invest.tinkoff.ru/openapi",
233
+ description: "Работа с биржей",
234
+ },
235
+ {
236
+ url: "https://api-invest.tinkoff.ru/openapi/sandbox",
237
+ description: "Работа в sandbox",
238
+ }
239
+ ]
240
+ end
241
+
242
+ def operation_server_settings
243
+ {
244
+ }
245
+ end
246
+
247
+ # Returns URL based on server settings
248
+ #
249
+ # @param index array index of the server settings
250
+ # @param variables hash of variable and the corresponding value
251
+ def server_url(index, variables = {}, servers = nil)
252
+ servers = server_settings if servers == nil
253
+
254
+ # check array index out of bound
255
+ if (index < 0 || index >= servers.size)
256
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
257
+ end
258
+
259
+ server = servers[index]
260
+ url = server[:url]
261
+
262
+ return url unless server.key? :variables
263
+
264
+ # go through variable and assign a value
265
+ server[:variables].each do |name, variable|
266
+ if variables.key?(name)
267
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
268
+ url.gsub! "{" + name.to_s + "}", variables[name]
269
+ else
270
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
271
+ end
272
+ else
273
+ # use default value
274
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
275
+ end
276
+ end
277
+
278
+ url
279
+ end
280
+ end
281
+ end
@@ -0,0 +1,37 @@
1
+ =begin
2
+ #OpenAPI
3
+
4
+ #tinkoff.ru/invest OpenAPI.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: al.a.volkov@tinkoff.ru
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TinkoffInvestClient
17
+ class BrokerAccountType
18
+ TINKOFF = "Tinkoff".freeze
19
+ TINKOFF_IIS = "TinkoffIis".freeze
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ constantValues = BrokerAccountType.constants.select { |c| BrokerAccountType::const_get(c) == value }
33
+ raise "Invalid ENUM value #{value} for class #BrokerAccountType" if constantValues.empty?
34
+ value
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,322 @@
1
+ =begin
2
+ #OpenAPI
3
+
4
+ #tinkoff.ru/invest OpenAPI.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: al.a.volkov@tinkoff.ru
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TinkoffInvestClient
17
+ class Candle
18
+ attr_accessor :figi
19
+
20
+ attr_accessor :interval
21
+
22
+ attr_accessor :o
23
+
24
+ attr_accessor :c
25
+
26
+ attr_accessor :h
27
+
28
+ attr_accessor :l
29
+
30
+ attr_accessor :v
31
+
32
+ # ISO8601
33
+ attr_accessor :time
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'figi' => :'figi',
39
+ :'interval' => :'interval',
40
+ :'o' => :'o',
41
+ :'c' => :'c',
42
+ :'h' => :'h',
43
+ :'l' => :'l',
44
+ :'v' => :'v',
45
+ :'time' => :'time'
46
+ }
47
+ end
48
+
49
+ # Returns all the JSON keys this model knows about
50
+ def self.acceptable_attributes
51
+ attribute_map.values
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'figi' => :'String',
58
+ :'interval' => :'CandleResolution',
59
+ :'o' => :'Float',
60
+ :'c' => :'Float',
61
+ :'h' => :'Float',
62
+ :'l' => :'Float',
63
+ :'v' => :'Integer',
64
+ :'time' => :'Time'
65
+ }
66
+ end
67
+
68
+ # List of attributes with nullable: true
69
+ def self.openapi_nullable
70
+ Set.new([
71
+ ])
72
+ end
73
+
74
+ # Initializes the object
75
+ # @param [Hash] attributes Model attributes in the form of hash
76
+ def initialize(attributes = {})
77
+ if (!attributes.is_a?(Hash))
78
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TinkoffInvestClient::Candle` initialize method"
79
+ end
80
+
81
+ # check to see if the attribute exists and convert string to symbol for hash key
82
+ attributes = attributes.each_with_object({}) { |(k, v), h|
83
+ if (!self.class.attribute_map.key?(k.to_sym))
84
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TinkoffInvestClient::Candle`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
85
+ end
86
+ h[k.to_sym] = v
87
+ }
88
+
89
+ if attributes.key?(:'figi')
90
+ self.figi = attributes[:'figi']
91
+ end
92
+
93
+ if attributes.key?(:'interval')
94
+ self.interval = attributes[:'interval']
95
+ end
96
+
97
+ if attributes.key?(:'o')
98
+ self.o = attributes[:'o']
99
+ end
100
+
101
+ if attributes.key?(:'c')
102
+ self.c = attributes[:'c']
103
+ end
104
+
105
+ if attributes.key?(:'h')
106
+ self.h = attributes[:'h']
107
+ end
108
+
109
+ if attributes.key?(:'l')
110
+ self.l = attributes[:'l']
111
+ end
112
+
113
+ if attributes.key?(:'v')
114
+ self.v = attributes[:'v']
115
+ end
116
+
117
+ if attributes.key?(:'time')
118
+ self.time = attributes[:'time']
119
+ end
120
+ end
121
+
122
+ # Show invalid properties with the reasons. Usually used together with valid?
123
+ # @return Array for valid properties with the reasons
124
+ def list_invalid_properties
125
+ invalid_properties = Array.new
126
+ if @figi.nil?
127
+ invalid_properties.push('invalid value for "figi", figi cannot be nil.')
128
+ end
129
+
130
+ if @interval.nil?
131
+ invalid_properties.push('invalid value for "interval", interval cannot be nil.')
132
+ end
133
+
134
+ if @o.nil?
135
+ invalid_properties.push('invalid value for "o", o cannot be nil.')
136
+ end
137
+
138
+ if @c.nil?
139
+ invalid_properties.push('invalid value for "c", c cannot be nil.')
140
+ end
141
+
142
+ if @h.nil?
143
+ invalid_properties.push('invalid value for "h", h cannot be nil.')
144
+ end
145
+
146
+ if @l.nil?
147
+ invalid_properties.push('invalid value for "l", l cannot be nil.')
148
+ end
149
+
150
+ if @v.nil?
151
+ invalid_properties.push('invalid value for "v", v cannot be nil.')
152
+ end
153
+
154
+ if @time.nil?
155
+ invalid_properties.push('invalid value for "time", time cannot be nil.')
156
+ end
157
+
158
+ invalid_properties
159
+ end
160
+
161
+ # Check to see if the all the properties in the model are valid
162
+ # @return true if the model is valid
163
+ def valid?
164
+ return false if @figi.nil?
165
+ return false if @interval.nil?
166
+ return false if @o.nil?
167
+ return false if @c.nil?
168
+ return false if @h.nil?
169
+ return false if @l.nil?
170
+ return false if @v.nil?
171
+ return false if @time.nil?
172
+ true
173
+ end
174
+
175
+ # Checks equality by comparing each attribute.
176
+ # @param [Object] Object to be compared
177
+ def ==(o)
178
+ return true if self.equal?(o)
179
+ self.class == o.class &&
180
+ figi == o.figi &&
181
+ interval == o.interval &&
182
+ o == o.o &&
183
+ c == o.c &&
184
+ h == o.h &&
185
+ l == o.l &&
186
+ v == o.v &&
187
+ time == o.time
188
+ end
189
+
190
+ # @see the `==` method
191
+ # @param [Object] Object to be compared
192
+ def eql?(o)
193
+ self == o
194
+ end
195
+
196
+ # Calculates hash code according to all attributes.
197
+ # @return [Integer] Hash code
198
+ def hash
199
+ [figi, interval, o, c, h, l, v, time].hash
200
+ end
201
+
202
+ # Builds the object from hash
203
+ # @param [Hash] attributes Model attributes in the form of hash
204
+ # @return [Object] Returns the model itself
205
+ def self.build_from_hash(attributes)
206
+ new.build_from_hash(attributes)
207
+ end
208
+
209
+ # Builds the object from hash
210
+ # @param [Hash] attributes Model attributes in the form of hash
211
+ # @return [Object] Returns the model itself
212
+ def build_from_hash(attributes)
213
+ return nil unless attributes.is_a?(Hash)
214
+ self.class.openapi_types.each_pair do |key, type|
215
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
216
+ self.send("#{key}=", nil)
217
+ elsif type =~ /\AArray<(.*)>/i
218
+ # check to ensure the input is an array given that the attribute
219
+ # is documented as an array but the input is not
220
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
221
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
222
+ end
223
+ elsif !attributes[self.class.attribute_map[key]].nil?
224
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
225
+ end
226
+ end
227
+
228
+ self
229
+ end
230
+
231
+ # Deserializes the data based on type
232
+ # @param string type Data type
233
+ # @param string value Value to be deserialized
234
+ # @return [Object] Deserialized data
235
+ def _deserialize(type, value)
236
+ case type.to_sym
237
+ when :Time
238
+ Time.parse(value)
239
+ when :Date
240
+ Date.parse(value)
241
+ when :String
242
+ value.to_s
243
+ when :Integer
244
+ value.to_i
245
+ when :Float
246
+ value.to_f
247
+ when :Boolean
248
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
249
+ true
250
+ else
251
+ false
252
+ end
253
+ when :Object
254
+ # generic object (usually a Hash), return directly
255
+ value
256
+ when /\AArray<(?<inner_type>.+)>\z/
257
+ inner_type = Regexp.last_match[:inner_type]
258
+ value.map { |v| _deserialize(inner_type, v) }
259
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
260
+ k_type = Regexp.last_match[:k_type]
261
+ v_type = Regexp.last_match[:v_type]
262
+ {}.tap do |hash|
263
+ value.each do |k, v|
264
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
265
+ end
266
+ end
267
+ else # model
268
+ # models (e.g. Pet) or oneOf
269
+ klass = TinkoffInvestClient.const_get(type)
270
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
271
+ end
272
+ end
273
+
274
+ # Returns the string representation of the object
275
+ # @return [String] String presentation of the object
276
+ def to_s
277
+ to_hash.to_s
278
+ end
279
+
280
+ # to_body is an alias to to_hash (backward compatibility)
281
+ # @return [Hash] Returns the object in the form of hash
282
+ def to_body
283
+ to_hash
284
+ end
285
+
286
+ # Returns the object in the form of hash
287
+ # @return [Hash] Returns the object in the form of hash
288
+ def to_hash
289
+ hash = {}
290
+ self.class.attribute_map.each_pair do |attr, param|
291
+ value = self.send(attr)
292
+ if value.nil?
293
+ is_nullable = self.class.openapi_nullable.include?(attr)
294
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
295
+ end
296
+
297
+ hash[param] = _to_hash(value)
298
+ end
299
+ hash
300
+ end
301
+
302
+ # Outputs non-array value in the form of hash
303
+ # For object, use to_hash. Otherwise, just return the value
304
+ # @param [Object] value Any valid value
305
+ # @return [Hash] Returns the value in the form of hash
306
+ def _to_hash(value)
307
+ if value.is_a?(Array)
308
+ value.compact.map { |v| _to_hash(v) }
309
+ elsif value.is_a?(Hash)
310
+ {}.tap do |hash|
311
+ value.each { |k, v| hash[k] = _to_hash(v) }
312
+ end
313
+ elsif value.respond_to? :to_hash
314
+ value.to_hash
315
+ else
316
+ value
317
+ end
318
+ end
319
+
320
+ end
321
+
322
+ end