form_api 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +11 -5
- data/docs/CreateSubmissionBatchResponse.md +1 -1
- data/docs/{CreateSubmissionResponse1.md → CreateSubmissionBatchSubmissionsResponse.md} +1 -1
- data/docs/CreateSubmissionBatchV1SubmissionsResponse.md +10 -0
- data/docs/CreateSubmissionDataRequestTokenResponse.md +10 -0
- data/docs/CreateSubmissionDataRequestTokenResponseToken.md +11 -0
- data/docs/CreateSubmissionResponse.md +1 -0
- data/docs/PDFApi.md +102 -2
- data/docs/SubmissionDataRequest.md +16 -0
- data/form_api.gemspec +2 -2
- data/lib/form_api.rb +5 -1
- data/lib/form_api/api/client.rb +3 -3
- data/lib/form_api/api/pdf_api.rb +105 -3
- data/lib/form_api/api_client.rb +19 -2
- data/lib/form_api/models/create_submission_batch_response.rb +1 -1
- data/lib/form_api/models/{create_submission_response1.rb → create_submission_batch_submissions_response.rb} +1 -1
- data/lib/form_api/models/create_submission_batch_v1_submissions_response.rb +237 -0
- data/lib/form_api/models/create_submission_data_request_token_response.rb +237 -0
- data/lib/form_api/models/create_submission_data_request_token_response_token.rb +210 -0
- data/lib/form_api/models/create_submission_response.rb +12 -1
- data/lib/form_api/models/submission.rb +2 -2
- data/lib/form_api/models/submission_data_request.rb +336 -0
- data/lib/form_api/version.rb +1 -1
- data/spec/api/{client_spec.rb → client_integration_spec.rb} +20 -0
- data/spec/api/{pdf_api_spec.rb → pdf_api_integration_spec.rb} +39 -0
- data/spec/api/pdf_api_spec_original.skipped.rb +207 -0
- data/spec/configuration_spec.rb +11 -0
- data/spec/models/{create_submission_response1_spec.rb → create_submission_batch_submissions_response_spec.rb} +6 -6
- data/spec/models/create_submission_batch_v1_submissions_response_spec.rb +57 -0
- data/spec/models/create_submission_data_request_token_response_spec.rb +57 -0
- data/spec/models/create_submission_data_request_token_response_token_spec.rb +59 -0
- data/spec/models/create_submission_response_spec.rb +6 -0
- data/spec/models/submission_data_request_spec.rb +93 -0
- data/spec/models/submission_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +31 -13
@@ -0,0 +1,210 @@
|
|
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 CreateSubmissionDataRequestTokenResponseToken
|
17
|
+
attr_accessor :expires_at
|
18
|
+
|
19
|
+
attr_accessor :id
|
20
|
+
|
21
|
+
attr_accessor :secret
|
22
|
+
|
23
|
+
attr_accessor :data_request_url
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'expires_at' => :'expires_at',
|
29
|
+
:'id' => :'id',
|
30
|
+
:'secret' => :'secret',
|
31
|
+
:'data_request_url' => :'data_request_url'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'expires_at' => :'String',
|
39
|
+
:'id' => :'String',
|
40
|
+
:'secret' => :'String',
|
41
|
+
:'data_request_url' => :'String'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Initializes the object
|
46
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
47
|
+
def initialize(attributes = {})
|
48
|
+
return unless attributes.is_a?(Hash)
|
49
|
+
|
50
|
+
# convert string to symbol for hash key
|
51
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
52
|
+
|
53
|
+
if attributes.has_key?(:'expires_at')
|
54
|
+
self.expires_at = attributes[:'expires_at']
|
55
|
+
end
|
56
|
+
|
57
|
+
if attributes.has_key?(:'id')
|
58
|
+
self.id = attributes[:'id']
|
59
|
+
end
|
60
|
+
|
61
|
+
if attributes.has_key?(:'secret')
|
62
|
+
self.secret = attributes[:'secret']
|
63
|
+
end
|
64
|
+
|
65
|
+
if attributes.has_key?(:'data_request_url')
|
66
|
+
self.data_request_url = attributes[:'data_request_url']
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
71
|
+
# @return Array for valid properties with the reasons
|
72
|
+
def list_invalid_properties
|
73
|
+
invalid_properties = Array.new
|
74
|
+
invalid_properties
|
75
|
+
end
|
76
|
+
|
77
|
+
# Check to see if the all the properties in the model are valid
|
78
|
+
# @return true if the model is valid
|
79
|
+
def valid?
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
# Checks equality by comparing each attribute.
|
84
|
+
# @param [Object] Object to be compared
|
85
|
+
def ==(o)
|
86
|
+
return true if self.equal?(o)
|
87
|
+
self.class == o.class &&
|
88
|
+
expires_at == o.expires_at &&
|
89
|
+
id == o.id &&
|
90
|
+
secret == o.secret &&
|
91
|
+
data_request_url == o.data_request_url
|
92
|
+
end
|
93
|
+
|
94
|
+
# @see the `==` method
|
95
|
+
# @param [Object] Object to be compared
|
96
|
+
def eql?(o)
|
97
|
+
self == o
|
98
|
+
end
|
99
|
+
|
100
|
+
# Calculates hash code according to all attributes.
|
101
|
+
# @return [Fixnum] Hash code
|
102
|
+
def hash
|
103
|
+
[expires_at, id, secret, data_request_url].hash
|
104
|
+
end
|
105
|
+
|
106
|
+
# Builds the object from hash
|
107
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
108
|
+
# @return [Object] Returns the model itself
|
109
|
+
def build_from_hash(attributes)
|
110
|
+
return nil unless attributes.is_a?(Hash)
|
111
|
+
self.class.openapi_types.each_pair do |key, type|
|
112
|
+
if type =~ /\AArray<(.*)>/i
|
113
|
+
# check to ensure the input is an array given that the the attribute
|
114
|
+
# is documented as an array but the input is not
|
115
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
116
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
117
|
+
end
|
118
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
119
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
120
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
121
|
+
end
|
122
|
+
|
123
|
+
self
|
124
|
+
end
|
125
|
+
|
126
|
+
# Deserializes the data based on type
|
127
|
+
# @param string type Data type
|
128
|
+
# @param string value Value to be deserialized
|
129
|
+
# @return [Object] Deserialized data
|
130
|
+
def _deserialize(type, value)
|
131
|
+
case type.to_sym
|
132
|
+
when :DateTime
|
133
|
+
DateTime.parse(value)
|
134
|
+
when :Date
|
135
|
+
Date.parse(value)
|
136
|
+
when :String
|
137
|
+
value.to_s
|
138
|
+
when :Integer
|
139
|
+
value.to_i
|
140
|
+
when :Float
|
141
|
+
value.to_f
|
142
|
+
when :BOOLEAN
|
143
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
144
|
+
true
|
145
|
+
else
|
146
|
+
false
|
147
|
+
end
|
148
|
+
when :Object
|
149
|
+
# generic object (usually a Hash), return directly
|
150
|
+
value
|
151
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
152
|
+
inner_type = Regexp.last_match[:inner_type]
|
153
|
+
value.map { |v| _deserialize(inner_type, v) }
|
154
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
155
|
+
k_type = Regexp.last_match[:k_type]
|
156
|
+
v_type = Regexp.last_match[:v_type]
|
157
|
+
{}.tap do |hash|
|
158
|
+
value.each do |k, v|
|
159
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
else # model
|
163
|
+
temp_model = FormAPI.const_get(type).new
|
164
|
+
temp_model.build_from_hash(value)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# Returns the string representation of the object
|
169
|
+
# @return [String] String presentation of the object
|
170
|
+
def to_s
|
171
|
+
to_hash.to_s
|
172
|
+
end
|
173
|
+
|
174
|
+
# to_body is an alias to to_hash (backward compatibility)
|
175
|
+
# @return [Hash] Returns the object in the form of hash
|
176
|
+
def to_body
|
177
|
+
to_hash
|
178
|
+
end
|
179
|
+
|
180
|
+
# Returns the object in the form of hash
|
181
|
+
# @return [Hash] Returns the object in the form of hash
|
182
|
+
def to_hash
|
183
|
+
hash = {}
|
184
|
+
self.class.attribute_map.each_pair do |attr, param|
|
185
|
+
value = self.send(attr)
|
186
|
+
next if value.nil?
|
187
|
+
hash[param] = _to_hash(value)
|
188
|
+
end
|
189
|
+
hash
|
190
|
+
end
|
191
|
+
|
192
|
+
# Outputs non-array value in the form of hash
|
193
|
+
# For object, use to_hash. Otherwise, just return the value
|
194
|
+
# @param [Object] value Any valid value
|
195
|
+
# @return [Hash] Returns the value in the form of hash
|
196
|
+
def _to_hash(value)
|
197
|
+
if value.is_a?(Array)
|
198
|
+
value.compact.map { |v| _to_hash(v) }
|
199
|
+
elsif value.is_a?(Hash)
|
200
|
+
{}.tap do |hash|
|
201
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
202
|
+
end
|
203
|
+
elsif value.respond_to? :to_hash
|
204
|
+
value.to_hash
|
205
|
+
else
|
206
|
+
value
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
@@ -18,6 +18,8 @@ module FormAPI
|
|
18
18
|
|
19
19
|
attr_accessor :errors
|
20
20
|
|
21
|
+
attr_accessor :data_requests
|
22
|
+
|
21
23
|
attr_accessor :status
|
22
24
|
|
23
25
|
class EnumAttributeValidator
|
@@ -47,6 +49,7 @@ module FormAPI
|
|
47
49
|
{
|
48
50
|
:'submission' => :'submission',
|
49
51
|
:'errors' => :'errors',
|
52
|
+
:'data_requests' => :'data_requests',
|
50
53
|
:'status' => :'status'
|
51
54
|
}
|
52
55
|
end
|
@@ -56,6 +59,7 @@ module FormAPI
|
|
56
59
|
{
|
57
60
|
:'submission' => :'Submission',
|
58
61
|
:'errors' => :'Array<String>',
|
62
|
+
:'data_requests' => :'Array<SubmissionDataRequest>',
|
59
63
|
:'status' => :'String'
|
60
64
|
}
|
61
65
|
end
|
@@ -78,6 +82,12 @@ module FormAPI
|
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
85
|
+
if attributes.has_key?(:'data_requests')
|
86
|
+
if (value = attributes[:'data_requests']).is_a?(Array)
|
87
|
+
self.data_requests = value
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
81
91
|
if attributes.has_key?(:'status')
|
82
92
|
self.status = attributes[:'status']
|
83
93
|
end
|
@@ -115,6 +125,7 @@ module FormAPI
|
|
115
125
|
self.class == o.class &&
|
116
126
|
submission == o.submission &&
|
117
127
|
errors == o.errors &&
|
128
|
+
data_requests == o.data_requests &&
|
118
129
|
status == o.status
|
119
130
|
end
|
120
131
|
|
@@ -127,7 +138,7 @@ module FormAPI
|
|
127
138
|
# Calculates hash code according to all attributes.
|
128
139
|
# @return [Fixnum] Hash code
|
129
140
|
def hash
|
130
|
-
[submission, errors, status].hash
|
141
|
+
[submission, errors, data_requests, status].hash
|
131
142
|
end
|
132
143
|
|
133
144
|
# Builds the object from hash
|
@@ -159,7 +159,7 @@ module FormAPI
|
|
159
159
|
return false if @test.nil?
|
160
160
|
return false if @expired.nil?
|
161
161
|
return false if @state.nil?
|
162
|
-
state_validator = EnumAttributeValidator.new('String', ['pending', 'processed', 'invalid_data', 'error', 'image_download_failed', 'image_processing_failed'])
|
162
|
+
state_validator = EnumAttributeValidator.new('String', ['pending', 'processed', 'invalid_data', 'error', 'image_download_failed', 'image_processing_failed', 'waiting_for_data_requests'])
|
163
163
|
return false unless state_validator.valid?(@state)
|
164
164
|
true
|
165
165
|
end
|
@@ -167,7 +167,7 @@ module FormAPI
|
|
167
167
|
# Custom attribute writer method checking allowed values (enum).
|
168
168
|
# @param [Object] state Object to be assigned
|
169
169
|
def state=(state)
|
170
|
-
validator = EnumAttributeValidator.new('String', ['pending', 'processed', 'invalid_data', 'error', 'image_download_failed', 'image_processing_failed'])
|
170
|
+
validator = EnumAttributeValidator.new('String', ['pending', 'processed', 'invalid_data', 'error', 'image_download_failed', 'image_processing_failed', 'waiting_for_data_requests'])
|
171
171
|
unless validator.valid?(state)
|
172
172
|
fail ArgumentError, 'invalid value for "state", must be one of #{validator.allowable_values}.'
|
173
173
|
end
|
@@ -0,0 +1,336 @@
|
|
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 SubmissionDataRequest
|
17
|
+
attr_accessor :id
|
18
|
+
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
attr_accessor :email
|
22
|
+
|
23
|
+
attr_accessor :order
|
24
|
+
|
25
|
+
attr_accessor :fields
|
26
|
+
|
27
|
+
attr_accessor :metadata
|
28
|
+
|
29
|
+
attr_accessor :state
|
30
|
+
|
31
|
+
attr_accessor :viewed_at
|
32
|
+
|
33
|
+
attr_accessor :completed_at
|
34
|
+
|
35
|
+
class EnumAttributeValidator
|
36
|
+
attr_reader :datatype
|
37
|
+
attr_reader :allowable_values
|
38
|
+
|
39
|
+
def initialize(datatype, allowable_values)
|
40
|
+
@allowable_values = allowable_values.map do |value|
|
41
|
+
case datatype.to_s
|
42
|
+
when /Integer/i
|
43
|
+
value.to_i
|
44
|
+
when /Float/i
|
45
|
+
value.to_f
|
46
|
+
else
|
47
|
+
value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def valid?(value)
|
53
|
+
!value || allowable_values.include?(value)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
58
|
+
def self.attribute_map
|
59
|
+
{
|
60
|
+
:'id' => :'id',
|
61
|
+
:'name' => :'name',
|
62
|
+
:'email' => :'email',
|
63
|
+
:'order' => :'order',
|
64
|
+
:'fields' => :'fields',
|
65
|
+
:'metadata' => :'metadata',
|
66
|
+
:'state' => :'state',
|
67
|
+
:'viewed_at' => :'viewed_at',
|
68
|
+
:'completed_at' => :'completed_at'
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
# Attribute type mapping.
|
73
|
+
def self.openapi_types
|
74
|
+
{
|
75
|
+
:'id' => :'String',
|
76
|
+
:'name' => :'String',
|
77
|
+
:'email' => :'String',
|
78
|
+
:'order' => :'Float',
|
79
|
+
:'fields' => :'Array<String>',
|
80
|
+
:'metadata' => :'Object',
|
81
|
+
:'state' => :'String',
|
82
|
+
:'viewed_at' => :'String',
|
83
|
+
:'completed_at' => :'String'
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
# Initializes the object
|
88
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
89
|
+
def initialize(attributes = {})
|
90
|
+
return unless attributes.is_a?(Hash)
|
91
|
+
|
92
|
+
# convert string to symbol for hash key
|
93
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
94
|
+
|
95
|
+
if attributes.has_key?(:'id')
|
96
|
+
self.id = attributes[:'id']
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes.has_key?(:'name')
|
100
|
+
self.name = attributes[:'name']
|
101
|
+
end
|
102
|
+
|
103
|
+
if attributes.has_key?(:'email')
|
104
|
+
self.email = attributes[:'email']
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.has_key?(:'order')
|
108
|
+
self.order = attributes[:'order']
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.has_key?(:'fields')
|
112
|
+
if (value = attributes[:'fields']).is_a?(Array)
|
113
|
+
self.fields = value
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.has_key?(:'metadata')
|
118
|
+
self.metadata = attributes[:'metadata']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.has_key?(:'state')
|
122
|
+
self.state = attributes[:'state']
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.has_key?(:'viewed_at')
|
126
|
+
self.viewed_at = attributes[:'viewed_at']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.has_key?(:'completed_at')
|
130
|
+
self.completed_at = attributes[:'completed_at']
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
135
|
+
# @return Array for valid properties with the reasons
|
136
|
+
def list_invalid_properties
|
137
|
+
invalid_properties = Array.new
|
138
|
+
if @id.nil?
|
139
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
140
|
+
end
|
141
|
+
|
142
|
+
if @name.nil?
|
143
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
144
|
+
end
|
145
|
+
|
146
|
+
if @email.nil?
|
147
|
+
invalid_properties.push('invalid value for "email", email cannot be nil.')
|
148
|
+
end
|
149
|
+
|
150
|
+
if @order.nil?
|
151
|
+
invalid_properties.push('invalid value for "order", order cannot be nil.')
|
152
|
+
end
|
153
|
+
|
154
|
+
if @fields.nil?
|
155
|
+
invalid_properties.push('invalid value for "fields", fields cannot be nil.')
|
156
|
+
end
|
157
|
+
|
158
|
+
if @metadata.nil?
|
159
|
+
invalid_properties.push('invalid value for "metadata", metadata cannot be nil.')
|
160
|
+
end
|
161
|
+
|
162
|
+
if @state.nil?
|
163
|
+
invalid_properties.push('invalid value for "state", state cannot be nil.')
|
164
|
+
end
|
165
|
+
|
166
|
+
if @viewed_at.nil?
|
167
|
+
invalid_properties.push('invalid value for "viewed_at", viewed_at cannot be nil.')
|
168
|
+
end
|
169
|
+
|
170
|
+
if @completed_at.nil?
|
171
|
+
invalid_properties.push('invalid value for "completed_at", completed_at cannot be nil.')
|
172
|
+
end
|
173
|
+
|
174
|
+
invalid_properties
|
175
|
+
end
|
176
|
+
|
177
|
+
# Check to see if the all the properties in the model are valid
|
178
|
+
# @return true if the model is valid
|
179
|
+
def valid?
|
180
|
+
return false if @id.nil?
|
181
|
+
return false if @name.nil?
|
182
|
+
return false if @email.nil?
|
183
|
+
return false if @order.nil?
|
184
|
+
return false if @fields.nil?
|
185
|
+
return false if @metadata.nil?
|
186
|
+
return false if @state.nil?
|
187
|
+
state_validator = EnumAttributeValidator.new('String', ['pending', 'complete'])
|
188
|
+
return false unless state_validator.valid?(@state)
|
189
|
+
return false if @viewed_at.nil?
|
190
|
+
return false if @completed_at.nil?
|
191
|
+
true
|
192
|
+
end
|
193
|
+
|
194
|
+
# Custom attribute writer method checking allowed values (enum).
|
195
|
+
# @param [Object] state Object to be assigned
|
196
|
+
def state=(state)
|
197
|
+
validator = EnumAttributeValidator.new('String', ['pending', 'complete'])
|
198
|
+
unless validator.valid?(state)
|
199
|
+
fail ArgumentError, 'invalid value for "state", must be one of #{validator.allowable_values}.'
|
200
|
+
end
|
201
|
+
@state = state
|
202
|
+
end
|
203
|
+
|
204
|
+
# Checks equality by comparing each attribute.
|
205
|
+
# @param [Object] Object to be compared
|
206
|
+
def ==(o)
|
207
|
+
return true if self.equal?(o)
|
208
|
+
self.class == o.class &&
|
209
|
+
id == o.id &&
|
210
|
+
name == o.name &&
|
211
|
+
email == o.email &&
|
212
|
+
order == o.order &&
|
213
|
+
fields == o.fields &&
|
214
|
+
metadata == o.metadata &&
|
215
|
+
state == o.state &&
|
216
|
+
viewed_at == o.viewed_at &&
|
217
|
+
completed_at == o.completed_at
|
218
|
+
end
|
219
|
+
|
220
|
+
# @see the `==` method
|
221
|
+
# @param [Object] Object to be compared
|
222
|
+
def eql?(o)
|
223
|
+
self == o
|
224
|
+
end
|
225
|
+
|
226
|
+
# Calculates hash code according to all attributes.
|
227
|
+
# @return [Fixnum] Hash code
|
228
|
+
def hash
|
229
|
+
[id, name, email, order, fields, metadata, state, viewed_at, completed_at].hash
|
230
|
+
end
|
231
|
+
|
232
|
+
# Builds the object from hash
|
233
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
234
|
+
# @return [Object] Returns the model itself
|
235
|
+
def build_from_hash(attributes)
|
236
|
+
return nil unless attributes.is_a?(Hash)
|
237
|
+
self.class.openapi_types.each_pair do |key, type|
|
238
|
+
if type =~ /\AArray<(.*)>/i
|
239
|
+
# check to ensure the input is an array given that the the attribute
|
240
|
+
# is documented as an array but the input is not
|
241
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
242
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
243
|
+
end
|
244
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
245
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
246
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
247
|
+
end
|
248
|
+
|
249
|
+
self
|
250
|
+
end
|
251
|
+
|
252
|
+
# Deserializes the data based on type
|
253
|
+
# @param string type Data type
|
254
|
+
# @param string value Value to be deserialized
|
255
|
+
# @return [Object] Deserialized data
|
256
|
+
def _deserialize(type, value)
|
257
|
+
case type.to_sym
|
258
|
+
when :DateTime
|
259
|
+
DateTime.parse(value)
|
260
|
+
when :Date
|
261
|
+
Date.parse(value)
|
262
|
+
when :String
|
263
|
+
value.to_s
|
264
|
+
when :Integer
|
265
|
+
value.to_i
|
266
|
+
when :Float
|
267
|
+
value.to_f
|
268
|
+
when :BOOLEAN
|
269
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
270
|
+
true
|
271
|
+
else
|
272
|
+
false
|
273
|
+
end
|
274
|
+
when :Object
|
275
|
+
# generic object (usually a Hash), return directly
|
276
|
+
value
|
277
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
278
|
+
inner_type = Regexp.last_match[:inner_type]
|
279
|
+
value.map { |v| _deserialize(inner_type, v) }
|
280
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
281
|
+
k_type = Regexp.last_match[:k_type]
|
282
|
+
v_type = Regexp.last_match[:v_type]
|
283
|
+
{}.tap do |hash|
|
284
|
+
value.each do |k, v|
|
285
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
else # model
|
289
|
+
temp_model = FormAPI.const_get(type).new
|
290
|
+
temp_model.build_from_hash(value)
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
# Returns the string representation of the object
|
295
|
+
# @return [String] String presentation of the object
|
296
|
+
def to_s
|
297
|
+
to_hash.to_s
|
298
|
+
end
|
299
|
+
|
300
|
+
# to_body is an alias to to_hash (backward compatibility)
|
301
|
+
# @return [Hash] Returns the object in the form of hash
|
302
|
+
def to_body
|
303
|
+
to_hash
|
304
|
+
end
|
305
|
+
|
306
|
+
# Returns the object in the form of hash
|
307
|
+
# @return [Hash] Returns the object in the form of hash
|
308
|
+
def to_hash
|
309
|
+
hash = {}
|
310
|
+
self.class.attribute_map.each_pair do |attr, param|
|
311
|
+
value = self.send(attr)
|
312
|
+
next if value.nil?
|
313
|
+
hash[param] = _to_hash(value)
|
314
|
+
end
|
315
|
+
hash
|
316
|
+
end
|
317
|
+
|
318
|
+
# Outputs non-array value in the form of hash
|
319
|
+
# For object, use to_hash. Otherwise, just return the value
|
320
|
+
# @param [Object] value Any valid value
|
321
|
+
# @return [Hash] Returns the value in the form of hash
|
322
|
+
def _to_hash(value)
|
323
|
+
if value.is_a?(Array)
|
324
|
+
value.compact.map { |v| _to_hash(v) }
|
325
|
+
elsif value.is_a?(Hash)
|
326
|
+
{}.tap do |hash|
|
327
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
328
|
+
end
|
329
|
+
elsif value.respond_to? :to_hash
|
330
|
+
value.to_hash
|
331
|
+
else
|
332
|
+
value
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|