plainrouter-sdk 0.1.0 → 0.2.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 (127) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/plainrouter/client.rb +73 -1
  4. data/lib/plainrouter/openapi/api/action_dry_run_api_api.rb +96 -0
  5. data/lib/plainrouter/openapi/api/action_proposal_api_api.rb +96 -0
  6. data/lib/plainrouter/openapi/api/action_read_api_api.rb +404 -0
  7. data/lib/plainrouter/openapi/api/event_api.rb +15 -15
  8. data/lib/plainrouter/openapi/api/operations_api.rb +24 -28
  9. data/lib/plainrouter/openapi/api/sandbox_api.rb +74 -17
  10. data/lib/plainrouter/openapi/api_client.rb +2 -2
  11. data/lib/plainrouter/openapi/api_error.rb +2 -2
  12. data/lib/plainrouter/openapi/api_model_base.rb +2 -2
  13. data/lib/plainrouter/openapi/configuration.rb +10 -3
  14. data/lib/plainrouter/openapi/models/action_batch_read.rb +164 -0
  15. data/lib/plainrouter/openapi/models/action_batch_read_data.rb +450 -0
  16. data/lib/plainrouter/openapi/models/action_current_disposition.rb +294 -0
  17. data/lib/plainrouter/openapi/models/action_decision_receipt_read.rb +244 -0
  18. data/lib/plainrouter/openapi/models/action_decision_receipt_read_chain_entry.rb +190 -0
  19. data/lib/plainrouter/openapi/models/action_detail_read.rb +164 -0
  20. data/lib/plainrouter/openapi/models/action_dry_run_read.rb +164 -0
  21. data/lib/plainrouter/openapi/models/action_dry_run_read_dry_run.rb +166 -0
  22. data/lib/plainrouter/openapi/models/action_dry_run_read_dry_run_actions_inner.rb +103 -0
  23. data/lib/plainrouter/openapi/models/action_dry_run_read_dry_run_actions_inner_any_of.rb +376 -0
  24. data/lib/plainrouter/openapi/models/action_dry_run_read_dry_run_actions_inner_any_of1.rb +268 -0
  25. data/lib/plainrouter/openapi/models/action_dry_run_read_dry_run_actions_inner_any_of_diff.rb +162 -0
  26. data/lib/plainrouter/openapi/models/action_dry_run_read_dry_run_actions_inner_any_of_target_entity.rb +199 -0
  27. data/lib/plainrouter/openapi/models/action_list_read.rb +192 -0
  28. data/lib/plainrouter/openapi/models/action_list_read_meta.rb +242 -0
  29. data/lib/plainrouter/openapi/models/action_policy_read.rb +164 -0
  30. data/lib/plainrouter/openapi/models/action_policy_read_data.rb +380 -0
  31. data/lib/plainrouter/openapi/models/action_proposal_input.rb +378 -0
  32. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner.rb +115 -0
  33. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of.rb +303 -0
  34. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of1.rb +303 -0
  35. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of10.rb +303 -0
  36. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of10_params.rb +356 -0
  37. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of11.rb +303 -0
  38. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of11_params.rb +173 -0
  39. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of12.rb +303 -0
  40. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of12_params.rb +188 -0
  41. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of13.rb +303 -0
  42. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of13_params.rb +259 -0
  43. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of2.rb +303 -0
  44. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of3.rb +303 -0
  45. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of4.rb +303 -0
  46. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of4_target_entity.rb +253 -0
  47. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of5.rb +303 -0
  48. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of6.rb +303 -0
  49. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of7.rb +303 -0
  50. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of8.rb +303 -0
  51. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of9.rb +303 -0
  52. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of_params.rb +173 -0
  53. data/lib/plainrouter/openapi/models/action_proposal_input_actions_inner_any_of_target_entity.rb +264 -0
  54. data/lib/plainrouter/openapi/models/action_proposal_input_evidence_inner.rb +262 -0
  55. data/lib/plainrouter/openapi/models/action_proposal_read.rb +164 -0
  56. data/lib/plainrouter/openapi/models/action_proposal_read_proposal.rb +452 -0
  57. data/lib/plainrouter/openapi/models/action_proposal_read_proposal_actions_inner.rb +386 -0
  58. data/lib/plainrouter/openapi/models/action_proposal_read_proposal_actions_inner_params.rb +103 -0
  59. data/lib/plainrouter/openapi/models/action_proposal_read_proposal_proposed_by.rb +202 -0
  60. data/lib/plainrouter/openapi/models/action_read_item.rb +516 -0
  61. data/lib/plainrouter/openapi/models/create_event200_response.rb +2 -2
  62. data/lib/plainrouter/openapi/models/create_event202_response.rb +218 -0
  63. data/lib/plainrouter/openapi/models/create_event202_response_warnings_inner.rb +240 -0
  64. data/lib/plainrouter/openapi/models/create_event_request.rb +2 -2
  65. data/lib/plainrouter/openapi/models/create_event_request_any_of.rb +2 -2
  66. data/lib/plainrouter/openapi/models/create_event_request_any_of1.rb +2 -2
  67. data/lib/plainrouter/openapi/models/create_event_request_any_of_event_time.rb +2 -2
  68. data/lib/plainrouter/openapi/models/create_event_request_any_of_value_data.rb +2 -2
  69. data/lib/plainrouter/openapi/models/delete_user_data200_response.rb +2 -2
  70. data/lib/plainrouter/openapi/models/delete_user_data_request.rb +35 -36
  71. data/lib/plainrouter/openapi/models/delivery_status.rb +2 -2
  72. data/lib/plainrouter/openapi/models/destination.rb +30 -3
  73. data/lib/plainrouter/openapi/models/destination_credential_source.rb +3 -4
  74. data/lib/plainrouter/openapi/models/destination_status.rb +2 -2
  75. data/lib/plainrouter/openapi/models/destination_type.rb +2 -2
  76. data/lib/plainrouter/openapi/models/emq_snapshot.rb +30 -3
  77. data/lib/plainrouter/openapi/models/error_message.rb +2 -2
  78. data/lib/plainrouter/openapi/models/event.rb +89 -45
  79. data/lib/plainrouter/openapi/models/get_emq_report200_response.rb +2 -2
  80. data/lib/plainrouter/openapi/models/get_emq_report200_response_snapshots_inner.rb +30 -3
  81. data/lib/plainrouter/openapi/models/get_event200_response.rb +2 -2
  82. data/lib/plainrouter/openapi/models/get_event200_response_deliveries_inner.rb +30 -3
  83. data/lib/plainrouter/openapi/models/get_event200_response_event.rb +31 -4
  84. data/lib/plainrouter/openapi/models/get_event200_response_event_consent.rb +2 -2
  85. data/lib/plainrouter/openapi/models/get_event200_response_event_deliveries_inner.rb +30 -3
  86. data/lib/plainrouter/openapi/models/get_event200_response_event_user_data_hashed.rb +104 -0
  87. data/lib/plainrouter/openapi/models/get_event200_response_lineage.rb +2 -2
  88. data/lib/plainrouter/openapi/models/get_event200_response_lineage_children_inner.rb +31 -4
  89. data/lib/plainrouter/openapi/models/get_event200_response_lineage_parent.rb +31 -4
  90. data/lib/plainrouter/openapi/models/get_reconciliation_report200_response.rb +2 -2
  91. data/lib/plainrouter/openapi/models/get_reconciliation_report200_response_reports_inner.rb +30 -3
  92. data/lib/plainrouter/openapi/models/get_reconciliation_report200_response_reports_inner_buckets_value.rb +2 -2
  93. data/lib/plainrouter/openapi/models/get_reconciliation_report200_response_reports_inner_event_counts.rb +2 -2
  94. data/lib/plainrouter/openapi/models/get_reconciliation_report200_response_reports_inner_event_counts_accepted.rb +2 -2
  95. data/lib/plainrouter/openapi/models/get_sandbox200_response.rb +2 -2
  96. data/lib/plainrouter/openapi/models/get_sandbox200_response_self_serve_key.rb +32 -6
  97. data/lib/plainrouter/openapi/models/{create_sandbox_key201_response.rb → get_sandbox200_response_self_serve_key_issued_key.rb} +6 -6
  98. data/lib/plainrouter/openapi/models/{create_sandbox_key201_response_use.rb → get_sandbox200_response_self_serve_key_issued_key_use.rb} +5 -5
  99. data/lib/plainrouter/openapi/models/get_sandbox200_response_try.rb +2 -2
  100. data/lib/plainrouter/openapi/models/get_sandbox200_response_try_body.rb +2 -2
  101. data/lib/plainrouter/openapi/models/get_sandbox200_response_try_body_value_data.rb +2 -2
  102. data/lib/plainrouter/openapi/models/ingestion_warning_code.rb +39 -0
  103. data/lib/plainrouter/openapi/models/jurisdiction_policy_class.rb +2 -2
  104. data/lib/plainrouter/openapi/models/list_events200_response.rb +2 -2
  105. data/lib/plainrouter/openapi/models/list_events200_response_events.rb +2 -2
  106. data/lib/plainrouter/openapi/models/list_events200_response_events_links_inner.rb +2 -2
  107. data/lib/plainrouter/openapi/models/list_events200_response_metrics.rb +2 -2
  108. data/lib/plainrouter/openapi/models/list_events_by_cursor200_response.rb +2 -2
  109. data/lib/plainrouter/openapi/models/list_events_by_cursor200_response_events.rb +2 -2
  110. data/lib/plainrouter/openapi/models/reconciliation_report.rb +31 -3
  111. data/lib/plainrouter/openapi/models/replay_deliveries202_response.rb +2 -2
  112. data/lib/plainrouter/openapi/models/replay_deliveries_request.rb +2 -2
  113. data/lib/plainrouter/openapi/models/send_test_purchase200_response.rb +2 -2
  114. data/lib/plainrouter/openapi/models/send_test_purchase422_response.rb +2 -2
  115. data/lib/plainrouter/openapi/models/send_test_purchase_request.rb +2 -2
  116. data/lib/plainrouter/openapi/models/set_destination_test_mode200_response.rb +2 -2
  117. data/lib/plainrouter/openapi/models/set_destination_test_mode200_response_destination.rb +30 -3
  118. data/lib/plainrouter/openapi/models/set_destination_test_mode_request.rb +2 -2
  119. data/lib/plainrouter/openapi/models/traffic_class.rb +2 -2
  120. data/lib/plainrouter/openapi/models/validate_sandbox_event200_response.rb +2 -2
  121. data/lib/plainrouter/openapi/models/validate_sandbox_event_request.rb +2 -2
  122. data/lib/plainrouter/openapi/models/validate_sandbox_event_request_value_data.rb +2 -2
  123. data/lib/plainrouter/openapi/models/validation_error.rb +2 -2
  124. data/lib/plainrouter/openapi/version.rb +3 -3
  125. data/lib/plainrouter/openapi.rb +58 -4
  126. data/lib/plainrouter/version.rb +1 -1
  127. metadata +64 -10
@@ -0,0 +1,378 @@
1
+ =begin
2
+ #Plainrouter Conversion API
3
+
4
+ #Plainrouter public Signals Conversion API.
5
+
6
+ The version of the OpenAPI document: 0.5.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.25.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PlainRouter::OpenAPI
17
+ class ActionProposalInput < ApiModelBase
18
+ attr_accessor :actions
19
+
20
+ attr_accessor :rationale
21
+
22
+ attr_accessor :idempotency_key
23
+
24
+ attr_accessor :evidence
25
+
26
+ attr_accessor :target_source
27
+
28
+ attr_accessor :account_id
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'actions' => :'actions',
56
+ :'rationale' => :'rationale',
57
+ :'idempotency_key' => :'idempotency_key',
58
+ :'evidence' => :'evidence',
59
+ :'target_source' => :'target_source',
60
+ :'account_id' => :'account_id'
61
+ }
62
+ end
63
+
64
+ # Returns attribute mapping this model knows about
65
+ def self.acceptable_attribute_map
66
+ attribute_map
67
+ end
68
+
69
+ # Returns all the JSON keys this model knows about
70
+ def self.acceptable_attributes
71
+ acceptable_attribute_map.values
72
+ end
73
+
74
+ # Attribute type mapping.
75
+ def self.openapi_types
76
+ {
77
+ :'actions' => :'Array<ActionProposalInputActionsInner>',
78
+ :'rationale' => :'String',
79
+ :'idempotency_key' => :'String',
80
+ :'evidence' => :'Array<ActionProposalInputEvidenceInner>',
81
+ :'target_source' => :'String',
82
+ :'account_id' => :'Integer'
83
+ }
84
+ end
85
+
86
+ # List of attributes with nullable: true
87
+ def self.openapi_nullable
88
+ Set.new([
89
+ ])
90
+ end
91
+
92
+ # Initializes the object
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ def initialize(attributes = {})
95
+ if (!attributes.is_a?(Hash))
96
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PlainRouter::OpenAPI::ActionProposalInput` initialize method"
97
+ end
98
+
99
+ # check to see if the attribute exists and convert string to symbol for hash key
100
+ acceptable_attribute_map = self.class.acceptable_attribute_map
101
+ attributes = attributes.each_with_object({}) { |(k, v), h|
102
+ if (!acceptable_attribute_map.key?(k.to_sym))
103
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PlainRouter::OpenAPI::ActionProposalInput`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
104
+ end
105
+ h[k.to_sym] = v
106
+ }
107
+
108
+ if attributes.key?(:'actions')
109
+ if (value = attributes[:'actions']).is_a?(Array)
110
+ self.actions = value
111
+ end
112
+ else
113
+ self.actions = nil
114
+ end
115
+
116
+ if attributes.key?(:'rationale')
117
+ self.rationale = attributes[:'rationale']
118
+ else
119
+ self.rationale = nil
120
+ end
121
+
122
+ if attributes.key?(:'idempotency_key')
123
+ self.idempotency_key = attributes[:'idempotency_key']
124
+ else
125
+ self.idempotency_key = nil
126
+ end
127
+
128
+ if attributes.key?(:'evidence')
129
+ if (value = attributes[:'evidence']).is_a?(Array)
130
+ self.evidence = value
131
+ end
132
+ else
133
+ self.evidence = nil
134
+ end
135
+
136
+ if attributes.key?(:'target_source')
137
+ self.target_source = attributes[:'target_source']
138
+ else
139
+ self.target_source = nil
140
+ end
141
+
142
+ if attributes.key?(:'account_id')
143
+ self.account_id = attributes[:'account_id']
144
+ end
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properties with the reasons
149
+ def list_invalid_properties
150
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
151
+ invalid_properties = Array.new
152
+ if @actions.nil?
153
+ invalid_properties.push('invalid value for "actions", actions cannot be nil.')
154
+ end
155
+
156
+ if @actions.length > 25
157
+ invalid_properties.push('invalid value for "actions", number of items must be less than or equal to 25.')
158
+ end
159
+
160
+ if @actions.length < 1
161
+ invalid_properties.push('invalid value for "actions", number of items must be greater than or equal to 1.')
162
+ end
163
+
164
+ if @rationale.nil?
165
+ invalid_properties.push('invalid value for "rationale", rationale cannot be nil.')
166
+ end
167
+
168
+ if @rationale.to_s.length > 4000
169
+ invalid_properties.push('invalid value for "rationale", the character length must be smaller than or equal to 4000.')
170
+ end
171
+
172
+ if @idempotency_key.nil?
173
+ invalid_properties.push('invalid value for "idempotency_key", idempotency_key cannot be nil.')
174
+ end
175
+
176
+ if @idempotency_key.to_s.length > 64
177
+ invalid_properties.push('invalid value for "idempotency_key", the character length must be smaller than or equal to 64.')
178
+ end
179
+
180
+ if @evidence.nil?
181
+ invalid_properties.push('invalid value for "evidence", evidence cannot be nil.')
182
+ end
183
+
184
+ if @evidence.length > 3
185
+ invalid_properties.push('invalid value for "evidence", number of items must be less than or equal to 3.')
186
+ end
187
+
188
+ if @evidence.length < 1
189
+ invalid_properties.push('invalid value for "evidence", number of items must be greater than or equal to 1.')
190
+ end
191
+
192
+ if @target_source.nil?
193
+ invalid_properties.push('invalid value for "target_source", target_source cannot be nil.')
194
+ end
195
+
196
+ if !@account_id.nil? && @account_id < 1
197
+ invalid_properties.push('invalid value for "account_id", must be greater than or equal to 1.')
198
+ end
199
+
200
+ invalid_properties
201
+ end
202
+
203
+ # Check to see if the all the properties in the model are valid
204
+ # @return true if the model is valid
205
+ def valid?
206
+ warn '[DEPRECATED] the `valid?` method is obsolete'
207
+ return false if @actions.nil?
208
+ return false if @actions.length > 25
209
+ return false if @actions.length < 1
210
+ return false if @rationale.nil?
211
+ return false if @rationale.to_s.length > 4000
212
+ return false if @idempotency_key.nil?
213
+ return false if @idempotency_key.to_s.length > 64
214
+ return false if @evidence.nil?
215
+ return false if @evidence.length > 3
216
+ return false if @evidence.length < 1
217
+ return false if @target_source.nil?
218
+ target_source_validator = EnumAttributeValidator.new('String', ["human_supplied"])
219
+ return false unless target_source_validator.valid?(@target_source)
220
+ return false if !@account_id.nil? && @account_id < 1
221
+ true
222
+ end
223
+
224
+ # Custom attribute writer method with validation
225
+ # @param [Object] actions Value to be assigned
226
+ def actions=(actions)
227
+ if actions.nil?
228
+ fail ArgumentError, 'actions cannot be nil'
229
+ end
230
+
231
+ if actions.length > 25
232
+ fail ArgumentError, 'invalid value for "actions", number of items must be less than or equal to 25.'
233
+ end
234
+
235
+ if actions.length < 1
236
+ fail ArgumentError, 'invalid value for "actions", number of items must be greater than or equal to 1.'
237
+ end
238
+
239
+ @actions = actions
240
+ end
241
+
242
+ # Custom attribute writer method with validation
243
+ # @param [Object] rationale Value to be assigned
244
+ def rationale=(rationale)
245
+ if rationale.nil?
246
+ fail ArgumentError, 'rationale cannot be nil'
247
+ end
248
+
249
+ if rationale.to_s.length > 4000
250
+ fail ArgumentError, 'invalid value for "rationale", the character length must be smaller than or equal to 4000.'
251
+ end
252
+
253
+ @rationale = rationale
254
+ end
255
+
256
+ # Custom attribute writer method with validation
257
+ # @param [Object] idempotency_key Value to be assigned
258
+ def idempotency_key=(idempotency_key)
259
+ if idempotency_key.nil?
260
+ fail ArgumentError, 'idempotency_key cannot be nil'
261
+ end
262
+
263
+ if idempotency_key.to_s.length > 64
264
+ fail ArgumentError, 'invalid value for "idempotency_key", the character length must be smaller than or equal to 64.'
265
+ end
266
+
267
+ @idempotency_key = idempotency_key
268
+ end
269
+
270
+ # Custom attribute writer method with validation
271
+ # @param [Object] evidence Value to be assigned
272
+ def evidence=(evidence)
273
+ if evidence.nil?
274
+ fail ArgumentError, 'evidence cannot be nil'
275
+ end
276
+
277
+ if evidence.length > 3
278
+ fail ArgumentError, 'invalid value for "evidence", number of items must be less than or equal to 3.'
279
+ end
280
+
281
+ if evidence.length < 1
282
+ fail ArgumentError, 'invalid value for "evidence", number of items must be greater than or equal to 1.'
283
+ end
284
+
285
+ @evidence = evidence
286
+ end
287
+
288
+ # Custom attribute writer method checking allowed values (enum).
289
+ # @param [Object] target_source Object to be assigned
290
+ def target_source=(target_source)
291
+ validator = EnumAttributeValidator.new('String', ["human_supplied"])
292
+ unless validator.valid?(target_source)
293
+ fail ArgumentError, "invalid value for \"target_source\", must be one of #{validator.allowable_values}."
294
+ end
295
+ @target_source = target_source
296
+ end
297
+
298
+ # Custom attribute writer method with validation
299
+ # @param [Object] account_id Value to be assigned
300
+ def account_id=(account_id)
301
+ if account_id.nil?
302
+ fail ArgumentError, 'account_id cannot be nil'
303
+ end
304
+
305
+ if account_id < 1
306
+ fail ArgumentError, 'invalid value for "account_id", must be greater than or equal to 1.'
307
+ end
308
+
309
+ @account_id = account_id
310
+ end
311
+
312
+ # Checks equality by comparing each attribute.
313
+ # @param [Object] Object to be compared
314
+ def ==(o)
315
+ return true if self.equal?(o)
316
+ self.class == o.class &&
317
+ actions == o.actions &&
318
+ rationale == o.rationale &&
319
+ idempotency_key == o.idempotency_key &&
320
+ evidence == o.evidence &&
321
+ target_source == o.target_source &&
322
+ account_id == o.account_id
323
+ end
324
+
325
+ # @see the `==` method
326
+ # @param [Object] Object to be compared
327
+ def eql?(o)
328
+ self == o
329
+ end
330
+
331
+ # Calculates hash code according to all attributes.
332
+ # @return [Integer] Hash code
333
+ def hash
334
+ [actions, rationale, idempotency_key, evidence, target_source, account_id].hash
335
+ end
336
+
337
+ # Builds the object from hash
338
+ # @param [Hash] attributes Model attributes in the form of hash
339
+ # @return [Object] Returns the model itself
340
+ def self.build_from_hash(attributes)
341
+ return nil unless attributes.is_a?(Hash)
342
+ attributes = attributes.transform_keys(&:to_sym)
343
+ transformed_hash = {}
344
+ openapi_types.each_pair do |key, type|
345
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
346
+ transformed_hash["#{key}"] = nil
347
+ elsif type =~ /\AArray<(.*)>/i
348
+ # check to ensure the input is an array given that the attribute
349
+ # is documented as an array but the input is not
350
+ if attributes[attribute_map[key]].is_a?(Array)
351
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
352
+ end
353
+ elsif !attributes[attribute_map[key]].nil?
354
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
355
+ end
356
+ end
357
+ new(transformed_hash)
358
+ end
359
+
360
+ # Returns the object in the form of hash
361
+ # @return [Hash] Returns the object in the form of hash
362
+ def to_hash
363
+ hash = {}
364
+ self.class.attribute_map.each_pair do |attr, param|
365
+ value = self.send(attr)
366
+ if value.nil?
367
+ is_nullable = self.class.openapi_nullable.include?(attr)
368
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
369
+ end
370
+
371
+ hash[param] = _to_hash(value)
372
+ end
373
+ hash
374
+ end
375
+
376
+ end
377
+
378
+ end
@@ -0,0 +1,115 @@
1
+ =begin
2
+ #Plainrouter Conversion API
3
+
4
+ #Plainrouter public Signals Conversion API.
5
+
6
+ The version of the OpenAPI document: 0.5.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.25.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PlainRouter::OpenAPI
17
+ module ActionProposalInputActionsInner
18
+ class << self
19
+ # List of class defined in anyOf (OpenAPI v3)
20
+ def openapi_any_of
21
+ [
22
+ :'ActionProposalInputActionsInnerAnyOf',
23
+ :'ActionProposalInputActionsInnerAnyOf1',
24
+ :'ActionProposalInputActionsInnerAnyOf10',
25
+ :'ActionProposalInputActionsInnerAnyOf11',
26
+ :'ActionProposalInputActionsInnerAnyOf12',
27
+ :'ActionProposalInputActionsInnerAnyOf13',
28
+ :'ActionProposalInputActionsInnerAnyOf2',
29
+ :'ActionProposalInputActionsInnerAnyOf3',
30
+ :'ActionProposalInputActionsInnerAnyOf4',
31
+ :'ActionProposalInputActionsInnerAnyOf5',
32
+ :'ActionProposalInputActionsInnerAnyOf6',
33
+ :'ActionProposalInputActionsInnerAnyOf7',
34
+ :'ActionProposalInputActionsInnerAnyOf8',
35
+ :'ActionProposalInputActionsInnerAnyOf9'
36
+ ]
37
+ end
38
+
39
+ # Builds the object
40
+ # @param [Mixed] Data to be matched against the list of anyOf items
41
+ # @return [Object] Returns the model or the data itself
42
+ def build(data)
43
+ # Go through the list of anyOf items and attempt to identify the appropriate one.
44
+ # Note:
45
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
46
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
47
+ # - TODO: scalar values are de facto behaving as if they were nullable.
48
+ # - TODO: logging when debugging is set.
49
+ openapi_any_of.each do |klass|
50
+ begin
51
+ next if klass == :AnyType # "nullable: true"
52
+ return find_and_cast_into_type(klass, data)
53
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
54
+ end
55
+ end
56
+
57
+ openapi_any_of.include?(:AnyType) ? data : nil
58
+ end
59
+
60
+ private
61
+
62
+ SchemaMismatchError = Class.new(StandardError)
63
+
64
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
65
+ def find_and_cast_into_type(klass, data)
66
+ return if data.nil?
67
+
68
+ case klass.to_s
69
+ when 'Boolean'
70
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
71
+ when 'Float'
72
+ return data if data.instance_of?(Float)
73
+ when 'Integer'
74
+ return data if data.instance_of?(Integer)
75
+ when 'Time'
76
+ return Time.parse(data)
77
+ when 'Date'
78
+ return Date.iso8601(data)
79
+ when 'String'
80
+ return data if data.instance_of?(String)
81
+ when 'Object' # "type: object"
82
+ return data if data.instance_of?(Hash)
83
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
84
+ if data.instance_of?(Array)
85
+ sub_type = Regexp.last_match[:sub_type]
86
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
87
+ end
88
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
89
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
90
+ sub_type = Regexp.last_match[:sub_type]
91
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
92
+ end
93
+ else # model
94
+ const = PlainRouter::OpenAPI.const_get(klass)
95
+ if const
96
+ if const.respond_to?(:openapi_any_of) # nested anyOf model
97
+ model = const.build(data)
98
+ return model if model
99
+ else
100
+ # raise if data contains keys that are not known to the model
101
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
102
+ model = const.build_from_hash(data)
103
+ return model if model
104
+ end
105
+ end
106
+ end
107
+
108
+ raise # if no match by now, raise
109
+ rescue
110
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
111
+ end
112
+ end
113
+ end
114
+
115
+ end