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,255 @@
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 OrdersResponse
18
+ attr_accessor :tracking_id
19
+
20
+ attr_accessor :status
21
+
22
+ attr_accessor :payload
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'tracking_id' => :'trackingId',
28
+ :'status' => :'status',
29
+ :'payload' => :'payload'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'tracking_id' => :'String',
42
+ :'status' => :'String',
43
+ :'payload' => :'Array<Order>'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TinkoffInvestClient::OrdersResponse` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TinkoffInvestClient::OrdersResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'tracking_id')
69
+ self.tracking_id = attributes[:'tracking_id']
70
+ end
71
+
72
+ if attributes.key?(:'status')
73
+ self.status = attributes[:'status']
74
+ else
75
+ self.status = 'Ok'
76
+ end
77
+
78
+ if attributes.key?(:'payload')
79
+ if (value = attributes[:'payload']).is_a?(Array)
80
+ self.payload = value
81
+ end
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = Array.new
89
+ if @tracking_id.nil?
90
+ invalid_properties.push('invalid value for "tracking_id", tracking_id cannot be nil.')
91
+ end
92
+
93
+ if @status.nil?
94
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
95
+ end
96
+
97
+ if @payload.nil?
98
+ invalid_properties.push('invalid value for "payload", payload cannot be nil.')
99
+ end
100
+
101
+ invalid_properties
102
+ end
103
+
104
+ # Check to see if the all the properties in the model are valid
105
+ # @return true if the model is valid
106
+ def valid?
107
+ return false if @tracking_id.nil?
108
+ return false if @status.nil?
109
+ return false if @payload.nil?
110
+ true
111
+ end
112
+
113
+ # Checks equality by comparing each attribute.
114
+ # @param [Object] Object to be compared
115
+ def ==(o)
116
+ return true if self.equal?(o)
117
+ self.class == o.class &&
118
+ tracking_id == o.tracking_id &&
119
+ status == o.status &&
120
+ payload == o.payload
121
+ end
122
+
123
+ # @see the `==` method
124
+ # @param [Object] Object to be compared
125
+ def eql?(o)
126
+ self == o
127
+ end
128
+
129
+ # Calculates hash code according to all attributes.
130
+ # @return [Integer] Hash code
131
+ def hash
132
+ [tracking_id, status, payload].hash
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def self.build_from_hash(attributes)
139
+ new.build_from_hash(attributes)
140
+ end
141
+
142
+ # Builds the object from hash
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ # @return [Object] Returns the model itself
145
+ def build_from_hash(attributes)
146
+ return nil unless attributes.is_a?(Hash)
147
+ self.class.openapi_types.each_pair do |key, type|
148
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
149
+ self.send("#{key}=", nil)
150
+ elsif type =~ /\AArray<(.*)>/i
151
+ # check to ensure the input is an array given that the attribute
152
+ # is documented as an array but the input is not
153
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
154
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
155
+ end
156
+ elsif !attributes[self.class.attribute_map[key]].nil?
157
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
158
+ end
159
+ end
160
+
161
+ self
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def _deserialize(type, value)
169
+ case type.to_sym
170
+ when :Time
171
+ Time.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :String
175
+ value.to_s
176
+ when :Integer
177
+ value.to_i
178
+ when :Float
179
+ value.to_f
180
+ when :Boolean
181
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
182
+ true
183
+ else
184
+ false
185
+ end
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ else # model
201
+ # models (e.g. Pet) or oneOf
202
+ klass = TinkoffInvestClient.const_get(type)
203
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
204
+ end
205
+ end
206
+
207
+ # Returns the string representation of the object
208
+ # @return [String] String presentation of the object
209
+ def to_s
210
+ to_hash.to_s
211
+ end
212
+
213
+ # to_body is an alias to to_hash (backward compatibility)
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_body
216
+ to_hash
217
+ end
218
+
219
+ # Returns the object in the form of hash
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_hash
222
+ hash = {}
223
+ self.class.attribute_map.each_pair do |attr, param|
224
+ value = self.send(attr)
225
+ if value.nil?
226
+ is_nullable = self.class.openapi_nullable.include?(attr)
227
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
+ end
229
+
230
+ hash[param] = _to_hash(value)
231
+ end
232
+ hash
233
+ end
234
+
235
+ # Outputs non-array value in the form of hash
236
+ # For object, use to_hash. Otherwise, just return the value
237
+ # @param [Object] value Any valid value
238
+ # @return [Hash] Returns the value in the form of hash
239
+ def _to_hash(value)
240
+ if value.is_a?(Array)
241
+ value.compact.map { |v| _to_hash(v) }
242
+ elsif value.is_a?(Hash)
243
+ {}.tap do |hash|
244
+ value.each { |k, v| hash[k] = _to_hash(v) }
245
+ end
246
+ elsif value.respond_to? :to_hash
247
+ value.to_hash
248
+ else
249
+ value
250
+ end
251
+ end
252
+
253
+ end
254
+
255
+ end
@@ -0,0 +1,307 @@
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 PlacedLimitOrder
18
+ attr_accessor :order_id
19
+
20
+ attr_accessor :operation
21
+
22
+ attr_accessor :status
23
+
24
+ attr_accessor :reject_reason
25
+
26
+ # Сообщение об ошибке
27
+ attr_accessor :message
28
+
29
+ attr_accessor :requested_lots
30
+
31
+ attr_accessor :executed_lots
32
+
33
+ attr_accessor :commission
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'order_id' => :'orderId',
39
+ :'operation' => :'operation',
40
+ :'status' => :'status',
41
+ :'reject_reason' => :'rejectReason',
42
+ :'message' => :'message',
43
+ :'requested_lots' => :'requestedLots',
44
+ :'executed_lots' => :'executedLots',
45
+ :'commission' => :'commission'
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
+ :'order_id' => :'String',
58
+ :'operation' => :'OperationType',
59
+ :'status' => :'OrderStatus',
60
+ :'reject_reason' => :'String',
61
+ :'message' => :'String',
62
+ :'requested_lots' => :'Integer',
63
+ :'executed_lots' => :'Integer',
64
+ :'commission' => :'MoneyAmount'
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::PlacedLimitOrder` 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::PlacedLimitOrder`. 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?(:'order_id')
90
+ self.order_id = attributes[:'order_id']
91
+ end
92
+
93
+ if attributes.key?(:'operation')
94
+ self.operation = attributes[:'operation']
95
+ end
96
+
97
+ if attributes.key?(:'status')
98
+ self.status = attributes[:'status']
99
+ end
100
+
101
+ if attributes.key?(:'reject_reason')
102
+ self.reject_reason = attributes[:'reject_reason']
103
+ end
104
+
105
+ if attributes.key?(:'message')
106
+ self.message = attributes[:'message']
107
+ end
108
+
109
+ if attributes.key?(:'requested_lots')
110
+ self.requested_lots = attributes[:'requested_lots']
111
+ end
112
+
113
+ if attributes.key?(:'executed_lots')
114
+ self.executed_lots = attributes[:'executed_lots']
115
+ end
116
+
117
+ if attributes.key?(:'commission')
118
+ self.commission = attributes[:'commission']
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 @order_id.nil?
127
+ invalid_properties.push('invalid value for "order_id", order_id cannot be nil.')
128
+ end
129
+
130
+ if @operation.nil?
131
+ invalid_properties.push('invalid value for "operation", operation cannot be nil.')
132
+ end
133
+
134
+ if @status.nil?
135
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
136
+ end
137
+
138
+ if @requested_lots.nil?
139
+ invalid_properties.push('invalid value for "requested_lots", requested_lots cannot be nil.')
140
+ end
141
+
142
+ if @executed_lots.nil?
143
+ invalid_properties.push('invalid value for "executed_lots", executed_lots cannot be nil.')
144
+ end
145
+
146
+ invalid_properties
147
+ end
148
+
149
+ # Check to see if the all the properties in the model are valid
150
+ # @return true if the model is valid
151
+ def valid?
152
+ return false if @order_id.nil?
153
+ return false if @operation.nil?
154
+ return false if @status.nil?
155
+ return false if @requested_lots.nil?
156
+ return false if @executed_lots.nil?
157
+ true
158
+ end
159
+
160
+ # Checks equality by comparing each attribute.
161
+ # @param [Object] Object to be compared
162
+ def ==(o)
163
+ return true if self.equal?(o)
164
+ self.class == o.class &&
165
+ order_id == o.order_id &&
166
+ operation == o.operation &&
167
+ status == o.status &&
168
+ reject_reason == o.reject_reason &&
169
+ message == o.message &&
170
+ requested_lots == o.requested_lots &&
171
+ executed_lots == o.executed_lots &&
172
+ commission == o.commission
173
+ end
174
+
175
+ # @see the `==` method
176
+ # @param [Object] Object to be compared
177
+ def eql?(o)
178
+ self == o
179
+ end
180
+
181
+ # Calculates hash code according to all attributes.
182
+ # @return [Integer] Hash code
183
+ def hash
184
+ [order_id, operation, status, reject_reason, message, requested_lots, executed_lots, commission].hash
185
+ end
186
+
187
+ # Builds the object from hash
188
+ # @param [Hash] attributes Model attributes in the form of hash
189
+ # @return [Object] Returns the model itself
190
+ def self.build_from_hash(attributes)
191
+ new.build_from_hash(attributes)
192
+ end
193
+
194
+ # Builds the object from hash
195
+ # @param [Hash] attributes Model attributes in the form of hash
196
+ # @return [Object] Returns the model itself
197
+ def build_from_hash(attributes)
198
+ return nil unless attributes.is_a?(Hash)
199
+ self.class.openapi_types.each_pair do |key, type|
200
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
201
+ self.send("#{key}=", nil)
202
+ elsif type =~ /\AArray<(.*)>/i
203
+ # check to ensure the input is an array given that the attribute
204
+ # is documented as an array but the input is not
205
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
206
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
207
+ end
208
+ elsif !attributes[self.class.attribute_map[key]].nil?
209
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
210
+ end
211
+ end
212
+
213
+ self
214
+ end
215
+
216
+ # Deserializes the data based on type
217
+ # @param string type Data type
218
+ # @param string value Value to be deserialized
219
+ # @return [Object] Deserialized data
220
+ def _deserialize(type, value)
221
+ case type.to_sym
222
+ when :Time
223
+ Time.parse(value)
224
+ when :Date
225
+ Date.parse(value)
226
+ when :String
227
+ value.to_s
228
+ when :Integer
229
+ value.to_i
230
+ when :Float
231
+ value.to_f
232
+ when :Boolean
233
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
234
+ true
235
+ else
236
+ false
237
+ end
238
+ when :Object
239
+ # generic object (usually a Hash), return directly
240
+ value
241
+ when /\AArray<(?<inner_type>.+)>\z/
242
+ inner_type = Regexp.last_match[:inner_type]
243
+ value.map { |v| _deserialize(inner_type, v) }
244
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
245
+ k_type = Regexp.last_match[:k_type]
246
+ v_type = Regexp.last_match[:v_type]
247
+ {}.tap do |hash|
248
+ value.each do |k, v|
249
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
250
+ end
251
+ end
252
+ else # model
253
+ # models (e.g. Pet) or oneOf
254
+ klass = TinkoffInvestClient.const_get(type)
255
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
256
+ end
257
+ end
258
+
259
+ # Returns the string representation of the object
260
+ # @return [String] String presentation of the object
261
+ def to_s
262
+ to_hash.to_s
263
+ end
264
+
265
+ # to_body is an alias to to_hash (backward compatibility)
266
+ # @return [Hash] Returns the object in the form of hash
267
+ def to_body
268
+ to_hash
269
+ end
270
+
271
+ # Returns the object in the form of hash
272
+ # @return [Hash] Returns the object in the form of hash
273
+ def to_hash
274
+ hash = {}
275
+ self.class.attribute_map.each_pair do |attr, param|
276
+ value = self.send(attr)
277
+ if value.nil?
278
+ is_nullable = self.class.openapi_nullable.include?(attr)
279
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
280
+ end
281
+
282
+ hash[param] = _to_hash(value)
283
+ end
284
+ hash
285
+ end
286
+
287
+ # Outputs non-array value in the form of hash
288
+ # For object, use to_hash. Otherwise, just return the value
289
+ # @param [Object] value Any valid value
290
+ # @return [Hash] Returns the value in the form of hash
291
+ def _to_hash(value)
292
+ if value.is_a?(Array)
293
+ value.compact.map { |v| _to_hash(v) }
294
+ elsif value.is_a?(Hash)
295
+ {}.tap do |hash|
296
+ value.each { |k, v| hash[k] = _to_hash(v) }
297
+ end
298
+ elsif value.respond_to? :to_hash
299
+ value.to_hash
300
+ else
301
+ value
302
+ end
303
+ end
304
+
305
+ end
306
+
307
+ end