form_api 1.6.0 → 1.7.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +21 -10
  5. data/docs/{CreateSubmissionDataBatchV1.md → CombinePdfsData.md} +4 -4
  6. data/docs/CombinedSubmission.md +1 -0
  7. data/docs/CreateCustomFileData.md +8 -0
  8. data/docs/CreateCustomFileResponse.md +10 -0
  9. data/docs/CreateTemplateData.md +8 -0
  10. data/docs/CustomFile.md +9 -0
  11. data/docs/PDFApi.md +208 -12
  12. data/docs/SubmissionBatchData.md +1 -1
  13. data/docs/{CreateSubmissionData.md → SubmissionData.md} +1 -1
  14. data/docs/{CreateSubmissionDataBatchRequest.md → SubmissionDataBatchRequest.md} +5 -5
  15. data/docs/Templatesv2Template.md +19 -0
  16. data/docs/Templatesv2TemplateDocument.md +10 -0
  17. data/docs/Templatesv2TemplateDocumentMetadata.md +10 -0
  18. data/lib/form_api.rb +10 -3
  19. data/lib/form_api/api/client.rb +25 -9
  20. data/lib/form_api/api/pdf_api.rb +224 -20
  21. data/lib/form_api/models/{create_submission_data_batch_request.rb → combine_pdfs_data.rb} +31 -43
  22. data/lib/form_api/models/combined_submission.rb +12 -1
  23. data/lib/form_api/models/create_custom_file_data.rb +188 -0
  24. data/lib/form_api/models/create_custom_file_response.rb +237 -0
  25. data/lib/form_api/models/create_template_data.rb +188 -0
  26. data/lib/form_api/models/custom_file.rb +192 -0
  27. data/lib/form_api/models/submission_batch_data.rb +1 -1
  28. data/lib/form_api/models/{create_submission_data.rb → submission_data.rb} +1 -1
  29. data/lib/form_api/models/{create_submission_data_batch_v1.rb → submission_data_batch_request.rb} +32 -28
  30. data/lib/form_api/models/templatesv2_template.rb +316 -0
  31. data/lib/form_api/models/templatesv2_template_document.rb +235 -0
  32. data/lib/form_api/models/templatesv2_template_document_metadata.rb +235 -0
  33. data/lib/form_api/version.rb +1 -1
  34. data/spec/api/client_integration_spec.rb +41 -4
  35. data/spec/api/pdf_api_integration_spec.rb +7 -7
  36. data/spec/api/pdf_api_spec_original.skipped.rb +55 -9
  37. data/spec/models/{create_submission_data_batch_v1_spec.rb → combine_pdfs_data_spec.rb} +10 -10
  38. data/spec/models/combined_submission_spec.rb +6 -0
  39. data/spec/models/create_custom_file_data_spec.rb +41 -0
  40. data/spec/models/create_custom_file_response_spec.rb +57 -0
  41. data/spec/models/create_template_data_spec.rb +41 -0
  42. data/spec/models/custom_file_spec.rb +47 -0
  43. data/spec/models/{create_submission_data_batch_request_spec.rb → submission_data_batch_request_spec.rb} +12 -12
  44. data/spec/models/{create_submission_data_spec.rb → submission_data_spec.rb} +6 -6
  45. data/spec/models/templatesv2_template_document_metadata_spec.rb +57 -0
  46. data/spec/models/templatesv2_template_document_spec.rb +57 -0
  47. data/spec/models/templatesv2_template_spec.rb +111 -0
  48. data/spec/spec_helper.rb +3 -0
  49. metadata +42 -14
@@ -13,40 +13,36 @@ OpenAPI Generator version: 3.3.0-SNAPSHOT
13
13
  require 'date'
14
14
 
15
15
  module FormAPI
16
- class CreateSubmissionDataBatchRequest
17
- attr_accessor :template_id
18
-
16
+ class CombinePdfsData
19
17
  attr_accessor :test
20
18
 
21
- attr_accessor :data
19
+ attr_accessor :source_pdfs
22
20
 
23
- attr_accessor :html
21
+ attr_accessor :metadata
24
22
 
25
- attr_accessor :css
23
+ attr_accessor :expires_in
26
24
 
27
- attr_accessor :metadata
25
+ attr_accessor :delete_custom_files
28
26
 
29
27
  # Attribute mapping from ruby-style variable name to JSON key.
30
28
  def self.attribute_map
31
29
  {
32
- :'template_id' => :'template_id',
33
30
  :'test' => :'test',
34
- :'data' => :'data',
35
- :'html' => :'html',
36
- :'css' => :'css',
37
- :'metadata' => :'metadata'
31
+ :'source_pdfs' => :'source_pdfs',
32
+ :'metadata' => :'metadata',
33
+ :'expires_in' => :'expires_in',
34
+ :'delete_custom_files' => :'delete_custom_files'
38
35
  }
39
36
  end
40
37
 
41
38
  # Attribute type mapping.
42
39
  def self.openapi_types
43
40
  {
44
- :'template_id' => :'String',
45
41
  :'test' => :'BOOLEAN',
46
- :'data' => :'Object',
47
- :'html' => :'String',
48
- :'css' => :'String',
49
- :'metadata' => :'Object'
42
+ :'source_pdfs' => :'Array<Object>',
43
+ :'metadata' => :'Object',
44
+ :'expires_in' => :'Integer',
45
+ :'delete_custom_files' => :'BOOLEAN'
50
46
  }
51
47
  end
52
48
 
@@ -58,28 +54,26 @@ module FormAPI
58
54
  # convert string to symbol for hash key
59
55
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
60
56
 
61
- if attributes.has_key?(:'template_id')
62
- self.template_id = attributes[:'template_id']
63
- end
64
-
65
57
  if attributes.has_key?(:'test')
66
58
  self.test = attributes[:'test']
67
59
  end
68
60
 
69
- if attributes.has_key?(:'data')
70
- self.data = attributes[:'data']
61
+ if attributes.has_key?(:'source_pdfs')
62
+ if (value = attributes[:'source_pdfs']).is_a?(Array)
63
+ self.source_pdfs = value
64
+ end
71
65
  end
72
66
 
73
- if attributes.has_key?(:'html')
74
- self.html = attributes[:'html']
67
+ if attributes.has_key?(:'metadata')
68
+ self.metadata = attributes[:'metadata']
75
69
  end
76
70
 
77
- if attributes.has_key?(:'css')
78
- self.css = attributes[:'css']
71
+ if attributes.has_key?(:'expires_in')
72
+ self.expires_in = attributes[:'expires_in']
79
73
  end
80
74
 
81
- if attributes.has_key?(:'metadata')
82
- self.metadata = attributes[:'metadata']
75
+ if attributes.has_key?(:'delete_custom_files')
76
+ self.delete_custom_files = attributes[:'delete_custom_files']
83
77
  end
84
78
  end
85
79
 
@@ -87,12 +81,8 @@ module FormAPI
87
81
  # @return Array for valid properties with the reasons
88
82
  def list_invalid_properties
89
83
  invalid_properties = Array.new
90
- if @template_id.nil?
91
- invalid_properties.push('invalid value for "template_id", template_id cannot be nil.')
92
- end
93
-
94
- if @data.nil?
95
- invalid_properties.push('invalid value for "data", data cannot be nil.')
84
+ if @source_pdfs.nil?
85
+ invalid_properties.push('invalid value for "source_pdfs", source_pdfs cannot be nil.')
96
86
  end
97
87
 
98
88
  invalid_properties
@@ -101,8 +91,7 @@ module FormAPI
101
91
  # Check to see if the all the properties in the model are valid
102
92
  # @return true if the model is valid
103
93
  def valid?
104
- return false if @template_id.nil?
105
- return false if @data.nil?
94
+ return false if @source_pdfs.nil?
106
95
  true
107
96
  end
108
97
 
@@ -111,12 +100,11 @@ module FormAPI
111
100
  def ==(o)
112
101
  return true if self.equal?(o)
113
102
  self.class == o.class &&
114
- template_id == o.template_id &&
115
103
  test == o.test &&
116
- data == o.data &&
117
- html == o.html &&
118
- css == o.css &&
119
- metadata == o.metadata
104
+ source_pdfs == o.source_pdfs &&
105
+ metadata == o.metadata &&
106
+ expires_in == o.expires_in &&
107
+ delete_custom_files == o.delete_custom_files
120
108
  end
121
109
 
122
110
  # @see the `==` method
@@ -128,7 +116,7 @@ module FormAPI
128
116
  # Calculates hash code according to all attributes.
129
117
  # @return [Fixnum] Hash code
130
118
  def hash
131
- [template_id, test, data, html, css, metadata].hash
119
+ [test, source_pdfs, metadata, expires_in, delete_custom_files].hash
132
120
  end
133
121
 
134
122
  # Builds the object from hash
@@ -20,6 +20,8 @@ module FormAPI
20
20
 
21
21
  attr_accessor :expires_at
22
22
 
23
+ attr_accessor :source_pdfs
24
+
23
25
  attr_accessor :download_url
24
26
 
25
27
  attr_accessor :submission_ids
@@ -58,6 +60,7 @@ module FormAPI
58
60
  :'metadata' => :'metadata',
59
61
  :'expired' => :'expired',
60
62
  :'expires_at' => :'expires_at',
63
+ :'source_pdfs' => :'source_pdfs',
61
64
  :'download_url' => :'download_url',
62
65
  :'submission_ids' => :'submission_ids',
63
66
  :'id' => :'id',
@@ -72,6 +75,7 @@ module FormAPI
72
75
  :'metadata' => :'Object',
73
76
  :'expired' => :'BOOLEAN',
74
77
  :'expires_at' => :'String',
78
+ :'source_pdfs' => :'Array<Object>',
75
79
  :'download_url' => :'String',
76
80
  :'submission_ids' => :'Array<String>',
77
81
  :'id' => :'String',
@@ -100,6 +104,12 @@ module FormAPI
100
104
  self.expires_at = attributes[:'expires_at']
101
105
  end
102
106
 
107
+ if attributes.has_key?(:'source_pdfs')
108
+ if (value = attributes[:'source_pdfs']).is_a?(Array)
109
+ self.source_pdfs = value
110
+ end
111
+ end
112
+
103
113
  if attributes.has_key?(:'download_url')
104
114
  self.download_url = attributes[:'download_url']
105
115
  end
@@ -158,6 +168,7 @@ module FormAPI
158
168
  metadata == o.metadata &&
159
169
  expired == o.expired &&
160
170
  expires_at == o.expires_at &&
171
+ source_pdfs == o.source_pdfs &&
161
172
  download_url == o.download_url &&
162
173
  submission_ids == o.submission_ids &&
163
174
  id == o.id &&
@@ -174,7 +185,7 @@ module FormAPI
174
185
  # Calculates hash code according to all attributes.
175
186
  # @return [Fixnum] Hash code
176
187
  def hash
177
- [metadata, expired, expires_at, download_url, submission_ids, id, state, actions].hash
188
+ [metadata, expired, expires_at, source_pdfs, download_url, submission_ids, id, state, actions].hash
178
189
  end
179
190
 
180
191
  # Builds the object from hash
@@ -0,0 +1,188 @@
1
+ =begin
2
+ #API v1
3
+
4
+ #FormAPI is a service that helps you fill out and sign PDF templates.
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 CreateCustomFileData
17
+ attr_accessor :cache_id
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'cache_id' => :'cache_id'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.openapi_types
28
+ {
29
+ :'cache_id' => :'String'
30
+ }
31
+ end
32
+
33
+ # Initializes the object
34
+ # @param [Hash] attributes Model attributes in the form of hash
35
+ def initialize(attributes = {})
36
+ return unless attributes.is_a?(Hash)
37
+
38
+ # convert string to symbol for hash key
39
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
40
+
41
+ if attributes.has_key?(:'cache_id')
42
+ self.cache_id = attributes[:'cache_id']
43
+ end
44
+ end
45
+
46
+ # Show invalid properties with the reasons. Usually used together with valid?
47
+ # @return Array for valid properties with the reasons
48
+ def list_invalid_properties
49
+ invalid_properties = Array.new
50
+ if @cache_id.nil?
51
+ invalid_properties.push('invalid value for "cache_id", cache_id cannot be nil.')
52
+ end
53
+
54
+ invalid_properties
55
+ end
56
+
57
+ # Check to see if the all the properties in the model are valid
58
+ # @return true if the model is valid
59
+ def valid?
60
+ return false if @cache_id.nil?
61
+ true
62
+ end
63
+
64
+ # Checks equality by comparing each attribute.
65
+ # @param [Object] Object to be compared
66
+ def ==(o)
67
+ return true if self.equal?(o)
68
+ self.class == o.class &&
69
+ cache_id == o.cache_id
70
+ end
71
+
72
+ # @see the `==` method
73
+ # @param [Object] Object to be compared
74
+ def eql?(o)
75
+ self == o
76
+ end
77
+
78
+ # Calculates hash code according to all attributes.
79
+ # @return [Fixnum] Hash code
80
+ def hash
81
+ [cache_id].hash
82
+ end
83
+
84
+ # Builds the object from hash
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ # @return [Object] Returns the model itself
87
+ def build_from_hash(attributes)
88
+ return nil unless attributes.is_a?(Hash)
89
+ self.class.openapi_types.each_pair do |key, type|
90
+ if type =~ /\AArray<(.*)>/i
91
+ # check to ensure the input is an array given that the the attribute
92
+ # is documented as an array but the input is not
93
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
94
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
95
+ end
96
+ elsif !attributes[self.class.attribute_map[key]].nil?
97
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
98
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
99
+ end
100
+
101
+ self
102
+ end
103
+
104
+ # Deserializes the data based on type
105
+ # @param string type Data type
106
+ # @param string value Value to be deserialized
107
+ # @return [Object] Deserialized data
108
+ def _deserialize(type, value)
109
+ case type.to_sym
110
+ when :DateTime
111
+ DateTime.parse(value)
112
+ when :Date
113
+ Date.parse(value)
114
+ when :String
115
+ value.to_s
116
+ when :Integer
117
+ value.to_i
118
+ when :Float
119
+ value.to_f
120
+ when :BOOLEAN
121
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
122
+ true
123
+ else
124
+ false
125
+ end
126
+ when :Object
127
+ # generic object (usually a Hash), return directly
128
+ value
129
+ when /\AArray<(?<inner_type>.+)>\z/
130
+ inner_type = Regexp.last_match[:inner_type]
131
+ value.map { |v| _deserialize(inner_type, v) }
132
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
133
+ k_type = Regexp.last_match[:k_type]
134
+ v_type = Regexp.last_match[:v_type]
135
+ {}.tap do |hash|
136
+ value.each do |k, v|
137
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
138
+ end
139
+ end
140
+ else # model
141
+ temp_model = FormAPI.const_get(type).new
142
+ temp_model.build_from_hash(value)
143
+ end
144
+ end
145
+
146
+ # Returns the string representation of the object
147
+ # @return [String] String presentation of the object
148
+ def to_s
149
+ to_hash.to_s
150
+ end
151
+
152
+ # to_body is an alias to to_hash (backward compatibility)
153
+ # @return [Hash] Returns the object in the form of hash
154
+ def to_body
155
+ to_hash
156
+ end
157
+
158
+ # Returns the object in the form of hash
159
+ # @return [Hash] Returns the object in the form of hash
160
+ def to_hash
161
+ hash = {}
162
+ self.class.attribute_map.each_pair do |attr, param|
163
+ value = self.send(attr)
164
+ next if value.nil?
165
+ hash[param] = _to_hash(value)
166
+ end
167
+ hash
168
+ end
169
+
170
+ # Outputs non-array value in the form of hash
171
+ # For object, use to_hash. Otherwise, just return the value
172
+ # @param [Object] value Any valid value
173
+ # @return [Hash] Returns the value in the form of hash
174
+ def _to_hash(value)
175
+ if value.is_a?(Array)
176
+ value.compact.map { |v| _to_hash(v) }
177
+ elsif value.is_a?(Hash)
178
+ {}.tap do |hash|
179
+ value.each { |k, v| hash[k] = _to_hash(v) }
180
+ end
181
+ elsif value.respond_to? :to_hash
182
+ value.to_hash
183
+ else
184
+ value
185
+ end
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,237 @@
1
+ =begin
2
+ #API v1
3
+
4
+ #FormAPI is a service that helps you fill out and sign PDF templates.
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 CreateCustomFileResponse
17
+ attr_accessor :custom_file
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
+ :'custom_file' => :'custom_file',
49
+ :'errors' => :'errors',
50
+ :'status' => :'status'
51
+ }
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'custom_file' => :'CustomFile',
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?(:'custom_file')
72
+ self.custom_file = attributes[:'custom_file']
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
+ custom_file == o.custom_file &&
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
+ [custom_file, 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