petstore-test-18052023 1.0.1.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +193 -0
  4. data/lib/merged_api/api_helper.rb +10 -0
  5. data/lib/merged_api/client.rb +97 -0
  6. data/lib/merged_api/configuration.rb +127 -0
  7. data/lib/merged_api/controllers/authentication_controller.rb +36 -0
  8. data/lib/merged_api/controllers/base_controller.rb +65 -0
  9. data/lib/merged_api/controllers/insured_risk_controller.rb +47 -0
  10. data/lib/merged_api/controllers/o_auth_authorization_controller.rb +42 -0
  11. data/lib/merged_api/controllers/policy_controller.rb +66 -0
  12. data/lib/merged_api/controllers/quoting_controller.rb +41 -0
  13. data/lib/merged_api/controllers/simple_calculator_controller.rb +33 -0
  14. data/lib/merged_api/exceptions/api_exception.rb +10 -0
  15. data/lib/merged_api/exceptions/auth_oauth2_token400_error1_exception.rb +32 -0
  16. data/lib/merged_api/exceptions/insured_risks400_error1_exception.rb +41 -0
  17. data/lib/merged_api/exceptions/insured_risks401_error1_exception.rb +32 -0
  18. data/lib/merged_api/exceptions/insured_risks403_error1_exception.rb +41 -0
  19. data/lib/merged_api/exceptions/insured_risks415_error1_exception.rb +41 -0
  20. data/lib/merged_api/exceptions/insured_risks500_error1_exception.rb +41 -0
  21. data/lib/merged_api/exceptions/o_auth_provider_exception.rb +48 -0
  22. data/lib/merged_api/exceptions/policies400_error1_exception.rb +41 -0
  23. data/lib/merged_api/exceptions/policies401_error1_exception.rb +32 -0
  24. data/lib/merged_api/exceptions/policies403_error1_exception.rb +41 -0
  25. data/lib/merged_api/exceptions/policies500_error1_exception.rb +41 -0
  26. data/lib/merged_api/exceptions/quotes400_error1_exception.rb +41 -0
  27. data/lib/merged_api/exceptions/quotes401_error1_exception.rb +32 -0
  28. data/lib/merged_api/exceptions/quotes500_error1_exception.rb +41 -0
  29. data/lib/merged_api/http/auth/o_auth2.rb +63 -0
  30. data/lib/merged_api/http/http_call_back.rb +10 -0
  31. data/lib/merged_api/http/http_method_enum.rb +10 -0
  32. data/lib/merged_api/http/http_request.rb +10 -0
  33. data/lib/merged_api/http/http_response.rb +10 -0
  34. data/lib/merged_api/models/accept_enum.rb +14 -0
  35. data/lib/merged_api/models/additional_insured.rb +68 -0
  36. data/lib/merged_api/models/additional_interests.rb +68 -0
  37. data/lib/merged_api/models/agent.rb +48 -0
  38. data/lib/merged_api/models/agent3.rb +48 -0
  39. data/lib/merged_api/models/agent6.rb +48 -0
  40. data/lib/merged_api/models/attributes.rb +87 -0
  41. data/lib/merged_api/models/attributes1.rb +80 -0
  42. data/lib/merged_api/models/attributes10.rb +86 -0
  43. data/lib/merged_api/models/attributes11.rb +137 -0
  44. data/lib/merged_api/models/attributes12.rb +48 -0
  45. data/lib/merged_api/models/attributes2.rb +80 -0
  46. data/lib/merged_api/models/attributes3.rb +412 -0
  47. data/lib/merged_api/models/attributes4.rb +126 -0
  48. data/lib/merged_api/models/attributes5.rb +80 -0
  49. data/lib/merged_api/models/attributes6.rb +422 -0
  50. data/lib/merged_api/models/attributes9.rb +284 -0
  51. data/lib/merged_api/models/auth_oauth2_token_response.rb +70 -0
  52. data/lib/merged_api/models/base_model.rb +58 -0
  53. data/lib/merged_api/models/billing_address.rb +86 -0
  54. data/lib/merged_api/models/content_type1_enum.rb +14 -0
  55. data/lib/merged_api/models/content_type_enum.rb +14 -0
  56. data/lib/merged_api/models/coverage.rb +48 -0
  57. data/lib/merged_api/models/coverages.rb +68 -0
  58. data/lib/merged_api/models/coverages2.rb +57 -0
  59. data/lib/merged_api/models/coverages3.rb +57 -0
  60. data/lib/merged_api/models/customer.rb +48 -0
  61. data/lib/merged_api/models/customer2.rb +48 -0
  62. data/lib/merged_api/models/customer3.rb +48 -0
  63. data/lib/merged_api/models/data.rb +77 -0
  64. data/lib/merged_api/models/data1.rb +57 -0
  65. data/lib/merged_api/models/data11.rb +57 -0
  66. data/lib/merged_api/models/data12.rb +57 -0
  67. data/lib/merged_api/models/data18.rb +57 -0
  68. data/lib/merged_api/models/data19.rb +57 -0
  69. data/lib/merged_api/models/data2.rb +57 -0
  70. data/lib/merged_api/models/data20.rb +57 -0
  71. data/lib/merged_api/models/data21.rb +57 -0
  72. data/lib/merged_api/models/data24.rb +87 -0
  73. data/lib/merged_api/models/data3.rb +75 -0
  74. data/lib/merged_api/models/data39.rb +66 -0
  75. data/lib/merged_api/models/data40.rb +58 -0
  76. data/lib/merged_api/models/data41.rb +58 -0
  77. data/lib/merged_api/models/data42.rb +58 -0
  78. data/lib/merged_api/models/data43.rb +57 -0
  79. data/lib/merged_api/models/data44.rb +57 -0
  80. data/lib/merged_api/models/data45.rb +76 -0
  81. data/lib/merged_api/models/data46.rb +57 -0
  82. data/lib/merged_api/models/data47.rb +57 -0
  83. data/lib/merged_api/models/data6.rb +66 -0
  84. data/lib/merged_api/models/data7.rb +57 -0
  85. data/lib/merged_api/models/data8.rb +57 -0
  86. data/lib/merged_api/models/data9.rb +76 -0
  87. data/lib/merged_api/models/endorsement.rb +48 -0
  88. data/lib/merged_api/models/entity_type_enum.rb +17 -0
  89. data/lib/merged_api/models/errors.rb +61 -0
  90. data/lib/merged_api/models/errors1.rb +60 -0
  91. data/lib/merged_api/models/expires_in_enum.rb +14 -0
  92. data/lib/merged_api/models/grant_type_enum.rb +14 -0
  93. data/lib/merged_api/models/included.rb +75 -0
  94. data/lib/merged_api/models/included1.rb +75 -0
  95. data/lib/merged_api/models/included3.rb +76 -0
  96. data/lib/merged_api/models/included31.rb +67 -0
  97. data/lib/merged_api/models/included32.rb +67 -0
  98. data/lib/merged_api/models/included4.rb +85 -0
  99. data/lib/merged_api/models/included41.rb +85 -0
  100. data/lib/merged_api/models/included42.rb +85 -0
  101. data/lib/merged_api/models/installment_plan.rb +49 -0
  102. data/lib/merged_api/models/installment_plan2.rb +85 -0
  103. data/lib/merged_api/models/insured_risk.rb +48 -0
  104. data/lib/merged_api/models/insured_risk2.rb +48 -0
  105. data/lib/merged_api/models/insured_risk3.rb +48 -0
  106. data/lib/merged_api/models/insured_risks_request.rb +48 -0
  107. data/lib/merged_api/models/insured_risks_response.rb +48 -0
  108. data/lib/merged_api/models/mailing_address.rb +86 -0
  109. data/lib/merged_api/models/meta.rb +50 -0
  110. data/lib/merged_api/models/o_auth_provider_error_enum.rb +39 -0
  111. data/lib/merged_api/models/o_auth_token.rb +100 -0
  112. data/lib/merged_api/models/operation_type_enum.rb +23 -0
  113. data/lib/merged_api/models/parent.rb +48 -0
  114. data/lib/merged_api/models/policies_request.rb +48 -0
  115. data/lib/merged_api/models/policies_response.rb +59 -0
  116. data/lib/merged_api/models/policies_response1.rb +57 -0
  117. data/lib/merged_api/models/policy.rb +48 -0
  118. data/lib/merged_api/models/policy_state2_enum.rb +164 -0
  119. data/lib/merged_api/models/policy_state_enum.rb +165 -0
  120. data/lib/merged_api/models/product.rb +49 -0
  121. data/lib/merged_api/models/product2.rb +49 -0
  122. data/lib/merged_api/models/product3.rb +48 -0
  123. data/lib/merged_api/models/product6.rb +50 -0
  124. data/lib/merged_api/models/product_coverage.rb +48 -0
  125. data/lib/merged_api/models/quotes_request.rb +57 -0
  126. data/lib/merged_api/models/quotes_response.rb +57 -0
  127. data/lib/merged_api/models/relationships.rb +61 -0
  128. data/lib/merged_api/models/relationships1.rb +59 -0
  129. data/lib/merged_api/models/relationships10.rb +49 -0
  130. data/lib/merged_api/models/relationships11.rb +90 -0
  131. data/lib/merged_api/models/relationships13.rb +48 -0
  132. data/lib/merged_api/models/relationships14.rb +60 -0
  133. data/lib/merged_api/models/relationships2.rb +61 -0
  134. data/lib/merged_api/models/relationships3.rb +127 -0
  135. data/lib/merged_api/models/relationships4.rb +66 -0
  136. data/lib/merged_api/models/relationships5.rb +57 -0
  137. data/lib/merged_api/models/relationships9.rb +81 -0
  138. data/lib/merged_api/models/state_enum.rb +164 -0
  139. data/lib/merged_api/models/status2_enum.rb +26 -0
  140. data/lib/merged_api/models/status_enum.rb +32 -0
  141. data/lib/merged_api/models/token_type_enum.rb +14 -0
  142. data/lib/merged_api/utilities/date_time_helper.rb +11 -0
  143. data/lib/merged_api/utilities/file_wrapper.rb +16 -0
  144. data/lib/merged_api.rb +165 -0
  145. data/test/controllers/controller_test_base.rb +33 -0
  146. data/test/controllers/test_policy_controller.rb +36 -0
  147. data/test/controllers/test_simple_calculator_controller.rb +34 -0
  148. data/test/http_response_catcher.rb +19 -0
  149. metadata +267 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b04fda3441726cfefb7313d6887fcb1fede8c81cb60419f7cfd4bfa0d8451d5c
4
+ data.tar.gz: df92602b1c4ddf952bc6d264d4f73da784552ba0ba3cad09d1d45754531c6ac5
5
+ SHA512:
6
+ metadata.gz: fe6a04ceeb74279f80d8666187fa2f1b2faa945fe09af330ebdbc156428760abc2bd5606ca82c0cc18503555a3f192e3b6299fb266026ea01bfce9cc5c893855
7
+ data.tar.gz: 40e22bbe5520b600b60ee9682c9402a39792284132549b5cfda7d1e3d2fc9ddffc2dd409456fcec506b0ab3da25f3750f78d9f8dfe8aa66260c7697a7c36afc5
data/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ License:
2
+ ========
3
+ The MIT License (MIT)
4
+ http://opensource.org/licenses/MIT
5
+
6
+ Copyright (c) 2014 - 2023 APIMATIC Limited
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
26
+ Trade Mark:
27
+ ==========
28
+ APIMATIC is a trade mark for APIMATIC Limited
data/README.md ADDED
@@ -0,0 +1,193 @@
1
+
2
+ # Getting Started with Merged Api
3
+
4
+ ## Introduction
5
+
6
+ Boost API example documentation.
7
+
8
+ ### Authentication
9
+
10
+ <!-- ReDoc-Inject: <security-definitions> -->, Simple calculator API hosted on APIMATIC
11
+
12
+
13
+ ## Install the Package
14
+
15
+ Install the gem from the command line:
16
+
17
+ ```ruby
18
+ gem install petstore-test-18052023 -v 1.0.1-alpha.1
19
+ ```
20
+
21
+ Or add the gem to your Gemfile and run `bundle`:
22
+
23
+ ```ruby
24
+ gem 'petstore-test-18052023', '1.0.1-alpha.1'
25
+ ```
26
+
27
+ For additional gem details, see the [RubyGems page for the petstore-test-18052023 gem](https://rubygems.org/gems/petstore-test-18052023/versions/1.0.1-alpha.1).
28
+
29
+ ## Test the SDK
30
+
31
+ To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
32
+
33
+ ```
34
+ rake
35
+ ```
36
+
37
+ ## Initialize the API Client
38
+
39
+ **_Note:_** Documentation for the client can be found [here.](doc/client.md)
40
+
41
+ The following parameters are configurable for the API Client:
42
+
43
+ | Parameter | Type | Description |
44
+ | --- | --- | --- |
45
+ | `environment` | Environment | The API environment. <br> **Default: `Environment.PRODUCTION22`** |
46
+ | `connection` | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
47
+ | `adapter` | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
48
+ | `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
49
+ | `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
50
+ | `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
51
+ | `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
52
+ | `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
53
+ | `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
54
+ | `http_callback` | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
55
+ | `o_auth_client_id` | `String` | OAuth 2 Client ID |
56
+ | `o_auth_client_secret` | `String` | OAuth 2 Client Secret |
57
+ | `o_auth_token` | `OAuthToken` | Object for storing information about the OAuth token |
58
+
59
+ The API client can be initialized as follows:
60
+
61
+ ```ruby
62
+ client = MergedApi::Client.new(
63
+ o_auth_client_id: 'OAuthClientId',
64
+ o_auth_client_secret: 'OAuthClientSecret',
65
+ environment: Environment::PRODUCTION22
66
+ )
67
+ ```
68
+
69
+ ## Environments
70
+
71
+ The SDK can be configured to use a different environment for making API calls. Available environments are:
72
+
73
+ ### Fields
74
+
75
+ | Name | Description |
76
+ | --- | --- |
77
+ | production22 | **Default** Production environment, This environment connect to the LIVE calculator API |
78
+ | development | development |
79
+
80
+ ## Authorization
81
+
82
+ This API uses `OAuth 2 Client Credentials Grant`.
83
+
84
+ ## Client Credentials Grant
85
+
86
+ Your application must obtain user authorization before it can execute an endpoint call in case this SDK chooses to use *OAuth 2.0 Client Credentials Grant*. This authorization includes the following steps
87
+
88
+ The `fetch_token()` method will exchange the OAuth client credentials for an *access token*. The access token is an object containing information for authorizing client requests and refreshing the token itself.
89
+
90
+ ```ruby
91
+ begin
92
+ token = client.auth.fetch_token
93
+ # update the cloned configuration with the token
94
+ config = client.config.clone_with(o_auth_token: token)
95
+ # re-instantiate the client with updated configuration
96
+ client = MergedApi::Client.new(config: config)
97
+ rescue OAuthProviderException => ex
98
+ # handle exception
99
+ rescue APIException => ex
100
+ # handle exception
101
+ end
102
+ ```
103
+
104
+ The client can now make authorized endpoint calls.
105
+
106
+ ### Storing an access token for reuse
107
+
108
+ It is recommended that you store the access token for reuse.
109
+
110
+ ```ruby
111
+ # store token
112
+ save_token_to_database(client.config.o_auth_token)
113
+ ```
114
+
115
+ ### Creating a client from a stored token
116
+
117
+ To authorize a client from a stored access token, just set the access token in Configuration along with the other configuration parameters before creating the client:
118
+
119
+ ```ruby
120
+ # load token later...
121
+ token = load_token_from_database
122
+
123
+ # Update the cloned configuration with the token
124
+ config = client.config.clone_with(o_auth_token: token)
125
+ # Re-instantiate the client with updated configuration
126
+ client = Client.new(config: config)
127
+ ```
128
+
129
+ ### Complete example
130
+
131
+ ```ruby
132
+ require 'merged_api'
133
+
134
+ include merged_api
135
+
136
+ # function for storing token to database
137
+ def save_token_to_database(token)
138
+ # code to save the token to database
139
+ end
140
+
141
+ # function for loading token from database
142
+ def load_token_from_database
143
+ # load token from database and return it (return nil if no token exists)
144
+ end
145
+
146
+ # create a new client
147
+ client = MergedApi::Client.new(
148
+ o_auth_client_id: 'OAuthClientId',
149
+ o_auth_client_secret: 'OAuthClientSecret',
150
+ environment: Environment::PRODUCTION22
151
+ )
152
+
153
+ # obtain access token, needed for client to be authorized
154
+ previous_token = load_token_from_database
155
+ if previous_token
156
+ # update the cloned configuration with the restored token
157
+ config = client.config.clone_with(o_auth_token: previous_token)
158
+ # re-instantiate the client with updated configuration
159
+ client = MergedApi::Client.new(config: config)
160
+ else
161
+ # obtain new access token
162
+ begin
163
+ token = client.auth.fetch_token
164
+ save_token_to_database(token)
165
+ # update the cloned configuration with the token
166
+ config = client.config.clone_with(o_auth_token: token)
167
+ # re-instantiate the client with updated configuration
168
+ client = MergedApi::Client.new(config: config)
169
+ rescue APIException => ex
170
+ # handle exception
171
+ rescue APIException => ex
172
+ # handle exception
173
+ end
174
+ end
175
+
176
+ # the client is now authorized; you can use client to make endpoint calls
177
+ ```
178
+
179
+ ## List of APIs
180
+
181
+ * [Simple Calculator](doc/controllers/simple-calculator.md)
182
+ * [O Auth Authorization](doc/controllers/o-auth-authorization.md)
183
+ * [Authentication](doc/controllers/authentication.md)
184
+ * [Quoting](doc/controllers/quoting.md)
185
+ * [Policy](doc/controllers/policy.md)
186
+ * [Insured-Risk](doc/controllers/insured-risk.md)
187
+
188
+ ## Classes Documentation
189
+
190
+ * [Utility Classes](doc/utility-classes.md)
191
+ * [HttpResponse](doc/http-response.md)
192
+ * [HttpRequest](doc/http-request.md)
193
+
@@ -0,0 +1,10 @@
1
+ # merged_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module MergedApi
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,97 @@
1
+ # merged_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module MergedApi
7
+ # merged_api client class.
8
+ class Client
9
+ attr_reader :config, :auth_managers
10
+
11
+ # Returns the configured authentication instance.
12
+ def auth
13
+ @auth_managers['global']
14
+ end
15
+
16
+ # Access to quoting controller.
17
+ # @return [QuotingController] Returns the controller instance.
18
+ def quoting
19
+ @quoting ||= QuotingController.new @global_configuration
20
+ end
21
+
22
+ # Access to policy controller.
23
+ # @return [PolicyController] Returns the controller instance.
24
+ def policy
25
+ @policy ||= PolicyController.new @global_configuration
26
+ end
27
+
28
+ # Access to insured_risk controller.
29
+ # @return [InsuredRiskController] Returns the controller instance.
30
+ def insured_risk
31
+ @insured_risk ||= InsuredRiskController.new @global_configuration
32
+ end
33
+
34
+ # Access to simple_calculator controller.
35
+ # @return [SimpleCalculatorController] Returns the controller instance.
36
+ def simple_calculator
37
+ @simple_calculator ||= SimpleCalculatorController.new @global_configuration
38
+ end
39
+
40
+ # Access to authentication controller.
41
+ # @return [AuthenticationController] Returns the controller instance.
42
+ def authentication
43
+ @authentication ||= AuthenticationController.new @global_configuration
44
+ end
45
+
46
+ # Access to o_auth_authorization controller.
47
+ # @return [OAuthAuthorizationController] Returns the controller instance.
48
+ def o_auth_authorization
49
+ @o_auth_authorization ||= OAuthAuthorizationController.new @global_configuration
50
+ end
51
+
52
+ def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
53
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
54
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
55
+ retry_methods: %i[get put], http_callback: nil,
56
+ environment: Environment::PRODUCTION22,
57
+ o_auth_client_id: 'TODO: Replace',
58
+ o_auth_client_secret: 'TODO: Replace', o_auth_token: nil,
59
+ config: nil)
60
+ @config = if config.nil?
61
+ Configuration.new(connection: connection, adapter: adapter,
62
+ timeout: timeout, max_retries: max_retries,
63
+ retry_interval: retry_interval,
64
+ backoff_factor: backoff_factor,
65
+ retry_statuses: retry_statuses,
66
+ retry_methods: retry_methods,
67
+ http_callback: http_callback,
68
+ environment: environment,
69
+ o_auth_client_id: o_auth_client_id,
70
+ o_auth_client_secret: o_auth_client_secret,
71
+ o_auth_token: o_auth_token)
72
+ else
73
+ config
74
+ end
75
+
76
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
77
+ .base_uri_executor(@config.method(:get_base_uri))
78
+ .global_errors(BaseController::GLOBAL_ERRORS)
79
+ .user_agent(BaseController.user_agent)
80
+ .sdk_module(MergedApi)
81
+
82
+ initialize_auth_managers(@global_configuration)
83
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
84
+ end
85
+
86
+ # Initializes the auth managers hash used for authenticating API calls.
87
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
88
+ def initialize_auth_managers(global_config)
89
+ @auth_managers = {}
90
+ http_client_config = global_config.client_configuration
91
+ ['global'].each { |auth| @auth_managers[auth] = nil }
92
+ @auth_managers['global'] = OAuth2.new(http_client_config.o_auth_client_id,
93
+ http_client_config.o_auth_client_secret,
94
+ http_client_config.o_auth_token, global_config)
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,127 @@
1
+ # merged_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module MergedApi
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ # PRODUCTION22: Production environment, This environment connect to the LIVE calculator API
10
+ # DEVELOPMENT: development
11
+ ENVIRONMENT = [
12
+ PRODUCTION22 = 'production22'.freeze,
13
+ DEVELOPMENT = 'development'.freeze
14
+ ].freeze
15
+ end
16
+
17
+ # An enum for API servers.
18
+ class Server
19
+ SERVER = [
20
+ DEFAULT = 'default'.freeze,
21
+ CALCULATOR = 'Calculator'.freeze
22
+ ].freeze
23
+ end
24
+
25
+ # All configuration including auth info and base URI for the API access
26
+ # are configured in this class.
27
+ class Configuration < CoreLibrary::HttpClientConfiguration
28
+ # The attribute readers for properties.
29
+ attr_reader :environment, :o_auth_client_id, :o_auth_client_secret
30
+
31
+ def o_auth_token
32
+ if @o_auth_token.is_a? OAuthToken
33
+ OAuthToken.from_hash @o_auth_token.to_hash
34
+ else
35
+ @o_auth_token
36
+ end
37
+ end
38
+
39
+ class << self
40
+ attr_reader :environments
41
+ end
42
+
43
+ def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
44
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
45
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
46
+ retry_methods: %i[get put], http_callback: nil,
47
+ environment: Environment::PRODUCTION22,
48
+ o_auth_client_id: 'TODO: Replace',
49
+ o_auth_client_secret: 'TODO: Replace', o_auth_token: nil)
50
+
51
+ super connection: connection, adapter: adapter, timeout: timeout,
52
+ max_retries: max_retries, retry_interval: retry_interval,
53
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
54
+ retry_methods: retry_methods, http_callback: http_callback
55
+
56
+ # Current API environment
57
+ @environment = String(environment)
58
+
59
+ # OAuth 2 Client ID
60
+ @o_auth_client_id = o_auth_client_id
61
+
62
+ # OAuth 2 Client Secret
63
+ @o_auth_client_secret = o_auth_client_secret
64
+
65
+ # Object for storing information about the OAuth token
66
+ @o_auth_token = if o_auth_token.is_a? OAuthToken
67
+ OAuthToken.from_hash o_auth_token.to_hash
68
+ else
69
+ o_auth_token
70
+ end
71
+
72
+ # The Http Client to use for making requests.
73
+ set_http_client CoreLibrary::FaradayClient.new(self)
74
+ end
75
+
76
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
77
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
78
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
79
+ environment: nil, o_auth_client_id: nil,
80
+ o_auth_client_secret: nil, o_auth_token: nil)
81
+ connection ||= self.connection
82
+ adapter ||= self.adapter
83
+ timeout ||= self.timeout
84
+ max_retries ||= self.max_retries
85
+ retry_interval ||= self.retry_interval
86
+ backoff_factor ||= self.backoff_factor
87
+ retry_statuses ||= self.retry_statuses
88
+ retry_methods ||= self.retry_methods
89
+ http_callback ||= self.http_callback
90
+ environment ||= self.environment
91
+ o_auth_client_id ||= self.o_auth_client_id
92
+ o_auth_client_secret ||= self.o_auth_client_secret
93
+ o_auth_token ||= self.o_auth_token
94
+
95
+ Configuration.new(connection: connection, adapter: adapter,
96
+ timeout: timeout, max_retries: max_retries,
97
+ retry_interval: retry_interval,
98
+ backoff_factor: backoff_factor,
99
+ retry_statuses: retry_statuses,
100
+ retry_methods: retry_methods,
101
+ http_callback: http_callback, environment: environment,
102
+ o_auth_client_id: o_auth_client_id,
103
+ o_auth_client_secret: o_auth_client_secret,
104
+ o_auth_token: o_auth_token)
105
+ end
106
+
107
+ # All the environments the SDK can run in.
108
+ ENVIRONMENTS = {
109
+ Environment::PRODUCTION22 => {
110
+ Server::DEFAULT => 'https://api.insurtech.dev',
111
+ Server::CALCULATOR => 'https://examples.apimatic.io/apps/calculator'
112
+ },
113
+ Environment::DEVELOPMENT => {
114
+ Server::DEFAULT => 'https://staging.api.insurtech.dev',
115
+ Server::CALCULATOR => 'https://examples.apimatic.io/apps/calculator'
116
+ }
117
+ }.freeze
118
+
119
+ # Generates the appropriate base URI for the environment and the server.
120
+ # @param [Configuration::Server] server The server enum for which the base URI is
121
+ # required.
122
+ # @return [String] The base URI.
123
+ def get_base_uri(server = Server::DEFAULT)
124
+ ENVIRONMENTS[environment][server].clone
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,36 @@
1
+ # merged_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module MergedApi
7
+ # AuthenticationController
8
+ class AuthenticationController < BaseController
9
+ # Generates an access token which must be used on all subsequent API calls.
10
+ # @param [String] client_id Required parameter: Your Client ID
11
+ # @param [String] client_secret Required parameter: Your Client Secret
12
+ # @return [AuthOauth2TokenResponse] response from the API call
13
+ def get_o_auth_token(client_id,
14
+ client_secret)
15
+ new_api_call_builder
16
+ .request(new_request_builder(HttpMethodEnum::POST,
17
+ '/auth/oauth2/token',
18
+ Server::DEFAULT)
19
+ .form_param(new_parameter(client_id, key: 'client_id'))
20
+ .form_param(new_parameter(client_secret, key: 'client_secret'))
21
+ .form_param(new_parameter('client_credentials', key: 'grant_type'))
22
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
23
+ .header_param(new_parameter('application/json', key: 'accept')))
24
+ .response(new_response_handler
25
+ .deserializer(APIHelper.method(:custom_type_deserializer))
26
+ .deserialize_into(AuthOauth2TokenResponse.method(:from_hash))
27
+ .local_error('400',
28
+ 'Request is invalid',
29
+ AuthOauth2Token400Error1Exception)
30
+ .local_error('500',
31
+ 'Internal Server Error',
32
+ APIException))
33
+ .execute
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,65 @@
1
+ # merged_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module MergedApi
7
+ # BaseController.
8
+ class BaseController
9
+ attr_accessor :config, :http_call_back
10
+
11
+ def self.user_agent
12
+ 'APIMATIC 3.0'
13
+ end
14
+
15
+
16
+ GLOBAL_ERRORS = {
17
+ 'default' => ErrorCase.new
18
+ .error_message('HTTP response not OK.')
19
+ .exception_type(APIException)
20
+ }.freeze
21
+
22
+ # Initialization constructor.
23
+ # @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
24
+ def initialize(global_configuration)
25
+ @global_configuration = global_configuration
26
+ @config = @global_configuration.client_configuration
27
+ @http_call_back = @config.http_callback
28
+ @api_call = ApiCall.new(@global_configuration)
29
+ end
30
+
31
+ # Creates a new builder for the Api Call instance.
32
+ # @return [ApiCall] The instance of ApiCall.
33
+ def new_api_call_builder
34
+ @api_call.new_builder
35
+ end
36
+
37
+ # Creates a new instance of the request builder.
38
+ # @param [HttpMethodEnum] http_method The HTTP method to use in the request.
39
+ # @param [String] path The endpoint path to use in the request.
40
+ # @param [String] server The server to extract the base uri for the request.
41
+ # @return [RequestBuilder] The instance of RequestBuilder.
42
+ def new_request_builder(http_method, path, server)
43
+ RequestBuilder.new
44
+ .http_method(http_method)
45
+ .path(path)
46
+ .server(server)
47
+ end
48
+
49
+ # Creates a new instance of the response handler.
50
+ # @return [ResponseHandler] The instance of ResponseHandler.
51
+ def new_response_handler
52
+ ResponseHandler.new
53
+ end
54
+
55
+ # Creates a new instance of the parameter.
56
+ # @param [String|optional] key The key of the parameter.
57
+ # @param [Object] value The value of the parameter.
58
+ # @return [Parameter] The instance of Parameter.
59
+ def new_parameter(value, key: nil)
60
+ Parameter.new
61
+ .key(key)
62
+ .value(value)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,47 @@
1
+ # merged_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module MergedApi
7
+ # InsuredRiskController
8
+ class InsuredRiskController < BaseController
9
+ # Creates a new insured risk to then utilize when creating a policy.
10
+ # @param [UUID | String] boost_user Required parameter: UUID that identifies
11
+ # the user.
12
+ # @param [InsuredRisksRequest] body Required parameter: Example:
13
+ # @return [InsuredRisksResponse] response from the API call
14
+ def post_insured_risk(boost_user,
15
+ body)
16
+ new_api_call_builder
17
+ .request(new_request_builder(HttpMethodEnum::POST,
18
+ '/insured-risks',
19
+ Server::DEFAULT)
20
+ .header_param(new_parameter(boost_user, key: 'Boost-User'))
21
+ .header_param(new_parameter('application/vnd.api+json', key: 'Content-Type'))
22
+ .body_param(new_parameter(body))
23
+ .header_param(new_parameter('application/json', key: 'accept'))
24
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
25
+ .auth(Single.new('global')))
26
+ .response(new_response_handler
27
+ .deserializer(APIHelper.method(:custom_type_deserializer))
28
+ .deserialize_into(InsuredRisksResponse.method(:from_hash))
29
+ .local_error('400',
30
+ 'Request is invalid.',
31
+ InsuredRisks400Error1Exception)
32
+ .local_error('401',
33
+ 'Unauthorized. The bearer authentication failed.',
34
+ InsuredRisks401Error1Exception)
35
+ .local_error('403',
36
+ 'Forbidden. The operation is not allowed.',
37
+ InsuredRisks403Error1Exception)
38
+ .local_error('415',
39
+ 'Unsupported Media Type. Only JSONAPI is supported.',
40
+ InsuredRisks415Error1Exception)
41
+ .local_error('500',
42
+ 'Internal Server Error.',
43
+ InsuredRisks500Error1Exception))
44
+ .execute
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,42 @@
1
+ # merged_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module MergedApi
7
+ # OAuthAuthorizationController
8
+ class OAuthAuthorizationController < BaseController
9
+ # Create a new OAuth 2 token.
10
+ # @param [String] authorization Required parameter: Authorization header in
11
+ # Basic auth format
12
+ # @param [String] scope Optional parameter: Requested scopes as a
13
+ # space-delimited list.
14
+ # @param [Hash] _field_parameters Additional optional form parameters are
15
+ # supported by this endpoint.
16
+ # @return [OAuthToken] response from the API call
17
+ def request_token(authorization,
18
+ scope: nil,
19
+ _field_parameters: nil)
20
+ new_api_call_builder
21
+ .request(new_request_builder(HttpMethodEnum::POST,
22
+ '/auth/oauth2/token',
23
+ Server::DEFAULT)
24
+ .form_param(new_parameter('client_credentials', key: 'grant_type'))
25
+ .header_param(new_parameter(authorization, key: 'Authorization'))
26
+ .form_param(new_parameter(scope, key: 'scope'))
27
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
28
+ .header_param(new_parameter('application/json', key: 'accept'))
29
+ .additional_form_params(_field_parameters))
30
+ .response(new_response_handler
31
+ .deserializer(APIHelper.method(:custom_type_deserializer))
32
+ .deserialize_into(OAuthToken.method(:from_hash))
33
+ .local_error('400',
34
+ 'OAuth 2 provider returned an error.',
35
+ OAuthProviderException)
36
+ .local_error('401',
37
+ 'OAuth 2 provider says client authentication failed.',
38
+ OAuthProviderException))
39
+ .execute
40
+ end
41
+ end
42
+ end