factpulse 4.1.2 → 4.3.0

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 (160) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -5
  3. data/Gemfile.lock +2 -2
  4. data/docs/AFNORBasicAuthentication.md +20 -0
  5. data/docs/AFNORCallbackAuthentication.md +49 -0
  6. data/docs/AFNORCallbackHeader.md +20 -0
  7. data/docs/AFNORCallbackParameters.md +24 -0
  8. data/docs/AFNORCallbackSignature.md +20 -0
  9. data/docs/{AFNORFacilityNature.md → AFNORContainsOrStrictOperator.md} +2 -2
  10. data/docs/AFNORCoreFlowInfo.md +26 -0
  11. data/docs/{AFNORDirectoryLinePayloadHistoryLegalUnitFacilityRoutingCode.md → AFNORDirectoryLinePayloadLegalUnitFacilityRoutingCode.md} +5 -5
  12. data/docs/AFNORDirectoryLinePayloadStatusLegalUnitFacilityRoutingCode.md +34 -0
  13. data/docs/AFNORDirectoryLineSearchPost200Response.md +1 -1
  14. data/docs/{AFNORDiffusionStatus.md → AFNORDirectoryLineStatus.md} +2 -2
  15. data/docs/AFNORError.md +4 -4
  16. data/docs/AFNORFacilityPayloadHistory.md +3 -3
  17. data/docs/AFNORFacilityPayloadIncluded.md +0 -2
  18. data/docs/AFNORFlow.md +16 -14
  19. data/docs/AFNORFlowExtension.md +26 -0
  20. data/docs/AFNORFlowInfo.md +3 -3
  21. data/docs/AFNORFlowInfoExtension.md +18 -0
  22. data/docs/AFNORFullFlowInfo.md +8 -8
  23. data/docs/AFNORFullFlowInfoExtension.md +20 -0
  24. data/docs/AFNORLegalUnitPayloadHistory.md +3 -1
  25. data/docs/AFNOROAuth2Authentication.md +22 -0
  26. data/docs/AFNORPDPPADirectoryServiceApi.md +4 -648
  27. data/docs/AFNORPDPPAFlowServiceApi.md +320 -1
  28. data/docs/AFNORRoutingCodeSearch.md +1 -1
  29. data/docs/AFNORRoutingCodeSearchFiltersRoutingCodeName.md +1 -1
  30. data/docs/AFNORRoutingCodeSearchFiltersRoutingIdentifier.md +1 -1
  31. data/docs/AFNORSearchDirectoryLine.md +2 -2
  32. data/docs/AFNORSearchDirectoryLineFiltersAddressingIdentifier.md +1 -1
  33. data/docs/AFNORSearchDirectoryLineFiltersAddressingSuffix.md +1 -1
  34. data/docs/AFNORSearchFlowFilters.md +1 -1
  35. data/docs/AFNORSearchSiren.md +1 -1
  36. data/docs/AFNORSearchSirenFiltersBusinessName.md +1 -1
  37. data/docs/AFNORSearchSirenFiltersSiren.md +1 -1
  38. data/docs/AFNORSearchSiret.md +2 -2
  39. data/docs/AFNORSearchSiretFiltersCountrySubdivision.md +1 -1
  40. data/docs/AFNORSearchSiretFiltersFacilityType.md +1 -1
  41. data/docs/AFNORSearchSiretFiltersLocality.md +1 -1
  42. data/docs/AFNORSearchSiretFiltersName.md +1 -1
  43. data/docs/AFNORSearchSiretFiltersPostalCode.md +1 -1
  44. data/docs/AFNORSearchSiretFiltersSiret.md +1 -1
  45. data/docs/AFNORSirenInstructions.md +18 -0
  46. data/docs/AFNORSiretInstructions.md +18 -0
  47. data/docs/{AFNORPlatformStatus.md → AFNORStrictOrStartWithOperator.md} +2 -2
  48. data/docs/AFNORWebhook.md +22 -0
  49. data/docs/AFNORWebhookIdParam.md +18 -0
  50. data/docs/AFNORWebhookMetadata.md +24 -0
  51. data/docs/AFNORWebhookParams.md +20 -0
  52. data/docs/AFNORWebhookPatchPayload.md +22 -0
  53. data/docs/ChorusProCredentials.md +8 -8
  54. data/docs/ChorusProDestination.md +1 -1
  55. data/docs/FactureElectroniqueRestApiSchemasCdarValidationErrorResponse.md +24 -0
  56. data/docs/FactureElectroniqueRestApiSchemasEreportingInvoiceTypeCode.md +15 -0
  57. data/docs/FactureElectroniqueRestApiSchemasProcessingChorusProCredentials.md +26 -0
  58. data/docs/GetChorusProIdRequest.md +1 -1
  59. data/docs/GetInvoiceRequest.md +1 -1
  60. data/docs/GetStructureRequest.md +1 -1
  61. data/docs/InvoiceInput.md +1 -1
  62. data/docs/SearchStructureRequest.md +1 -1
  63. data/docs/SimplifiedInvoiceData.md +1 -1
  64. data/docs/SubmitInvoiceRequest.md +1 -1
  65. data/docs/ValidateCDARResponse.md +2 -2
  66. data/docs/ValidationErrorResponse.md +2 -8
  67. data/lib/factpulse/api/afnorpdppa_directory_service_api.rb +3 -621
  68. data/lib/factpulse/api/afnorpdppa_flow_service_api.rb +303 -0
  69. data/lib/factpulse/models/afnor_algorithm.rb +4 -3
  70. data/lib/factpulse/models/afnor_basic_authentication.rb +190 -0
  71. data/lib/factpulse/models/afnor_callback_authentication.rb +105 -0
  72. data/lib/factpulse/models/afnor_callback_header.rb +190 -0
  73. data/lib/factpulse/models/afnor_callback_parameters.rb +193 -0
  74. data/lib/factpulse/models/{afnor_directory_line_payload_history_legal_unit_facility_routing_code_platform.rb → afnor_callback_signature.rb} +51 -16
  75. data/lib/factpulse/models/{afnor_diffusion_status.rb → afnor_contains_or_strict_operator.rb} +6 -6
  76. data/lib/factpulse/models/{afnor_routing_code_post201_response.rb → afnor_core_flow_info.rb} +103 -61
  77. data/lib/factpulse/models/afnor_directory_line_field.rb +1 -2
  78. data/lib/factpulse/models/{afnor_directory_line_payload_history_legal_unit_facility_routing_code.rb → afnor_directory_line_payload_legal_unit_facility_routing_code.rb} +36 -14
  79. data/lib/factpulse/models/{afnor_create_directory_line_body_addressing_information.rb → afnor_directory_line_payload_status_legal_unit_facility_routing_code.rb} +105 -56
  80. data/lib/factpulse/models/afnor_directory_line_search_post200_response.rb +1 -1
  81. data/lib/factpulse/models/{afnor_platform_status.rb → afnor_directory_line_status.rb} +5 -4
  82. data/lib/factpulse/models/afnor_error.rb +30 -39
  83. data/lib/factpulse/models/afnor_facility_payload_history.rb +11 -11
  84. data/lib/factpulse/models/afnor_facility_payload_included.rb +1 -10
  85. data/lib/factpulse/models/afnor_flow.rb +218 -57
  86. data/lib/factpulse/models/{afnor_update_patch_routing_code_body.rb → afnor_flow_extension.rb} +103 -66
  87. data/lib/factpulse/models/afnor_flow_info.rb +20 -4
  88. data/lib/factpulse/models/{afnor_create_directory_line_body_period.rb → afnor_flow_info_extension.rb} +26 -31
  89. data/lib/factpulse/models/afnor_full_flow_info.rb +79 -46
  90. data/lib/factpulse/models/afnor_full_flow_info_extension.rb +202 -0
  91. data/lib/factpulse/models/afnor_legal_unit_payload_history.rb +13 -4
  92. data/lib/factpulse/models/afnor_processing_rule.rb +4 -1
  93. data/lib/factpulse/models/afnor_routing_code_field.rb +1 -2
  94. data/lib/factpulse/models/afnor_routing_code_search_filters_routing_code_name.rb +1 -1
  95. data/lib/factpulse/models/afnor_routing_code_search_filters_routing_identifier.rb +1 -1
  96. data/lib/factpulse/models/afnor_search_directory_line_filters_addressing_identifier.rb +1 -1
  97. data/lib/factpulse/models/afnor_search_directory_line_filters_addressing_suffix.rb +1 -1
  98. data/lib/factpulse/models/afnor_search_flow_filters.rb +1 -0
  99. data/lib/factpulse/models/afnor_search_siren_filters_business_name.rb +1 -1
  100. data/lib/factpulse/models/afnor_search_siren_filters_siren.rb +1 -1
  101. data/lib/factpulse/models/afnor_search_siret_filters_country_subdivision.rb +1 -1
  102. data/lib/factpulse/models/afnor_search_siret_filters_facility_type.rb +1 -1
  103. data/lib/factpulse/models/afnor_search_siret_filters_locality.rb +1 -1
  104. data/lib/factpulse/models/afnor_search_siret_filters_name.rb +1 -1
  105. data/lib/factpulse/models/afnor_search_siret_filters_postal_code.rb +1 -1
  106. data/lib/factpulse/models/afnor_search_siret_filters_siret.rb +1 -1
  107. data/lib/factpulse/models/afnor_siren_field.rb +2 -2
  108. data/lib/factpulse/models/{afnor_update_patch_directory_line_body.rb → afnor_siren_instructions.rb} +12 -11
  109. data/lib/factpulse/models/afnor_siret_field.rb +3 -4
  110. data/lib/factpulse/models/{afnor_create_directory_line_body.rb → afnor_siret_instructions.rb} +12 -19
  111. data/lib/factpulse/models/{afnor_facility_nature.rb → afnor_strict_or_start_with_operator.rb} +6 -6
  112. data/lib/factpulse/models/{afnor_directory_line_post201_response.rb → afnor_webhook.rb} +55 -35
  113. data/lib/factpulse/models/{afnor_webhook_callback_content.rb → afnor_webhook_id_param.rb} +10 -11
  114. data/lib/factpulse/models/{afnor_legal_unit_payload_included_no_siren.rb → afnor_webhook_metadata.rb} +56 -33
  115. data/lib/factpulse/models/afnor_webhook_params.rb +190 -0
  116. data/lib/factpulse/models/{facture_electronique_rest_api_schemas_validation_validation_error_response.rb → afnor_webhook_patch_payload.rb} +29 -30
  117. data/lib/factpulse/models/afnoro_auth2_authentication.rb +216 -0
  118. data/lib/factpulse/models/chorus_pro_credentials.rb +94 -26
  119. data/lib/factpulse/models/chorus_pro_destination.rb +1 -1
  120. data/lib/factpulse/models/facture_electronique_rest_api_schemas_cdar_validation_error_response.rb +215 -0
  121. data/lib/factpulse/models/{facture_electronique_models_invoice_type_code.rb → facture_electronique_rest_api_schemas_ereporting_invoice_type_code.rb} +9 -20
  122. data/lib/factpulse/models/facture_electronique_rest_api_schemas_processing_chorus_pro_credentials.rb +191 -0
  123. data/lib/factpulse/models/get_chorus_pro_id_request.rb +1 -1
  124. data/lib/factpulse/models/get_invoice_request.rb +1 -1
  125. data/lib/factpulse/models/get_structure_request.rb +1 -1
  126. data/lib/factpulse/models/invoice_input.rb +1 -1
  127. data/lib/factpulse/models/invoice_type_code.rb +17 -6
  128. data/lib/factpulse/models/processing_rule.rb +4 -1
  129. data/lib/factpulse/models/search_structure_request.rb +1 -1
  130. data/lib/factpulse/models/simplified_invoice_data.rb +1 -1
  131. data/lib/factpulse/models/submit_invoice_request.rb +1 -1
  132. data/lib/factpulse/models/validate_cdar_response.rb +2 -2
  133. data/lib/factpulse/models/validation_error_response.rb +20 -67
  134. data/lib/factpulse/version.rb +1 -1
  135. data/lib/factpulse.rb +25 -22
  136. metadata +52 -46
  137. data/docs/AFNORAddressEdit.md +0 -30
  138. data/docs/AFNORAddressPatch.md +0 -30
  139. data/docs/AFNORAddressPut.md +0 -30
  140. data/docs/AFNORCreateDirectoryLineBody.md +0 -20
  141. data/docs/AFNORCreateDirectoryLineBodyAddressingInformation.md +0 -24
  142. data/docs/AFNORCreateDirectoryLineBodyPeriod.md +0 -20
  143. data/docs/AFNORCreateRoutingCodeBody.md +0 -32
  144. data/docs/AFNORDirectoryLinePayloadHistoryLegalUnitFacilityRoutingCodePlatform.md +0 -20
  145. data/docs/AFNORDirectoryLinePost201Response.md +0 -22
  146. data/docs/AFNORLegalUnitPayloadIncludedNoSiren.md +0 -22
  147. data/docs/AFNORRoutingCodePost201Response.md +0 -22
  148. data/docs/AFNORUpdatePatchDirectoryLineBody.md +0 -18
  149. data/docs/AFNORUpdatePatchRoutingCodeBody.md +0 -24
  150. data/docs/AFNORUpdatePutRoutingCodeBody.md +0 -24
  151. data/docs/AFNORWebhookCallbackContent.md +0 -18
  152. data/docs/FactureElectroniqueModelsInvoiceTypeCode.md +0 -15
  153. data/docs/FactureElectroniqueRestApiSchemasChorusProChorusProCredentials.md +0 -26
  154. data/docs/FactureElectroniqueRestApiSchemasValidationValidationErrorResponse.md +0 -18
  155. data/lib/factpulse/models/afnor_address_edit.rb +0 -353
  156. data/lib/factpulse/models/afnor_address_patch.rb +0 -386
  157. data/lib/factpulse/models/afnor_address_put.rb +0 -435
  158. data/lib/factpulse/models/afnor_create_routing_code_body.rb +0 -412
  159. data/lib/factpulse/models/afnor_update_put_routing_code_body.rb +0 -289
  160. data/lib/factpulse/models/facture_electronique_rest_api_schemas_chorus_pro_chorus_pro_credentials.rb +0 -259
@@ -19,6 +19,126 @@ module FactPulse
19
19
  def initialize(api_client = ApiClient.default)
20
20
  @api_client = api_client
21
21
  end
22
+ # Create a webhook
23
+ # Register a new webhook subscription (AFNOR XP Z12-013 v1.2.0)
24
+ # @param [Hash] opts the optional parameters
25
+ # @return [Object]
26
+ def create_webhook_proxy_api_v1_afnor_flow_v1_webhooks_post(opts = {})
27
+ data, _status_code, _headers = create_webhook_proxy_api_v1_afnor_flow_v1_webhooks_post_with_http_info(opts)
28
+ data
29
+ end
30
+
31
+ # Create a webhook
32
+ # Register a new webhook subscription (AFNOR XP Z12-013 v1.2.0)
33
+ # @param [Hash] opts the optional parameters
34
+ # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers
35
+ def create_webhook_proxy_api_v1_afnor_flow_v1_webhooks_post_with_http_info(opts = {})
36
+ if @api_client.config.debugging
37
+ @api_client.config.logger.debug 'Calling API: AFNORPDPPAFlowServiceApi.create_webhook_proxy_api_v1_afnor_flow_v1_webhooks_post ...'
38
+ end
39
+ # resource path
40
+ local_var_path = '/api/v1/afnor/flow/v1/webhooks'
41
+
42
+ # query parameters
43
+ query_params = opts[:query_params] || {}
44
+
45
+ # header parameters
46
+ header_params = opts[:header_params] || {}
47
+ # HTTP header 'Accept' (if needed)
48
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
49
+
50
+ # form parameters
51
+ form_params = opts[:form_params] || {}
52
+
53
+ # http body (model)
54
+ post_body = opts[:debug_body]
55
+
56
+ # return_type
57
+ return_type = opts[:debug_return_type] || 'Object'
58
+
59
+ # auth_names
60
+ auth_names = opts[:debug_auth_names] || []
61
+
62
+ new_options = opts.merge(
63
+ :operation => :"AFNORPDPPAFlowServiceApi.create_webhook_proxy_api_v1_afnor_flow_v1_webhooks_post",
64
+ :header_params => header_params,
65
+ :query_params => query_params,
66
+ :form_params => form_params,
67
+ :body => post_body,
68
+ :auth_names => auth_names,
69
+ :return_type => return_type
70
+ )
71
+
72
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
73
+ if @api_client.config.debugging
74
+ @api_client.config.logger.debug "API called: AFNORPDPPAFlowServiceApi#create_webhook_proxy_api_v1_afnor_flow_v1_webhooks_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
75
+ end
76
+ return data, status_code, headers
77
+ end
78
+
79
+ # Delete a webhook
80
+ # Delete a webhook subscription (AFNOR XP Z12-013 v1.2.0)
81
+ # @param webhook_uid [String] Webhook unique identifier (UUID)
82
+ # @param [Hash] opts the optional parameters
83
+ # @return [Object]
84
+ def delete_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_delete(webhook_uid, opts = {})
85
+ data, _status_code, _headers = delete_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_delete_with_http_info(webhook_uid, opts)
86
+ data
87
+ end
88
+
89
+ # Delete a webhook
90
+ # Delete a webhook subscription (AFNOR XP Z12-013 v1.2.0)
91
+ # @param webhook_uid [String] Webhook unique identifier (UUID)
92
+ # @param [Hash] opts the optional parameters
93
+ # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers
94
+ def delete_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_delete_with_http_info(webhook_uid, opts = {})
95
+ if @api_client.config.debugging
96
+ @api_client.config.logger.debug 'Calling API: AFNORPDPPAFlowServiceApi.delete_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_delete ...'
97
+ end
98
+ # verify the required parameter 'webhook_uid' is set
99
+ if @api_client.config.client_side_validation && webhook_uid.nil?
100
+ fail ArgumentError, "Missing the required parameter 'webhook_uid' when calling AFNORPDPPAFlowServiceApi.delete_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_delete"
101
+ end
102
+ # resource path
103
+ local_var_path = '/api/v1/afnor/flow/v1/webhooks/{webhookUid}'.sub('{' + 'webhookUid' + '}', CGI.escape(webhook_uid.to_s))
104
+
105
+ # query parameters
106
+ query_params = opts[:query_params] || {}
107
+
108
+ # header parameters
109
+ header_params = opts[:header_params] || {}
110
+ # HTTP header 'Accept' (if needed)
111
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
112
+
113
+ # form parameters
114
+ form_params = opts[:form_params] || {}
115
+
116
+ # http body (model)
117
+ post_body = opts[:debug_body]
118
+
119
+ # return_type
120
+ return_type = opts[:debug_return_type] || 'Object'
121
+
122
+ # auth_names
123
+ auth_names = opts[:debug_auth_names] || []
124
+
125
+ new_options = opts.merge(
126
+ :operation => :"AFNORPDPPAFlowServiceApi.delete_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_delete",
127
+ :header_params => header_params,
128
+ :query_params => query_params,
129
+ :form_params => form_params,
130
+ :body => post_body,
131
+ :auth_names => auth_names,
132
+ :return_type => return_type
133
+ )
134
+
135
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
136
+ if @api_client.config.debugging
137
+ @api_client.config.logger.debug "API called: AFNORPDPPAFlowServiceApi#delete_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
138
+ end
139
+ return data, status_code, headers
140
+ end
141
+
22
142
  # Download a flow
23
143
  # Download a file related to a given flow (AFNOR XP Z12-013 compliant): - Metadata [Default]: provides the flow metadata as JSON - Original: the document initially sent by the emitter - Converted: the document optionally converted by the system - ReadableView: the document optionally generated as readable file
24
144
  # @param flow_id [String] AFNOR flow identifier (UUID)
@@ -142,6 +262,126 @@ module FactPulse
142
262
  return data, status_code, headers
143
263
  end
144
264
 
265
+ # Get a webhook
266
+ # Get details of a specific webhook (AFNOR XP Z12-013 v1.2.0)
267
+ # @param webhook_uid [String] Webhook unique identifier (UUID)
268
+ # @param [Hash] opts the optional parameters
269
+ # @return [AFNORWebhook]
270
+ def get_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_get(webhook_uid, opts = {})
271
+ data, _status_code, _headers = get_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_get_with_http_info(webhook_uid, opts)
272
+ data
273
+ end
274
+
275
+ # Get a webhook
276
+ # Get details of a specific webhook (AFNOR XP Z12-013 v1.2.0)
277
+ # @param webhook_uid [String] Webhook unique identifier (UUID)
278
+ # @param [Hash] opts the optional parameters
279
+ # @return [Array<(AFNORWebhook, Integer, Hash)>] AFNORWebhook data, response status code and response headers
280
+ def get_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_get_with_http_info(webhook_uid, opts = {})
281
+ if @api_client.config.debugging
282
+ @api_client.config.logger.debug 'Calling API: AFNORPDPPAFlowServiceApi.get_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_get ...'
283
+ end
284
+ # verify the required parameter 'webhook_uid' is set
285
+ if @api_client.config.client_side_validation && webhook_uid.nil?
286
+ fail ArgumentError, "Missing the required parameter 'webhook_uid' when calling AFNORPDPPAFlowServiceApi.get_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_get"
287
+ end
288
+ # resource path
289
+ local_var_path = '/api/v1/afnor/flow/v1/webhooks/{webhookUid}'.sub('{' + 'webhookUid' + '}', CGI.escape(webhook_uid.to_s))
290
+
291
+ # query parameters
292
+ query_params = opts[:query_params] || {}
293
+
294
+ # header parameters
295
+ header_params = opts[:header_params] || {}
296
+ # HTTP header 'Accept' (if needed)
297
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
298
+
299
+ # form parameters
300
+ form_params = opts[:form_params] || {}
301
+
302
+ # http body (model)
303
+ post_body = opts[:debug_body]
304
+
305
+ # return_type
306
+ return_type = opts[:debug_return_type] || 'AFNORWebhook'
307
+
308
+ # auth_names
309
+ auth_names = opts[:debug_auth_names] || []
310
+
311
+ new_options = opts.merge(
312
+ :operation => :"AFNORPDPPAFlowServiceApi.get_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_get",
313
+ :header_params => header_params,
314
+ :query_params => query_params,
315
+ :form_params => form_params,
316
+ :body => post_body,
317
+ :auth_names => auth_names,
318
+ :return_type => return_type
319
+ )
320
+
321
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
322
+ if @api_client.config.debugging
323
+ @api_client.config.logger.debug "API called: AFNORPDPPAFlowServiceApi#get_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
324
+ end
325
+ return data, status_code, headers
326
+ end
327
+
328
+ # List webhooks
329
+ # List all registered webhooks (AFNOR XP Z12-013 v1.2.0)
330
+ # @param [Hash] opts the optional parameters
331
+ # @return [Array<AFNORWebhook>]
332
+ def list_webhooks_proxy_api_v1_afnor_flow_v1_webhooks_get(opts = {})
333
+ data, _status_code, _headers = list_webhooks_proxy_api_v1_afnor_flow_v1_webhooks_get_with_http_info(opts)
334
+ data
335
+ end
336
+
337
+ # List webhooks
338
+ # List all registered webhooks (AFNOR XP Z12-013 v1.2.0)
339
+ # @param [Hash] opts the optional parameters
340
+ # @return [Array<(Array<AFNORWebhook>, Integer, Hash)>] Array<AFNORWebhook> data, response status code and response headers
341
+ def list_webhooks_proxy_api_v1_afnor_flow_v1_webhooks_get_with_http_info(opts = {})
342
+ if @api_client.config.debugging
343
+ @api_client.config.logger.debug 'Calling API: AFNORPDPPAFlowServiceApi.list_webhooks_proxy_api_v1_afnor_flow_v1_webhooks_get ...'
344
+ end
345
+ # resource path
346
+ local_var_path = '/api/v1/afnor/flow/v1/webhooks'
347
+
348
+ # query parameters
349
+ query_params = opts[:query_params] || {}
350
+
351
+ # header parameters
352
+ header_params = opts[:header_params] || {}
353
+ # HTTP header 'Accept' (if needed)
354
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
355
+
356
+ # form parameters
357
+ form_params = opts[:form_params] || {}
358
+
359
+ # http body (model)
360
+ post_body = opts[:debug_body]
361
+
362
+ # return_type
363
+ return_type = opts[:debug_return_type] || 'Array<AFNORWebhook>'
364
+
365
+ # auth_names
366
+ auth_names = opts[:debug_auth_names] || []
367
+
368
+ new_options = opts.merge(
369
+ :operation => :"AFNORPDPPAFlowServiceApi.list_webhooks_proxy_api_v1_afnor_flow_v1_webhooks_get",
370
+ :header_params => header_params,
371
+ :query_params => query_params,
372
+ :form_params => form_params,
373
+ :body => post_body,
374
+ :auth_names => auth_names,
375
+ :return_type => return_type
376
+ )
377
+
378
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
379
+ if @api_client.config.debugging
380
+ @api_client.config.logger.debug "API called: AFNORPDPPAFlowServiceApi#list_webhooks_proxy_api_v1_afnor_flow_v1_webhooks_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
381
+ end
382
+ return data, status_code, headers
383
+ end
384
+
145
385
  # Search flows
146
386
  # Search invoicing flows by criteria (AFNOR XP Z12-013 compliant)
147
387
  # @param afnor_search_flow_params [AFNORSearchFlowParams]
@@ -285,5 +525,68 @@ module FactPulse
285
525
  end
286
526
  return data, status_code, headers
287
527
  end
528
+
529
+ # Update a webhook
530
+ # Partially update a webhook subscription (AFNOR XP Z12-013 v1.2.0)
531
+ # @param webhook_uid [String] Webhook unique identifier (UUID)
532
+ # @param [Hash] opts the optional parameters
533
+ # @return [AFNORWebhook]
534
+ def update_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_patch(webhook_uid, opts = {})
535
+ data, _status_code, _headers = update_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_patch_with_http_info(webhook_uid, opts)
536
+ data
537
+ end
538
+
539
+ # Update a webhook
540
+ # Partially update a webhook subscription (AFNOR XP Z12-013 v1.2.0)
541
+ # @param webhook_uid [String] Webhook unique identifier (UUID)
542
+ # @param [Hash] opts the optional parameters
543
+ # @return [Array<(AFNORWebhook, Integer, Hash)>] AFNORWebhook data, response status code and response headers
544
+ def update_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_patch_with_http_info(webhook_uid, opts = {})
545
+ if @api_client.config.debugging
546
+ @api_client.config.logger.debug 'Calling API: AFNORPDPPAFlowServiceApi.update_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_patch ...'
547
+ end
548
+ # verify the required parameter 'webhook_uid' is set
549
+ if @api_client.config.client_side_validation && webhook_uid.nil?
550
+ fail ArgumentError, "Missing the required parameter 'webhook_uid' when calling AFNORPDPPAFlowServiceApi.update_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_patch"
551
+ end
552
+ # resource path
553
+ local_var_path = '/api/v1/afnor/flow/v1/webhooks/{webhookUid}'.sub('{' + 'webhookUid' + '}', CGI.escape(webhook_uid.to_s))
554
+
555
+ # query parameters
556
+ query_params = opts[:query_params] || {}
557
+
558
+ # header parameters
559
+ header_params = opts[:header_params] || {}
560
+ # HTTP header 'Accept' (if needed)
561
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
562
+
563
+ # form parameters
564
+ form_params = opts[:form_params] || {}
565
+
566
+ # http body (model)
567
+ post_body = opts[:debug_body]
568
+
569
+ # return_type
570
+ return_type = opts[:debug_return_type] || 'AFNORWebhook'
571
+
572
+ # auth_names
573
+ auth_names = opts[:debug_auth_names] || []
574
+
575
+ new_options = opts.merge(
576
+ :operation => :"AFNORPDPPAFlowServiceApi.update_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_patch",
577
+ :header_params => header_params,
578
+ :query_params => query_params,
579
+ :form_params => form_params,
580
+ :body => post_body,
581
+ :auth_names => auth_names,
582
+ :return_type => return_type
583
+ )
584
+
585
+ data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
586
+ if @api_client.config.debugging
587
+ @api_client.config.logger.debug "API called: AFNORPDPPAFlowServiceApi#update_webhook_proxy_api_v1_afnor_flow_v1_webhooks_webhook_uid_patch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
588
+ end
589
+ return data, status_code, headers
590
+ end
288
591
  end
289
592
  end
@@ -15,14 +15,15 @@ require 'time'
15
15
 
16
16
  module FactPulse
17
17
  class AFNORAlgorithm
18
- RSA = "RSA".freeze
18
+ RS256 = "RS256".freeze
19
+ HS256 = "HS256".freeze
19
20
  ECDSA = "ECDSA".freeze
20
- RSA_PSS = "RSA_PSS".freeze
21
21
  EDDSA_25519 = "EDDSA_25519".freeze
22
+ RSA_PSS = "RSA_PSS".freeze
22
23
  EDDSA_448 = "EDDSA_448".freeze
23
24
 
24
25
  def self.all_vars
25
- @all_vars ||= [RSA, ECDSA, RSA_PSS, EDDSA_25519, EDDSA_448].freeze
26
+ @all_vars ||= [RS256, HS256, ECDSA, EDDSA_25519, RSA_PSS, EDDSA_448].freeze
26
27
  end
27
28
 
28
29
  # Builds the enum from string
@@ -0,0 +1,190 @@
1
+ =begin
2
+ #FactPulse REST API
3
+
4
+ # REST API for electronic invoicing in France: Factur-X (CII), UBL 2.1, AFNOR PDP/PA, electronic signatures. ## 🎯 Main Features ### 📄 Invoice Generation - **Formats**: CII XML, UBL 2.1 XML, or Factur-X PDF/A-3 - **Profiles** (CII/PDF): MINIMUM, BASIC, EN16931, EXTENDED - **UBL**: Always EN16931 compliant - **Standards**: EN 16931 (EU directive 2014/55), ISO 19005-3 (PDF/A-3), CII (UN/CEFACT), UBL 2.1 (OASIS) - **Simplified Format**: Generation from SIRET + auto-enrichment (Chorus Pro API + Business Search) ### ✅ Factur-X - Validation - **XML Validation**: Schematron (45 to 210+ rules depending on profile) - **PDF Validation**: PDF/A-3, Factur-X XMP metadata - **VeraPDF**: Strict PDF/A validation (146+ ISO 19005-3 rules) ### ✍️ Electronic Signature - **Standards**: PAdES-B-B, PAdES-B-T (RFC 3161 timestamping), PAdES-B-LT (long-term archival) - **eIDAS Levels**: SES (self-signed), AdES (commercial CA), QES (QTSP) - **Validation**: Cryptographic integrity and certificate verification ### 📋 Flux 6 - Invoice Lifecycle (CDAR) - **CDAR Messages**: Acknowledgements, invoice statuses - **PPF Statuses**: REFUSED (210), PAID (212) ### 📊 Flux 10 - E-Reporting - **Tax Declarations**: International B2B, B2C - **Flow Types**: 10.1 (B2B transactions), 10.2 (B2B payments), 10.3 (B2C transactions), 10.4 (B2C payments) ### 📡 AFNOR PDP/PA (XP Z12-013) - **Flow Service**: Submit and search flows to PDPs - **Directory Service**: Company search (SIREN/SIRET) - **Multi-client**: Support for multiple PDP configs per user ### 🏛️ Chorus Pro - **Public Sector Invoicing**: Complete API for Chorus Pro ### ⏳ Async Tasks - **Celery**: Asynchronous generation, validation and signing - **Polling**: Status tracking via `/tasks/{task_id}/status` - **Webhooks**: Automatic notifications when tasks complete ## 🔒 Authentication All requests require a **JWT token** in the Authorization header: ``` Authorization: Bearer YOUR_JWT_TOKEN ``` ### How to obtain a JWT token? #### 🔑 Method 1: `/api/token/` API (Recommended) **URL:** `https://factpulse.fr/api/token/` This method is **recommended** for integration in your applications and CI/CD workflows. **Prerequisites:** Having set a password on your account **For users registered via email/password:** - You already have a password, use it directly **For users registered via OAuth (Google/GitHub):** - You must first set a password at: https://factpulse.fr/accounts/password/set/ - Once the password is created, you can use the API **Request example:** ```bash curl -X POST https://factpulse.fr/api/token/ \\ -H \"Content-Type: application/json\" \\ -d '{ \"username\": \"your_email@example.com\", \"password\": \"your_password\" }' ``` **Optional `client_uid` parameter:** To select credentials for a specific client (PA/PDP, Chorus Pro, signing certificates), add `client_uid`: ```bash curl -X POST https://factpulse.fr/api/token/ \\ -H \"Content-Type: application/json\" \\ -d '{ \"username\": \"your_email@example.com\", \"password\": \"your_password\", \"client_uid\": \"550e8400-e29b-41d4-a716-446655440000\" }' ``` The `client_uid` will be included in the JWT and allow the API to automatically use: - AFNOR/PDP credentials configured for this client - Chorus Pro credentials configured for this client - Electronic signature certificates configured for this client **Response:** ```json { \"access\": \"eyJ0eXAiOiJKV1QiLCJhbGc...\", // Access token (validity: 30 min) \"refresh\": \"eyJ0eXAiOiJKV1QiLCJhbGc...\" // Refresh token (validity: 7 days) } ``` **Advantages:** - ✅ Full automation (CI/CD, scripts) - ✅ Programmatic token management - ✅ Refresh token support for automatic access renewal - ✅ Easy integration in any language/tool #### 🖥️ Method 2: Dashboard Generation (Alternative) **URL:** https://factpulse.fr/api/dashboard/ This method is suitable for quick tests or occasional use via the graphical interface. **How it works:** - Log in to the dashboard - Use the \"Generate Test Token\" or \"Generate Production Token\" buttons - Works for **all** users (OAuth and email/password), without requiring a password **Token types:** - **Test Token**: 24h validity, 1000 calls/day quota (free) - **Production Token**: 7 days validity, quota based on your plan **Advantages:** - ✅ Quick for API testing - ✅ No password required - ✅ Simple visual interface **Disadvantages:** - ❌ Requires manual action - ❌ No refresh token - ❌ Less suited for automation ### 📚 Full Documentation For more information on authentication and API usage: https://factpulse.fr/documentation-api/
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: contact@factpulse.fr
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.21.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module FactPulse
17
+ class AFNORBasicAuthentication < ApiModelBase
18
+ attr_accessor :user_id
19
+
20
+ attr_accessor :user_password
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'user_id' => :'userId',
26
+ :'user_password' => :'userPassword'
27
+ }
28
+ end
29
+
30
+ # Returns attribute mapping this model knows about
31
+ def self.acceptable_attribute_map
32
+ attribute_map
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ acceptable_attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'user_id' => :'String',
44
+ :'user_password' => :'String'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FactPulse::AFNORBasicAuthentication` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ acceptable_attribute_map = self.class.acceptable_attribute_map
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!acceptable_attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FactPulse::AFNORBasicAuthentication`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'user_id')
71
+ self.user_id = attributes[:'user_id']
72
+ else
73
+ self.user_id = nil
74
+ end
75
+
76
+ if attributes.key?(:'user_password')
77
+ self.user_password = attributes[:'user_password']
78
+ else
79
+ self.user_password = nil
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
87
+ invalid_properties = Array.new
88
+ if @user_id.nil?
89
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
90
+ end
91
+
92
+ if @user_password.nil?
93
+ invalid_properties.push('invalid value for "user_password", user_password cannot be nil.')
94
+ end
95
+
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ warn '[DEPRECATED] the `valid?` method is obsolete'
103
+ return false if @user_id.nil?
104
+ return false if @user_password.nil?
105
+ true
106
+ end
107
+
108
+ # Custom attribute writer method with validation
109
+ # @param [Object] user_id Value to be assigned
110
+ def user_id=(user_id)
111
+ if user_id.nil?
112
+ fail ArgumentError, 'user_id cannot be nil'
113
+ end
114
+
115
+ @user_id = user_id
116
+ end
117
+
118
+ # Custom attribute writer method with validation
119
+ # @param [Object] user_password Value to be assigned
120
+ def user_password=(user_password)
121
+ if user_password.nil?
122
+ fail ArgumentError, 'user_password cannot be nil'
123
+ end
124
+
125
+ @user_password = user_password
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ user_id == o.user_id &&
134
+ user_password == o.user_password
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Integer] Hash code
145
+ def hash
146
+ [user_id, user_password].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ return nil unless attributes.is_a?(Hash)
154
+ attributes = attributes.transform_keys(&:to_sym)
155
+ transformed_hash = {}
156
+ openapi_types.each_pair do |key, type|
157
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
158
+ transformed_hash["#{key}"] = nil
159
+ elsif type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[attribute_map[key]].is_a?(Array)
163
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
164
+ end
165
+ elsif !attributes[attribute_map[key]].nil?
166
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
167
+ end
168
+ end
169
+ new(transformed_hash)
170
+ end
171
+
172
+ # Returns the object in the form of hash
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_hash
175
+ hash = {}
176
+ self.class.attribute_map.each_pair do |attr, param|
177
+ value = self.send(attr)
178
+ if value.nil?
179
+ is_nullable = self.class.openapi_nullable.include?(attr)
180
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
181
+ end
182
+
183
+ hash[param] = _to_hash(value)
184
+ end
185
+ hash
186
+ end
187
+
188
+ end
189
+
190
+ end
@@ -0,0 +1,105 @@
1
+ =begin
2
+ #FactPulse REST API
3
+
4
+ # REST API for electronic invoicing in France: Factur-X (CII), UBL 2.1, AFNOR PDP/PA, electronic signatures. ## 🎯 Main Features ### 📄 Invoice Generation - **Formats**: CII XML, UBL 2.1 XML, or Factur-X PDF/A-3 - **Profiles** (CII/PDF): MINIMUM, BASIC, EN16931, EXTENDED - **UBL**: Always EN16931 compliant - **Standards**: EN 16931 (EU directive 2014/55), ISO 19005-3 (PDF/A-3), CII (UN/CEFACT), UBL 2.1 (OASIS) - **Simplified Format**: Generation from SIRET + auto-enrichment (Chorus Pro API + Business Search) ### ✅ Factur-X - Validation - **XML Validation**: Schematron (45 to 210+ rules depending on profile) - **PDF Validation**: PDF/A-3, Factur-X XMP metadata - **VeraPDF**: Strict PDF/A validation (146+ ISO 19005-3 rules) ### ✍️ Electronic Signature - **Standards**: PAdES-B-B, PAdES-B-T (RFC 3161 timestamping), PAdES-B-LT (long-term archival) - **eIDAS Levels**: SES (self-signed), AdES (commercial CA), QES (QTSP) - **Validation**: Cryptographic integrity and certificate verification ### 📋 Flux 6 - Invoice Lifecycle (CDAR) - **CDAR Messages**: Acknowledgements, invoice statuses - **PPF Statuses**: REFUSED (210), PAID (212) ### 📊 Flux 10 - E-Reporting - **Tax Declarations**: International B2B, B2C - **Flow Types**: 10.1 (B2B transactions), 10.2 (B2B payments), 10.3 (B2C transactions), 10.4 (B2C payments) ### 📡 AFNOR PDP/PA (XP Z12-013) - **Flow Service**: Submit and search flows to PDPs - **Directory Service**: Company search (SIREN/SIRET) - **Multi-client**: Support for multiple PDP configs per user ### 🏛️ Chorus Pro - **Public Sector Invoicing**: Complete API for Chorus Pro ### ⏳ Async Tasks - **Celery**: Asynchronous generation, validation and signing - **Polling**: Status tracking via `/tasks/{task_id}/status` - **Webhooks**: Automatic notifications when tasks complete ## 🔒 Authentication All requests require a **JWT token** in the Authorization header: ``` Authorization: Bearer YOUR_JWT_TOKEN ``` ### How to obtain a JWT token? #### 🔑 Method 1: `/api/token/` API (Recommended) **URL:** `https://factpulse.fr/api/token/` This method is **recommended** for integration in your applications and CI/CD workflows. **Prerequisites:** Having set a password on your account **For users registered via email/password:** - You already have a password, use it directly **For users registered via OAuth (Google/GitHub):** - You must first set a password at: https://factpulse.fr/accounts/password/set/ - Once the password is created, you can use the API **Request example:** ```bash curl -X POST https://factpulse.fr/api/token/ \\ -H \"Content-Type: application/json\" \\ -d '{ \"username\": \"your_email@example.com\", \"password\": \"your_password\" }' ``` **Optional `client_uid` parameter:** To select credentials for a specific client (PA/PDP, Chorus Pro, signing certificates), add `client_uid`: ```bash curl -X POST https://factpulse.fr/api/token/ \\ -H \"Content-Type: application/json\" \\ -d '{ \"username\": \"your_email@example.com\", \"password\": \"your_password\", \"client_uid\": \"550e8400-e29b-41d4-a716-446655440000\" }' ``` The `client_uid` will be included in the JWT and allow the API to automatically use: - AFNOR/PDP credentials configured for this client - Chorus Pro credentials configured for this client - Electronic signature certificates configured for this client **Response:** ```json { \"access\": \"eyJ0eXAiOiJKV1QiLCJhbGc...\", // Access token (validity: 30 min) \"refresh\": \"eyJ0eXAiOiJKV1QiLCJhbGc...\" // Refresh token (validity: 7 days) } ``` **Advantages:** - ✅ Full automation (CI/CD, scripts) - ✅ Programmatic token management - ✅ Refresh token support for automatic access renewal - ✅ Easy integration in any language/tool #### 🖥️ Method 2: Dashboard Generation (Alternative) **URL:** https://factpulse.fr/api/dashboard/ This method is suitable for quick tests or occasional use via the graphical interface. **How it works:** - Log in to the dashboard - Use the \"Generate Test Token\" or \"Generate Production Token\" buttons - Works for **all** users (OAuth and email/password), without requiring a password **Token types:** - **Test Token**: 24h validity, 1000 calls/day quota (free) - **Production Token**: 7 days validity, quota based on your plan **Advantages:** - ✅ Quick for API testing - ✅ No password required - ✅ Simple visual interface **Disadvantages:** - ❌ Requires manual action - ❌ No refresh token - ❌ Less suited for automation ### 📚 Full Documentation For more information on authentication and API usage: https://factpulse.fr/documentation-api/
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: contact@factpulse.fr
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.21.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module FactPulse
17
+ # The authentication mode required for the callback call
18
+ module AFNORCallbackAuthentication
19
+ class << self
20
+ # List of class defined in oneOf (OpenAPI v3)
21
+ def openapi_one_of
22
+ [
23
+ :'AFNORBasicAuthentication',
24
+ :'AFNOROAuth2Authentication'
25
+ ]
26
+ end
27
+
28
+ # Builds the object
29
+ # @param [Mixed] Data to be matched against the list of oneOf items
30
+ # @return [Object] Returns the model or the data itself
31
+ def build(data)
32
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
33
+ # Note:
34
+ # - We do not attempt to check whether exactly one item matches.
35
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
36
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
37
+ # - TODO: scalar values are de facto behaving as if they were nullable.
38
+ # - TODO: logging when debugging is set.
39
+ openapi_one_of.each do |klass|
40
+ begin
41
+ next if klass == :AnyType # "nullable: true"
42
+ return find_and_cast_into_type(klass, data)
43
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
44
+ end
45
+ end
46
+
47
+ openapi_one_of.include?(:AnyType) ? data : nil
48
+ end
49
+
50
+ private
51
+
52
+ SchemaMismatchError = Class.new(StandardError)
53
+
54
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
55
+ def find_and_cast_into_type(klass, data)
56
+ return if data.nil?
57
+
58
+ case klass.to_s
59
+ when 'Boolean'
60
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
61
+ when 'Float'
62
+ return data if data.instance_of?(Float)
63
+ when 'Integer'
64
+ return data if data.instance_of?(Integer)
65
+ when 'Time'
66
+ return Time.parse(data)
67
+ when 'Date'
68
+ return Date.iso8601(data)
69
+ when 'String'
70
+ return data if data.instance_of?(String)
71
+ when 'Object' # "type: object"
72
+ return data if data.instance_of?(Hash)
73
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
74
+ if data.instance_of?(Array)
75
+ sub_type = Regexp.last_match[:sub_type]
76
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
77
+ end
78
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ else # model
84
+ const = FactPulse.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
87
+ model = const.build(data)
88
+ return model if model
89
+ else
90
+ # raise if data contains keys that are not known to the model
91
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
92
+ model = const.build_from_hash(data)
93
+ return model if model
94
+ end
95
+ end
96
+ end
97
+
98
+ raise # if no match by now, raise
99
+ rescue
100
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
101
+ end
102
+ end
103
+ end
104
+
105
+ end