messente_api 1.0.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 +79 -0
- data/README.md +118 -0
- data/Rakefile +10 -0
- data/docs/BlacklistApi.md +209 -0
- data/docs/Channel.md +16 -0
- data/docs/ContactEnvelope.md +17 -0
- data/docs/ContactFields.md +35 -0
- data/docs/ContactListEnvelope.md +17 -0
- data/docs/ContactUpdateFields.md +33 -0
- data/docs/ContactsApi.md +430 -0
- data/docs/DeliveryReportApi.md +60 -0
- data/docs/DeliveryReportResponse.md +21 -0
- data/docs/DeliveryResult.md +27 -0
- data/docs/ErrorCodeOmnichannel.md +16 -0
- data/docs/ErrorCodeOmnichannelMachine.md +16 -0
- data/docs/ErrorCodePhonebook.md +16 -0
- data/docs/ErrorItemOmnichannel.md +23 -0
- data/docs/ErrorItemPhonebook.md +21 -0
- data/docs/ErrorOmnichannel.md +17 -0
- data/docs/ErrorPhonebook.md +17 -0
- data/docs/ErrorTitleOmnichannel.md +16 -0
- data/docs/ErrorTitlePhonebook.md +16 -0
- data/docs/FetchBlacklistSuccess.md +17 -0
- data/docs/GroupEnvelope.md +17 -0
- data/docs/GroupListEnvelope.md +17 -0
- data/docs/GroupName.md +17 -0
- data/docs/GroupResponseFields.md +23 -0
- data/docs/GroupsApi.md +265 -0
- data/docs/MessageResult.md +21 -0
- data/docs/NumberToBlacklist.md +17 -0
- data/docs/OmniMessageCreateSuccessResponse.md +21 -0
- data/docs/Omnimessage.md +25 -0
- data/docs/OmnimessageApi.md +111 -0
- data/docs/SMS.md +27 -0
- data/docs/Status.md +16 -0
- data/docs/TextStore.md +16 -0
- data/docs/Viber.md +29 -0
- data/docs/WhatsApp.md +29 -0
- data/docs/WhatsAppAudio.md +17 -0
- data/docs/WhatsAppDocument.md +19 -0
- data/docs/WhatsAppImage.md +19 -0
- data/docs/WhatsAppText.md +19 -0
- data/git_push.sh +55 -0
- data/lib/messente_api.rb +78 -0
- data/lib/messente_api/api/blacklist_api.rb +258 -0
- data/lib/messente_api/api/contacts_api.rb +521 -0
- data/lib/messente_api/api/delivery_report_api.rb +82 -0
- data/lib/messente_api/api/groups_api.rb +326 -0
- data/lib/messente_api/api/omnimessage_api.rb +144 -0
- data/lib/messente_api/api_client.rb +387 -0
- data/lib/messente_api/api_error.rb +57 -0
- data/lib/messente_api/configuration.rb +251 -0
- data/lib/messente_api/models/channel.rb +37 -0
- data/lib/messente_api/models/contact_envelope.rb +196 -0
- data/lib/messente_api/models/contact_fields.rb +283 -0
- data/lib/messente_api/models/contact_list_envelope.rb +198 -0
- data/lib/messente_api/models/contact_update_fields.rb +268 -0
- data/lib/messente_api/models/delivery_report_response.rb +234 -0
- data/lib/messente_api/models/delivery_result.rb +244 -0
- data/lib/messente_api/models/error_code_omnichannel.rb +41 -0
- data/lib/messente_api/models/error_code_omnichannel_machine.rb +46 -0
- data/lib/messente_api/models/error_code_phonebook.rb +40 -0
- data/lib/messente_api/models/error_item_omnichannel.rb +245 -0
- data/lib/messente_api/models/error_item_phonebook.rb +230 -0
- data/lib/messente_api/models/error_omnichannel.rb +203 -0
- data/lib/messente_api/models/error_phonebook.rb +203 -0
- data/lib/messente_api/models/error_title_omnichannel.rb +41 -0
- data/lib/messente_api/models/error_title_phonebook.rb +40 -0
- data/lib/messente_api/models/fetch_blacklist_success.rb +198 -0
- data/lib/messente_api/models/group_envelope.rb +196 -0
- data/lib/messente_api/models/group_list_envelope.rb +198 -0
- data/lib/messente_api/models/group_name.rb +220 -0
- data/lib/messente_api/models/group_response_fields.rb +240 -0
- data/lib/messente_api/models/message_result.rb +231 -0
- data/lib/messente_api/models/number_to_blacklist.rb +202 -0
- data/lib/messente_api/models/omni_message_create_success_response.rb +234 -0
- data/lib/messente_api/models/omnimessage.rb +247 -0
- data/lib/messente_api/models/sms.rb +300 -0
- data/lib/messente_api/models/status.rb +45 -0
- data/lib/messente_api/models/text_store.rb +37 -0
- data/lib/messente_api/models/viber.rb +293 -0
- data/lib/messente_api/models/whats_app.rb +289 -0
- data/lib/messente_api/models/whats_app_audio.rb +202 -0
- data/lib/messente_api/models/whats_app_document.rb +212 -0
- data/lib/messente_api/models/whats_app_image.rb +212 -0
- data/lib/messente_api/models/whats_app_text.rb +214 -0
- data/lib/messente_api/version.rb +15 -0
- data/messente_api.gemspec +45 -0
- data/spec/api/blacklist_api_spec.rb +78 -0
- data/spec/api/contacts_api_spec.rb +126 -0
- data/spec/api/delivery_report_api_spec.rb +46 -0
- data/spec/api/groups_api_spec.rb +90 -0
- data/spec/api/omnimessage_api_spec.rb +57 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/channel_spec.rb +35 -0
- data/spec/models/contact_envelope_spec.rb +41 -0
- data/spec/models/contact_fields_spec.rb +95 -0
- data/spec/models/contact_list_envelope_spec.rb +41 -0
- data/spec/models/contact_update_fields_spec.rb +89 -0
- data/spec/models/delivery_report_response_spec.rb +53 -0
- data/spec/models/delivery_result_spec.rb +71 -0
- data/spec/models/error_code_omnichannel_machine_spec.rb +35 -0
- data/spec/models/error_code_omnichannel_spec.rb +35 -0
- data/spec/models/error_code_phonebook_spec.rb +35 -0
- data/spec/models/error_item_omnichannel_spec.rb +59 -0
- data/spec/models/error_item_phonebook_spec.rb +53 -0
- data/spec/models/error_omnichannel_spec.rb +41 -0
- data/spec/models/error_phonebook_spec.rb +41 -0
- data/spec/models/error_title_omnichannel_spec.rb +35 -0
- data/spec/models/error_title_phonebook_spec.rb +35 -0
- data/spec/models/fetch_blacklist_success_spec.rb +41 -0
- data/spec/models/group_envelope_spec.rb +41 -0
- data/spec/models/group_list_envelope_spec.rb +41 -0
- data/spec/models/group_name_spec.rb +41 -0
- data/spec/models/group_response_fields_spec.rb +59 -0
- data/spec/models/message_result_spec.rb +53 -0
- data/spec/models/number_to_blacklist_spec.rb +41 -0
- data/spec/models/omni_message_create_success_response_spec.rb +53 -0
- data/spec/models/omnimessage_spec.rb +65 -0
- data/spec/models/sms_spec.rb +79 -0
- data/spec/models/status_spec.rb +35 -0
- data/spec/models/text_store_spec.rb +35 -0
- data/spec/models/viber_spec.rb +81 -0
- data/spec/models/whats_app_audio_spec.rb +41 -0
- data/spec/models/whats_app_document_spec.rb +47 -0
- data/spec/models/whats_app_image_spec.rb +47 -0
- data/spec/models/whats_app_spec.rb +81 -0
- data/spec/models/whats_app_text_spec.rb +47 -0
- data/spec/spec_helper.rb +111 -0
- metadata +401 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
=begin
|
2
|
+
#Messente API
|
3
|
+
|
4
|
+
#[Messente](https://messente.com) is a global provider of messaging and user verification services. Use Messente API library to send and receive SMS, Viber and WhatsApp messages, blacklist phone numbers to make sure you're not sending any unwanted messages, manage contacts and groups. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.1
|
7
|
+
Contact: messente@messente.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module MessenteApi
|
16
|
+
class Status
|
17
|
+
ACK = "ACK".freeze
|
18
|
+
DELIVRD = "DELIVRD".freeze
|
19
|
+
UNDELIV = "UNDELIV".freeze
|
20
|
+
FAILED = "FAILED".freeze
|
21
|
+
UNKNOWN = "UNKNOWN".freeze
|
22
|
+
ACCEPTD = "ACCEPTD".freeze
|
23
|
+
REJECTD = "REJECTD".freeze
|
24
|
+
DELETED = "DELETED".freeze
|
25
|
+
EXPIRED = "EXPIRED".freeze
|
26
|
+
NACK = "NACK".freeze
|
27
|
+
SEEN = "SEEN".freeze
|
28
|
+
|
29
|
+
# Builds the enum from string
|
30
|
+
# @param [String] The enum value in the form of the string
|
31
|
+
# @return [String] The enum value
|
32
|
+
def self.build_from_hash(value)
|
33
|
+
new.build_from_hash(value)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Builds the enum from string
|
37
|
+
# @param [String] The enum value in the form of the string
|
38
|
+
# @return [String] The enum value
|
39
|
+
def build_from_hash(value)
|
40
|
+
constantValues = Status.constants.select { |c| Status::const_get(c) == value }
|
41
|
+
raise "Invalid ENUM value #{value} for class #Status" if constantValues.empty?
|
42
|
+
value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
=begin
|
2
|
+
#Messente API
|
3
|
+
|
4
|
+
#[Messente](https://messente.com) is a global provider of messaging and user verification services. Use Messente API library to send and receive SMS, Viber and WhatsApp messages, blacklist phone numbers to make sure you're not sending any unwanted messages, manage contacts and groups. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.1
|
7
|
+
Contact: messente@messente.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module MessenteApi
|
16
|
+
class TextStore
|
17
|
+
NOSTORE = "nostore".freeze
|
18
|
+
PLAINTEXT = "plaintext".freeze
|
19
|
+
SHA256 = "sha256".freeze
|
20
|
+
|
21
|
+
# Builds the enum from string
|
22
|
+
# @param [String] The enum value in the form of the string
|
23
|
+
# @return [String] The enum value
|
24
|
+
def self.build_from_hash(value)
|
25
|
+
new.build_from_hash(value)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Builds the enum from string
|
29
|
+
# @param [String] The enum value in the form of the string
|
30
|
+
# @return [String] The enum value
|
31
|
+
def build_from_hash(value)
|
32
|
+
constantValues = TextStore.constants.select { |c| TextStore::const_get(c) == value }
|
33
|
+
raise "Invalid ENUM value #{value} for class #TextStore" if constantValues.empty?
|
34
|
+
value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,293 @@
|
|
1
|
+
=begin
|
2
|
+
#Messente API
|
3
|
+
|
4
|
+
#[Messente](https://messente.com) is a global provider of messaging and user verification services. Use Messente API library to send and receive SMS, Viber and WhatsApp messages, blacklist phone numbers to make sure you're not sending any unwanted messages, manage contacts and groups. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.1
|
7
|
+
Contact: messente@messente.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module MessenteApi
|
16
|
+
# Viber message content
|
17
|
+
class Viber
|
18
|
+
# Phone number or alphanumeric sender name
|
19
|
+
attr_accessor :sender
|
20
|
+
|
21
|
+
# After how many minutes this channel is considered as failed and the next channel is attempted
|
22
|
+
attr_accessor :validity
|
23
|
+
|
24
|
+
# Plaintext content for Viber
|
25
|
+
attr_accessor :text
|
26
|
+
|
27
|
+
# URL for the embedded image. Valid combinations: 1) image_url, 2) text, image_url, button_url, button_text
|
28
|
+
attr_accessor :image_url
|
29
|
+
|
30
|
+
# URL of the button, must be specified along with ''text'', ''button_text'' and ''image_url'' (optional)
|
31
|
+
attr_accessor :button_url
|
32
|
+
|
33
|
+
# Must be specified along with ''text'', ''button_url'', ''button_text'', ''image_url'' (optional)
|
34
|
+
attr_accessor :button_text
|
35
|
+
|
36
|
+
attr_accessor :channel
|
37
|
+
|
38
|
+
class EnumAttributeValidator
|
39
|
+
attr_reader :datatype
|
40
|
+
attr_reader :allowable_values
|
41
|
+
|
42
|
+
def initialize(datatype, allowable_values)
|
43
|
+
@allowable_values = allowable_values.map do |value|
|
44
|
+
case datatype.to_s
|
45
|
+
when /Integer/i
|
46
|
+
value.to_i
|
47
|
+
when /Float/i
|
48
|
+
value.to_f
|
49
|
+
else
|
50
|
+
value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def valid?(value)
|
56
|
+
!value || allowable_values.include?(value)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
61
|
+
def self.attribute_map
|
62
|
+
{
|
63
|
+
:'sender' => :'sender',
|
64
|
+
:'validity' => :'validity',
|
65
|
+
:'text' => :'text',
|
66
|
+
:'image_url' => :'image_url',
|
67
|
+
:'button_url' => :'button_url',
|
68
|
+
:'button_text' => :'button_text',
|
69
|
+
:'channel' => :'channel'
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
# Attribute type mapping.
|
74
|
+
def self.openapi_types
|
75
|
+
{
|
76
|
+
:'sender' => :'String',
|
77
|
+
:'validity' => :'Integer',
|
78
|
+
:'text' => :'String',
|
79
|
+
:'image_url' => :'String',
|
80
|
+
:'button_url' => :'String',
|
81
|
+
:'button_text' => :'String',
|
82
|
+
:'channel' => :'String'
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
# Initializes the object
|
87
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
88
|
+
def initialize(attributes = {})
|
89
|
+
if (!attributes.is_a?(Hash))
|
90
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `MessenteApi::Viber` initialize method"
|
91
|
+
end
|
92
|
+
|
93
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
94
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
95
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
96
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MessenteApi::Viber`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
97
|
+
end
|
98
|
+
h[k.to_sym] = v
|
99
|
+
}
|
100
|
+
|
101
|
+
if attributes.key?(:'sender')
|
102
|
+
self.sender = attributes[:'sender']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'validity')
|
106
|
+
self.validity = attributes[:'validity']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:'text')
|
110
|
+
self.text = attributes[:'text']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:'image_url')
|
114
|
+
self.image_url = attributes[:'image_url']
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.key?(:'button_url')
|
118
|
+
self.button_url = attributes[:'button_url']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.key?(:'button_text')
|
122
|
+
self.button_text = attributes[:'button_text']
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.key?(:'channel')
|
126
|
+
self.channel = attributes[:'channel']
|
127
|
+
else
|
128
|
+
self.channel = 'viber'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
133
|
+
# @return Array for valid properties with the reasons
|
134
|
+
def list_invalid_properties
|
135
|
+
invalid_properties = Array.new
|
136
|
+
invalid_properties
|
137
|
+
end
|
138
|
+
|
139
|
+
# Check to see if the all the properties in the model are valid
|
140
|
+
# @return true if the model is valid
|
141
|
+
def valid?
|
142
|
+
channel_validator = EnumAttributeValidator.new('String', ["viber"])
|
143
|
+
return false unless channel_validator.valid?(@channel)
|
144
|
+
true
|
145
|
+
end
|
146
|
+
|
147
|
+
# Custom attribute writer method checking allowed values (enum).
|
148
|
+
# @param [Object] channel Object to be assigned
|
149
|
+
def channel=(channel)
|
150
|
+
validator = EnumAttributeValidator.new('String', ["viber"])
|
151
|
+
unless validator.valid?(channel)
|
152
|
+
fail ArgumentError, "invalid value for \"channel\", must be one of #{validator.allowable_values}."
|
153
|
+
end
|
154
|
+
@channel = channel
|
155
|
+
end
|
156
|
+
|
157
|
+
# Checks equality by comparing each attribute.
|
158
|
+
# @param [Object] Object to be compared
|
159
|
+
def ==(o)
|
160
|
+
return true if self.equal?(o)
|
161
|
+
self.class == o.class &&
|
162
|
+
sender == o.sender &&
|
163
|
+
validity == o.validity &&
|
164
|
+
text == o.text &&
|
165
|
+
image_url == o.image_url &&
|
166
|
+
button_url == o.button_url &&
|
167
|
+
button_text == o.button_text &&
|
168
|
+
channel == o.channel
|
169
|
+
end
|
170
|
+
|
171
|
+
# @see the `==` method
|
172
|
+
# @param [Object] Object to be compared
|
173
|
+
def eql?(o)
|
174
|
+
self == o
|
175
|
+
end
|
176
|
+
|
177
|
+
# Calculates hash code according to all attributes.
|
178
|
+
# @return [Integer] Hash code
|
179
|
+
def hash
|
180
|
+
[sender, validity, text, image_url, button_url, button_text, channel].hash
|
181
|
+
end
|
182
|
+
|
183
|
+
# Builds the object from hash
|
184
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
185
|
+
# @return [Object] Returns the model itself
|
186
|
+
def self.build_from_hash(attributes)
|
187
|
+
new.build_from_hash(attributes)
|
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 build_from_hash(attributes)
|
194
|
+
return nil unless attributes.is_a?(Hash)
|
195
|
+
self.class.openapi_types.each_pair do |key, type|
|
196
|
+
if type =~ /\AArray<(.*)>/i
|
197
|
+
# check to ensure the input is an array given that the attribute
|
198
|
+
# is documented as an array but the input is not
|
199
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
200
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
201
|
+
end
|
202
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
203
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
204
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
205
|
+
end
|
206
|
+
|
207
|
+
self
|
208
|
+
end
|
209
|
+
|
210
|
+
# Deserializes the data based on type
|
211
|
+
# @param string type Data type
|
212
|
+
# @param string value Value to be deserialized
|
213
|
+
# @return [Object] Deserialized data
|
214
|
+
def _deserialize(type, value)
|
215
|
+
case type.to_sym
|
216
|
+
when :DateTime
|
217
|
+
DateTime.parse(value)
|
218
|
+
when :Date
|
219
|
+
Date.parse(value)
|
220
|
+
when :String
|
221
|
+
value.to_s
|
222
|
+
when :Integer
|
223
|
+
value.to_i
|
224
|
+
when :Float
|
225
|
+
value.to_f
|
226
|
+
when :Boolean
|
227
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
228
|
+
true
|
229
|
+
else
|
230
|
+
false
|
231
|
+
end
|
232
|
+
when :Object
|
233
|
+
# generic object (usually a Hash), return directly
|
234
|
+
value
|
235
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
236
|
+
inner_type = Regexp.last_match[:inner_type]
|
237
|
+
value.map { |v| _deserialize(inner_type, v) }
|
238
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
239
|
+
k_type = Regexp.last_match[:k_type]
|
240
|
+
v_type = Regexp.last_match[:v_type]
|
241
|
+
{}.tap do |hash|
|
242
|
+
value.each do |k, v|
|
243
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
else # model
|
247
|
+
MessenteApi.const_get(type).build_from_hash(value)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
# Returns the string representation of the object
|
252
|
+
# @return [String] String presentation of the object
|
253
|
+
def to_s
|
254
|
+
to_hash.to_s
|
255
|
+
end
|
256
|
+
|
257
|
+
# to_body is an alias to to_hash (backward compatibility)
|
258
|
+
# @return [Hash] Returns the object in the form of hash
|
259
|
+
def to_body
|
260
|
+
to_hash
|
261
|
+
end
|
262
|
+
|
263
|
+
# Returns the object in the form of hash
|
264
|
+
# @return [Hash] Returns the object in the form of hash
|
265
|
+
def to_hash
|
266
|
+
hash = {}
|
267
|
+
self.class.attribute_map.each_pair do |attr, param|
|
268
|
+
value = self.send(attr)
|
269
|
+
next if value.nil?
|
270
|
+
hash[param] = _to_hash(value)
|
271
|
+
end
|
272
|
+
hash
|
273
|
+
end
|
274
|
+
|
275
|
+
# Outputs non-array value in the form of hash
|
276
|
+
# For object, use to_hash. Otherwise, just return the value
|
277
|
+
# @param [Object] value Any valid value
|
278
|
+
# @return [Hash] Returns the value in the form of hash
|
279
|
+
def _to_hash(value)
|
280
|
+
if value.is_a?(Array)
|
281
|
+
value.compact.map { |v| _to_hash(v) }
|
282
|
+
elsif value.is_a?(Hash)
|
283
|
+
{}.tap do |hash|
|
284
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
285
|
+
end
|
286
|
+
elsif value.respond_to? :to_hash
|
287
|
+
value.to_hash
|
288
|
+
else
|
289
|
+
value
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
@@ -0,0 +1,289 @@
|
|
1
|
+
=begin
|
2
|
+
#Messente API
|
3
|
+
|
4
|
+
#[Messente](https://messente.com) is a global provider of messaging and user verification services. Use Messente API library to send and receive SMS, Viber and WhatsApp messages, blacklist phone numbers to make sure you're not sending any unwanted messages, manage contacts and groups. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.1
|
7
|
+
Contact: messente@messente.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module MessenteApi
|
16
|
+
# WhatsApp message content. Only one of \"text\", \"image\", \"document\" or \"audio\" can be provided.
|
17
|
+
class WhatsApp
|
18
|
+
# Phone number or alphanumeric sender name
|
19
|
+
attr_accessor :sender
|
20
|
+
|
21
|
+
# After how many minutes this channel is considered as failed and the next channel is attempted
|
22
|
+
attr_accessor :validity
|
23
|
+
|
24
|
+
attr_accessor :text
|
25
|
+
|
26
|
+
attr_accessor :image
|
27
|
+
|
28
|
+
attr_accessor :document
|
29
|
+
|
30
|
+
attr_accessor :audio
|
31
|
+
|
32
|
+
attr_accessor :channel
|
33
|
+
|
34
|
+
class EnumAttributeValidator
|
35
|
+
attr_reader :datatype
|
36
|
+
attr_reader :allowable_values
|
37
|
+
|
38
|
+
def initialize(datatype, allowable_values)
|
39
|
+
@allowable_values = allowable_values.map do |value|
|
40
|
+
case datatype.to_s
|
41
|
+
when /Integer/i
|
42
|
+
value.to_i
|
43
|
+
when /Float/i
|
44
|
+
value.to_f
|
45
|
+
else
|
46
|
+
value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def valid?(value)
|
52
|
+
!value || allowable_values.include?(value)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
57
|
+
def self.attribute_map
|
58
|
+
{
|
59
|
+
:'sender' => :'sender',
|
60
|
+
:'validity' => :'validity',
|
61
|
+
:'text' => :'text',
|
62
|
+
:'image' => :'image',
|
63
|
+
:'document' => :'document',
|
64
|
+
:'audio' => :'audio',
|
65
|
+
:'channel' => :'channel'
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
# Attribute type mapping.
|
70
|
+
def self.openapi_types
|
71
|
+
{
|
72
|
+
:'sender' => :'String',
|
73
|
+
:'validity' => :'Integer',
|
74
|
+
:'text' => :'WhatsAppText',
|
75
|
+
:'image' => :'WhatsAppImage',
|
76
|
+
:'document' => :'WhatsAppDocument',
|
77
|
+
:'audio' => :'WhatsAppAudio',
|
78
|
+
:'channel' => :'String'
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
# Initializes the object
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
84
|
+
def initialize(attributes = {})
|
85
|
+
if (!attributes.is_a?(Hash))
|
86
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `MessenteApi::WhatsApp` initialize method"
|
87
|
+
end
|
88
|
+
|
89
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
90
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
91
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
92
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MessenteApi::WhatsApp`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
93
|
+
end
|
94
|
+
h[k.to_sym] = v
|
95
|
+
}
|
96
|
+
|
97
|
+
if attributes.key?(:'sender')
|
98
|
+
self.sender = attributes[:'sender']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:'validity')
|
102
|
+
self.validity = attributes[:'validity']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'text')
|
106
|
+
self.text = attributes[:'text']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:'image')
|
110
|
+
self.image = attributes[:'image']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:'document')
|
114
|
+
self.document = attributes[:'document']
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.key?(:'audio')
|
118
|
+
self.audio = attributes[:'audio']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.key?(:'channel')
|
122
|
+
self.channel = attributes[:'channel']
|
123
|
+
else
|
124
|
+
self.channel = 'whatsapp'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
129
|
+
# @return Array for valid properties with the reasons
|
130
|
+
def list_invalid_properties
|
131
|
+
invalid_properties = Array.new
|
132
|
+
invalid_properties
|
133
|
+
end
|
134
|
+
|
135
|
+
# Check to see if the all the properties in the model are valid
|
136
|
+
# @return true if the model is valid
|
137
|
+
def valid?
|
138
|
+
channel_validator = EnumAttributeValidator.new('String', ["whatsapp"])
|
139
|
+
return false unless channel_validator.valid?(@channel)
|
140
|
+
true
|
141
|
+
end
|
142
|
+
|
143
|
+
# Custom attribute writer method checking allowed values (enum).
|
144
|
+
# @param [Object] channel Object to be assigned
|
145
|
+
def channel=(channel)
|
146
|
+
validator = EnumAttributeValidator.new('String', ["whatsapp"])
|
147
|
+
unless validator.valid?(channel)
|
148
|
+
fail ArgumentError, "invalid value for \"channel\", must be one of #{validator.allowable_values}."
|
149
|
+
end
|
150
|
+
@channel = channel
|
151
|
+
end
|
152
|
+
|
153
|
+
# Checks equality by comparing each attribute.
|
154
|
+
# @param [Object] Object to be compared
|
155
|
+
def ==(o)
|
156
|
+
return true if self.equal?(o)
|
157
|
+
self.class == o.class &&
|
158
|
+
sender == o.sender &&
|
159
|
+
validity == o.validity &&
|
160
|
+
text == o.text &&
|
161
|
+
image == o.image &&
|
162
|
+
document == o.document &&
|
163
|
+
audio == o.audio &&
|
164
|
+
channel == o.channel
|
165
|
+
end
|
166
|
+
|
167
|
+
# @see the `==` method
|
168
|
+
# @param [Object] Object to be compared
|
169
|
+
def eql?(o)
|
170
|
+
self == o
|
171
|
+
end
|
172
|
+
|
173
|
+
# Calculates hash code according to all attributes.
|
174
|
+
# @return [Integer] Hash code
|
175
|
+
def hash
|
176
|
+
[sender, validity, text, image, document, audio, channel].hash
|
177
|
+
end
|
178
|
+
|
179
|
+
# Builds the object from hash
|
180
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
181
|
+
# @return [Object] Returns the model itself
|
182
|
+
def self.build_from_hash(attributes)
|
183
|
+
new.build_from_hash(attributes)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Builds the object from hash
|
187
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
188
|
+
# @return [Object] Returns the model itself
|
189
|
+
def build_from_hash(attributes)
|
190
|
+
return nil unless attributes.is_a?(Hash)
|
191
|
+
self.class.openapi_types.each_pair do |key, type|
|
192
|
+
if type =~ /\AArray<(.*)>/i
|
193
|
+
# check to ensure the input is an array given that the attribute
|
194
|
+
# is documented as an array but the input is not
|
195
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
196
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
197
|
+
end
|
198
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
199
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
200
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
201
|
+
end
|
202
|
+
|
203
|
+
self
|
204
|
+
end
|
205
|
+
|
206
|
+
# Deserializes the data based on type
|
207
|
+
# @param string type Data type
|
208
|
+
# @param string value Value to be deserialized
|
209
|
+
# @return [Object] Deserialized data
|
210
|
+
def _deserialize(type, value)
|
211
|
+
case type.to_sym
|
212
|
+
when :DateTime
|
213
|
+
DateTime.parse(value)
|
214
|
+
when :Date
|
215
|
+
Date.parse(value)
|
216
|
+
when :String
|
217
|
+
value.to_s
|
218
|
+
when :Integer
|
219
|
+
value.to_i
|
220
|
+
when :Float
|
221
|
+
value.to_f
|
222
|
+
when :Boolean
|
223
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
224
|
+
true
|
225
|
+
else
|
226
|
+
false
|
227
|
+
end
|
228
|
+
when :Object
|
229
|
+
# generic object (usually a Hash), return directly
|
230
|
+
value
|
231
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
232
|
+
inner_type = Regexp.last_match[:inner_type]
|
233
|
+
value.map { |v| _deserialize(inner_type, v) }
|
234
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
235
|
+
k_type = Regexp.last_match[:k_type]
|
236
|
+
v_type = Regexp.last_match[:v_type]
|
237
|
+
{}.tap do |hash|
|
238
|
+
value.each do |k, v|
|
239
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
else # model
|
243
|
+
MessenteApi.const_get(type).build_from_hash(value)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
# Returns the string representation of the object
|
248
|
+
# @return [String] String presentation of the object
|
249
|
+
def to_s
|
250
|
+
to_hash.to_s
|
251
|
+
end
|
252
|
+
|
253
|
+
# to_body is an alias to to_hash (backward compatibility)
|
254
|
+
# @return [Hash] Returns the object in the form of hash
|
255
|
+
def to_body
|
256
|
+
to_hash
|
257
|
+
end
|
258
|
+
|
259
|
+
# Returns the object in the form of hash
|
260
|
+
# @return [Hash] Returns the object in the form of hash
|
261
|
+
def to_hash
|
262
|
+
hash = {}
|
263
|
+
self.class.attribute_map.each_pair do |attr, param|
|
264
|
+
value = self.send(attr)
|
265
|
+
next if value.nil?
|
266
|
+
hash[param] = _to_hash(value)
|
267
|
+
end
|
268
|
+
hash
|
269
|
+
end
|
270
|
+
|
271
|
+
# Outputs non-array value in the form of hash
|
272
|
+
# For object, use to_hash. Otherwise, just return the value
|
273
|
+
# @param [Object] value Any valid value
|
274
|
+
# @return [Hash] Returns the value in the form of hash
|
275
|
+
def _to_hash(value)
|
276
|
+
if value.is_a?(Array)
|
277
|
+
value.compact.map { |v| _to_hash(v) }
|
278
|
+
elsif value.is_a?(Hash)
|
279
|
+
{}.tap do |hash|
|
280
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
281
|
+
end
|
282
|
+
elsif value.respond_to? :to_hash
|
283
|
+
value.to_hash
|
284
|
+
else
|
285
|
+
value
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|