reference_service 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +79 -0
  4. data/README.md +126 -0
  5. data/Rakefile +10 -0
  6. data/docs/ActiveSubscription.md +27 -0
  7. data/docs/Error.md +17 -0
  8. data/docs/ErrorErrors.md +17 -0
  9. data/docs/ErrorErrorsError.md +25 -0
  10. data/docs/ReportsApi.md +168 -0
  11. data/docs/Sector.md +19 -0
  12. data/docs/SectorApi.md +100 -0
  13. data/docs/SectorSpending.md +23 -0
  14. data/docs/SpendingReport.md +23 -0
  15. data/docs/SubscribeApi.md +244 -0
  16. data/docs/Subscription.md +17 -0
  17. data/docs/SubscriptionObject.md +27 -0
  18. data/docs/SubscriptionPaymentCard.md +21 -0
  19. data/docs/SubscriptionResponse.md +19 -0
  20. data/docs/TopLocationsReport.md +17 -0
  21. data/docs/UnsubscribedResponse.md +19 -0
  22. data/git_push.sh +55 -0
  23. data/lib/openapi_client.rb +55 -0
  24. data/lib/openapi_client/api/reports_api.rb +252 -0
  25. data/lib/openapi_client/api/sector_api.rb +151 -0
  26. data/lib/openapi_client/api/subscribe_api.rb +334 -0
  27. data/lib/openapi_client/api_client.rb +386 -0
  28. data/lib/openapi_client/api_error.rb +57 -0
  29. data/lib/openapi_client/configuration.rb +244 -0
  30. data/lib/openapi_client/models/active_subscription.rb +262 -0
  31. data/lib/openapi_client/models/error.rb +201 -0
  32. data/lib/openapi_client/models/error_errors.rb +203 -0
  33. data/lib/openapi_client/models/error_errors_error.rb +232 -0
  34. data/lib/openapi_client/models/sector.rb +216 -0
  35. data/lib/openapi_client/models/sector_spending.rb +244 -0
  36. data/lib/openapi_client/models/spending_report.rb +235 -0
  37. data/lib/openapi_client/models/subscription.rb +197 -0
  38. data/lib/openapi_client/models/subscription_object.rb +247 -0
  39. data/lib/openapi_client/models/subscription_payment_card.rb +254 -0
  40. data/lib/openapi_client/models/subscription_response.rb +206 -0
  41. data/lib/openapi_client/models/top_locations_report.rb +200 -0
  42. data/lib/openapi_client/models/unsubscribed_response.rb +207 -0
  43. data/lib/openapi_client/version.rb +15 -0
  44. data/openapi_client.gemspec +38 -0
  45. data/spec/api/reports_api_spec.rb +77 -0
  46. data/spec/api/sector_api_spec.rb +58 -0
  47. data/spec/api/subscribe_api_spec.rb +92 -0
  48. data/spec/api_client_spec.rb +226 -0
  49. data/spec/configuration_spec.rb +42 -0
  50. data/spec/models/active_subscription_spec.rb +71 -0
  51. data/spec/models/error_errors_error_spec.rb +65 -0
  52. data/spec/models/error_errors_spec.rb +41 -0
  53. data/spec/models/error_spec.rb +41 -0
  54. data/spec/models/sector_spec.rb +47 -0
  55. data/spec/models/sector_spending_spec.rb +59 -0
  56. data/spec/models/spending_report_spec.rb +59 -0
  57. data/spec/models/subscription_object_spec.rb +71 -0
  58. data/spec/models/subscription_payment_card_spec.rb +53 -0
  59. data/spec/models/subscription_response_spec.rb +47 -0
  60. data/spec/models/subscription_spec.rb +41 -0
  61. data/spec/models/top_locations_report_spec.rb +41 -0
  62. data/spec/models/unsubscribed_response_spec.rb +47 -0
  63. data/spec/spec_helper.rb +111 -0
  64. metadata +199 -0
@@ -0,0 +1,235 @@
1
+ =begin
2
+ #Golden Service API
3
+
4
+ #An API that conforms to the standards and best practices that should be adhered to in all Mastercard owned APIs. Can be used to create subscriptions to reports that are generated twice daily (6am & 6pm) that deliver e-commerce spending across multiple sectors and locations. <br/> --- * **All requests must be signed using oauth 1.0a. Please refer to: https://developer.mastercard.com/platform/documentation/using-oauth-1a-to-access-mastercard-apis/** --- * **The user must provide their card details when creating a subscription. These details must be encrypted before entering transit. Please refer to [Mastercard security](https://stage.developer.mastercard.com/platform/documentation/securing-sensitive-data-using-payload-encryption/)** ---
5
+
6
+ The version of the OpenAPI document: 1.1.0
7
+ Contact: developers@mastercard.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module OpenapiClient
16
+ # Spending report for a particular location
17
+ class SpendingReport
18
+ # The location being reported on
19
+ attr_accessor :location
20
+
21
+ # The spending type being reported
22
+ attr_accessor :spending_type
23
+
24
+ # The amount spent for the given location
25
+ attr_accessor :amount
26
+
27
+ # Array of sector spending objects
28
+ attr_accessor :sectors
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'location' => :'location',
34
+ :'spending_type' => :'spendingType',
35
+ :'amount' => :'amount',
36
+ :'sectors' => :'sectors'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'location' => :'String',
44
+ :'spending_type' => :'String',
45
+ :'amount' => :'Float',
46
+ :'sectors' => :'Array<SectorSpending>'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::SpendingReport` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::SpendingReport`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'location')
66
+ self.location = attributes[:'location']
67
+ end
68
+
69
+ if attributes.key?(:'spending_type')
70
+ self.spending_type = attributes[:'spending_type']
71
+ end
72
+
73
+ if attributes.key?(:'amount')
74
+ self.amount = attributes[:'amount']
75
+ end
76
+
77
+ if attributes.key?(:'sectors')
78
+ if (value = attributes[:'sectors']).is_a?(Array)
79
+ self.sectors = value
80
+ end
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ if @location.nil?
89
+ invalid_properties.push('invalid value for "location", location cannot be nil.')
90
+ end
91
+
92
+ invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ return false if @location.nil?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ location == o.location &&
108
+ spending_type == o.spending_type &&
109
+ amount == o.amount &&
110
+ sectors == o.sectors
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [location, spending_type, amount, sectors].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ self.class.openapi_types.each_pair do |key, type|
138
+ if type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :DateTime
159
+ DateTime.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ OpenapiClient.const_get(type).build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ next if value.nil?
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,197 @@
1
+ =begin
2
+ #Golden Service API
3
+
4
+ #An API that conforms to the standards and best practices that should be adhered to in all Mastercard owned APIs. Can be used to create subscriptions to reports that are generated twice daily (6am & 6pm) that deliver e-commerce spending across multiple sectors and locations. <br/> --- * **All requests must be signed using oauth 1.0a. Please refer to: https://developer.mastercard.com/platform/documentation/using-oauth-1a-to-access-mastercard-apis/** --- * **The user must provide their card details when creating a subscription. These details must be encrypted before entering transit. Please refer to [Mastercard security](https://stage.developer.mastercard.com/platform/documentation/securing-sensitive-data-using-payload-encryption/)** ---
5
+
6
+ The version of the OpenAPI document: 1.1.0
7
+ Contact: developers@mastercard.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module OpenapiClient
16
+ # Subscription request body object that can be used to create or update a subscription
17
+ class Subscription
18
+ attr_accessor :subscription
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'subscription' => :'subscription'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.openapi_types
29
+ {
30
+ :'subscription' => :'SubscriptionObject'
31
+ }
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ if (!attributes.is_a?(Hash))
38
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Subscription` initialize method"
39
+ end
40
+
41
+ # check to see if the attribute exists and convert string to symbol for hash key
42
+ attributes = attributes.each_with_object({}) { |(k, v), h|
43
+ if (!self.class.attribute_map.key?(k.to_sym))
44
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Subscription`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
45
+ end
46
+ h[k.to_sym] = v
47
+ }
48
+
49
+ if attributes.key?(:'subscription')
50
+ self.subscription = attributes[:'subscription']
51
+ end
52
+ end
53
+
54
+ # Show invalid properties with the reasons. Usually used together with valid?
55
+ # @return Array for valid properties with the reasons
56
+ def list_invalid_properties
57
+ invalid_properties = Array.new
58
+ invalid_properties
59
+ end
60
+
61
+ # Check to see if the all the properties in the model are valid
62
+ # @return true if the model is valid
63
+ def valid?
64
+ true
65
+ end
66
+
67
+ # Checks equality by comparing each attribute.
68
+ # @param [Object] Object to be compared
69
+ def ==(o)
70
+ return true if self.equal?(o)
71
+ self.class == o.class &&
72
+ subscription == o.subscription
73
+ end
74
+
75
+ # @see the `==` method
76
+ # @param [Object] Object to be compared
77
+ def eql?(o)
78
+ self == o
79
+ end
80
+
81
+ # Calculates hash code according to all attributes.
82
+ # @return [Integer] Hash code
83
+ def hash
84
+ [subscription].hash
85
+ end
86
+
87
+ # Builds the object from hash
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ # @return [Object] Returns the model itself
90
+ def self.build_from_hash(attributes)
91
+ new.build_from_hash(attributes)
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def build_from_hash(attributes)
98
+ return nil unless attributes.is_a?(Hash)
99
+ self.class.openapi_types.each_pair do |key, type|
100
+ if type =~ /\AArray<(.*)>/i
101
+ # check to ensure the input is an array given that the attribute
102
+ # is documented as an array but the input is not
103
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
104
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
105
+ end
106
+ elsif !attributes[self.class.attribute_map[key]].nil?
107
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
108
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
109
+ end
110
+
111
+ self
112
+ end
113
+
114
+ # Deserializes the data based on type
115
+ # @param string type Data type
116
+ # @param string value Value to be deserialized
117
+ # @return [Object] Deserialized data
118
+ def _deserialize(type, value)
119
+ case type.to_sym
120
+ when :DateTime
121
+ DateTime.parse(value)
122
+ when :Date
123
+ Date.parse(value)
124
+ when :String
125
+ value.to_s
126
+ when :Integer
127
+ value.to_i
128
+ when :Float
129
+ value.to_f
130
+ when :Boolean
131
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
132
+ true
133
+ else
134
+ false
135
+ end
136
+ when :Object
137
+ # generic object (usually a Hash), return directly
138
+ value
139
+ when /\AArray<(?<inner_type>.+)>\z/
140
+ inner_type = Regexp.last_match[:inner_type]
141
+ value.map { |v| _deserialize(inner_type, v) }
142
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
143
+ k_type = Regexp.last_match[:k_type]
144
+ v_type = Regexp.last_match[:v_type]
145
+ {}.tap do |hash|
146
+ value.each do |k, v|
147
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
148
+ end
149
+ end
150
+ else # model
151
+ OpenapiClient.const_get(type).build_from_hash(value)
152
+ end
153
+ end
154
+
155
+ # Returns the string representation of the object
156
+ # @return [String] String presentation of the object
157
+ def to_s
158
+ to_hash.to_s
159
+ end
160
+
161
+ # to_body is an alias to to_hash (backward compatibility)
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_body
164
+ to_hash
165
+ end
166
+
167
+ # Returns the object in the form of hash
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = self.send(attr)
173
+ next if value.nil?
174
+ hash[param] = _to_hash(value)
175
+ end
176
+ hash
177
+ end
178
+
179
+ # Outputs non-array value in the form of hash
180
+ # For object, use to_hash. Otherwise, just return the value
181
+ # @param [Object] value Any valid value
182
+ # @return [Hash] Returns the value in the form of hash
183
+ def _to_hash(value)
184
+ if value.is_a?(Array)
185
+ value.compact.map { |v| _to_hash(v) }
186
+ elsif value.is_a?(Hash)
187
+ {}.tap do |hash|
188
+ value.each { |k, v| hash[k] = _to_hash(v) }
189
+ end
190
+ elsif value.respond_to? :to_hash
191
+ value.to_hash
192
+ else
193
+ value
194
+ end
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,247 @@
1
+ =begin
2
+ #Golden Service API
3
+
4
+ #An API that conforms to the standards and best practices that should be adhered to in all Mastercard owned APIs. Can be used to create subscriptions to reports that are generated twice daily (6am & 6pm) that deliver e-commerce spending across multiple sectors and locations. <br/> --- * **All requests must be signed using oauth 1.0a. Please refer to: https://developer.mastercard.com/platform/documentation/using-oauth-1a-to-access-mastercard-apis/** --- * **The user must provide their card details when creating a subscription. These details must be encrypted before entering transit. Please refer to [Mastercard security](https://stage.developer.mastercard.com/platform/documentation/securing-sensitive-data-using-payload-encryption/)** ---
5
+
6
+ The version of the OpenAPI document: 1.1.0
7
+ Contact: developers@mastercard.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module OpenapiClient
16
+ # Subscription body object that represents a subscription
17
+ class SubscriptionObject
18
+ # The email address to which the reports will be sent to
19
+ attr_accessor :email_address
20
+
21
+ # The location you wish to create a subscription for
22
+ attr_accessor :location
23
+
24
+ # The sector for which you wish to receive reports. Sector ids can be retrieved from sectors call
25
+ attr_accessor :sector
26
+
27
+ # b - Bi-Daily, d - Daily, w - Weekly
28
+ attr_accessor :frequency
29
+
30
+ # An image that can be included as part of the subscription. MUST be sent in base64 format.
31
+ attr_accessor :subscription_image
32
+
33
+ attr_accessor :subscription_payment_card
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'email_address' => :'emailAddress',
39
+ :'location' => :'location',
40
+ :'sector' => :'sector',
41
+ :'frequency' => :'frequency',
42
+ :'subscription_image' => :'subscriptionImage',
43
+ :'subscription_payment_card' => :'subscriptionPaymentCard'
44
+ }
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'email_address' => :'String',
51
+ :'location' => :'String',
52
+ :'sector' => :'Integer',
53
+ :'frequency' => :'String',
54
+ :'subscription_image' => :'String',
55
+ :'subscription_payment_card' => :'SubscriptionPaymentCard'
56
+ }
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::SubscriptionObject` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ attributes = attributes.each_with_object({}) { |(k, v), h|
68
+ if (!self.class.attribute_map.key?(k.to_sym))
69
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::SubscriptionObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
70
+ end
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:'email_address')
75
+ self.email_address = attributes[:'email_address']
76
+ end
77
+
78
+ if attributes.key?(:'location')
79
+ self.location = attributes[:'location']
80
+ end
81
+
82
+ if attributes.key?(:'sector')
83
+ self.sector = attributes[:'sector']
84
+ end
85
+
86
+ if attributes.key?(:'frequency')
87
+ self.frequency = attributes[:'frequency']
88
+ end
89
+
90
+ if attributes.key?(:'subscription_image')
91
+ self.subscription_image = attributes[:'subscription_image']
92
+ end
93
+
94
+ if attributes.key?(:'subscription_payment_card')
95
+ self.subscription_payment_card = attributes[:'subscription_payment_card']
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ invalid_properties = Array.new
103
+ invalid_properties
104
+ end
105
+
106
+ # Check to see if the all the properties in the model are valid
107
+ # @return true if the model is valid
108
+ def valid?
109
+ true
110
+ end
111
+
112
+ # Checks equality by comparing each attribute.
113
+ # @param [Object] Object to be compared
114
+ def ==(o)
115
+ return true if self.equal?(o)
116
+ self.class == o.class &&
117
+ email_address == o.email_address &&
118
+ location == o.location &&
119
+ sector == o.sector &&
120
+ frequency == o.frequency &&
121
+ subscription_image == o.subscription_image &&
122
+ subscription_payment_card == o.subscription_payment_card
123
+ end
124
+
125
+ # @see the `==` method
126
+ # @param [Object] Object to be compared
127
+ def eql?(o)
128
+ self == o
129
+ end
130
+
131
+ # Calculates hash code according to all attributes.
132
+ # @return [Integer] Hash code
133
+ def hash
134
+ [email_address, location, sector, frequency, subscription_image, subscription_payment_card].hash
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def self.build_from_hash(attributes)
141
+ new.build_from_hash(attributes)
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ self.class.openapi_types.each_pair do |key, type|
150
+ if type =~ /\AArray<(.*)>/i
151
+ # check to ensure the input is an array given that the attribute
152
+ # is documented as an array but the input is not
153
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
154
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
155
+ end
156
+ elsif !attributes[self.class.attribute_map[key]].nil?
157
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
158
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
159
+ end
160
+
161
+ self
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def _deserialize(type, value)
169
+ case type.to_sym
170
+ when :DateTime
171
+ DateTime.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :String
175
+ value.to_s
176
+ when :Integer
177
+ value.to_i
178
+ when :Float
179
+ value.to_f
180
+ when :Boolean
181
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
182
+ true
183
+ else
184
+ false
185
+ end
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ else # model
201
+ OpenapiClient.const_get(type).build_from_hash(value)
202
+ end
203
+ end
204
+
205
+ # Returns the string representation of the object
206
+ # @return [String] String presentation of the object
207
+ def to_s
208
+ to_hash.to_s
209
+ end
210
+
211
+ # to_body is an alias to to_hash (backward compatibility)
212
+ # @return [Hash] Returns the object in the form of hash
213
+ def to_body
214
+ to_hash
215
+ end
216
+
217
+ # Returns the object in the form of hash
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_hash
220
+ hash = {}
221
+ self.class.attribute_map.each_pair do |attr, param|
222
+ value = self.send(attr)
223
+ next if value.nil?
224
+ hash[param] = _to_hash(value)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Outputs non-array value in the form of hash
230
+ # For object, use to_hash. Otherwise, just return the value
231
+ # @param [Object] value Any valid value
232
+ # @return [Hash] Returns the value in the form of hash
233
+ def _to_hash(value)
234
+ if value.is_a?(Array)
235
+ value.compact.map { |v| _to_hash(v) }
236
+ elsif value.is_a?(Hash)
237
+ {}.tap do |hash|
238
+ value.each { |k, v| hash[k] = _to_hash(v) }
239
+ end
240
+ elsif value.respond_to? :to_hash
241
+ value.to_hash
242
+ else
243
+ value
244
+ end
245
+ end
246
+ end
247
+ end