hydrogen-proton-api 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +82 -0
  4. data/Rakefile +8 -0
  5. data/git_push.sh +55 -0
  6. data/lib/proton_api.rb +141 -0
  7. data/lib/proton_api/api/annuities_api.rb +347 -0
  8. data/lib/proton_api/api/business_financial_management_api.rb +293 -0
  9. data/lib/proton_api/api/cards_api.rb +185 -0
  10. data/lib/proton_api/api/financial_health_api.rb +239 -0
  11. data/lib/proton_api/api/financial_planning_api.rb +671 -0
  12. data/lib/proton_api/api/goals_api.rb +347 -0
  13. data/lib/proton_api/api/life_insurance_api.rb +77 -0
  14. data/lib/proton_api/api/personal_financial_management_api.rb +347 -0
  15. data/lib/proton_api/api/portfolio_construction_api.rb +77 -0
  16. data/lib/proton_api/api/portfolio_management_api.rb +77 -0
  17. data/lib/proton_api/api/risk_scoring_api.rb +185 -0
  18. data/lib/proton_api/api/simulations_api.rb +401 -0
  19. data/lib/proton_api/api/util_api.rb +185 -0
  20. data/lib/proton_api/api_client.rb +391 -0
  21. data/lib/proton_api/api_error.rb +38 -0
  22. data/lib/proton_api/auth_configuration.rb +181 -0
  23. data/lib/proton_api/configuration.rb +209 -0
  24. data/lib/proton_api/environment.rb +36 -0
  25. data/lib/proton_api/models/accumulation_goal_deposit_config.rb +338 -0
  26. data/lib/proton_api/models/annuity_calculator_accumulation_horizon_request.rb +459 -0
  27. data/lib/proton_api/models/annuity_calculator_annuity_amount_request.rb +461 -0
  28. data/lib/proton_api/models/annuity_calculator_decumulation_horizon_request.rb +459 -0
  29. data/lib/proton_api/models/annuity_calculator_deposit_amount_request.rb +468 -0
  30. data/lib/proton_api/models/annuity_calculator_initial_balance_request.rb +468 -0
  31. data/lib/proton_api/models/annuity_deposit_schedule.rb +254 -0
  32. data/lib/proton_api/models/answer.rb +186 -0
  33. data/lib/proton_api/models/backtest_request.rb +295 -0
  34. data/lib/proton_api/models/beneficiary_bequest_config.rb +257 -0
  35. data/lib/proton_api/models/budget_aggregation_account.rb +186 -0
  36. data/lib/proton_api/models/budget_calculator_request.rb +334 -0
  37. data/lib/proton_api/models/budget_component.rb +228 -0
  38. data/lib/proton_api/models/budget_details.rb +337 -0
  39. data/lib/proton_api/models/business_financial_health_check_request.rb +484 -0
  40. data/lib/proton_api/models/business_invoice_analysis_request.rb +361 -0
  41. data/lib/proton_api/models/calculator_deposit_schedule.rb +228 -0
  42. data/lib/proton_api/models/calculator_deposit_schedule1.rb +254 -0
  43. data/lib/proton_api/models/card_analysis_request.rb +372 -0
  44. data/lib/proton_api/models/card_limit_check_request.rb +231 -0
  45. data/lib/proton_api/models/card_transaction_authorization_request.rb +422 -0
  46. data/lib/proton_api/models/cash_analysis_request.rb +340 -0
  47. data/lib/proton_api/models/cash_flow_analysis_request.rb +366 -0
  48. data/lib/proton_api/models/children_education_config.rb +221 -0
  49. data/lib/proton_api/models/customer_analysis_request.rb +292 -0
  50. data/lib/proton_api/models/decision_tree_result_request.rb +236 -0
  51. data/lib/proton_api/models/decumulation_goal_deposit_config.rb +335 -0
  52. data/lib/proton_api/models/dimensional_risk_score_request.rb +282 -0
  53. data/lib/proton_api/models/diversification_score_request.rb +324 -0
  54. data/lib/proton_api/models/education_calculator_annual_cost_request.rb +450 -0
  55. data/lib/proton_api/models/education_calculator_deposit_amount_request.rb +483 -0
  56. data/lib/proton_api/models/education_calculator_percent_covered_request.rb +448 -0
  57. data/lib/proton_api/models/education_config.rb +271 -0
  58. data/lib/proton_api/models/emergency_fund_calculator_request.rb +561 -0
  59. data/lib/proton_api/models/event_study_request.rb +317 -0
  60. data/lib/proton_api/models/fee_analysis_request.rb +239 -0
  61. data/lib/proton_api/models/financial_health_check_request.rb +384 -0
  62. data/lib/proton_api/models/financial_picture_request.rb +270 -0
  63. data/lib/proton_api/models/financial_statement_analysis_request.rb +461 -0
  64. data/lib/proton_api/models/goal_accumulation_allocation_request.rb +729 -0
  65. data/lib/proton_api/models/goal_accumulation_recommendation_request.rb +622 -0
  66. data/lib/proton_api/models/goal_accumulation_status_request.rb +622 -0
  67. data/lib/proton_api/models/goal_config.rb +222 -0
  68. data/lib/proton_api/models/goal_decumulation_allocation_request.rb +764 -0
  69. data/lib/proton_api/models/goal_decumulation_recommendation_request.rb +657 -0
  70. data/lib/proton_api/models/goal_decumulation_status_request.rb +657 -0
  71. data/lib/proton_api/models/goal_withdrawal_config.rb +335 -0
  72. data/lib/proton_api/models/guaranteed_rate_benefit.rb +272 -0
  73. data/lib/proton_api/models/income_config.rb +266 -0
  74. data/lib/proton_api/models/life_insurance_needs_calculator_request.rb +515 -0
  75. data/lib/proton_api/models/location.rb +183 -0
  76. data/lib/proton_api/models/monte_carlo_request.rb +504 -0
  77. data/lib/proton_api/models/mortgage_calculator_down_payment_request.rb +299 -0
  78. data/lib/proton_api/models/mortgage_calculator_home_price_request.rb +299 -0
  79. data/lib/proton_api/models/mortgage_calculator_periodic_payment_request.rb +299 -0
  80. data/lib/proton_api/models/mvo_request.rb +366 -0
  81. data/lib/proton_api/models/opt_config.rb +300 -0
  82. data/lib/proton_api/models/opt_config1.rb +260 -0
  83. data/lib/proton_api/models/order_rebalance_request.rb +398 -0
  84. data/lib/proton_api/models/performance_calculator_request.rb +687 -0
  85. data/lib/proton_api/models/periods.rb +220 -0
  86. data/lib/proton_api/models/portfolio_optimization_score_request.rb +356 -0
  87. data/lib/proton_api/models/portfolio_what_if_request.rb +351 -0
  88. data/lib/proton_api/models/purchase_calculator_amount_request.rb +401 -0
  89. data/lib/proton_api/models/purchase_calculator_deposit_amount_request.rb +434 -0
  90. data/lib/proton_api/models/purchase_calculator_horizon_request.rb +356 -0
  91. data/lib/proton_api/models/ratio_targets.rb +328 -0
  92. data/lib/proton_api/models/ratio_targets1.rb +328 -0
  93. data/lib/proton_api/models/rebalancing_signal_request.rb +238 -0
  94. data/lib/proton_api/models/recommendation_config.rb +357 -0
  95. data/lib/proton_api/models/recommendation_config1.rb +346 -0
  96. data/lib/proton_api/models/recurring_transaction_analysis_request.rb +400 -0
  97. data/lib/proton_api/models/retirement_calculator_deposit_amount_request.rb +509 -0
  98. data/lib/proton_api/models/retirement_calculator_expenses_request.rb +476 -0
  99. data/lib/proton_api/models/retirement_calculator_percent_covered_request.rb +474 -0
  100. data/lib/proton_api/models/risk_allocation_request.rb +316 -0
  101. data/lib/proton_api/models/risk_score_request.rb +239 -0
  102. data/lib/proton_api/models/savings_calculator_request.rb +395 -0
  103. data/lib/proton_api/models/savings_deposit_schedule.rb +276 -0
  104. data/lib/proton_api/models/scenario_analysis_request.rb +401 -0
  105. data/lib/proton_api/models/sensitivity_analysis_request.rb +399 -0
  106. data/lib/proton_api/models/sensitivity_factor.rb +278 -0
  107. data/lib/proton_api/models/settings.rb +287 -0
  108. data/lib/proton_api/models/spending_analysis_request.rb +505 -0
  109. data/lib/proton_api/models/variable_annuity_request.rb +700 -0
  110. data/lib/proton_api/models/w_config.rb +382 -0
  111. data/lib/proton_api/models/w_config1.rb +347 -0
  112. data/lib/proton_api/version.rb +15 -0
  113. data/proton_api.gemspec +46 -0
  114. data/spec/api/annuities_api_spec.rb +107 -0
  115. data/spec/api/business_financial_management_api_spec.rb +95 -0
  116. data/spec/api/cards_api_spec.rb +71 -0
  117. data/spec/api/financial_health_api_spec.rb +83 -0
  118. data/spec/api/financial_planning_api_spec.rb +179 -0
  119. data/spec/api/goals_api_spec.rb +107 -0
  120. data/spec/api/life_insurance_api_spec.rb +47 -0
  121. data/spec/api/personal_financial_management_api_spec.rb +107 -0
  122. data/spec/api/portfolio_construction_api_spec.rb +47 -0
  123. data/spec/api/portfolio_management_api_spec.rb +47 -0
  124. data/spec/api/risk_scoring_api_spec.rb +71 -0
  125. data/spec/api/simulations_api_spec.rb +119 -0
  126. data/spec/api/util_api_spec.rb +71 -0
  127. data/spec/api_client_spec.rb +243 -0
  128. data/spec/configuration_spec.rb +42 -0
  129. data/spec/models/accumulation_goal_deposit_config_spec.rb +89 -0
  130. data/spec/models/annuity_calculator_accumulation_horizon_request_spec.rb +111 -0
  131. data/spec/models/annuity_calculator_annuity_amount_request_spec.rb +111 -0
  132. data/spec/models/annuity_calculator_decumulation_horizon_request_spec.rb +111 -0
  133. data/spec/models/annuity_calculator_deposit_amount_request_spec.rb +111 -0
  134. data/spec/models/annuity_calculator_initial_balance_request_spec.rb +111 -0
  135. data/spec/models/annuity_deposit_schedule_spec.rb +57 -0
  136. data/spec/models/answer_spec.rb +41 -0
  137. data/spec/models/backtest_request_spec.rb +95 -0
  138. data/spec/models/beneficiary_bequest_config_spec.rb +53 -0
  139. data/spec/models/budget_aggregation_account_spec.rb +41 -0
  140. data/spec/models/budget_calculator_request_spec.rb +105 -0
  141. data/spec/models/budget_component_spec.rb +53 -0
  142. data/spec/models/budget_details_spec.rb +99 -0
  143. data/spec/models/business_financial_health_check_request_spec.rb +143 -0
  144. data/spec/models/business_invoice_analysis_request_spec.rb +123 -0
  145. data/spec/models/calculator_deposit_schedule1_spec.rb +57 -0
  146. data/spec/models/calculator_deposit_schedule_spec.rb +51 -0
  147. data/spec/models/card_analysis_request_spec.rb +129 -0
  148. data/spec/models/card_limit_check_request_spec.rb +65 -0
  149. data/spec/models/card_transaction_authorization_request_spec.rb +157 -0
  150. data/spec/models/cash_analysis_request_spec.rb +115 -0
  151. data/spec/models/cash_flow_analysis_request_spec.rb +135 -0
  152. data/spec/models/children_education_config_spec.rb +47 -0
  153. data/spec/models/customer_analysis_request_spec.rb +101 -0
  154. data/spec/models/decision_tree_result_request_spec.rb +51 -0
  155. data/spec/models/decumulation_goal_deposit_config_spec.rb +89 -0
  156. data/spec/models/dimensional_risk_score_request_spec.rb +89 -0
  157. data/spec/models/diversification_score_request_spec.rb +111 -0
  158. data/spec/models/education_calculator_annual_cost_request_spec.rb +101 -0
  159. data/spec/models/education_calculator_deposit_amount_request_spec.rb +107 -0
  160. data/spec/models/education_calculator_percent_covered_request_spec.rb +101 -0
  161. data/spec/models/education_config_spec.rb +53 -0
  162. data/spec/models/emergency_fund_calculator_request_spec.rb +141 -0
  163. data/spec/models/event_study_request_spec.rb +109 -0
  164. data/spec/models/fee_analysis_request_spec.rb +77 -0
  165. data/spec/models/financial_health_check_request_spec.rb +95 -0
  166. data/spec/models/financial_picture_request_spec.rb +95 -0
  167. data/spec/models/financial_statement_analysis_request_spec.rb +155 -0
  168. data/spec/models/goal_accumulation_allocation_request_spec.rb +215 -0
  169. data/spec/models/goal_accumulation_recommendation_request_spec.rb +173 -0
  170. data/spec/models/goal_accumulation_status_request_spec.rb +173 -0
  171. data/spec/models/goal_config_spec.rb +47 -0
  172. data/spec/models/goal_decumulation_allocation_request_spec.rb +221 -0
  173. data/spec/models/goal_decumulation_recommendation_request_spec.rb +179 -0
  174. data/spec/models/goal_decumulation_status_request_spec.rb +179 -0
  175. data/spec/models/goal_withdrawal_config_spec.rb +89 -0
  176. data/spec/models/guaranteed_rate_benefit_spec.rb +59 -0
  177. data/spec/models/income_config_spec.rb +53 -0
  178. data/spec/models/life_insurance_needs_calculator_request_spec.rb +125 -0
  179. data/spec/models/location_spec.rb +41 -0
  180. data/spec/models/monte_carlo_request_spec.rb +179 -0
  181. data/spec/models/mortgage_calculator_down_payment_request_spec.rb +59 -0
  182. data/spec/models/mortgage_calculator_home_price_request_spec.rb +59 -0
  183. data/spec/models/mortgage_calculator_periodic_payment_request_spec.rb +59 -0
  184. data/spec/models/mvo_request_spec.rb +113 -0
  185. data/spec/models/opt_config1_spec.rb +69 -0
  186. data/spec/models/opt_config_spec.rb +81 -0
  187. data/spec/models/order_rebalance_request_spec.rb +123 -0
  188. data/spec/models/performance_calculator_request_spec.rb +233 -0
  189. data/spec/models/periods_spec.rb +47 -0
  190. data/spec/models/portfolio_optimization_score_request_spec.rb +127 -0
  191. data/spec/models/portfolio_what_if_request_spec.rb +123 -0
  192. data/spec/models/purchase_calculator_amount_request_spec.rb +93 -0
  193. data/spec/models/purchase_calculator_deposit_amount_request_spec.rb +99 -0
  194. data/spec/models/purchase_calculator_horizon_request_spec.rb +83 -0
  195. data/spec/models/ratio_targets1_spec.rb +71 -0
  196. data/spec/models/ratio_targets_spec.rb +71 -0
  197. data/spec/models/rebalancing_signal_request_spec.rb +71 -0
  198. data/spec/models/recommendation_config1_spec.rb +77 -0
  199. data/spec/models/recommendation_config_spec.rb +83 -0
  200. data/spec/models/recurring_transaction_analysis_request_spec.rb +129 -0
  201. data/spec/models/retirement_calculator_deposit_amount_request_spec.rb +113 -0
  202. data/spec/models/retirement_calculator_expenses_request_spec.rb +107 -0
  203. data/spec/models/retirement_calculator_percent_covered_request_spec.rb +107 -0
  204. data/spec/models/risk_allocation_request_spec.rb +85 -0
  205. data/spec/models/risk_score_request_spec.rb +71 -0
  206. data/spec/models/savings_calculator_request_spec.rb +99 -0
  207. data/spec/models/savings_deposit_schedule_spec.rb +63 -0
  208. data/spec/models/scenario_analysis_request_spec.rb +133 -0
  209. data/spec/models/sensitivity_analysis_request_spec.rb +133 -0
  210. data/spec/models/sensitivity_factor_spec.rb +59 -0
  211. data/spec/models/settings_spec.rb +79 -0
  212. data/spec/models/spending_analysis_request_spec.rb +187 -0
  213. data/spec/models/variable_annuity_request_spec.rb +209 -0
  214. data/spec/models/w_config1_spec.rb +65 -0
  215. data/spec/models/w_config_spec.rb +65 -0
  216. data/spec/spec_helper.rb +111 -0
  217. metadata +561 -0
@@ -0,0 +1,38 @@
1
+ =begin
2
+ #Hydrogen Proton API
3
+
4
+ #Financial engineering module of Hydrogen Atom
5
+
6
+ OpenAPI spec version: 1.9.1
7
+ Contact: info@hydrogenplatform.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.19
10
+
11
+ =end
12
+
13
+ module ProtonApi
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
+ end
38
+ end
@@ -0,0 +1,181 @@
1
+ =begin
2
+ #Hydrogen Proton API
3
+
4
+ #Financial engineering module of Hydrogen Atom
5
+
6
+ OpenAPI spec version: 1.9.1
7
+ Contact: info@hydrogenplatform.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.13
10
+
11
+ =end
12
+ require 'date'
13
+ require 'json'
14
+ require 'logger'
15
+ require 'tempfile'
16
+ require 'typhoeus'
17
+ require 'uri'
18
+ module ProtonApi
19
+ class AuthConfiguration < Configuration
20
+ attr_accessor :authorization
21
+ attr_accessor :client_token
22
+ attr_accessor :grant_type_key
23
+ attr_accessor :client_credentials
24
+ attr_accessor :password
25
+ attr_accessor :username
26
+ attr_accessor :application_json_value
27
+ attr_accessor :auth_uri
28
+ attr_accessor :client_token_auth_uri
29
+ attr_accessor :config
30
+ attr_accessor :bearer
31
+ attr_accessor :base_url
32
+ def initialize
33
+ super
34
+ @authorization = 'Authorization'
35
+ @client_token = 'Client-Token'
36
+ @grant_type_key = 'grant_type'
37
+ @client_credentials = 'client_credentials'
38
+ @password = 'password'
39
+ @username = 'username'
40
+ @application_json_value = 'application/json'
41
+ @auth_uri = '/authorization/v1/oauth/token'
42
+ @client_token_auth_uri = '/authorization/v1/client-token'
43
+ @bearer = 'Bearer '
44
+ @config = Configuration.default
45
+ yield(self) if block_given?
46
+ end
47
+
48
+ def self.default
49
+ @@default ||= AuthConfiguration.new
50
+ end
51
+
52
+ def configure
53
+ yield(self) if block_given?
54
+ end
55
+
56
+ def set_base_url(base_url)
57
+ @config.host = base_url
58
+ end
59
+
60
+ def auth_url(host)
61
+ url = "#{scheme}://#{[host, auth_uri].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
62
+ URI.encode(url)
63
+ end
64
+
65
+ def client_token_auth_url(host)
66
+ url = "#{scheme}://#{[host, client_token_auth_uri].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
67
+ URI.encode(url)
68
+ end
69
+
70
+ def create_client_token_credential(client_id, client_secret, client_token)
71
+ basic_cred = 'Basic ' + ["#{client_id}:#{client_secret}"].pack('m').delete("\r\n")
72
+ header_params = {}
73
+ header_params[@authorization] = basic_cred;
74
+ header_params[@client_token] = @bearer + client_token;
75
+ response = Typhoeus::Request.new(
76
+ client_token_auth_url(@config.host),
77
+ :method => :post,
78
+ :headers => header_params,
79
+ :params => nil
80
+ ).run
81
+
82
+ if @debugging
83
+ @logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
84
+ end
85
+ body = JSON.parse(response.body)
86
+ unless response.success?
87
+ if response.timed_out?
88
+ raise ApiError.new('Connection timed out')
89
+ elsif response.code == 0
90
+ # Errors from libcurl will be made visible here
91
+ raise ApiError.new(:code => 0,
92
+ :message => response.return_message)
93
+ else
94
+ raise ApiError.new(:code => response.code,
95
+ :response_headers => response.headers,
96
+ :response_body => response.body), response.body
97
+ end
98
+ end
99
+ @config.access_token = body['access_token']
100
+ end
101
+
102
+ def create_client_credential(client_id, client_secret)
103
+ basic_cred = 'Basic ' + ["#{client_id}:#{client_secret}"].pack('m').delete("\r\n")
104
+ # Request Params
105
+ params = {}
106
+ params[@grant_type_key] = @client_credentials
107
+ # Header parameters
108
+ header_params = {}
109
+ header_params['Accept'] = '*/*'
110
+ header_params['Content-Type'] = 'application/json'
111
+ header_params[@authorization] = basic_cred
112
+ response = Typhoeus::Request.new(
113
+ auth_url(@config.host),
114
+ :method => :post,
115
+ :headers => header_params,
116
+ :params => params
117
+ ).run
118
+
119
+ if @debugging
120
+ @logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
121
+ end
122
+ body = JSON.parse(response.body)
123
+ unless response.success?
124
+ if response.timed_out?
125
+ raise ApiError.new('Connection timed out')
126
+ elsif response.code == 0
127
+ # Errors from libcurl will be made visible here
128
+ raise ApiError.new(:code => 0,
129
+ :message => response.return_message)
130
+ else
131
+ raise ApiError.new(:code => response.code,
132
+ :response_headers => response.headers,
133
+ :response_body => response.body), response.body
134
+ end
135
+ end
136
+ @config.access_token = body['access_token']
137
+ end
138
+
139
+ def set_access_token(token)
140
+ @config.access_token = token
141
+ end
142
+
143
+ def create_password_credential(client_id, client_secret, username, password)
144
+ basic_cred = 'Basic ' + ["#{client_id}:#{client_secret}"].pack('m').delete("\r\n")
145
+ # Request Params
146
+ params = {}
147
+ params[@grant_type_key] = @password
148
+ params[@username] = username
149
+ params[@password] = password
150
+ # header parameters
151
+ header_params = {}
152
+ header_params['Accept'] = '*/*'
153
+ header_params['Content-Type'] = 'application/json'
154
+ header_params[@authorization] = basic_cred
155
+ response = Typhoeus::Request.new(
156
+ auth_url(@config.host),
157
+ :method => :post,
158
+ :headers => header_params,
159
+ :params => params
160
+ ).run
161
+ if @debugging
162
+ @logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
163
+ end
164
+ body = JSON.parse(response.body)
165
+ unless response.success?
166
+ if response.timed_out?
167
+ raise ApiError.new('Connection timed out')
168
+ elsif response.code == 0
169
+ # Errors from libcurl will be made visible here
170
+ raise ApiError.new(:code => 0,
171
+ :message => response.return_message)
172
+ else
173
+ raise ApiError.new(:code => response.code,
174
+ :response_headers => response.headers,
175
+ :response_body => response.body), body
176
+ end
177
+ end
178
+ @config.access_token = body['access_token']
179
+ end
180
+ end
181
+ end
@@ -0,0 +1,209 @@
1
+ =begin
2
+ #Hydrogen Proton API
3
+
4
+ #Financial engineering module of Hydrogen Atom
5
+
6
+ OpenAPI spec version: 1.9.1
7
+ Contact: info@hydrogenplatform.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.19
10
+
11
+ =end
12
+
13
+ require 'addressable/uri'
14
+
15
+ module ProtonApi
16
+ class Configuration
17
+ # Defines url scheme
18
+ attr_accessor :scheme
19
+
20
+ # Defines url host
21
+ attr_accessor :host
22
+
23
+ # Defines url base path
24
+ attr_accessor :base_path
25
+
26
+ # Defines API keys used with API Key authentications.
27
+ #
28
+ # @return [Hash] key: parameter name, value: parameter value (API key)
29
+ #
30
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
31
+ # config.api_key['api_key'] = 'xxx'
32
+ attr_accessor :api_key
33
+
34
+ # Defines API key prefixes used with API Key authentications.
35
+ #
36
+ # @return [Hash] key: parameter name, value: API key prefix
37
+ #
38
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
39
+ # config.api_key_prefix['api_key'] = 'Token'
40
+ attr_accessor :api_key_prefix
41
+
42
+ # Defines the username used with HTTP basic authentication.
43
+ #
44
+ # @return [String]
45
+ attr_accessor :username
46
+
47
+ # Defines the password used with HTTP basic authentication.
48
+ #
49
+ # @return [String]
50
+ attr_accessor :password
51
+
52
+ # Defines the access token (Bearer) used with OAuth2.
53
+ attr_accessor :access_token
54
+
55
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
56
+ # details will be logged with `logger.debug` (see the `logger` attribute).
57
+ # Default to false.
58
+ #
59
+ # @return [true, false]
60
+ attr_accessor :debugging
61
+
62
+ # Defines the logger used for debugging.
63
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
64
+ #
65
+ # @return [#debug]
66
+ attr_accessor :logger
67
+
68
+ # Defines the temporary folder to store downloaded files
69
+ # (for API endpoints that have file response).
70
+ # Default to use `Tempfile`.
71
+ #
72
+ # @return [String]
73
+ attr_accessor :temp_folder_path
74
+
75
+ # The time limit for HTTP request in seconds.
76
+ # Default to 0 (never times out).
77
+ attr_accessor :timeout
78
+
79
+ # Set this to false to skip client side validation in the operation.
80
+ # Default to true.
81
+ # @return [true, false]
82
+ attr_accessor :client_side_validation
83
+
84
+ ### TLS/SSL setting
85
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
86
+ # Default to true.
87
+ #
88
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
89
+ #
90
+ # @return [true, false]
91
+ attr_accessor :verify_ssl
92
+
93
+ ### TLS/SSL setting
94
+ # Set this to false to skip verifying SSL host name
95
+ # Default to true.
96
+ #
97
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
98
+ #
99
+ # @return [true, false]
100
+ attr_accessor :verify_ssl_host
101
+
102
+ ### TLS/SSL setting
103
+ # Set this to customize the certificate file to verify the peer.
104
+ #
105
+ # @return [String] the path to the certificate file
106
+ #
107
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
108
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
109
+ attr_accessor :ssl_ca_cert
110
+
111
+ ### TLS/SSL setting
112
+ # Client certificate file (for client certificate)
113
+ attr_accessor :cert_file
114
+
115
+ ### TLS/SSL setting
116
+ # Client private key file (for client certificate)
117
+ attr_accessor :key_file
118
+
119
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
120
+ # Default to nil.
121
+ #
122
+ # @see The params_encoding option of Ethon. Related source code:
123
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
124
+ attr_accessor :params_encoding
125
+
126
+ attr_accessor :inject_format
127
+
128
+ attr_accessor :force_ending_format
129
+
130
+ def initialize
131
+ @scheme = 'https'
132
+ @host = 'api.hydrogenplatform.com'
133
+ @base_path = '/proton/v1'
134
+ @api_key = {}
135
+ @api_key_prefix = {}
136
+ @timeout = 0
137
+ @client_side_validation = true
138
+ @verify_ssl = true
139
+ @verify_ssl_host = true
140
+ @params_encoding = nil
141
+ @cert_file = nil
142
+ @key_file = nil
143
+ @debugging = false
144
+ @inject_format = false
145
+ @force_ending_format = false
146
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
147
+
148
+ yield(self) if block_given?
149
+ end
150
+
151
+ # The default Configuration object.
152
+ def self.default
153
+ @@default ||= Configuration.new
154
+ end
155
+
156
+ def configure
157
+ yield(self) if block_given?
158
+ end
159
+
160
+ def scheme=(scheme)
161
+ # remove :// from scheme
162
+ @scheme = scheme.sub(/:\/\//, '')
163
+ end
164
+
165
+ def host=(host)
166
+ # remove http(s):// and anything after a slash
167
+ @host = host.sub(/https?:\/\//, '').split('/').first
168
+ end
169
+
170
+ def base_path=(base_path)
171
+ # Add leading and trailing slashes to base_path
172
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
173
+ @base_path = '' if @base_path == '/'
174
+ end
175
+
176
+ def base_url
177
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
178
+ Addressable::URI.encode(url)
179
+ end
180
+
181
+ # Gets API key (with prefix if set).
182
+ # @param [String] param_name the parameter name of API key auth
183
+ def api_key_with_prefix(param_name)
184
+ if @api_key_prefix[param_name]
185
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
186
+ else
187
+ @api_key[param_name]
188
+ end
189
+ end
190
+
191
+ # Gets Basic Auth token string
192
+ def basic_auth_token
193
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
194
+ end
195
+
196
+ # Returns Auth Settings hash for api client.
197
+ def auth_settings
198
+ {
199
+ 'oauth2' =>
200
+ {
201
+ type: 'oauth2',
202
+ in: 'header',
203
+ key: 'Authorization',
204
+ value: "Bearer #{access_token}"
205
+ },
206
+ }
207
+ end
208
+ end
209
+ end
@@ -0,0 +1,36 @@
1
+ =begin
2
+ #Hydrogen Proton API
3
+
4
+ #Financial engineering module of Hydrogen Atom
5
+
6
+ OpenAPI spec version: 1.9.1
7
+ Contact: info@hydrogenplatform.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.13
10
+
11
+ =end
12
+ require 'uri'
13
+
14
+ module ProtonApi
15
+ class Environment
16
+ attr_accessor :api_client
17
+ attr_accessor :auth_config
18
+ attr_accessor :SANDBOX
19
+ attr_accessor :PRODUCTION
20
+ def initialize(api_client = ApiClient.default, config = Configuration.default, auth_config = AuthConfiguration.default)
21
+ @api_client = api_client
22
+ @config = config
23
+ @auth_config = auth_config
24
+ @SANDBOX = 'sandbox.hydrogenplatform.com'
25
+ @PRODUCTION = 'api.hydrogenplatform.com'
26
+ end
27
+
28
+ def set_environment(host)
29
+ if (host)
30
+ @config.config.host=host
31
+ @api_client.config.host=host
32
+ @auth_config.set_base_url(host)
33
+ end
34
+ end
35
+ end
36
+ end