dadapush_client 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +79 -0
  4. data/README.md +105 -0
  5. data/Rakefile +10 -0
  6. data/dadapush_client.gemspec +45 -0
  7. data/docs/Action.md +21 -0
  8. data/docs/DaDaPushMessageApi.md +218 -0
  9. data/docs/MessageObject.md +27 -0
  10. data/docs/MessagePushRequest.md +23 -0
  11. data/docs/MessagePushResponse.md +17 -0
  12. data/docs/PageResponseOfMessageObject.md +21 -0
  13. data/docs/Result.md +21 -0
  14. data/docs/ResultOfMessageObject.md +21 -0
  15. data/docs/ResultOfMessagePushResponse.md +21 -0
  16. data/docs/ResultOfPageResponseOfMessageObject.md +21 -0
  17. data/git_push.sh +55 -0
  18. data/lib/dadapush_client.rb +49 -0
  19. data/lib/dadapush_client/api/da_da_push_message_api.rb +292 -0
  20. data/lib/dadapush_client/api_client.rb +385 -0
  21. data/lib/dadapush_client/api_error.rb +57 -0
  22. data/lib/dadapush_client/configuration.rb +241 -0
  23. data/lib/dadapush_client/models/action.rb +328 -0
  24. data/lib/dadapush_client/models/message_object.rb +269 -0
  25. data/lib/dadapush_client/models/message_push_request.rb +300 -0
  26. data/lib/dadapush_client/models/message_push_response.rb +201 -0
  27. data/lib/dadapush_client/models/page_response_of_message_object.rb +216 -0
  28. data/lib/dadapush_client/models/result.rb +224 -0
  29. data/lib/dadapush_client/models/result_of_message_object.rb +224 -0
  30. data/lib/dadapush_client/models/result_of_message_push_response.rb +224 -0
  31. data/lib/dadapush_client/models/result_of_page_response_of_message_object.rb +224 -0
  32. data/lib/dadapush_client/version.rb +15 -0
  33. data/spec/api/da_da_push_message_api_spec.rb +88 -0
  34. data/spec/api_client_spec.rb +226 -0
  35. data/spec/configuration_spec.rb +42 -0
  36. data/spec/models/action_spec.rb +57 -0
  37. data/spec/models/message_object_spec.rb +71 -0
  38. data/spec/models/message_push_request_spec.rb +59 -0
  39. data/spec/models/message_push_response_spec.rb +41 -0
  40. data/spec/models/page_response_of_message_object_spec.rb +53 -0
  41. data/spec/models/result_of_message_object_spec.rb +53 -0
  42. data/spec/models/result_of_message_push_response_spec.rb +53 -0
  43. data/spec/models/result_of_page_response_of_message_object_spec.rb +53 -0
  44. data/spec/models/result_spec.rb +53 -0
  45. data/spec/spec_helper.rb +111 -0
  46. metadata +282 -0
@@ -0,0 +1,328 @@
1
+ =begin
2
+ #DaDaPush Public API
3
+
4
+ #DaDaPush: Real-time Notifications App Send real-time notifications through our API without coding and maintaining your own app for iOS or Android devices.
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: contacts@dadapush.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DaDaPushClient
16
+ class Action
17
+ # action button name
18
+ attr_accessor :name
19
+
20
+ # fix value: link
21
+ attr_accessor :type
22
+
23
+ # action url
24
+ attr_accessor :url
25
+
26
+ class EnumAttributeValidator
27
+ attr_reader :datatype
28
+ attr_reader :allowable_values
29
+
30
+ def initialize(datatype, allowable_values)
31
+ @allowable_values = allowable_values.map do |value|
32
+ case datatype.to_s
33
+ when /Integer/i
34
+ value.to_i
35
+ when /Float/i
36
+ value.to_f
37
+ else
38
+ value
39
+ end
40
+ end
41
+ end
42
+
43
+ def valid?(value)
44
+ !value || allowable_values.include?(value)
45
+ end
46
+ end
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'name' => :'name',
52
+ :'type' => :'type',
53
+ :'url' => :'url'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'name' => :'String',
61
+ :'type' => :'String',
62
+ :'url' => :'String'
63
+ }
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DaDaPushClient::Action` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ attributes = attributes.each_with_object({}) { |(k, v), h|
75
+ if (!self.class.attribute_map.key?(k.to_sym))
76
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DaDaPushClient::Action`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
+ end
78
+ h[k.to_sym] = v
79
+ }
80
+
81
+ if attributes.key?(:'name')
82
+ self.name = attributes[:'name']
83
+ end
84
+
85
+ if attributes.key?(:'type')
86
+ self.type = attributes[:'type']
87
+ end
88
+
89
+ if attributes.key?(:'url')
90
+ self.url = attributes[:'url']
91
+ end
92
+ end
93
+
94
+ # Show invalid properties with the reasons. Usually used together with valid?
95
+ # @return Array for valid properties with the reasons
96
+ def list_invalid_properties
97
+ invalid_properties = Array.new
98
+ if @name.nil?
99
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
100
+ end
101
+
102
+ if @name.to_s.length > 20
103
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 20.')
104
+ end
105
+
106
+ if @name.to_s.length < 1
107
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
108
+ end
109
+
110
+ if @type.nil?
111
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
112
+ end
113
+
114
+ pattern = Regexp.new(/link/)
115
+ if @type !~ pattern
116
+ invalid_properties.push("invalid value for \"type\", must conform to the pattern #{pattern}.")
117
+ end
118
+
119
+ if @url.nil?
120
+ invalid_properties.push('invalid value for "url", url cannot be nil.')
121
+ end
122
+
123
+ if @url.to_s.length > 500
124
+ invalid_properties.push('invalid value for "url", the character length must be smaller than or equal to 500.')
125
+ end
126
+
127
+ if @url.to_s.length < 1
128
+ invalid_properties.push('invalid value for "url", the character length must be great than or equal to 1.')
129
+ end
130
+
131
+ invalid_properties
132
+ end
133
+
134
+ # Check to see if the all the properties in the model are valid
135
+ # @return true if the model is valid
136
+ def valid?
137
+ return false if @name.nil?
138
+ return false if @name.to_s.length > 20
139
+ return false if @name.to_s.length < 1
140
+ return false if @type.nil?
141
+ type_validator = EnumAttributeValidator.new('String', ["link"])
142
+ return false unless type_validator.valid?(@type)
143
+ return false if @type !~ Regexp.new(/link/)
144
+ return false if @url.nil?
145
+ return false if @url.to_s.length > 500
146
+ return false if @url.to_s.length < 1
147
+ true
148
+ end
149
+
150
+ # Custom attribute writer method with validation
151
+ # @param [Object] name Value to be assigned
152
+ def name=(name)
153
+ if name.nil?
154
+ fail ArgumentError, 'name cannot be nil'
155
+ end
156
+
157
+ if name.to_s.length > 20
158
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 20.'
159
+ end
160
+
161
+ if name.to_s.length < 1
162
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
163
+ end
164
+
165
+ @name = name
166
+ end
167
+
168
+ # Custom attribute writer method checking allowed values (enum).
169
+ # @param [Object] type Object to be assigned
170
+ def type=(type)
171
+ validator = EnumAttributeValidator.new('String', ["link"])
172
+ unless validator.valid?(type)
173
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
174
+ end
175
+ @type = type
176
+ end
177
+
178
+ # Custom attribute writer method with validation
179
+ # @param [Object] url Value to be assigned
180
+ def url=(url)
181
+ if url.nil?
182
+ fail ArgumentError, 'url cannot be nil'
183
+ end
184
+
185
+ if url.to_s.length > 500
186
+ fail ArgumentError, 'invalid value for "url", the character length must be smaller than or equal to 500.'
187
+ end
188
+
189
+ if url.to_s.length < 1
190
+ fail ArgumentError, 'invalid value for "url", the character length must be great than or equal to 1.'
191
+ end
192
+
193
+ @url = url
194
+ end
195
+
196
+ # Checks equality by comparing each attribute.
197
+ # @param [Object] Object to be compared
198
+ def ==(o)
199
+ return true if self.equal?(o)
200
+ self.class == o.class &&
201
+ name == o.name &&
202
+ type == o.type &&
203
+ url == o.url
204
+ end
205
+
206
+ # @see the `==` method
207
+ # @param [Object] Object to be compared
208
+ def eql?(o)
209
+ self == o
210
+ end
211
+
212
+ # Calculates hash code according to all attributes.
213
+ # @return [Integer] Hash code
214
+ def hash
215
+ [name, type, url].hash
216
+ end
217
+
218
+ # Builds the object from hash
219
+ # @param [Hash] attributes Model attributes in the form of hash
220
+ # @return [Object] Returns the model itself
221
+ def self.build_from_hash(attributes)
222
+ new.build_from_hash(attributes)
223
+ end
224
+
225
+ # Builds the object from hash
226
+ # @param [Hash] attributes Model attributes in the form of hash
227
+ # @return [Object] Returns the model itself
228
+ def build_from_hash(attributes)
229
+ return nil unless attributes.is_a?(Hash)
230
+ self.class.openapi_types.each_pair do |key, type|
231
+ if type =~ /\AArray<(.*)>/i
232
+ # check to ensure the input is an array given that the attribute
233
+ # is documented as an array but the input is not
234
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
235
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
236
+ end
237
+ elsif !attributes[self.class.attribute_map[key]].nil?
238
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
239
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
240
+ end
241
+
242
+ self
243
+ end
244
+
245
+ # Deserializes the data based on type
246
+ # @param string type Data type
247
+ # @param string value Value to be deserialized
248
+ # @return [Object] Deserialized data
249
+ def _deserialize(type, value)
250
+ case type.to_sym
251
+ when :DateTime
252
+ DateTime.parse(value)
253
+ when :Date
254
+ Date.parse(value)
255
+ when :String
256
+ value.to_s
257
+ when :Integer
258
+ value.to_i
259
+ when :Float
260
+ value.to_f
261
+ when :Boolean
262
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
263
+ true
264
+ else
265
+ false
266
+ end
267
+ when :Object
268
+ # generic object (usually a Hash), return directly
269
+ value
270
+ when /\AArray<(?<inner_type>.+)>\z/
271
+ inner_type = Regexp.last_match[:inner_type]
272
+ value.map { |v| _deserialize(inner_type, v) }
273
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
274
+ k_type = Regexp.last_match[:k_type]
275
+ v_type = Regexp.last_match[:v_type]
276
+ {}.tap do |hash|
277
+ value.each do |k, v|
278
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
279
+ end
280
+ end
281
+ else # model
282
+ DaDaPushClient.const_get(type).build_from_hash(value)
283
+ end
284
+ end
285
+
286
+ # Returns the string representation of the object
287
+ # @return [String] String presentation of the object
288
+ def to_s
289
+ to_hash.to_s
290
+ end
291
+
292
+ # to_body is an alias to to_hash (backward compatibility)
293
+ # @return [Hash] Returns the object in the form of hash
294
+ def to_body
295
+ to_hash
296
+ end
297
+
298
+ # Returns the object in the form of hash
299
+ # @return [Hash] Returns the object in the form of hash
300
+ def to_hash
301
+ hash = {}
302
+ self.class.attribute_map.each_pair do |attr, param|
303
+ value = self.send(attr)
304
+ next if value.nil?
305
+ hash[param] = _to_hash(value)
306
+ end
307
+ hash
308
+ end
309
+
310
+ # Outputs non-array value in the form of hash
311
+ # For object, use to_hash. Otherwise, just return the value
312
+ # @param [Object] value Any valid value
313
+ # @return [Hash] Returns the value in the form of hash
314
+ def _to_hash(value)
315
+ if value.is_a?(Array)
316
+ value.compact.map { |v| _to_hash(v) }
317
+ elsif value.is_a?(Hash)
318
+ {}.tap do |hash|
319
+ value.each { |k, v| hash[k] = _to_hash(v) }
320
+ end
321
+ elsif value.respond_to? :to_hash
322
+ value.to_hash
323
+ else
324
+ value
325
+ end
326
+ end
327
+ end
328
+ end
@@ -0,0 +1,269 @@
1
+ =begin
2
+ #DaDaPush Public API
3
+
4
+ #DaDaPush: Real-time Notifications App Send real-time notifications through our API without coding and maintaining your own app for iOS or Android devices.
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: contacts@dadapush.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DaDaPushClient
16
+ class MessageObject
17
+ # action size range is 0,3
18
+ attr_accessor :actions
19
+
20
+ attr_accessor :channel_name
21
+
22
+ attr_accessor :content
23
+
24
+ attr_accessor :created_at
25
+
26
+ attr_accessor :id
27
+
28
+ attr_accessor :title
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'actions' => :'actions',
34
+ :'channel_name' => :'channelName',
35
+ :'content' => :'content',
36
+ :'created_at' => :'createdAt',
37
+ :'id' => :'id',
38
+ :'title' => :'title'
39
+ }
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'actions' => :'Array<Action>',
46
+ :'channel_name' => :'String',
47
+ :'content' => :'String',
48
+ :'created_at' => :'String',
49
+ :'id' => :'Integer',
50
+ :'title' => :'String'
51
+ }
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DaDaPushClient::MessageObject` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DaDaPushClient::MessageObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'actions')
70
+ if (value = attributes[:'actions']).is_a?(Array)
71
+ self.actions = value
72
+ end
73
+ end
74
+
75
+ if attributes.key?(:'channel_name')
76
+ self.channel_name = attributes[:'channel_name']
77
+ end
78
+
79
+ if attributes.key?(:'content')
80
+ self.content = attributes[:'content']
81
+ end
82
+
83
+ if attributes.key?(:'created_at')
84
+ self.created_at = attributes[:'created_at']
85
+ end
86
+
87
+ if attributes.key?(:'id')
88
+ self.id = attributes[:'id']
89
+ end
90
+
91
+ if attributes.key?(:'title')
92
+ self.title = attributes[:'title']
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ invalid_properties = Array.new
100
+ if @channel_name.nil?
101
+ invalid_properties.push('invalid value for "channel_name", channel_name cannot be nil.')
102
+ end
103
+
104
+ if @content.nil?
105
+ invalid_properties.push('invalid value for "content", content cannot be nil.')
106
+ end
107
+
108
+ if @created_at.nil?
109
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
110
+ end
111
+
112
+ if @id.nil?
113
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
114
+ end
115
+
116
+ if @title.nil?
117
+ invalid_properties.push('invalid value for "title", title cannot be nil.')
118
+ end
119
+
120
+ invalid_properties
121
+ end
122
+
123
+ # Check to see if the all the properties in the model are valid
124
+ # @return true if the model is valid
125
+ def valid?
126
+ return false if @channel_name.nil?
127
+ return false if @content.nil?
128
+ return false if @created_at.nil?
129
+ return false if @id.nil?
130
+ return false if @title.nil?
131
+ true
132
+ end
133
+
134
+ # Checks equality by comparing each attribute.
135
+ # @param [Object] Object to be compared
136
+ def ==(o)
137
+ return true if self.equal?(o)
138
+ self.class == o.class &&
139
+ actions == o.actions &&
140
+ channel_name == o.channel_name &&
141
+ content == o.content &&
142
+ created_at == o.created_at &&
143
+ id == o.id &&
144
+ title == o.title
145
+ end
146
+
147
+ # @see the `==` method
148
+ # @param [Object] Object to be compared
149
+ def eql?(o)
150
+ self == o
151
+ end
152
+
153
+ # Calculates hash code according to all attributes.
154
+ # @return [Integer] Hash code
155
+ def hash
156
+ [actions, channel_name, content, created_at, id, title].hash
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def self.build_from_hash(attributes)
163
+ new.build_from_hash(attributes)
164
+ end
165
+
166
+ # Builds the object from hash
167
+ # @param [Hash] attributes Model attributes in the form of hash
168
+ # @return [Object] Returns the model itself
169
+ def build_from_hash(attributes)
170
+ return nil unless attributes.is_a?(Hash)
171
+ self.class.openapi_types.each_pair do |key, type|
172
+ if type =~ /\AArray<(.*)>/i
173
+ # check to ensure the input is an array given that the attribute
174
+ # is documented as an array but the input is not
175
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
176
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
177
+ end
178
+ elsif !attributes[self.class.attribute_map[key]].nil?
179
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
180
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
181
+ end
182
+
183
+ self
184
+ end
185
+
186
+ # Deserializes the data based on type
187
+ # @param string type Data type
188
+ # @param string value Value to be deserialized
189
+ # @return [Object] Deserialized data
190
+ def _deserialize(type, value)
191
+ case type.to_sym
192
+ when :DateTime
193
+ DateTime.parse(value)
194
+ when :Date
195
+ Date.parse(value)
196
+ when :String
197
+ value.to_s
198
+ when :Integer
199
+ value.to_i
200
+ when :Float
201
+ value.to_f
202
+ when :Boolean
203
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
204
+ true
205
+ else
206
+ false
207
+ end
208
+ when :Object
209
+ # generic object (usually a Hash), return directly
210
+ value
211
+ when /\AArray<(?<inner_type>.+)>\z/
212
+ inner_type = Regexp.last_match[:inner_type]
213
+ value.map { |v| _deserialize(inner_type, v) }
214
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
215
+ k_type = Regexp.last_match[:k_type]
216
+ v_type = Regexp.last_match[:v_type]
217
+ {}.tap do |hash|
218
+ value.each do |k, v|
219
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
220
+ end
221
+ end
222
+ else # model
223
+ DaDaPushClient.const_get(type).build_from_hash(value)
224
+ end
225
+ end
226
+
227
+ # Returns the string representation of the object
228
+ # @return [String] String presentation of the object
229
+ def to_s
230
+ to_hash.to_s
231
+ end
232
+
233
+ # to_body is an alias to to_hash (backward compatibility)
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_body
236
+ to_hash
237
+ end
238
+
239
+ # Returns the object in the form of hash
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_hash
242
+ hash = {}
243
+ self.class.attribute_map.each_pair do |attr, param|
244
+ value = self.send(attr)
245
+ next if value.nil?
246
+ hash[param] = _to_hash(value)
247
+ end
248
+ hash
249
+ end
250
+
251
+ # Outputs non-array value in the form of hash
252
+ # For object, use to_hash. Otherwise, just return the value
253
+ # @param [Object] value Any valid value
254
+ # @return [Hash] Returns the value in the form of hash
255
+ def _to_hash(value)
256
+ if value.is_a?(Array)
257
+ value.compact.map { |v| _to_hash(v) }
258
+ elsif value.is_a?(Hash)
259
+ {}.tap do |hash|
260
+ value.each { |k, v| hash[k] = _to_hash(v) }
261
+ end
262
+ elsif value.respond_to? :to_hash
263
+ value.to_hash
264
+ else
265
+ value
266
+ end
267
+ end
268
+ end
269
+ end