crx_packmgr_api_client 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -16
- data/crx_packmgr_api_client-0.2.0.gem +0 -0
- data/crx_packmgr_api_client.gemspec +9 -4
- data/docs/DefaultApi.md +457 -7
- data/docs/{PackageFilter.md → Filter.md} +2 -2
- data/docs/FilterRule.md +9 -0
- data/docs/Group.md +11 -0
- data/docs/{InlineResponse200.md → GroupList.md} +2 -2
- data/docs/InitData.md +13 -0
- data/docs/InstallStatus.md +8 -0
- data/docs/InstallStatusStatus.md +9 -0
- data/docs/Package.md +1 -1
- data/docs/PackageList.md +1 -0
- data/docs/ServiceResponse.md +12 -0
- data/docs/ServiceResponseRequest.md +8 -0
- data/docs/ServiceResponseRequestParam.md +9 -0
- data/docs/ServiceResponseResponse.md +9 -0
- data/docs/UpdateStatus.md +10 -0
- data/git_push.sh +1 -1
- data/lib/crx_packmgr_api_client.rb +13 -2
- data/lib/crx_packmgr_api_client/api/default_api.rb +491 -8
- data/lib/crx_packmgr_api_client/api_client.rb +1 -1
- data/lib/crx_packmgr_api_client/api_error.rb +1 -1
- data/lib/crx_packmgr_api_client/configuration.rb +1 -1
- data/lib/crx_packmgr_api_client/models/{package_filter.rb → filter.rb} +3 -3
- data/lib/crx_packmgr_api_client/models/filter_rule.rb +241 -0
- data/lib/crx_packmgr_api_client/models/group.rb +226 -0
- data/lib/crx_packmgr_api_client/models/{inline_response_200.rb → group_list.rb} +10 -10
- data/lib/crx_packmgr_api_client/models/init_data.rb +246 -0
- data/lib/crx_packmgr_api_client/models/install_status.rb +199 -0
- data/lib/crx_packmgr_api_client/models/install_status_status.rb +208 -0
- data/lib/crx_packmgr_api_client/models/package.rb +2 -2
- data/lib/crx_packmgr_api_client/models/package_list.rb +14 -5
- data/lib/crx_packmgr_api_client/models/service_response.rb +235 -0
- data/lib/crx_packmgr_api_client/models/service_response_request.rb +201 -0
- data/lib/crx_packmgr_api_client/models/service_response_request_param.rb +208 -0
- data/lib/crx_packmgr_api_client/models/service_response_response.rb +208 -0
- data/lib/crx_packmgr_api_client/models/update_status.rb +217 -0
- data/lib/crx_packmgr_api_client/version.rb +2 -2
- data/spec/acceptance/default_api_spec.rb +150 -0
- data/spec/api/default_api_spec.rb +2 -14
- data/spec/api/download_api_spec.rb +95 -0
- data/spec/api/groups_api_spec.rb +193 -0
- data/spec/api/init_api_spec.rb +104 -0
- data/spec/api/installstatus_api_spec.rb +91 -0
- data/spec/api/list_api_spec.rb +130 -0
- data/spec/api/screenshot_api_spec.rb +93 -0
- data/spec/api/service_api_spec.rb +374 -0
- data/spec/api/thumbnail_api_spec.rb +93 -0
- data/spec/api_client_spec.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/files/list.json +533 -0
- data/spec/files/service_response.txt +11 -0
- data/spec/files/service_response1.txt +12 -0
- data/spec/files/test-1.0.0.zip +0 -0
- data/spec/files/thumbnail.png +0 -0
- data/spec/models/filter_rule_spec.rb +63 -0
- data/spec/models/{package_filter_spec.rb → filter_spec.rb} +7 -7
- data/spec/models/{inline_response_200_spec.rb → group_list_spec.rb} +8 -8
- data/spec/models/group_spec.rb +71 -0
- data/spec/models/init_data_spec.rb +83 -0
- data/spec/models/install_status_spec.rb +53 -0
- data/spec/models/install_status_status_spec.rb +59 -0
- data/spec/models/package_list_spec.rb +1 -1
- data/spec/models/package_spec.rb +1 -1
- data/spec/models/service_response_request_param_spec.rb +59 -0
- data/spec/models/service_response_request_spec.rb +53 -0
- data/spec/models/service_response_response_spec.rb +59 -0
- data/spec/models/service_response_spec.rb +77 -0
- data/spec/models/update_status_spec.rb +65 -0
- data/spec/spec_helper.rb +10 -1
- data/spec/spec_helper_acceptance.rb +19 -0
- metadata +130 -17
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
#API for interacting with the CRX Package Manager in AEM.
|
5
5
|
|
6
|
-
OpenAPI spec version:
|
6
|
+
OpenAPI spec version: 6.2.0
|
7
7
|
Contact: bryan.stopp@gmail.com
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
9
|
|
@@ -25,7 +25,7 @@ require 'date'
|
|
25
25
|
|
26
26
|
module CrxPackageManager
|
27
27
|
|
28
|
-
class
|
28
|
+
class Filter
|
29
29
|
attr_accessor :root
|
30
30
|
|
31
31
|
attr_accessor :rules
|
@@ -43,7 +43,7 @@ module CrxPackageManager
|
|
43
43
|
def self.swagger_types
|
44
44
|
{
|
45
45
|
:'root' => :'String',
|
46
|
-
:'rules' => :'Array<
|
46
|
+
:'rules' => :'Array<FilterRule>'
|
47
47
|
}
|
48
48
|
end
|
49
49
|
|
@@ -0,0 +1,241 @@
|
|
1
|
+
=begin
|
2
|
+
#CRX Package Manager API
|
3
|
+
|
4
|
+
#API for interacting with the CRX Package Manager in AEM.
|
5
|
+
|
6
|
+
OpenAPI spec version: 6.2.0
|
7
|
+
Contact: bryan.stopp@gmail.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
you may not use this file except in compliance with the License.
|
12
|
+
You may obtain a copy of the License at
|
13
|
+
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
See the License for the specific language governing permissions and
|
20
|
+
limitations under the License.
|
21
|
+
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'date'
|
25
|
+
|
26
|
+
module CrxPackageManager
|
27
|
+
|
28
|
+
class FilterRule
|
29
|
+
attr_accessor :modifier
|
30
|
+
|
31
|
+
attr_accessor :pattern
|
32
|
+
|
33
|
+
class EnumAttributeValidator
|
34
|
+
attr_reader :datatype
|
35
|
+
attr_reader :allowable_values
|
36
|
+
|
37
|
+
def initialize(datatype, allowable_values)
|
38
|
+
@allowable_values = allowable_values.map do |value|
|
39
|
+
case datatype.to_s
|
40
|
+
when /Integer/i
|
41
|
+
value.to_i
|
42
|
+
when /Float/i
|
43
|
+
value.to_f
|
44
|
+
else
|
45
|
+
value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def valid?(value)
|
51
|
+
!value || allowable_values.include?(value)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
56
|
+
def self.attribute_map
|
57
|
+
{
|
58
|
+
:'modifier' => :'modifier',
|
59
|
+
:'pattern' => :'pattern'
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
# Attribute type mapping.
|
64
|
+
def self.swagger_types
|
65
|
+
{
|
66
|
+
:'modifier' => :'String',
|
67
|
+
:'pattern' => :'String'
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
# Initializes the object
|
72
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
73
|
+
def initialize(attributes = {})
|
74
|
+
return unless attributes.is_a?(Hash)
|
75
|
+
|
76
|
+
# convert string to symbol for hash key
|
77
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
78
|
+
|
79
|
+
if attributes.has_key?(:'modifier')
|
80
|
+
self.modifier = attributes[:'modifier']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes.has_key?(:'pattern')
|
84
|
+
self.pattern = attributes[:'pattern']
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
90
|
+
# @return Array for valid properies with the reasons
|
91
|
+
def list_invalid_properties
|
92
|
+
invalid_properties = Array.new
|
93
|
+
return invalid_properties
|
94
|
+
end
|
95
|
+
|
96
|
+
# Check to see if the all the properties in the model are valid
|
97
|
+
# @return true if the model is valid
|
98
|
+
def valid?
|
99
|
+
modifier_validator = EnumAttributeValidator.new('String', ["exclude", "include"])
|
100
|
+
return false unless modifier_validator.valid?(@modifier)
|
101
|
+
return true
|
102
|
+
end
|
103
|
+
|
104
|
+
# Custom attribute writer method checking allowed values (enum).
|
105
|
+
# @param [Object] modifier Object to be assigned
|
106
|
+
def modifier=(modifier)
|
107
|
+
validator = EnumAttributeValidator.new('String', ["exclude", "include"])
|
108
|
+
unless validator.valid?(modifier)
|
109
|
+
fail ArgumentError, "invalid value for 'modifier', must be one of #{validator.allowable_values}."
|
110
|
+
end
|
111
|
+
@modifier = modifier
|
112
|
+
end
|
113
|
+
|
114
|
+
# Checks equality by comparing each attribute.
|
115
|
+
# @param [Object] Object to be compared
|
116
|
+
def ==(o)
|
117
|
+
return true if self.equal?(o)
|
118
|
+
self.class == o.class &&
|
119
|
+
modifier == o.modifier &&
|
120
|
+
pattern == o.pattern
|
121
|
+
end
|
122
|
+
|
123
|
+
# @see the `==` method
|
124
|
+
# @param [Object] Object to be compared
|
125
|
+
def eql?(o)
|
126
|
+
self == o
|
127
|
+
end
|
128
|
+
|
129
|
+
# Calculates hash code according to all attributes.
|
130
|
+
# @return [Fixnum] Hash code
|
131
|
+
def hash
|
132
|
+
[modifier, pattern].hash
|
133
|
+
end
|
134
|
+
|
135
|
+
# Builds the object from hash
|
136
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
137
|
+
# @return [Object] Returns the model itself
|
138
|
+
def build_from_hash(attributes)
|
139
|
+
return nil unless attributes.is_a?(Hash)
|
140
|
+
self.class.swagger_types.each_pair do |key, type|
|
141
|
+
if type =~ /^Array<(.*)>/i
|
142
|
+
# check to ensure the input is an array given that the the attribute
|
143
|
+
# is documented as an array but the input is not
|
144
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
145
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
146
|
+
end
|
147
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
148
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
149
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
150
|
+
end
|
151
|
+
|
152
|
+
self
|
153
|
+
end
|
154
|
+
|
155
|
+
# Deserializes the data based on type
|
156
|
+
# @param string type Data type
|
157
|
+
# @param string value Value to be deserialized
|
158
|
+
# @return [Object] Deserialized data
|
159
|
+
def _deserialize(type, value)
|
160
|
+
case type.to_sym
|
161
|
+
when :DateTime
|
162
|
+
DateTime.parse(value)
|
163
|
+
when :Date
|
164
|
+
Date.parse(value)
|
165
|
+
when :String
|
166
|
+
value.to_s
|
167
|
+
when :Integer
|
168
|
+
value.to_i
|
169
|
+
when :Float
|
170
|
+
value.to_f
|
171
|
+
when :BOOLEAN
|
172
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
173
|
+
true
|
174
|
+
else
|
175
|
+
false
|
176
|
+
end
|
177
|
+
when :Object
|
178
|
+
# generic object (usually a Hash), return directly
|
179
|
+
value
|
180
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
181
|
+
inner_type = Regexp.last_match[:inner_type]
|
182
|
+
value.map { |v| _deserialize(inner_type, v) }
|
183
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
184
|
+
k_type = Regexp.last_match[:k_type]
|
185
|
+
v_type = Regexp.last_match[:v_type]
|
186
|
+
{}.tap do |hash|
|
187
|
+
value.each do |k, v|
|
188
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
else # model
|
192
|
+
temp_model = CrxPackageManager.const_get(type).new
|
193
|
+
temp_model.build_from_hash(value)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns the string representation of the object
|
198
|
+
# @return [String] String presentation of the object
|
199
|
+
def to_s
|
200
|
+
to_hash.to_s
|
201
|
+
end
|
202
|
+
|
203
|
+
# to_body is an alias to to_hash (backward compatibility)
|
204
|
+
# @return [Hash] Returns the object in the form of hash
|
205
|
+
def to_body
|
206
|
+
to_hash
|
207
|
+
end
|
208
|
+
|
209
|
+
# Returns the object in the form of hash
|
210
|
+
# @return [Hash] Returns the object in the form of hash
|
211
|
+
def to_hash
|
212
|
+
hash = {}
|
213
|
+
self.class.attribute_map.each_pair do |attr, param|
|
214
|
+
value = self.send(attr)
|
215
|
+
next if value.nil?
|
216
|
+
hash[param] = _to_hash(value)
|
217
|
+
end
|
218
|
+
hash
|
219
|
+
end
|
220
|
+
|
221
|
+
# Outputs non-array value in the form of hash
|
222
|
+
# For object, use to_hash. Otherwise, just return the value
|
223
|
+
# @param [Object] value Any valid value
|
224
|
+
# @return [Hash] Returns the value in the form of hash
|
225
|
+
def _to_hash(value)
|
226
|
+
if value.is_a?(Array)
|
227
|
+
value.compact.map{ |v| _to_hash(v) }
|
228
|
+
elsif value.is_a?(Hash)
|
229
|
+
{}.tap do |hash|
|
230
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
231
|
+
end
|
232
|
+
elsif value.respond_to? :to_hash
|
233
|
+
value.to_hash
|
234
|
+
else
|
235
|
+
value
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
=begin
|
2
|
+
#CRX Package Manager API
|
3
|
+
|
4
|
+
#API for interacting with the CRX Package Manager in AEM.
|
5
|
+
|
6
|
+
OpenAPI spec version: 6.2.0
|
7
|
+
Contact: bryan.stopp@gmail.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
you may not use this file except in compliance with the License.
|
12
|
+
You may obtain a copy of the License at
|
13
|
+
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
See the License for the specific language governing permissions and
|
20
|
+
limitations under the License.
|
21
|
+
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'date'
|
25
|
+
|
26
|
+
module CrxPackageManager
|
27
|
+
|
28
|
+
class Group
|
29
|
+
attr_accessor :name
|
30
|
+
|
31
|
+
attr_accessor :title
|
32
|
+
|
33
|
+
attr_accessor :count
|
34
|
+
|
35
|
+
attr_accessor :deep_count
|
36
|
+
|
37
|
+
|
38
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
39
|
+
def self.attribute_map
|
40
|
+
{
|
41
|
+
:'name' => :'name',
|
42
|
+
:'title' => :'title',
|
43
|
+
:'count' => :'count',
|
44
|
+
:'deep_count' => :'deepCount'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Attribute type mapping.
|
49
|
+
def self.swagger_types
|
50
|
+
{
|
51
|
+
:'name' => :'String',
|
52
|
+
:'title' => :'String',
|
53
|
+
:'count' => :'Integer',
|
54
|
+
:'deep_count' => :'Integer'
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# Initializes the object
|
59
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
60
|
+
def initialize(attributes = {})
|
61
|
+
return unless attributes.is_a?(Hash)
|
62
|
+
|
63
|
+
# convert string to symbol for hash key
|
64
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
65
|
+
|
66
|
+
if attributes.has_key?(:'name')
|
67
|
+
self.name = attributes[:'name']
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.has_key?(:'title')
|
71
|
+
self.title = attributes[:'title']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.has_key?(:'count')
|
75
|
+
self.count = attributes[:'count']
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes.has_key?(:'deepCount')
|
79
|
+
self.deep_count = attributes[:'deepCount']
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
85
|
+
# @return Array for valid properies with the reasons
|
86
|
+
def list_invalid_properties
|
87
|
+
invalid_properties = Array.new
|
88
|
+
return invalid_properties
|
89
|
+
end
|
90
|
+
|
91
|
+
# Check to see if the all the properties in the model are valid
|
92
|
+
# @return true if the model is valid
|
93
|
+
def valid?
|
94
|
+
return true
|
95
|
+
end
|
96
|
+
|
97
|
+
# Checks equality by comparing each attribute.
|
98
|
+
# @param [Object] Object to be compared
|
99
|
+
def ==(o)
|
100
|
+
return true if self.equal?(o)
|
101
|
+
self.class == o.class &&
|
102
|
+
name == o.name &&
|
103
|
+
title == o.title &&
|
104
|
+
count == o.count &&
|
105
|
+
deep_count == o.deep_count
|
106
|
+
end
|
107
|
+
|
108
|
+
# @see the `==` method
|
109
|
+
# @param [Object] Object to be compared
|
110
|
+
def eql?(o)
|
111
|
+
self == o
|
112
|
+
end
|
113
|
+
|
114
|
+
# Calculates hash code according to all attributes.
|
115
|
+
# @return [Fixnum] Hash code
|
116
|
+
def hash
|
117
|
+
[name, title, count, deep_count].hash
|
118
|
+
end
|
119
|
+
|
120
|
+
# Builds the object from hash
|
121
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
122
|
+
# @return [Object] Returns the model itself
|
123
|
+
def build_from_hash(attributes)
|
124
|
+
return nil unless attributes.is_a?(Hash)
|
125
|
+
self.class.swagger_types.each_pair do |key, type|
|
126
|
+
if type =~ /^Array<(.*)>/i
|
127
|
+
# check to ensure the input is an array given that the the attribute
|
128
|
+
# is documented as an array but the input is not
|
129
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
130
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
131
|
+
end
|
132
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
133
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
134
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
135
|
+
end
|
136
|
+
|
137
|
+
self
|
138
|
+
end
|
139
|
+
|
140
|
+
# Deserializes the data based on type
|
141
|
+
# @param string type Data type
|
142
|
+
# @param string value Value to be deserialized
|
143
|
+
# @return [Object] Deserialized data
|
144
|
+
def _deserialize(type, value)
|
145
|
+
case type.to_sym
|
146
|
+
when :DateTime
|
147
|
+
DateTime.parse(value)
|
148
|
+
when :Date
|
149
|
+
Date.parse(value)
|
150
|
+
when :String
|
151
|
+
value.to_s
|
152
|
+
when :Integer
|
153
|
+
value.to_i
|
154
|
+
when :Float
|
155
|
+
value.to_f
|
156
|
+
when :BOOLEAN
|
157
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
158
|
+
true
|
159
|
+
else
|
160
|
+
false
|
161
|
+
end
|
162
|
+
when :Object
|
163
|
+
# generic object (usually a Hash), return directly
|
164
|
+
value
|
165
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
166
|
+
inner_type = Regexp.last_match[:inner_type]
|
167
|
+
value.map { |v| _deserialize(inner_type, v) }
|
168
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
169
|
+
k_type = Regexp.last_match[:k_type]
|
170
|
+
v_type = Regexp.last_match[:v_type]
|
171
|
+
{}.tap do |hash|
|
172
|
+
value.each do |k, v|
|
173
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
else # model
|
177
|
+
temp_model = CrxPackageManager.const_get(type).new
|
178
|
+
temp_model.build_from_hash(value)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Returns the string representation of the object
|
183
|
+
# @return [String] String presentation of the object
|
184
|
+
def to_s
|
185
|
+
to_hash.to_s
|
186
|
+
end
|
187
|
+
|
188
|
+
# to_body is an alias to to_hash (backward compatibility)
|
189
|
+
# @return [Hash] Returns the object in the form of hash
|
190
|
+
def to_body
|
191
|
+
to_hash
|
192
|
+
end
|
193
|
+
|
194
|
+
# Returns the object in the form of hash
|
195
|
+
# @return [Hash] Returns the object in the form of hash
|
196
|
+
def to_hash
|
197
|
+
hash = {}
|
198
|
+
self.class.attribute_map.each_pair do |attr, param|
|
199
|
+
value = self.send(attr)
|
200
|
+
next if value.nil?
|
201
|
+
hash[param] = _to_hash(value)
|
202
|
+
end
|
203
|
+
hash
|
204
|
+
end
|
205
|
+
|
206
|
+
# Outputs non-array value in the form of hash
|
207
|
+
# For object, use to_hash. Otherwise, just return the value
|
208
|
+
# @param [Object] value Any valid value
|
209
|
+
# @return [Hash] Returns the value in the form of hash
|
210
|
+
def _to_hash(value)
|
211
|
+
if value.is_a?(Array)
|
212
|
+
value.compact.map{ |v| _to_hash(v) }
|
213
|
+
elsif value.is_a?(Hash)
|
214
|
+
{}.tap do |hash|
|
215
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
216
|
+
end
|
217
|
+
elsif value.respond_to? :to_hash
|
218
|
+
value.to_hash
|
219
|
+
else
|
220
|
+
value
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|