adzerk_decision_sdk 1.0.0.pre.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +70 -0
- data/README.md +97 -0
- data/Rakefile +10 -0
- data/adzerk_decision_sdk.gemspec +39 -0
- data/docs/Consent.md +17 -0
- data/docs/ConsentRequest.md +19 -0
- data/docs/Content.md +25 -0
- data/docs/Decision.md +35 -0
- data/docs/DecisionApi.md +57 -0
- data/docs/DecisionData.md +25 -0
- data/docs/DecisionRequest.md +43 -0
- data/docs/DecisionResponse.md +21 -0
- data/docs/Event.md +19 -0
- data/docs/GdprConsent.md +19 -0
- data/docs/Placement.md +47 -0
- data/docs/PricingData.md +25 -0
- data/docs/Request.md +43 -0
- data/docs/RequestConsent.md +17 -0
- data/docs/Response.md +21 -0
- data/docs/User.md +17 -0
- data/docs/UserdbApi.md +536 -0
- data/git_push.sh +58 -0
- data/lib/adzerk_decision_sdk/api/decision_api.rb +80 -0
- data/lib/adzerk_decision_sdk/api/userdb_api.rb +731 -0
- data/lib/adzerk_decision_sdk/api_client.rb +386 -0
- data/lib/adzerk_decision_sdk/api_error.rb +57 -0
- data/lib/adzerk_decision_sdk/client.rb +43 -0
- data/lib/adzerk_decision_sdk/configuration.rb +262 -0
- data/lib/adzerk_decision_sdk/decision_client.rb +73 -0
- data/lib/adzerk_decision_sdk/event_type.rb +61 -0
- data/lib/adzerk_decision_sdk/models/consent_request.rb +215 -0
- data/lib/adzerk_decision_sdk/models/content.rb +242 -0
- data/lib/adzerk_decision_sdk/models/decision.rb +291 -0
- data/lib/adzerk_decision_sdk/models/decision_data.rb +242 -0
- data/lib/adzerk_decision_sdk/models/decision_request.rb +359 -0
- data/lib/adzerk_decision_sdk/models/decision_response.rb +224 -0
- data/lib/adzerk_decision_sdk/models/event.rb +215 -0
- data/lib/adzerk_decision_sdk/models/placement.rb +377 -0
- data/lib/adzerk_decision_sdk/models/pricing_data.rb +242 -0
- data/lib/adzerk_decision_sdk/models/user.rb +208 -0
- data/lib/adzerk_decision_sdk/pixel_client.rb +26 -0
- data/lib/adzerk_decision_sdk/rate_type.rb +8 -0
- data/lib/adzerk_decision_sdk/user_db_client.rb +64 -0
- data/lib/adzerk_decision_sdk/version.rb +15 -0
- data/lib/adzerk_decision_sdk.rb +58 -0
- data/pkg/adzerk_decision_sdk-1.0.0.gem +0 -0
- data/spec/.gitkeep +0 -0
- data/spec/placeholder_spec.rb +9 -0
- metadata +153 -0
@@ -0,0 +1,242 @@
|
|
1
|
+
=begin
|
2
|
+
#Adzerk Decision API
|
3
|
+
|
4
|
+
#Adzerk Decision API
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module AdzerkDecisionSdk
|
16
|
+
class Content
|
17
|
+
attr_accessor :type
|
18
|
+
|
19
|
+
attr_accessor :template
|
20
|
+
|
21
|
+
attr_accessor :custom_template
|
22
|
+
|
23
|
+
attr_accessor :data
|
24
|
+
|
25
|
+
attr_accessor :body
|
26
|
+
|
27
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
+
def self.attribute_map
|
29
|
+
{
|
30
|
+
:'type' => :'type',
|
31
|
+
:'template' => :'template',
|
32
|
+
:'custom_template' => :'customTemplate',
|
33
|
+
:'data' => :'data',
|
34
|
+
:'body' => :'body'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'type' => :'String',
|
42
|
+
:'template' => :'String',
|
43
|
+
:'custom_template' => :'String',
|
44
|
+
:'data' => :'DecisionData',
|
45
|
+
:'body' => :'String'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# List of attributes with nullable: true
|
50
|
+
def self.openapi_nullable
|
51
|
+
Set.new([
|
52
|
+
])
|
53
|
+
end
|
54
|
+
|
55
|
+
# Initializes the object
|
56
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
57
|
+
def initialize(attributes = {})
|
58
|
+
if (!attributes.is_a?(Hash))
|
59
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `AdzerkDecisionSdk::Content` initialize method"
|
60
|
+
end
|
61
|
+
|
62
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
63
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
64
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
65
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `AdzerkDecisionSdk::Content`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
66
|
+
end
|
67
|
+
h[k.to_sym] = v
|
68
|
+
}
|
69
|
+
|
70
|
+
if attributes.key?(:'type')
|
71
|
+
self.type = attributes[:'type']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.key?(:'template')
|
75
|
+
self.template = attributes[:'template']
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes.key?(:'custom_template')
|
79
|
+
self.custom_template = attributes[:'custom_template']
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'data')
|
83
|
+
self.data = attributes[:'data']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'body')
|
87
|
+
self.body = attributes[:'body']
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
92
|
+
# @return Array for valid properties with the reasons
|
93
|
+
def list_invalid_properties
|
94
|
+
invalid_properties = Array.new
|
95
|
+
invalid_properties
|
96
|
+
end
|
97
|
+
|
98
|
+
# Check to see if the all the properties in the model are valid
|
99
|
+
# @return true if the model is valid
|
100
|
+
def valid?
|
101
|
+
true
|
102
|
+
end
|
103
|
+
|
104
|
+
# Checks equality by comparing each attribute.
|
105
|
+
# @param [Object] Object to be compared
|
106
|
+
def ==(o)
|
107
|
+
return true if self.equal?(o)
|
108
|
+
self.class == o.class &&
|
109
|
+
type == o.type &&
|
110
|
+
template == o.template &&
|
111
|
+
custom_template == o.custom_template &&
|
112
|
+
data == o.data &&
|
113
|
+
body == o.body
|
114
|
+
end
|
115
|
+
|
116
|
+
# @see the `==` method
|
117
|
+
# @param [Object] Object to be compared
|
118
|
+
def eql?(o)
|
119
|
+
self == o
|
120
|
+
end
|
121
|
+
|
122
|
+
# Calculates hash code according to all attributes.
|
123
|
+
# @return [Integer] Hash code
|
124
|
+
def hash
|
125
|
+
[type, template, custom_template, data, body].hash
|
126
|
+
end
|
127
|
+
|
128
|
+
# Builds the object from hash
|
129
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
130
|
+
# @return [Object] Returns the model itself
|
131
|
+
def self.build_from_hash(attributes)
|
132
|
+
new.build_from_hash(attributes)
|
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.openapi_types.each_pair do |key, type|
|
141
|
+
if type =~ /\AArray<(.*)>/i
|
142
|
+
# check to ensure the input is an array given that 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 =~ /\A(true|t|yes|y|1)\z/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
|
+
AdzerkDecisionSdk.const_get(type).build_from_hash(value)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the string representation of the object
|
197
|
+
# @return [String] String presentation of the object
|
198
|
+
def to_s
|
199
|
+
to_hash.to_s
|
200
|
+
end
|
201
|
+
|
202
|
+
# to_body is an alias to to_hash (backward compatibility)
|
203
|
+
# @return [Hash] Returns the object in the form of hash
|
204
|
+
def to_body
|
205
|
+
to_hash
|
206
|
+
end
|
207
|
+
|
208
|
+
# Returns the object in the form of hash
|
209
|
+
# @return [Hash] Returns the object in the form of hash
|
210
|
+
def to_hash
|
211
|
+
hash = {}
|
212
|
+
self.class.attribute_map.each_pair do |attr, param|
|
213
|
+
value = self.send(attr)
|
214
|
+
if value.nil?
|
215
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
216
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
217
|
+
end
|
218
|
+
|
219
|
+
hash[param] = _to_hash(value)
|
220
|
+
end
|
221
|
+
hash
|
222
|
+
end
|
223
|
+
|
224
|
+
# Outputs non-array value in the form of hash
|
225
|
+
# For object, use to_hash. Otherwise, just return the value
|
226
|
+
# @param [Object] value Any valid value
|
227
|
+
# @return [Hash] Returns the value in the form of hash
|
228
|
+
def _to_hash(value)
|
229
|
+
if value.is_a?(Array)
|
230
|
+
value.compact.map { |v| _to_hash(v) }
|
231
|
+
elsif value.is_a?(Hash)
|
232
|
+
{}.tap do |hash|
|
233
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
234
|
+
end
|
235
|
+
elsif value.respond_to? :to_hash
|
236
|
+
value.to_hash
|
237
|
+
else
|
238
|
+
value
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
@@ -0,0 +1,291 @@
|
|
1
|
+
=begin
|
2
|
+
#Adzerk Decision API
|
3
|
+
|
4
|
+
#Adzerk Decision API
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module AdzerkDecisionSdk
|
16
|
+
class Decision
|
17
|
+
attr_accessor :ad_id
|
18
|
+
|
19
|
+
attr_accessor :creative_id
|
20
|
+
|
21
|
+
attr_accessor :flight_id
|
22
|
+
|
23
|
+
attr_accessor :campaign_id
|
24
|
+
|
25
|
+
attr_accessor :priority_id
|
26
|
+
|
27
|
+
attr_accessor :click_url
|
28
|
+
|
29
|
+
attr_accessor :contents
|
30
|
+
|
31
|
+
attr_accessor :impression_url
|
32
|
+
|
33
|
+
attr_accessor :events
|
34
|
+
|
35
|
+
attr_accessor :pricing
|
36
|
+
|
37
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
38
|
+
def self.attribute_map
|
39
|
+
{
|
40
|
+
:'ad_id' => :'adId',
|
41
|
+
:'creative_id' => :'creativeId',
|
42
|
+
:'flight_id' => :'flightId',
|
43
|
+
:'campaign_id' => :'campaignId',
|
44
|
+
:'priority_id' => :'priorityId',
|
45
|
+
:'click_url' => :'clickUrl',
|
46
|
+
:'contents' => :'contents',
|
47
|
+
:'impression_url' => :'impressionUrl',
|
48
|
+
:'events' => :'events',
|
49
|
+
:'pricing' => :'pricing'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
# Attribute type mapping.
|
54
|
+
def self.openapi_types
|
55
|
+
{
|
56
|
+
:'ad_id' => :'Integer',
|
57
|
+
:'creative_id' => :'Integer',
|
58
|
+
:'flight_id' => :'Integer',
|
59
|
+
:'campaign_id' => :'Integer',
|
60
|
+
:'priority_id' => :'Integer',
|
61
|
+
:'click_url' => :'String',
|
62
|
+
:'contents' => :'Array<Content>',
|
63
|
+
:'impression_url' => :'String',
|
64
|
+
:'events' => :'Array<Event>',
|
65
|
+
:'pricing' => :'PricingData'
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
# List of attributes with nullable: true
|
70
|
+
def self.openapi_nullable
|
71
|
+
Set.new([
|
72
|
+
])
|
73
|
+
end
|
74
|
+
|
75
|
+
# Initializes the object
|
76
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
77
|
+
def initialize(attributes = {})
|
78
|
+
if (!attributes.is_a?(Hash))
|
79
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `AdzerkDecisionSdk::Decision` initialize method"
|
80
|
+
end
|
81
|
+
|
82
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
83
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
84
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
85
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `AdzerkDecisionSdk::Decision`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
86
|
+
end
|
87
|
+
h[k.to_sym] = v
|
88
|
+
}
|
89
|
+
|
90
|
+
if attributes.key?(:'ad_id')
|
91
|
+
self.ad_id = attributes[:'ad_id']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'creative_id')
|
95
|
+
self.creative_id = attributes[:'creative_id']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:'flight_id')
|
99
|
+
self.flight_id = attributes[:'flight_id']
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes.key?(:'campaign_id')
|
103
|
+
self.campaign_id = attributes[:'campaign_id']
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.key?(:'priority_id')
|
107
|
+
self.priority_id = attributes[:'priority_id']
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.key?(:'click_url')
|
111
|
+
self.click_url = attributes[:'click_url']
|
112
|
+
end
|
113
|
+
|
114
|
+
if attributes.key?(:'contents')
|
115
|
+
if (value = attributes[:'contents']).is_a?(Array)
|
116
|
+
self.contents = value
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.key?(:'impression_url')
|
121
|
+
self.impression_url = attributes[:'impression_url']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'events')
|
125
|
+
if (value = attributes[:'events']).is_a?(Array)
|
126
|
+
self.events = value
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
if attributes.key?(:'pricing')
|
131
|
+
self.pricing = attributes[:'pricing']
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
136
|
+
# @return Array for valid properties with the reasons
|
137
|
+
def list_invalid_properties
|
138
|
+
invalid_properties = Array.new
|
139
|
+
invalid_properties
|
140
|
+
end
|
141
|
+
|
142
|
+
# Check to see if the all the properties in the model are valid
|
143
|
+
# @return true if the model is valid
|
144
|
+
def valid?
|
145
|
+
true
|
146
|
+
end
|
147
|
+
|
148
|
+
# Checks equality by comparing each attribute.
|
149
|
+
# @param [Object] Object to be compared
|
150
|
+
def ==(o)
|
151
|
+
return true if self.equal?(o)
|
152
|
+
self.class == o.class &&
|
153
|
+
ad_id == o.ad_id &&
|
154
|
+
creative_id == o.creative_id &&
|
155
|
+
flight_id == o.flight_id &&
|
156
|
+
campaign_id == o.campaign_id &&
|
157
|
+
priority_id == o.priority_id &&
|
158
|
+
click_url == o.click_url &&
|
159
|
+
contents == o.contents &&
|
160
|
+
impression_url == o.impression_url &&
|
161
|
+
events == o.events &&
|
162
|
+
pricing == o.pricing
|
163
|
+
end
|
164
|
+
|
165
|
+
# @see the `==` method
|
166
|
+
# @param [Object] Object to be compared
|
167
|
+
def eql?(o)
|
168
|
+
self == o
|
169
|
+
end
|
170
|
+
|
171
|
+
# Calculates hash code according to all attributes.
|
172
|
+
# @return [Integer] Hash code
|
173
|
+
def hash
|
174
|
+
[ad_id, creative_id, flight_id, campaign_id, priority_id, click_url, contents, impression_url, events, pricing].hash
|
175
|
+
end
|
176
|
+
|
177
|
+
# Builds the object from hash
|
178
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
179
|
+
# @return [Object] Returns the model itself
|
180
|
+
def self.build_from_hash(attributes)
|
181
|
+
new.build_from_hash(attributes)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Builds the object from hash
|
185
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
186
|
+
# @return [Object] Returns the model itself
|
187
|
+
def build_from_hash(attributes)
|
188
|
+
return nil unless attributes.is_a?(Hash)
|
189
|
+
self.class.openapi_types.each_pair do |key, type|
|
190
|
+
if type =~ /\AArray<(.*)>/i
|
191
|
+
# check to ensure the input is an array given that the attribute
|
192
|
+
# is documented as an array but the input is not
|
193
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
194
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
195
|
+
end
|
196
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
197
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
198
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
199
|
+
end
|
200
|
+
|
201
|
+
self
|
202
|
+
end
|
203
|
+
|
204
|
+
# Deserializes the data based on type
|
205
|
+
# @param string type Data type
|
206
|
+
# @param string value Value to be deserialized
|
207
|
+
# @return [Object] Deserialized data
|
208
|
+
def _deserialize(type, value)
|
209
|
+
case type.to_sym
|
210
|
+
when :DateTime
|
211
|
+
DateTime.parse(value)
|
212
|
+
when :Date
|
213
|
+
Date.parse(value)
|
214
|
+
when :String
|
215
|
+
value.to_s
|
216
|
+
when :Integer
|
217
|
+
value.to_i
|
218
|
+
when :Float
|
219
|
+
value.to_f
|
220
|
+
when :Boolean
|
221
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
222
|
+
true
|
223
|
+
else
|
224
|
+
false
|
225
|
+
end
|
226
|
+
when :Object
|
227
|
+
# generic object (usually a Hash), return directly
|
228
|
+
value
|
229
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
230
|
+
inner_type = Regexp.last_match[:inner_type]
|
231
|
+
value.map { |v| _deserialize(inner_type, v) }
|
232
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
233
|
+
k_type = Regexp.last_match[:k_type]
|
234
|
+
v_type = Regexp.last_match[:v_type]
|
235
|
+
{}.tap do |hash|
|
236
|
+
value.each do |k, v|
|
237
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
else # model
|
241
|
+
AdzerkDecisionSdk.const_get(type).build_from_hash(value)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
# Returns the string representation of the object
|
246
|
+
# @return [String] String presentation of the object
|
247
|
+
def to_s
|
248
|
+
to_hash.to_s
|
249
|
+
end
|
250
|
+
|
251
|
+
# to_body is an alias to to_hash (backward compatibility)
|
252
|
+
# @return [Hash] Returns the object in the form of hash
|
253
|
+
def to_body
|
254
|
+
to_hash
|
255
|
+
end
|
256
|
+
|
257
|
+
# Returns the object in the form of hash
|
258
|
+
# @return [Hash] Returns the object in the form of hash
|
259
|
+
def to_hash
|
260
|
+
hash = {}
|
261
|
+
self.class.attribute_map.each_pair do |attr, param|
|
262
|
+
value = self.send(attr)
|
263
|
+
if value.nil?
|
264
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
265
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
266
|
+
end
|
267
|
+
|
268
|
+
hash[param] = _to_hash(value)
|
269
|
+
end
|
270
|
+
hash
|
271
|
+
end
|
272
|
+
|
273
|
+
# Outputs non-array value in the form of hash
|
274
|
+
# For object, use to_hash. Otherwise, just return the value
|
275
|
+
# @param [Object] value Any valid value
|
276
|
+
# @return [Hash] Returns the value in the form of hash
|
277
|
+
def _to_hash(value)
|
278
|
+
if value.is_a?(Array)
|
279
|
+
value.compact.map { |v| _to_hash(v) }
|
280
|
+
elsif value.is_a?(Hash)
|
281
|
+
{}.tap do |hash|
|
282
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
283
|
+
end
|
284
|
+
elsif value.respond_to? :to_hash
|
285
|
+
value.to_hash
|
286
|
+
else
|
287
|
+
value
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|