devdraft 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +155 -253
  3. data/Rakefile +2 -0
  4. data/devdraft-1.0.0.gem +0 -0
  5. data/{devdraft_ai_sdk.gemspec → devdraft.gemspec} +15 -11
  6. data/docs/APIHealthApi.md +82 -30
  7. data/docs/AggregatedBalanceResponse.md +19 -6
  8. data/docs/AllBalancesResponse.md +19 -6
  9. data/docs/AppBalancesApi.md +125 -65
  10. data/docs/BridgeFiatPaymentRail.md +15 -0
  11. data/docs/BridgePaymentRail.md +12 -3
  12. data/docs/CreateBankPaymentIntentDto.md +49 -21
  13. data/docs/CreateCustomerDto.md +25 -9
  14. data/docs/CreateDirectBankTransferDto.md +29 -11
  15. data/docs/CreateDirectWalletTransferDto.md +21 -7
  16. data/docs/CreateExternalBankTransferDto.md +40 -0
  17. data/docs/CreateExternalStablecoinTransferDto.md +28 -0
  18. data/docs/CreateInvoiceDto.md +45 -19
  19. data/docs/CreateLiquidationAddressDto.md +43 -18
  20. data/docs/CreatePaymentLinkDto.md +53 -28
  21. data/docs/CreateStablePaymentIntentDto.md +43 -18
  22. data/docs/CreateStablecoinConversionDto.md +23 -8
  23. data/docs/CreateTaxDto.md +26 -0
  24. data/docs/CreateWebhookDto.md +23 -8
  25. data/docs/CustomerStatus.md +12 -3
  26. data/docs/CustomerType.md +15 -0
  27. data/docs/CustomersApi.md +187 -114
  28. data/docs/DestinationCurrency.md +12 -3
  29. data/docs/ExchangeRateResponseDto.md +25 -9
  30. data/docs/ExchangeRatesApi.md +130 -72
  31. data/docs/FiatCurrency.md +12 -3
  32. data/docs/HealthResponseDto.md +25 -9
  33. data/docs/InvoiceProductDto.md +17 -5
  34. data/docs/InvoicesApi.md +177 -104
  35. data/docs/LiquidationAddressResponseDto.md +41 -17
  36. data/docs/LiquidationAddressesApi.md +115 -61
  37. data/docs/PaymentIntentsApi.md +93 -57
  38. data/docs/PaymentLinkProductDto.md +17 -5
  39. data/docs/PaymentLinksApi.md +175 -102
  40. data/docs/PaymentRequestDto.md +21 -7
  41. data/docs/PaymentResponseDto.md +23 -8
  42. data/docs/ProductsApi.md +307 -194
  43. data/docs/PublicHealthResponseDto.md +19 -6
  44. data/docs/RefundResponseDto.md +23 -8
  45. data/docs/StableCoinCurrency.md +12 -3
  46. data/docs/TaxControllerCreate201Response.md +30 -0
  47. data/docs/TaxControllerDeleteWithoutId400Response.md +22 -0
  48. data/docs/TaxControllerUpdateWithoutId400Response.md +22 -0
  49. data/docs/TaxesApi.md +374 -122
  50. data/docs/TestPaymentsApi.md +150 -60
  51. data/docs/TransfersApi.md +274 -72
  52. data/docs/UpdateCustomerDto.md +25 -9
  53. data/docs/UpdateTaxDto.md +26 -0
  54. data/docs/UpdateWebhookDto.md +23 -8
  55. data/docs/WalletsApi.md +44 -24
  56. data/docs/WebhookResponseDto.md +29 -11
  57. data/docs/WebhooksApi.md +225 -134
  58. data/git_push.sh +41 -28
  59. data/lib/devdraft/api/api_health_api.rb +32 -16
  60. data/lib/devdraft/api/app_balances_api.rb +45 -22
  61. data/lib/devdraft/api/customers_api.rb +124 -71
  62. data/lib/devdraft/api/exchange_rates_api.rb +49 -26
  63. data/lib/devdraft/api/invoices_api.rb +89 -53
  64. data/lib/devdraft/api/liquidation_addresses_api.rb +70 -44
  65. data/lib/devdraft/api/payment_intents_api.rb +62 -40
  66. data/lib/devdraft/api/payment_links_api.rb +85 -49
  67. data/lib/devdraft/api/products_api.rb +214 -216
  68. data/lib/devdraft/api/taxes_api.rb +257 -66
  69. data/lib/devdraft/api/test_payments_api.rb +70 -44
  70. data/lib/devdraft/api/transfers_api.rb +206 -46
  71. data/lib/devdraft/api/wallets_api.rb +18 -9
  72. data/lib/devdraft/api/webhooks_api.rb +109 -66
  73. data/lib/devdraft/api_client.rb +76 -71
  74. data/lib/devdraft/api_error.rb +5 -4
  75. data/lib/devdraft/api_model_base.rb +88 -0
  76. data/lib/devdraft/configuration.rb +121 -18
  77. data/lib/devdraft/models/aggregated_balance_response.rb +68 -101
  78. data/lib/devdraft/models/all_balances_response.rb +76 -99
  79. data/lib/devdraft/models/bridge_fiat_payment_rail.rb +45 -0
  80. data/lib/devdraft/models/bridge_payment_rail.rb +36 -24
  81. data/lib/devdraft/models/create_bank_payment_intent_dto.rb +191 -114
  82. data/lib/devdraft/models/create_customer_dto.rb +123 -113
  83. data/lib/devdraft/models/create_direct_bank_transfer_dto.rb +105 -104
  84. data/lib/devdraft/models/create_direct_wallet_transfer_dto.rb +89 -100
  85. data/lib/devdraft/models/create_external_bank_transfer_dto.rb +505 -0
  86. data/lib/devdraft/models/create_external_stablecoin_transfer_dto.rb +266 -0
  87. data/lib/devdraft/models/create_invoice_dto.rb +151 -121
  88. data/lib/devdraft/models/create_liquidation_address_dto.rb +195 -115
  89. data/lib/devdraft/models/create_payment_link_dto.rb +192 -214
  90. data/lib/devdraft/models/create_stable_payment_intent_dto.rb +324 -111
  91. data/lib/devdraft/models/create_stablecoin_conversion_dto.rb +102 -101
  92. data/lib/devdraft/models/create_tax_dto.rb +281 -0
  93. data/lib/devdraft/models/create_webhook_dto.rb +104 -101
  94. data/lib/devdraft/models/customer_status.rb +23 -10
  95. data/lib/devdraft/models/customer_type.rb +45 -0
  96. data/lib/devdraft/models/destination_currency.rb +27 -15
  97. data/lib/devdraft/models/exchange_rate_response_dto.rb +103 -102
  98. data/lib/devdraft/models/fiat_currency.rb +22 -10
  99. data/lib/devdraft/models/health_response_dto.rb +99 -106
  100. data/lib/devdraft/models/invoice_product_dto.rb +63 -98
  101. data/lib/devdraft/models/liquidation_address_response_dto.rb +147 -110
  102. data/lib/devdraft/models/payment_link_product_dto.rb +70 -98
  103. data/lib/devdraft/models/payment_request_dto.rb +77 -100
  104. data/lib/devdraft/models/payment_response_dto.rb +102 -101
  105. data/lib/devdraft/models/public_health_response_dto.rb +68 -101
  106. data/lib/devdraft/models/refund_response_dto.rb +102 -101
  107. data/lib/devdraft/models/stable_coin_currency.rb +21 -9
  108. data/lib/devdraft/models/tax_controller_create201_response.rb +201 -0
  109. data/lib/devdraft/models/tax_controller_delete_without_id400_response.rb +165 -0
  110. data/lib/devdraft/models/tax_controller_update_without_id400_response.rb +165 -0
  111. data/lib/devdraft/models/update_customer_dto.rb +117 -113
  112. data/lib/devdraft/models/update_tax_dto.rb +256 -0
  113. data/lib/devdraft/models/update_webhook_dto.rb +70 -101
  114. data/lib/devdraft/models/webhook_response_dto.rb +140 -103
  115. data/lib/devdraft/version.rb +6 -5
  116. data/lib/devdraft.rb +18 -27
  117. data/spec/api/api_health_api_spec.rb +10 -9
  118. data/spec/api/app_balances_api_spec.rb +11 -10
  119. data/spec/api/customers_api_spec.rb +25 -24
  120. data/spec/api/exchange_rates_api_spec.rb +11 -10
  121. data/spec/api/invoices_api_spec.rb +16 -15
  122. data/spec/api/liquidation_addresses_api_spec.rb +13 -12
  123. data/spec/api/payment_intents_api_spec.rb +12 -11
  124. data/spec/api/payment_links_api_spec.rb +14 -13
  125. data/spec/api/products_api_spec.rb +41 -40
  126. data/spec/api/taxes_api_spec.rb +51 -21
  127. data/spec/api/test_payments_api_spec.rb +14 -13
  128. data/spec/api/transfers_api_spec.rb +36 -13
  129. data/spec/api/wallets_api_spec.rb +9 -8
  130. data/spec/api/webhooks_api_spec.rb +20 -19
  131. data/spec/models/aggregated_balance_response_spec.rb +15 -19
  132. data/spec/models/all_balances_response_spec.rb +14 -18
  133. data/spec/models/bridge_fiat_payment_rail_spec.rb +30 -0
  134. data/spec/models/bridge_payment_rail_spec.rb +11 -15
  135. data/spec/models/create_bank_payment_intent_dto_spec.rb +29 -33
  136. data/spec/models/create_customer_dto_spec.rb +17 -25
  137. data/spec/models/create_direct_bank_transfer_dto_spec.rb +19 -23
  138. data/spec/models/create_direct_wallet_transfer_dto_spec.rb +15 -19
  139. data/spec/models/create_external_bank_transfer_dto_spec.rb +102 -0
  140. data/spec/models/create_external_stablecoin_transfer_dto_spec.rb +66 -0
  141. data/spec/models/create_invoice_dto_spec.rb +31 -35
  142. data/spec/models/create_liquidation_address_dto_spec.rb +28 -32
  143. data/spec/models/create_payment_link_dto_spec.rb +34 -76
  144. data/spec/models/create_stable_payment_intent_dto_spec.rb +26 -30
  145. data/spec/models/create_stablecoin_conversion_dto_spec.rb +16 -20
  146. data/spec/models/create_tax_dto_spec.rb +60 -0
  147. data/spec/models/create_webhook_dto_spec.rb +16 -20
  148. data/spec/models/customer_status_spec.rb +11 -15
  149. data/spec/models/customer_type_spec.rb +30 -0
  150. data/spec/models/destination_currency_spec.rb +11 -15
  151. data/spec/models/exchange_rate_response_dto_spec.rb +17 -21
  152. data/spec/models/fiat_currency_spec.rb +11 -15
  153. data/spec/models/health_response_dto_spec.rb +19 -23
  154. data/spec/models/invoice_product_dto_spec.rb +13 -17
  155. data/spec/models/liquidation_address_response_dto_spec.rb +25 -29
  156. data/spec/models/payment_link_product_dto_spec.rb +13 -17
  157. data/spec/models/payment_request_dto_spec.rb +15 -19
  158. data/spec/models/payment_response_dto_spec.rb +16 -20
  159. data/spec/models/public_health_response_dto_spec.rb +15 -19
  160. data/spec/models/refund_response_dto_spec.rb +16 -20
  161. data/spec/models/stable_coin_currency_spec.rb +11 -15
  162. data/spec/models/tax_controller_create201_response_spec.rb +72 -0
  163. data/spec/models/tax_controller_delete_without_id400_response_spec.rb +48 -0
  164. data/spec/models/tax_controller_update_without_id400_response_spec.rb +48 -0
  165. data/spec/models/update_customer_dto_spec.rb +17 -25
  166. data/spec/models/update_tax_dto_spec.rb +60 -0
  167. data/spec/models/update_webhook_dto_spec.rb +16 -20
  168. data/spec/models/webhook_response_dto_spec.rb +19 -23
  169. data/spec/spec_helper.rb +5 -4
  170. metadata +49 -116
  171. data/docs/AllOfAllBalancesResponseEurc.md +0 -9
  172. data/docs/AllOfAllBalancesResponseUsdc.md +0 -9
  173. data/docs/AllOfCreateBankPaymentIntentDtoDestinationCurrency.md +0 -6
  174. data/docs/AllOfCreateBankPaymentIntentDtoDestinationNetwork.md +0 -6
  175. data/docs/AllOfCreateBankPaymentIntentDtoSourceCurrency.md +0 -6
  176. data/docs/AllOfCreateBankPaymentIntentDtoSourcePaymentRail.md +0 -6
  177. data/docs/AllOfCreateCustomerDtoStatus.md +0 -6
  178. data/docs/AllOfCreateLiquidationAddressDtoDestinationCurrency.md +0 -6
  179. data/docs/AllOfCreateLiquidationAddressDtoDestinationPaymentRail.md +0 -6
  180. data/docs/AllOfCreateStablePaymentIntentDtoDestinationCurrency.md +0 -6
  181. data/docs/AllOfCreateStablePaymentIntentDtoDestinationNetwork.md +0 -6
  182. data/docs/AllOfCreateStablePaymentIntentDtoSourceCurrency.md +0 -6
  183. data/docs/AllOfCreateStablePaymentIntentDtoSourceNetwork.md +0 -6
  184. data/docs/AllOfUpdateCustomerDtoStatus.md +0 -6
  185. data/docs/CreateProductDto.md +0 -18
  186. data/docs/CreateTaxInput.md +0 -6
  187. data/docs/UpdatePaymentLinkDto.md +0 -6
  188. data/docs/UpdatePreferenceInput.md +0 -6
  189. data/docs/UpdateProductDto.md +0 -18
  190. data/docs/UpdateTaxInput.md +0 -6
  191. data/example.rb +0 -129
  192. data/lib/devdraft/models/all_of_all_balances_response_eurc.rb +0 -283
  193. data/lib/devdraft/models/all_of_all_balances_response_usdc.rb +0 -283
  194. data/lib/devdraft/models/all_of_create_bank_payment_intent_dto_destination_currency.rb +0 -202
  195. data/lib/devdraft/models/all_of_create_bank_payment_intent_dto_destination_network.rb +0 -202
  196. data/lib/devdraft/models/all_of_create_bank_payment_intent_dto_source_currency.rb +0 -202
  197. data/lib/devdraft/models/all_of_create_bank_payment_intent_dto_source_payment_rail.rb +0 -202
  198. data/lib/devdraft/models/all_of_create_customer_dto_status.rb +0 -202
  199. data/lib/devdraft/models/all_of_create_liquidation_address_dto_destination_currency.rb +0 -202
  200. data/lib/devdraft/models/all_of_create_liquidation_address_dto_destination_payment_rail.rb +0 -202
  201. data/lib/devdraft/models/all_of_create_stable_payment_intent_dto_destination_currency.rb +0 -202
  202. data/lib/devdraft/models/all_of_create_stable_payment_intent_dto_destination_network.rb +0 -202
  203. data/lib/devdraft/models/all_of_create_stable_payment_intent_dto_source_currency.rb +0 -202
  204. data/lib/devdraft/models/all_of_create_stable_payment_intent_dto_source_network.rb +0 -202
  205. data/lib/devdraft/models/all_of_update_customer_dto_status.rb +0 -202
  206. data/lib/devdraft/models/create_product_dto.rb +0 -370
  207. data/lib/devdraft/models/create_tax_input.rb +0 -197
  208. data/lib/devdraft/models/update_payment_link_dto.rb +0 -197
  209. data/lib/devdraft/models/update_preference_input.rb +0 -197
  210. data/lib/devdraft/models/update_product_dto.rb +0 -355
  211. data/lib/devdraft/models/update_tax_input.rb +0 -197
  212. data/spec/api_client_spec.rb +0 -225
  213. data/spec/base_object_spec.rb +0 -109
  214. data/spec/configuration_spec.rb +0 -41
  215. data/spec/models/all_of_all_balances_response_eurc_spec.rb +0 -56
  216. data/spec/models/all_of_all_balances_response_usdc_spec.rb +0 -56
  217. data/spec/models/all_of_create_bank_payment_intent_dto_destination_currency_spec.rb +0 -34
  218. data/spec/models/all_of_create_bank_payment_intent_dto_destination_network_spec.rb +0 -34
  219. data/spec/models/all_of_create_bank_payment_intent_dto_source_currency_spec.rb +0 -34
  220. data/spec/models/all_of_create_bank_payment_intent_dto_source_payment_rail_spec.rb +0 -34
  221. data/spec/models/all_of_create_customer_dto_status_spec.rb +0 -34
  222. data/spec/models/all_of_create_liquidation_address_dto_destination_currency_spec.rb +0 -34
  223. data/spec/models/all_of_create_liquidation_address_dto_destination_payment_rail_spec.rb +0 -34
  224. data/spec/models/all_of_create_stable_payment_intent_dto_destination_currency_spec.rb +0 -34
  225. data/spec/models/all_of_create_stable_payment_intent_dto_destination_network_spec.rb +0 -34
  226. data/spec/models/all_of_create_stable_payment_intent_dto_source_currency_spec.rb +0 -34
  227. data/spec/models/all_of_create_stable_payment_intent_dto_source_network_spec.rb +0 -34
  228. data/spec/models/all_of_update_customer_dto_status_spec.rb +0 -34
  229. data/spec/models/create_product_dto_spec.rb +0 -110
  230. data/spec/models/create_tax_input_spec.rb +0 -34
  231. data/spec/models/update_payment_link_dto_spec.rb +0 -34
  232. data/spec/models/update_preference_input_spec.rb +0 -34
  233. data/spec/models/update_product_dto_spec.rb +0 -110
  234. data/spec/models/update_tax_input_spec.rb +0 -34
@@ -3,20 +3,22 @@
3
3
 
4
4
  # A comprehensive payment processing and business management API that enables seamless integration of cryptocurrency and traditional payment methods.
5
5
 
6
- OpenAPI spec version: 1.0.0
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.17.0
7
10
 
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 3.0.65
10
11
  =end
11
12
 
12
13
  require 'date'
13
14
  require 'json'
14
15
  require 'logger'
15
16
  require 'tempfile'
17
+ require 'time'
16
18
  require 'typhoeus'
17
- require 'uri'
18
19
 
19
- module DevDraftAI
20
+
21
+ module Devdraft
20
22
  class ApiClient
21
23
  # The Configuration object holding settings to be used in the API client.
22
24
  attr_accessor :config
@@ -30,7 +32,7 @@ module DevDraftAI
30
32
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
31
33
  def initialize(config = Configuration.default)
32
34
  @config = config
33
- @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
35
+ @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
34
36
  @default_headers = {
35
37
  'Content-Type' => 'application/json',
36
38
  'User-Agent' => @user_agent
@@ -44,9 +46,11 @@ module DevDraftAI
44
46
  # Call an API with given options.
45
47
  #
46
48
  # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
47
- # the data deserialized from response body (could be nil), response status code and response headers.
49
+ # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
48
50
  def call_api(http_method, path, opts = {})
49
51
  request = build_request(http_method, path, opts)
52
+ tempfile = nil
53
+ (download_file(request) { tempfile = _1 }) if opts[:return_type] == 'File'
50
54
  response = request.run
51
55
 
52
56
  if @config.debugging
@@ -68,7 +72,9 @@ module DevDraftAI
68
72
  end
69
73
  end
70
74
 
71
- if opts[:return_type]
75
+ if opts[:return_type] == 'File'
76
+ data = tempfile
77
+ elsif opts[:return_type]
72
78
  data = deserialize(response, opts[:return_type])
73
79
  else
74
80
  data = nil
@@ -86,12 +92,13 @@ module DevDraftAI
86
92
  # @option opts [Object] :body HTTP body (JSON/XML)
87
93
  # @return [Typhoeus::Request] A Typhoeus Request
88
94
  def build_request(http_method, path, opts = {})
89
- url = build_request_url(path)
95
+ url = build_request_url(path, opts)
90
96
  http_method = http_method.to_sym.downcase
91
97
 
92
98
  header_params = @default_headers.merge(opts[:header_params] || {})
93
99
  query_params = opts[:query_params] || {}
94
100
  form_params = opts[:form_params] || {}
101
+ follow_location = opts[:follow_location] || true
95
102
 
96
103
  update_params_for_auth! header_params, query_params, opts[:auth_names]
97
104
 
@@ -108,7 +115,8 @@ module DevDraftAI
108
115
  :ssl_verifyhost => _verify_ssl_host,
109
116
  :sslcert => @config.cert_file,
110
117
  :sslkey => @config.key_file,
111
- :verbose => @config.debugging
118
+ :verbose => @config.debugging,
119
+ :followlocation => follow_location
112
120
  }
113
121
 
114
122
  # set custom cert, if provided
@@ -122,9 +130,7 @@ module DevDraftAI
122
130
  end
123
131
  end
124
132
 
125
- request = Typhoeus::Request.new(url, req_opts)
126
- download_file(request) if opts[:return_type] == 'File'
127
- request
133
+ Typhoeus::Request.new(url, req_opts)
128
134
  end
129
135
 
130
136
  # Builds the HTTP request body
@@ -155,6 +161,47 @@ module DevDraftAI
155
161
  data
156
162
  end
157
163
 
164
+ # Save response body into a file in (the defined) temporary folder, using the filename
165
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
166
+ # The response body is written to the file in chunks in order to handle files which
167
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
168
+ # process can use.
169
+ #
170
+ # @see Configuration#temp_folder_path
171
+ #
172
+ # @return [Tempfile] the tempfile generated
173
+ def download_file(request)
174
+ tempfile = nil
175
+ encoding = nil
176
+ request.on_headers do |response|
177
+ content_disposition = response.headers['Content-Disposition']
178
+ if content_disposition && content_disposition =~ /filename=/i
179
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
180
+ prefix = sanitize_filename(filename)
181
+ else
182
+ prefix = 'download-'
183
+ end
184
+ prefix = prefix + '-' unless prefix.end_with?('-')
185
+ encoding = response.body.encoding
186
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
187
+ end
188
+ request.on_body do |chunk|
189
+ chunk.force_encoding(encoding)
190
+ tempfile.write(chunk)
191
+ end
192
+ request.on_complete do
193
+ if !tempfile
194
+ fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
195
+ end
196
+ tempfile.close
197
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
198
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
199
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
200
+ "explicitly with `tempfile.delete`"
201
+ yield tempfile if block_given?
202
+ end
203
+ end
204
+
158
205
  # Check if the given MIME is a JSON MIME.
159
206
  # JSON MIME examples:
160
207
  # application/json
@@ -164,7 +211,7 @@ module DevDraftAI
164
211
  # @param [String] mime MIME
165
212
  # @return [Boolean] True if the MIME is application/json
166
213
  def json_mime?(mime)
167
- (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
214
+ (mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
168
215
  end
169
216
 
170
217
  # Deserialize the response to the given return type.
@@ -173,15 +220,10 @@ module DevDraftAI
173
220
  # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
174
221
  def deserialize(response, return_type)
175
222
  body = response.body
176
-
177
- # handle file downloading - return the File instance processed in request callbacks
178
- # note that response body is empty when the file is written in chunks in request on_body callback
179
- return @tempfile if return_type == 'File'
180
-
181
223
  return nil if body.nil? || body.empty?
182
224
 
183
225
  # return response body directly for String return type
184
- return body if return_type == 'String'
226
+ return body.to_s if return_type == 'String'
185
227
 
186
228
  # ensuring a default content type
187
229
  content_type = response.headers['Content-Type'] || 'application/json'
@@ -191,7 +233,7 @@ module DevDraftAI
191
233
  begin
192
234
  data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
193
235
  rescue JSON::ParserError => e
194
- if %w(String Date DateTime).include?(return_type)
236
+ if %w(String Date Time).include?(return_type)
195
237
  data = body
196
238
  else
197
239
  raise e
@@ -216,9 +258,9 @@ module DevDraftAI
216
258
  data.to_f
217
259
  when 'Boolean'
218
260
  data == true
219
- when 'DateTime'
261
+ when 'Time'
220
262
  # parse date time (expecting ISO 8601 format)
221
- DateTime.parse data
263
+ Time.parse data
222
264
  when 'Date'
223
265
  # parse date time (expecting ISO 8601 format)
224
266
  Date.parse data
@@ -236,46 +278,9 @@ module DevDraftAI
236
278
  data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
237
279
  end
238
280
  else
239
- # models, e.g. Pet
240
- DevDraftAI.const_get(return_type).build_from_hash(data)
241
- end
242
- end
243
-
244
- # Save response body into a file in (the defined) temporary folder, using the filename
245
- # from the "Content-Disposition" header if provided, otherwise a random filename.
246
- # The response body is written to the file in chunks in order to handle files which
247
- # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
248
- # process can use.
249
- #
250
- # @see Configuration#temp_folder_path
251
- def download_file(request)
252
- tempfile = nil
253
- encoding = nil
254
- request.on_headers do |response|
255
- content_disposition = response.headers['Content-Disposition']
256
- if content_disposition && content_disposition =~ /filename=/i
257
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
258
- prefix = sanitize_filename(filename)
259
- else
260
- prefix = 'download-'
261
- end
262
- prefix = prefix + '-' unless prefix.end_with?('-')
263
- encoding = response.body.encoding
264
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
265
- @tempfile = tempfile
266
- end
267
- request.on_body do |chunk|
268
- chunk.force_encoding(encoding)
269
- tempfile.write(chunk)
270
- end
271
- request.on_complete do |response|
272
- if tempfile
273
- tempfile.close
274
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
275
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
276
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
277
- "explicitly with `tempfile.delete`"
278
- end
281
+ # models (e.g. Pet) or oneOf
282
+ klass = Devdraft.const_get(return_type)
283
+ klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
279
284
  end
280
285
  end
281
286
 
@@ -285,16 +290,16 @@ module DevDraftAI
285
290
  # @param [String] filename the filename to be sanitized
286
291
  # @return [String] the sanitized filename
287
292
  def sanitize_filename(filename)
288
- filename.gsub(/.*[\/\\]/, '')
293
+ filename.split(/[\/\\]/).last
289
294
  end
290
295
 
291
- def build_request_url(path)
296
+ def build_request_url(path, opts = {})
292
297
  # Add leading and trailing slashes to path
293
298
  path = "/#{path}".gsub(/\/+/, '/')
294
- @config.base_url + path
299
+ @config.base_url(opts[:operation]) + path
295
300
  end
296
301
 
297
- # Update hearder and query params based on authentication settings.
302
+ # Update header and query params based on authentication settings.
298
303
  #
299
304
  # @param [Hash] header_params Header parameters
300
305
  # @param [Hash] query_params Query parameters
@@ -306,14 +311,14 @@ module DevDraftAI
306
311
  case auth_setting[:in]
307
312
  when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
308
313
  when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
309
- else fail ArgumentError, 'Authentication token must be in `query` of `header`'
314
+ else fail ArgumentError, 'Authentication token must be in `query` or `header`'
310
315
  end
311
316
  end
312
317
  end
313
318
 
314
319
  # Sets user agent in HTTP header
315
320
  #
316
- # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
321
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
317
322
  def user_agent=(user_agent)
318
323
  @user_agent = user_agent
319
324
  @default_headers['User-Agent'] = @user_agent
@@ -333,8 +338,8 @@ module DevDraftAI
333
338
  # @param [Array] content_types array for Content-Type
334
339
  # @return [String] the Content-Type header (e.g. application/json)
335
340
  def select_header_content_type(content_types)
336
- # use application/json by default
337
- return 'application/json' if content_types.nil? || content_types.empty?
341
+ # return nil by default
342
+ return if content_types.nil? || content_types.empty?
338
343
  # use JSON when present, otherwise use the first one
339
344
  json_content_type = content_types.find { |s| json_mime?(s) }
340
345
  json_content_type || content_types.first
@@ -3,10 +3,11 @@
3
3
 
4
4
  # A comprehensive payment processing and business management API that enables seamless integration of cryptocurrency and traditional payment methods.
5
5
 
6
- OpenAPI spec version: 1.0.0
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.17.0
7
10
 
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 3.0.65
10
11
  =end
11
12
 
12
13
  module Devdraft
@@ -31,6 +32,7 @@ module Devdraft
31
32
  end
32
33
  else
33
34
  super arg
35
+ @message = arg
34
36
  end
35
37
  end
36
38
 
@@ -52,6 +54,5 @@ module Devdraft
52
54
 
53
55
  msg
54
56
  end
55
-
56
57
  end
57
58
  end
@@ -0,0 +1,88 @@
1
+ =begin
2
+ #Devdraft AI Payment & Business Management API
3
+
4
+ # A comprehensive payment processing and business management API that enables seamless integration of cryptocurrency and traditional payment methods.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.17.0
10
+
11
+ =end
12
+
13
+ module Devdraft
14
+ class ApiModelBase
15
+ # Deserializes the data based on type
16
+ # @param string type Data type
17
+ # @param string value Value to be deserialized
18
+ # @return [Object] Deserialized data
19
+ def self._deserialize(type, value)
20
+ case type.to_sym
21
+ when :Time
22
+ Time.parse(value)
23
+ when :Date
24
+ Date.parse(value)
25
+ when :String
26
+ value.to_s
27
+ when :Integer
28
+ value.to_i
29
+ when :Float
30
+ value.to_f
31
+ when :Boolean
32
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
33
+ true
34
+ else
35
+ false
36
+ end
37
+ when :Object
38
+ # generic object (usually a Hash), return directly
39
+ value
40
+ when /\AArray<(?<inner_type>.+)>\z/
41
+ inner_type = Regexp.last_match[:inner_type]
42
+ value.map { |v| _deserialize(inner_type, v) }
43
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
44
+ k_type = Regexp.last_match[:k_type]
45
+ v_type = Regexp.last_match[:v_type]
46
+ {}.tap do |hash|
47
+ value.each do |k, v|
48
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
49
+ end
50
+ end
51
+ else # model
52
+ # models (e.g. Pet) or oneOf
53
+ klass = Devdraft.const_get(type)
54
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
55
+ end
56
+ end
57
+
58
+ # Returns the string representation of the object
59
+ # @return [String] String presentation of the object
60
+ def to_s
61
+ to_hash.to_s
62
+ end
63
+
64
+ # to_body is an alias to to_hash (backward compatibility)
65
+ # @return [Hash] Returns the object in the form of hash
66
+ def to_body
67
+ to_hash
68
+ end
69
+
70
+ # Outputs non-array value in the form of hash
71
+ # For object, use to_hash. Otherwise, just return the value
72
+ # @param [Object] value Any valid value
73
+ # @return [Hash] Returns the value in the form of hash
74
+ def _to_hash(value)
75
+ if value.is_a?(Array)
76
+ value.compact.map { |v| _to_hash(v) }
77
+ elsif value.is_a?(Hash)
78
+ {}.tap do |hash|
79
+ value.each { |k, v| hash[k] = _to_hash(v) }
80
+ end
81
+ elsif value.respond_to? :to_hash
82
+ value.to_hash
83
+ else
84
+ value
85
+ end
86
+ end
87
+ end
88
+ end
@@ -3,10 +3,11 @@
3
3
 
4
4
  # A comprehensive payment processing and business management API that enables seamless integration of cryptocurrency and traditional payment methods.
5
5
 
6
- OpenAPI spec version: 1.0.0
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.17.0
7
10
 
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 3.0.65
10
11
  =end
11
12
 
12
13
  module Devdraft
@@ -20,6 +21,18 @@ module Devdraft
20
21
  # Defines url base path
21
22
  attr_accessor :base_path
22
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
+
23
36
  # Defines API keys used with API Key authentications.
24
37
  #
25
38
  # @return [Hash] key: parameter name, value: parameter value (API key)
@@ -49,6 +62,16 @@ module Devdraft
49
62
  # Defines the access token (Bearer) used with OAuth2.
50
63
  attr_accessor :access_token
51
64
 
65
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
66
+ # Overrides the access_token if set
67
+ # @return [Proc]
68
+ attr_accessor :access_token_getter
69
+
70
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
71
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
72
+ # Default to false.
73
+ attr_accessor :return_binary_data
74
+
52
75
  # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
53
76
  # details will be logged with `logger.debug` (see the `logger` attribute).
54
77
  # Default to false.
@@ -56,6 +79,14 @@ module Devdraft
56
79
  # @return [true, false]
57
80
  attr_accessor :debugging
58
81
 
82
+ # Set this to ignore operation servers for the API client. This is useful when you need to
83
+ # send requests to a different server than the one specified in the OpenAPI document.
84
+ # Will default to the base url defined in the spec but can be overridden by setting
85
+ # `scheme`, `host`, `base_path` directly.
86
+ # Default to false.
87
+ # @return [true, false]
88
+ attr_accessor :ignore_operation_servers
89
+
59
90
  # Defines the logger used for debugging.
60
91
  # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
61
92
  #
@@ -120,6 +151,7 @@ module Devdraft
120
151
  # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
121
152
  attr_accessor :params_encoding
122
153
 
154
+
123
155
  attr_accessor :inject_format
124
156
 
125
157
  attr_accessor :force_ending_format
@@ -127,17 +159,22 @@ module Devdraft
127
159
  def initialize
128
160
  @scheme = 'https'
129
161
  @host = 'api.devdraft.ai'
130
- @base_path = 'https://api.devdraft.ai'
162
+ @base_path = ''
163
+ @server_index = nil
164
+ @server_operation_index = {}
165
+ @server_variables = {}
166
+ @server_operation_variables = {}
131
167
  @api_key = {}
132
168
  @api_key_prefix = {}
133
- @timeout = 0
134
169
  @client_side_validation = true
135
170
  @verify_ssl = true
136
171
  @verify_ssl_host = true
137
- @params_encoding = nil
138
172
  @cert_file = nil
139
173
  @key_file = nil
174
+ @timeout = 0
175
+ @params_encoding = nil
140
176
  @debugging = false
177
+ @ignore_operation_servers = false
141
178
  @inject_format = false
142
179
  @force_ending_format = false
143
180
  @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
@@ -170,20 +207,35 @@ module Devdraft
170
207
  @base_path = '' if @base_path == '/'
171
208
  end
172
209
 
173
- def base_url
174
- "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
210
+ # Returns base URL for specified operation based on server settings
211
+ def base_url(operation = nil)
212
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
213
+ if operation_server_settings.key?(operation) then
214
+ index = server_operation_index.fetch(operation, server_index)
215
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
216
+ else
217
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
218
+ end
175
219
  end
176
220
 
177
221
  # Gets API key (with prefix if set).
178
222
  # @param [String] param_name the parameter name of API key auth
179
- def api_key_with_prefix(param_name)
223
+ def api_key_with_prefix(param_name, param_alias = nil)
224
+ key = @api_key[param_name]
225
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
180
226
  if @api_key_prefix[param_name]
181
- "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
227
+ "#{@api_key_prefix[param_name]} #{key}"
182
228
  else
183
- @api_key[param_name]
229
+ key
184
230
  end
185
231
  end
186
232
 
233
+ # Gets access_token using access_token_getter or uses the static access_token
234
+ def access_token_with_refresh
235
+ return access_token if access_token_getter.nil?
236
+ access_token_getter.call
237
+ end
238
+
187
239
  # Gets Basic Auth token string
188
240
  def basic_auth_token
189
241
  'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
@@ -192,13 +244,6 @@ module Devdraft
192
244
  # Returns Auth Settings hash for api client.
193
245
  def auth_settings
194
246
  {
195
- 'idempotency-key' =>
196
- {
197
- type: 'api_key',
198
- in: 'header',
199
- key: 'idempotency-key',
200
- value: api_key_with_prefix('idempotency-key')
201
- },
202
247
  'x-client-key' =>
203
248
  {
204
249
  type: 'api_key',
@@ -213,7 +258,65 @@ module Devdraft
213
258
  key: 'x-client-secret',
214
259
  value: api_key_with_prefix('x-client-secret')
215
260
  },
261
+ 'idempotency-key' =>
262
+ {
263
+ type: 'api_key',
264
+ in: 'header',
265
+ key: 'idempotency-key',
266
+ value: api_key_with_prefix('idempotency-key')
267
+ },
268
+ }
269
+ end
270
+
271
+ # Returns an array of Server setting
272
+ def server_settings
273
+ [
274
+ {
275
+ url: "https://api.devdraft.ai",
276
+ description: "Production Server",
277
+ }
278
+ ]
279
+ end
280
+
281
+ def operation_server_settings
282
+ {
216
283
  }
217
284
  end
285
+
286
+ # Returns URL based on server settings
287
+ #
288
+ # @param index array index of the server settings
289
+ # @param variables hash of variable and the corresponding value
290
+ def server_url(index, variables = {}, servers = nil)
291
+ servers = server_settings if servers == nil
292
+
293
+ # check array index out of bound
294
+ if (index.nil? || index < 0 || index >= servers.size)
295
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
296
+ end
297
+
298
+ server = servers[index]
299
+ url = server[:url]
300
+
301
+ return url unless server.key? :variables
302
+
303
+ # go through variable and assign a value
304
+ server[:variables].each do |name, variable|
305
+ if variables.key?(name)
306
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
307
+ url.gsub! "{" + name.to_s + "}", variables[name]
308
+ else
309
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
310
+ end
311
+ else
312
+ # use default value
313
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
314
+ end
315
+ end
316
+
317
+ url
318
+ end
319
+
320
+
218
321
  end
219
322
  end