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,300 @@
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 MessagePushRequest
17
+ # action size range is 0,3
18
+ attr_accessor :actions
19
+
20
+ # message content
21
+ attr_accessor :content
22
+
23
+ # when value is false, will not send client push
24
+ attr_accessor :need_push
25
+
26
+ # message title
27
+ attr_accessor :title
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'actions' => :'actions',
33
+ :'content' => :'content',
34
+ :'need_push' => :'needPush',
35
+ :'title' => :'title'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'actions' => :'Array<Action>',
43
+ :'content' => :'String',
44
+ :'need_push' => :'Boolean',
45
+ :'title' => :'String'
46
+ }
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DaDaPushClient::MessagePushRequest` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DaDaPushClient::MessagePushRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'actions')
65
+ if (value = attributes[:'actions']).is_a?(Array)
66
+ self.actions = value
67
+ end
68
+ end
69
+
70
+ if attributes.key?(:'content')
71
+ self.content = attributes[:'content']
72
+ end
73
+
74
+ if attributes.key?(:'need_push')
75
+ self.need_push = attributes[:'need_push']
76
+ end
77
+
78
+ if attributes.key?(:'title')
79
+ self.title = attributes[:'title']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ if @content.nil?
88
+ invalid_properties.push('invalid value for "content", content cannot be nil.')
89
+ end
90
+
91
+ if @content.to_s.length > 500
92
+ invalid_properties.push('invalid value for "content", the character length must be smaller than or equal to 500.')
93
+ end
94
+
95
+ if @content.to_s.length < 1
96
+ invalid_properties.push('invalid value for "content", the character length must be great than or equal to 1.')
97
+ end
98
+
99
+ if @need_push.nil?
100
+ invalid_properties.push('invalid value for "need_push", need_push cannot be nil.')
101
+ end
102
+
103
+ if @title.nil?
104
+ invalid_properties.push('invalid value for "title", title cannot be nil.')
105
+ end
106
+
107
+ if @title.to_s.length > 50
108
+ invalid_properties.push('invalid value for "title", the character length must be smaller than or equal to 50.')
109
+ end
110
+
111
+ if @title.to_s.length < 1
112
+ invalid_properties.push('invalid value for "title", the character length must be great than or equal to 1.')
113
+ end
114
+
115
+ invalid_properties
116
+ end
117
+
118
+ # Check to see if the all the properties in the model are valid
119
+ # @return true if the model is valid
120
+ def valid?
121
+ return false if @content.nil?
122
+ return false if @content.to_s.length > 500
123
+ return false if @content.to_s.length < 1
124
+ return false if @need_push.nil?
125
+ return false if @title.nil?
126
+ return false if @title.to_s.length > 50
127
+ return false if @title.to_s.length < 1
128
+ true
129
+ end
130
+
131
+ # Custom attribute writer method with validation
132
+ # @param [Object] content Value to be assigned
133
+ def content=(content)
134
+ if content.nil?
135
+ fail ArgumentError, 'content cannot be nil'
136
+ end
137
+
138
+ if content.to_s.length > 500
139
+ fail ArgumentError, 'invalid value for "content", the character length must be smaller than or equal to 500.'
140
+ end
141
+
142
+ if content.to_s.length < 1
143
+ fail ArgumentError, 'invalid value for "content", the character length must be great than or equal to 1.'
144
+ end
145
+
146
+ @content = content
147
+ end
148
+
149
+ # Custom attribute writer method with validation
150
+ # @param [Object] title Value to be assigned
151
+ def title=(title)
152
+ if title.nil?
153
+ fail ArgumentError, 'title cannot be nil'
154
+ end
155
+
156
+ if title.to_s.length > 50
157
+ fail ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 50.'
158
+ end
159
+
160
+ if title.to_s.length < 1
161
+ fail ArgumentError, 'invalid value for "title", the character length must be great than or equal to 1.'
162
+ end
163
+
164
+ @title = title
165
+ end
166
+
167
+ # Checks equality by comparing each attribute.
168
+ # @param [Object] Object to be compared
169
+ def ==(o)
170
+ return true if self.equal?(o)
171
+ self.class == o.class &&
172
+ actions == o.actions &&
173
+ content == o.content &&
174
+ need_push == o.need_push &&
175
+ title == o.title
176
+ end
177
+
178
+ # @see the `==` method
179
+ # @param [Object] Object to be compared
180
+ def eql?(o)
181
+ self == o
182
+ end
183
+
184
+ # Calculates hash code according to all attributes.
185
+ # @return [Integer] Hash code
186
+ def hash
187
+ [actions, content, need_push, title].hash
188
+ end
189
+
190
+ # Builds the object from hash
191
+ # @param [Hash] attributes Model attributes in the form of hash
192
+ # @return [Object] Returns the model itself
193
+ def self.build_from_hash(attributes)
194
+ new.build_from_hash(attributes)
195
+ end
196
+
197
+ # Builds the object from hash
198
+ # @param [Hash] attributes Model attributes in the form of hash
199
+ # @return [Object] Returns the model itself
200
+ def build_from_hash(attributes)
201
+ return nil unless attributes.is_a?(Hash)
202
+ self.class.openapi_types.each_pair do |key, type|
203
+ if type =~ /\AArray<(.*)>/i
204
+ # check to ensure the input is an array given that the attribute
205
+ # is documented as an array but the input is not
206
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
207
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
208
+ end
209
+ elsif !attributes[self.class.attribute_map[key]].nil?
210
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
211
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
212
+ end
213
+
214
+ self
215
+ end
216
+
217
+ # Deserializes the data based on type
218
+ # @param string type Data type
219
+ # @param string value Value to be deserialized
220
+ # @return [Object] Deserialized data
221
+ def _deserialize(type, value)
222
+ case type.to_sym
223
+ when :DateTime
224
+ DateTime.parse(value)
225
+ when :Date
226
+ Date.parse(value)
227
+ when :String
228
+ value.to_s
229
+ when :Integer
230
+ value.to_i
231
+ when :Float
232
+ value.to_f
233
+ when :Boolean
234
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
235
+ true
236
+ else
237
+ false
238
+ end
239
+ when :Object
240
+ # generic object (usually a Hash), return directly
241
+ value
242
+ when /\AArray<(?<inner_type>.+)>\z/
243
+ inner_type = Regexp.last_match[:inner_type]
244
+ value.map { |v| _deserialize(inner_type, v) }
245
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
246
+ k_type = Regexp.last_match[:k_type]
247
+ v_type = Regexp.last_match[:v_type]
248
+ {}.tap do |hash|
249
+ value.each do |k, v|
250
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
251
+ end
252
+ end
253
+ else # model
254
+ DaDaPushClient.const_get(type).build_from_hash(value)
255
+ end
256
+ end
257
+
258
+ # Returns the string representation of the object
259
+ # @return [String] String presentation of the object
260
+ def to_s
261
+ to_hash.to_s
262
+ end
263
+
264
+ # to_body is an alias to to_hash (backward compatibility)
265
+ # @return [Hash] Returns the object in the form of hash
266
+ def to_body
267
+ to_hash
268
+ end
269
+
270
+ # Returns the object in the form of hash
271
+ # @return [Hash] Returns the object in the form of hash
272
+ def to_hash
273
+ hash = {}
274
+ self.class.attribute_map.each_pair do |attr, param|
275
+ value = self.send(attr)
276
+ next if value.nil?
277
+ hash[param] = _to_hash(value)
278
+ end
279
+ hash
280
+ end
281
+
282
+ # Outputs non-array value in the form of hash
283
+ # For object, use to_hash. Otherwise, just return the value
284
+ # @param [Object] value Any valid value
285
+ # @return [Hash] Returns the value in the form of hash
286
+ def _to_hash(value)
287
+ if value.is_a?(Array)
288
+ value.compact.map { |v| _to_hash(v) }
289
+ elsif value.is_a?(Hash)
290
+ {}.tap do |hash|
291
+ value.each { |k, v| hash[k] = _to_hash(v) }
292
+ end
293
+ elsif value.respond_to? :to_hash
294
+ value.to_hash
295
+ else
296
+ value
297
+ end
298
+ end
299
+ end
300
+ end
@@ -0,0 +1,201 @@
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 MessagePushResponse
17
+ attr_accessor :message_id
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'message_id' => :'messageId'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.openapi_types
28
+ {
29
+ :'message_id' => :'Integer'
30
+ }
31
+ end
32
+
33
+ # Initializes the object
34
+ # @param [Hash] attributes Model attributes in the form of hash
35
+ def initialize(attributes = {})
36
+ if (!attributes.is_a?(Hash))
37
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DaDaPushClient::MessagePushResponse` initialize method"
38
+ end
39
+
40
+ # check to see if the attribute exists and convert string to symbol for hash key
41
+ attributes = attributes.each_with_object({}) { |(k, v), h|
42
+ if (!self.class.attribute_map.key?(k.to_sym))
43
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DaDaPushClient::MessagePushResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
44
+ end
45
+ h[k.to_sym] = v
46
+ }
47
+
48
+ if attributes.key?(:'message_id')
49
+ self.message_id = attributes[:'message_id']
50
+ end
51
+ end
52
+
53
+ # Show invalid properties with the reasons. Usually used together with valid?
54
+ # @return Array for valid properties with the reasons
55
+ def list_invalid_properties
56
+ invalid_properties = Array.new
57
+ if @message_id.nil?
58
+ invalid_properties.push('invalid value for "message_id", message_id cannot be nil.')
59
+ end
60
+
61
+ invalid_properties
62
+ end
63
+
64
+ # Check to see if the all the properties in the model are valid
65
+ # @return true if the model is valid
66
+ def valid?
67
+ return false if @message_id.nil?
68
+ true
69
+ end
70
+
71
+ # Checks equality by comparing each attribute.
72
+ # @param [Object] Object to be compared
73
+ def ==(o)
74
+ return true if self.equal?(o)
75
+ self.class == o.class &&
76
+ message_id == o.message_id
77
+ end
78
+
79
+ # @see the `==` method
80
+ # @param [Object] Object to be compared
81
+ def eql?(o)
82
+ self == o
83
+ end
84
+
85
+ # Calculates hash code according to all attributes.
86
+ # @return [Integer] Hash code
87
+ def hash
88
+ [message_id].hash
89
+ end
90
+
91
+ # Builds the object from hash
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ # @return [Object] Returns the model itself
94
+ def self.build_from_hash(attributes)
95
+ new.build_from_hash(attributes)
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def build_from_hash(attributes)
102
+ return nil unless attributes.is_a?(Hash)
103
+ self.class.openapi_types.each_pair do |key, type|
104
+ if type =~ /\AArray<(.*)>/i
105
+ # check to ensure the input is an array given that the attribute
106
+ # is documented as an array but the input is not
107
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
108
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
109
+ end
110
+ elsif !attributes[self.class.attribute_map[key]].nil?
111
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
112
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
113
+ end
114
+
115
+ self
116
+ end
117
+
118
+ # Deserializes the data based on type
119
+ # @param string type Data type
120
+ # @param string value Value to be deserialized
121
+ # @return [Object] Deserialized data
122
+ def _deserialize(type, value)
123
+ case type.to_sym
124
+ when :DateTime
125
+ DateTime.parse(value)
126
+ when :Date
127
+ Date.parse(value)
128
+ when :String
129
+ value.to_s
130
+ when :Integer
131
+ value.to_i
132
+ when :Float
133
+ value.to_f
134
+ when :Boolean
135
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
136
+ true
137
+ else
138
+ false
139
+ end
140
+ when :Object
141
+ # generic object (usually a Hash), return directly
142
+ value
143
+ when /\AArray<(?<inner_type>.+)>\z/
144
+ inner_type = Regexp.last_match[:inner_type]
145
+ value.map { |v| _deserialize(inner_type, v) }
146
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
147
+ k_type = Regexp.last_match[:k_type]
148
+ v_type = Regexp.last_match[:v_type]
149
+ {}.tap do |hash|
150
+ value.each do |k, v|
151
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
152
+ end
153
+ end
154
+ else # model
155
+ DaDaPushClient.const_get(type).build_from_hash(value)
156
+ end
157
+ end
158
+
159
+ # Returns the string representation of the object
160
+ # @return [String] String presentation of the object
161
+ def to_s
162
+ to_hash.to_s
163
+ end
164
+
165
+ # to_body is an alias to to_hash (backward compatibility)
166
+ # @return [Hash] Returns the object in the form of hash
167
+ def to_body
168
+ to_hash
169
+ end
170
+
171
+ # Returns the object in the form of hash
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_hash
174
+ hash = {}
175
+ self.class.attribute_map.each_pair do |attr, param|
176
+ value = self.send(attr)
177
+ next if value.nil?
178
+ hash[param] = _to_hash(value)
179
+ end
180
+ hash
181
+ end
182
+
183
+ # Outputs non-array value in the form of hash
184
+ # For object, use to_hash. Otherwise, just return the value
185
+ # @param [Object] value Any valid value
186
+ # @return [Hash] Returns the value in the form of hash
187
+ def _to_hash(value)
188
+ if value.is_a?(Array)
189
+ value.compact.map { |v| _to_hash(v) }
190
+ elsif value.is_a?(Hash)
191
+ {}.tap do |hash|
192
+ value.each { |k, v| hash[k] = _to_hash(v) }
193
+ end
194
+ elsif value.respond_to? :to_hash
195
+ value.to_hash
196
+ else
197
+ value
198
+ end
199
+ end
200
+ end
201
+ end