form_api 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/{.swagger-codegen-ignore → .openapi-generator-ignore} +3 -3
  4. data/.openapi-generator/VERSION +1 -0
  5. data/.rubocop.yml +154 -0
  6. data/Gemfile.lock +15 -16
  7. data/README.md +30 -28
  8. data/Rakefile +2 -0
  9. data/docs/{InlineResponse422.md → AuthenticationError.md} +3 -3
  10. data/docs/{InlineResponse401.md → AuthenticationSuccessResponse.md} +2 -2
  11. data/docs/CombinedSubmission.md +14 -0
  12. data/docs/CombinedSubmissionData.md +11 -0
  13. data/docs/CreateCombinedSubmissionResponse.md +10 -0
  14. data/docs/CreateSubmissionBatchResponse.md +12 -0
  15. data/docs/CreateSubmissionData.md +12 -0
  16. data/docs/CreateSubmissionDataBatchRequest.md +13 -0
  17. data/docs/CreateSubmissionResponse.md +10 -0
  18. data/docs/CreateSubmissionResponse1.md +10 -0
  19. data/docs/{InlineResponse200.md → Error.md} +3 -2
  20. data/docs/{InlineResponse400.md → InvalidRequest.md} +3 -3
  21. data/docs/PDFApi.md +148 -64
  22. data/docs/Submission.md +16 -0
  23. data/docs/SubmissionBatch.md +16 -0
  24. data/docs/SubmissionBatchData.md +11 -0
  25. data/docs/Template.md +21 -0
  26. data/form_api.gemspec +6 -11
  27. data/git_push.sh +3 -3
  28. data/lib/form_api.rb +22 -15
  29. data/lib/form_api/api/client.rb +91 -38
  30. data/lib/form_api/api/pdf_api.rb +222 -109
  31. data/lib/form_api/api_client.rb +13 -13
  32. data/lib/form_api/api_error.rb +3 -3
  33. data/lib/form_api/configuration.rb +26 -5
  34. data/lib/form_api/models/{inline_response_201_1.rb → authentication_error.rb} +25 -29
  35. data/lib/form_api/models/{inline_response_200.rb → authentication_success_response.rb} +15 -24
  36. data/lib/form_api/models/{inline_response_201_combined_submission.rb → combined_submission.rb} +42 -66
  37. data/lib/form_api/models/{create_combined_submission_body.rb → combined_submission_data.rb} +13 -18
  38. data/lib/form_api/models/{inline_response_201.rb → create_combined_submission_response.rb} +37 -35
  39. data/lib/form_api/models/create_submission_batch_response.rb +257 -0
  40. data/lib/form_api/models/{create_submission_batch_body.rb → create_submission_data.rb} +32 -19
  41. data/lib/form_api/models/{create_submission_body.rb → create_submission_data_batch_request.rb} +45 -18
  42. data/lib/form_api/models/create_submission_response.rb +237 -0
  43. data/lib/form_api/models/create_submission_response1.rb +237 -0
  44. data/lib/form_api/models/{inline_response_400.rb → error.rb} +17 -21
  45. data/lib/form_api/models/{inline_response_422.rb → invalid_request.rb} +17 -21
  46. data/lib/form_api/models/{templatestemplate_idsubmissionsbatch_submission.rb → submission.rb} +40 -26
  47. data/lib/form_api/models/submission_batch.rb +291 -0
  48. data/lib/form_api/models/{inline_response_401.rb → submission_batch_data.rb} +48 -24
  49. data/lib/form_api/models/{inline_response_200_1.rb → template.rb} +88 -152
  50. data/lib/form_api/version.rb +4 -4
  51. data/spec/api/client_spec.rb +197 -23
  52. data/spec/api/pdf_api_spec.rb +168 -63
  53. data/spec/api_client_spec.rb +37 -37
  54. data/spec/configuration_spec.rb +11 -11
  55. data/spec/models/authentication_error_spec.rb +51 -0
  56. data/spec/models/authentication_success_response_spec.rb +45 -0
  57. data/spec/models/combined_submission_data_spec.rb +59 -0
  58. data/spec/models/combined_submission_spec.rb +81 -0
  59. data/spec/models/create_combined_submission_response_spec.rb +57 -0
  60. data/spec/models/create_submission_batch_response_spec.rb +69 -0
  61. data/spec/models/create_submission_data_batch_request_spec.rb +71 -0
  62. data/spec/models/create_submission_data_spec.rb +65 -0
  63. data/spec/models/create_submission_response1_spec.rb +57 -0
  64. data/spec/models/create_submission_response_spec.rb +57 -0
  65. data/spec/models/error_spec.rb +51 -0
  66. data/spec/models/invalid_request_spec.rb +51 -0
  67. data/spec/models/submission_batch_data_spec.rb +59 -0
  68. data/spec/models/submission_batch_spec.rb +93 -0
  69. data/spec/models/submission_spec.rb +93 -0
  70. data/spec/models/template_spec.rb +123 -0
  71. data/spec/spec_helper.rb +3 -14
  72. metadata +70 -95
  73. data/.swagger-codegen/VERSION +0 -1
  74. data/docs/CreateCombinedSubmissionBody.md +0 -11
  75. data/docs/CreateSubmissionBatchBody.md +0 -10
  76. data/docs/CreateSubmissionBody.md +0 -10
  77. data/docs/InlineResponse2001.md +0 -21
  78. data/docs/InlineResponse201.md +0 -9
  79. data/docs/InlineResponse2011.md +0 -9
  80. data/docs/InlineResponse201CombinedSubmission.md +0 -14
  81. data/docs/TemplatestemplateIdsubmissionsbatchSubmission.md +0 -14
  82. data/spec/models/create_combined_submission_body_spec.rb +0 -60
  83. data/spec/models/create_submission_batch_body_spec.rb +0 -54
  84. data/spec/models/create_submission_body_spec.rb +0 -54
  85. data/spec/models/inline_response_200_1_spec.rb +0 -124
  86. data/spec/models/inline_response_200_spec.rb +0 -46
  87. data/spec/models/inline_response_201_1_spec.rb +0 -52
  88. data/spec/models/inline_response_201_combined_submission_spec.rb +0 -82
  89. data/spec/models/inline_response_201_spec.rb +0 -52
  90. data/spec/models/inline_response_400_spec.rb +0 -52
  91. data/spec/models/inline_response_401_spec.rb +0 -42
  92. data/spec/models/inline_response_422_spec.rb +0 -52
  93. data/spec/models/templatestemplate_idsubmissionsbatch_submission_spec.rb +0 -82
  94. data/spec/vcr_cassettes/FormAPI_Client/should_generate_a_PDF_and_wait_for_the_submission_to_be_processed.yml +0 -127
@@ -0,0 +1,237 @@
1
+ =begin
2
+ #API V1
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 3.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module FormAPI
16
+ class CreateSubmissionResponse
17
+ attr_accessor :submission
18
+
19
+ attr_accessor :errors
20
+
21
+ attr_accessor :status
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'submission' => :'submission',
49
+ :'errors' => :'errors',
50
+ :'status' => :'status'
51
+ }
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'submission' => :'Submission',
58
+ :'errors' => :'Array<String>',
59
+ :'status' => :'String'
60
+ }
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ return unless attributes.is_a?(Hash)
67
+
68
+ # convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
70
+
71
+ if attributes.has_key?(:'submission')
72
+ self.submission = attributes[:'submission']
73
+ end
74
+
75
+ if attributes.has_key?(:'errors')
76
+ if (value = attributes[:'errors']).is_a?(Array)
77
+ self.errors = value
78
+ end
79
+ end
80
+
81
+ if attributes.has_key?(:'status')
82
+ self.status = attributes[:'status']
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ status_validator = EnumAttributeValidator.new('String', ['success', 'error'])
97
+ return false unless status_validator.valid?(@status)
98
+ true
99
+ end
100
+
101
+ # Custom attribute writer method checking allowed values (enum).
102
+ # @param [Object] status Object to be assigned
103
+ def status=(status)
104
+ validator = EnumAttributeValidator.new('String', ['success', 'error'])
105
+ unless validator.valid?(status)
106
+ fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
107
+ end
108
+ @status = status
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ submission == o.submission &&
117
+ errors == o.errors &&
118
+ status == o.status
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(o)
124
+ self == o
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Fixnum] Hash code
129
+ def hash
130
+ [submission, errors, status].hash
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def build_from_hash(attributes)
137
+ return nil unless attributes.is_a?(Hash)
138
+ self.class.openapi_types.each_pair do |key, type|
139
+ if type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
143
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
144
+ end
145
+ elsif !attributes[self.class.attribute_map[key]].nil?
146
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
147
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
148
+ end
149
+
150
+ self
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def _deserialize(type, value)
158
+ case type.to_sym
159
+ when :DateTime
160
+ DateTime.parse(value)
161
+ when :Date
162
+ Date.parse(value)
163
+ when :String
164
+ value.to_s
165
+ when :Integer
166
+ value.to_i
167
+ when :Float
168
+ value.to_f
169
+ when :BOOLEAN
170
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
171
+ true
172
+ else
173
+ false
174
+ end
175
+ when :Object
176
+ # generic object (usually a Hash), return directly
177
+ value
178
+ when /\AArray<(?<inner_type>.+)>\z/
179
+ inner_type = Regexp.last_match[:inner_type]
180
+ value.map { |v| _deserialize(inner_type, v) }
181
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
182
+ k_type = Regexp.last_match[:k_type]
183
+ v_type = Regexp.last_match[:v_type]
184
+ {}.tap do |hash|
185
+ value.each do |k, v|
186
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
187
+ end
188
+ end
189
+ else # model
190
+ temp_model = FormAPI.const_get(type).new
191
+ temp_model.build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ next if value.nil?
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+ end
237
+ end
@@ -0,0 +1,237 @@
1
+ =begin
2
+ #API V1
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 3.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module FormAPI
16
+ class CreateSubmissionResponse1
17
+ attr_accessor :submission
18
+
19
+ attr_accessor :errors
20
+
21
+ attr_accessor :status
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'submission' => :'submission',
49
+ :'errors' => :'errors',
50
+ :'status' => :'status'
51
+ }
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'submission' => :'Submission',
58
+ :'errors' => :'Array<String>',
59
+ :'status' => :'String'
60
+ }
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ return unless attributes.is_a?(Hash)
67
+
68
+ # convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
70
+
71
+ if attributes.has_key?(:'submission')
72
+ self.submission = attributes[:'submission']
73
+ end
74
+
75
+ if attributes.has_key?(:'errors')
76
+ if (value = attributes[:'errors']).is_a?(Array)
77
+ self.errors = value
78
+ end
79
+ end
80
+
81
+ if attributes.has_key?(:'status')
82
+ self.status = attributes[:'status']
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ status_validator = EnumAttributeValidator.new('String', ['success', 'error', 'valid_but_not_saved'])
97
+ return false unless status_validator.valid?(@status)
98
+ true
99
+ end
100
+
101
+ # Custom attribute writer method checking allowed values (enum).
102
+ # @param [Object] status Object to be assigned
103
+ def status=(status)
104
+ validator = EnumAttributeValidator.new('String', ['success', 'error', 'valid_but_not_saved'])
105
+ unless validator.valid?(status)
106
+ fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
107
+ end
108
+ @status = status
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ submission == o.submission &&
117
+ errors == o.errors &&
118
+ status == o.status
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(o)
124
+ self == o
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Fixnum] Hash code
129
+ def hash
130
+ [submission, errors, status].hash
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def build_from_hash(attributes)
137
+ return nil unless attributes.is_a?(Hash)
138
+ self.class.openapi_types.each_pair do |key, type|
139
+ if type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
143
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
144
+ end
145
+ elsif !attributes[self.class.attribute_map[key]].nil?
146
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
147
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
148
+ end
149
+
150
+ self
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def _deserialize(type, value)
158
+ case type.to_sym
159
+ when :DateTime
160
+ DateTime.parse(value)
161
+ when :Date
162
+ Date.parse(value)
163
+ when :String
164
+ value.to_s
165
+ when :Integer
166
+ value.to_i
167
+ when :Float
168
+ value.to_f
169
+ when :BOOLEAN
170
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
171
+ true
172
+ else
173
+ false
174
+ end
175
+ when :Object
176
+ # generic object (usually a Hash), return directly
177
+ value
178
+ when /\AArray<(?<inner_type>.+)>\z/
179
+ inner_type = Regexp.last_match[:inner_type]
180
+ value.map { |v| _deserialize(inner_type, v) }
181
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
182
+ k_type = Regexp.last_match[:k_type]
183
+ v_type = Regexp.last_match[:v_type]
184
+ {}.tap do |hash|
185
+ value.each do |k, v|
186
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
187
+ end
188
+ end
189
+ else # model
190
+ temp_model = FormAPI.const_get(type).new
191
+ temp_model.build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ next if value.nil?
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+ end
237
+ end