whatsapp-ruby-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +85 -0
- data/lib/whats_app_cloud_api/api_helper.rb +277 -0
- data/lib/whats_app_cloud_api/client.rb +68 -0
- data/lib/whats_app_cloud_api/configuration.rb +132 -0
- data/lib/whats_app_cloud_api/controllers/base_controller.rb +52 -0
- data/lib/whats_app_cloud_api/controllers/business_profiles_controller.rb +94 -0
- data/lib/whats_app_cloud_api/controllers/media_controller.rb +142 -0
- data/lib/whats_app_cloud_api/controllers/messages_controller.rb +51 -0
- data/lib/whats_app_cloud_api/controllers/phone_numbers_controller.rb +141 -0
- data/lib/whats_app_cloud_api/controllers/registration_controller.rb +91 -0
- data/lib/whats_app_cloud_api/controllers/two_step_verification_controller.rb +57 -0
- data/lib/whats_app_cloud_api/exceptions/api_exception.rb +20 -0
- data/lib/whats_app_cloud_api/http/auth/o_auth2.rb +17 -0
- data/lib/whats_app_cloud_api/http/faraday_client.rb +97 -0
- data/lib/whats_app_cloud_api/http/http_call_back.rb +24 -0
- data/lib/whats_app_cloud_api/http/http_client.rb +123 -0
- data/lib/whats_app_cloud_api/http/http_method_enum.rb +13 -0
- data/lib/whats_app_cloud_api/http/http_request.rb +54 -0
- data/lib/whats_app_cloud_api/http/http_response.rb +29 -0
- data/lib/whats_app_cloud_api/models/action.rb +91 -0
- data/lib/whats_app_cloud_api/models/address.rb +110 -0
- data/lib/whats_app_cloud_api/models/audio.rb +61 -0
- data/lib/whats_app_cloud_api/models/base_model.rb +58 -0
- data/lib/whats_app_cloud_api/models/body.rb +49 -0
- data/lib/whats_app_cloud_api/models/business_profile.rb +123 -0
- data/lib/whats_app_cloud_api/models/button.rb +71 -0
- data/lib/whats_app_cloud_api/models/button_parameter.rb +72 -0
- data/lib/whats_app_cloud_api/models/button_parameter_type_enum.rb +17 -0
- data/lib/whats_app_cloud_api/models/component.rb +83 -0
- data/lib/whats_app_cloud_api/models/component_type_enum.rb +20 -0
- data/lib/whats_app_cloud_api/models/contact.rb +145 -0
- data/lib/whats_app_cloud_api/models/content_type_enum.rb +14 -0
- data/lib/whats_app_cloud_api/models/currency.rb +67 -0
- data/lib/whats_app_cloud_api/models/date_time_object.rb +128 -0
- data/lib/whats_app_cloud_api/models/document.rb +81 -0
- data/lib/whats_app_cloud_api/models/email_object.rb +60 -0
- data/lib/whats_app_cloud_api/models/footer.rb +49 -0
- data/lib/whats_app_cloud_api/models/get_business_profile_id_response.rb +57 -0
- data/lib/whats_app_cloud_api/models/get_phone_number_by_id_response.rb +78 -0
- data/lib/whats_app_cloud_api/models/header.rb +93 -0
- data/lib/whats_app_cloud_api/models/header_type_enum.rb +23 -0
- data/lib/whats_app_cloud_api/models/image.rb +71 -0
- data/lib/whats_app_cloud_api/models/interactive.rb +87 -0
- data/lib/whats_app_cloud_api/models/interactive_type_enum.rb +17 -0
- data/lib/whats_app_cloud_api/models/language.rb +60 -0
- data/lib/whats_app_cloud_api/models/location.rb +78 -0
- data/lib/whats_app_cloud_api/models/message.rb +194 -0
- data/lib/whats_app_cloud_api/models/message_type_enum.rb +41 -0
- data/lib/whats_app_cloud_api/models/name.rb +100 -0
- data/lib/whats_app_cloud_api/models/org.rb +70 -0
- data/lib/whats_app_cloud_api/models/parameter.rb +113 -0
- data/lib/whats_app_cloud_api/models/parameter_type_enum.rb +29 -0
- data/lib/whats_app_cloud_api/models/personal_information_type_enum.rb +17 -0
- data/lib/whats_app_cloud_api/models/phone_object.rb +70 -0
- data/lib/whats_app_cloud_api/models/phone_type_enum.rb +26 -0
- data/lib/whats_app_cloud_api/models/quality_rating_enum.rb +25 -0
- data/lib/whats_app_cloud_api/models/register_phone_request.rb +58 -0
- data/lib/whats_app_cloud_api/models/request_verification_code_method_enum.rb +17 -0
- data/lib/whats_app_cloud_api/models/request_verification_code_request.rb +57 -0
- data/lib/whats_app_cloud_api/models/response_contact.rb +57 -0
- data/lib/whats_app_cloud_api/models/response_message.rb +48 -0
- data/lib/whats_app_cloud_api/models/retrieve_media_url_response.rb +94 -0
- data/lib/whats_app_cloud_api/models/row.rb +68 -0
- data/lib/whats_app_cloud_api/models/section.rb +72 -0
- data/lib/whats_app_cloud_api/models/send_message_response.rb +85 -0
- data/lib/whats_app_cloud_api/models/set_two_step_verification_code_request.rb +48 -0
- data/lib/whats_app_cloud_api/models/sticker.rb +61 -0
- data/lib/whats_app_cloud_api/models/sub_type_enum.rb +20 -0
- data/lib/whats_app_cloud_api/models/success_response.rb +48 -0
- data/lib/whats_app_cloud_api/models/template.rb +78 -0
- data/lib/whats_app_cloud_api/models/text.rb +72 -0
- data/lib/whats_app_cloud_api/models/update_business_profile_request.rb +116 -0
- data/lib/whats_app_cloud_api/models/upload_media.rb +48 -0
- data/lib/whats_app_cloud_api/models/upload_media_request.rb +80 -0
- data/lib/whats_app_cloud_api/models/url_object.rb +60 -0
- data/lib/whats_app_cloud_api/models/verify_code_request.rb +48 -0
- data/lib/whats_app_cloud_api/models/vertical_enum.rb +68 -0
- data/lib/whats_app_cloud_api/models/video.rb +61 -0
- data/lib/whats_app_cloud_api/utilities/date_time_helper.rb +156 -0
- data/lib/whats_app_cloud_api/utilities/file_wrapper.rb +16 -0
- data/lib/whats_app_cloud_api.rb +104 -0
- metadata +266 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# whats_app_cloud_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WhatsAppCloudApi
|
|
7
|
+
# Interactive Model.
|
|
8
|
+
class Interactive < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Action you want the user to perform after reading the message.
|
|
13
|
+
# @return [Action]
|
|
14
|
+
attr_accessor :action
|
|
15
|
+
|
|
16
|
+
# The body of the message. Emojis and markdown are supported.
|
|
17
|
+
# @return [Body]
|
|
18
|
+
attr_accessor :body
|
|
19
|
+
|
|
20
|
+
# The footer of the message. Emojis and markdown are supported.
|
|
21
|
+
# @return [Footer]
|
|
22
|
+
attr_accessor :footer
|
|
23
|
+
|
|
24
|
+
# Header content displayed on top of a message.
|
|
25
|
+
# @return [Header]
|
|
26
|
+
attr_accessor :header
|
|
27
|
+
|
|
28
|
+
# The type of interactive message you want to send.
|
|
29
|
+
# @return [InteractiveTypeEnum]
|
|
30
|
+
attr_accessor :type
|
|
31
|
+
|
|
32
|
+
# A mapping from model property names to API property names.
|
|
33
|
+
def self.names
|
|
34
|
+
@_hash = {} if @_hash.nil?
|
|
35
|
+
@_hash['action'] = 'action'
|
|
36
|
+
@_hash['body'] = 'body'
|
|
37
|
+
@_hash['footer'] = 'footer'
|
|
38
|
+
@_hash['header'] = 'header'
|
|
39
|
+
@_hash['type'] = 'type'
|
|
40
|
+
@_hash
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# An array for optional fields
|
|
44
|
+
def optionals
|
|
45
|
+
%w[
|
|
46
|
+
footer
|
|
47
|
+
header
|
|
48
|
+
]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# An array for nullable fields
|
|
52
|
+
def nullables
|
|
53
|
+
[]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def initialize(action = nil,
|
|
57
|
+
body = nil,
|
|
58
|
+
type = nil,
|
|
59
|
+
footer = nil,
|
|
60
|
+
header = nil)
|
|
61
|
+
@action = action unless action == SKIP
|
|
62
|
+
@body = body unless body == SKIP
|
|
63
|
+
@footer = footer unless footer == SKIP
|
|
64
|
+
@header = header unless header == SKIP
|
|
65
|
+
@type = type unless type == SKIP
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Creates an instance of the object from a hash.
|
|
69
|
+
def self.from_hash(hash)
|
|
70
|
+
return nil unless hash
|
|
71
|
+
|
|
72
|
+
# Extract variables from the hash.
|
|
73
|
+
action = Action.from_hash(hash['action']) if hash['action']
|
|
74
|
+
body = Body.from_hash(hash['body']) if hash['body']
|
|
75
|
+
type = hash.key?('type') ? hash['type'] : SKIP
|
|
76
|
+
footer = Footer.from_hash(hash['footer']) if hash['footer']
|
|
77
|
+
header = Header.from_hash(hash['header']) if hash['header']
|
|
78
|
+
|
|
79
|
+
# Create object from extracted values.
|
|
80
|
+
Interactive.new(action,
|
|
81
|
+
body,
|
|
82
|
+
type,
|
|
83
|
+
footer,
|
|
84
|
+
header)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# whats_app_cloud_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WhatsAppCloudApi
|
|
7
|
+
# The type of interactive message you want to send.
|
|
8
|
+
class InteractiveTypeEnum
|
|
9
|
+
INTERACTIVE_TYPE_ENUM = [
|
|
10
|
+
# TODO: Write general description for LIST
|
|
11
|
+
LIST = 'list'.freeze,
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for BUTTON
|
|
14
|
+
BUTTON = 'button'.freeze
|
|
15
|
+
].freeze
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# whats_app_cloud_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WhatsAppCloudApi
|
|
7
|
+
# Language Model.
|
|
8
|
+
class Language < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# The code of the language or locale to use. Accepts both language and
|
|
13
|
+
# language_locale formats (e.g., en and en_US).
|
|
14
|
+
# @return [String]
|
|
15
|
+
attr_accessor :code
|
|
16
|
+
|
|
17
|
+
# The language policy the message should follow.
|
|
18
|
+
# @return [String]
|
|
19
|
+
attr_accessor :policy
|
|
20
|
+
|
|
21
|
+
# A mapping from model property names to API property names.
|
|
22
|
+
def self.names
|
|
23
|
+
@_hash = {} if @_hash.nil?
|
|
24
|
+
@_hash['code'] = 'code'
|
|
25
|
+
@_hash['policy'] = 'policy'
|
|
26
|
+
@_hash
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# An array for optional fields
|
|
30
|
+
def optionals
|
|
31
|
+
%w[
|
|
32
|
+
policy
|
|
33
|
+
]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# An array for nullable fields
|
|
37
|
+
def nullables
|
|
38
|
+
[]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def initialize(code = nil,
|
|
42
|
+
policy = 'deterministic')
|
|
43
|
+
@code = code unless code == SKIP
|
|
44
|
+
@policy = policy unless policy == SKIP
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Creates an instance of the object from a hash.
|
|
48
|
+
def self.from_hash(hash)
|
|
49
|
+
return nil unless hash
|
|
50
|
+
|
|
51
|
+
# Extract variables from the hash.
|
|
52
|
+
code = hash.key?('code') ? hash['code'] : SKIP
|
|
53
|
+
policy = hash['policy'] ||= 'deterministic'
|
|
54
|
+
|
|
55
|
+
# Create object from extracted values.
|
|
56
|
+
Language.new(code,
|
|
57
|
+
policy)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# whats_app_cloud_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WhatsAppCloudApi
|
|
7
|
+
# Location Model.
|
|
8
|
+
class Location < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Latitude of the location.
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_accessor :latitude
|
|
15
|
+
|
|
16
|
+
# Longitude of the location.
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_accessor :longitude
|
|
19
|
+
|
|
20
|
+
# Name of the location.
|
|
21
|
+
# @return [String]
|
|
22
|
+
attr_accessor :name
|
|
23
|
+
|
|
24
|
+
# Address of the location. Only displayed if name is present.
|
|
25
|
+
# @return [String]
|
|
26
|
+
attr_accessor :address
|
|
27
|
+
|
|
28
|
+
# A mapping from model property names to API property names.
|
|
29
|
+
def self.names
|
|
30
|
+
@_hash = {} if @_hash.nil?
|
|
31
|
+
@_hash['latitude'] = 'latitude'
|
|
32
|
+
@_hash['longitude'] = 'longitude'
|
|
33
|
+
@_hash['name'] = 'name'
|
|
34
|
+
@_hash['address'] = 'address'
|
|
35
|
+
@_hash
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# An array for optional fields
|
|
39
|
+
def optionals
|
|
40
|
+
%w[
|
|
41
|
+
name
|
|
42
|
+
address
|
|
43
|
+
]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# An array for nullable fields
|
|
47
|
+
def nullables
|
|
48
|
+
[]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def initialize(latitude = nil,
|
|
52
|
+
longitude = nil,
|
|
53
|
+
name = nil,
|
|
54
|
+
address = nil)
|
|
55
|
+
@latitude = latitude unless latitude == SKIP
|
|
56
|
+
@longitude = longitude unless longitude == SKIP
|
|
57
|
+
@name = name unless name == SKIP
|
|
58
|
+
@address = address unless address == SKIP
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Creates an instance of the object from a hash.
|
|
62
|
+
def self.from_hash(hash)
|
|
63
|
+
return nil unless hash
|
|
64
|
+
|
|
65
|
+
# Extract variables from the hash.
|
|
66
|
+
latitude = hash.key?('latitude') ? hash['latitude'] : SKIP
|
|
67
|
+
longitude = hash.key?('longitude') ? hash['longitude'] : SKIP
|
|
68
|
+
name = hash.key?('name') ? hash['name'] : SKIP
|
|
69
|
+
address = hash.key?('address') ? hash['address'] : SKIP
|
|
70
|
+
|
|
71
|
+
# Create object from extracted values.
|
|
72
|
+
Location.new(latitude,
|
|
73
|
+
longitude,
|
|
74
|
+
name,
|
|
75
|
+
address)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# whats_app_cloud_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WhatsAppCloudApi
|
|
7
|
+
# Message Model.
|
|
8
|
+
class Message < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# A media object containing audio. Required when type=audio.
|
|
13
|
+
# @return [Audio]
|
|
14
|
+
attr_accessor :audio
|
|
15
|
+
|
|
16
|
+
# A contact object. Required when type=contacts.
|
|
17
|
+
# @return [List of Contact]
|
|
18
|
+
attr_accessor :contacts
|
|
19
|
+
|
|
20
|
+
# A media object containing a document. Required when type=document.
|
|
21
|
+
# @return [Document]
|
|
22
|
+
attr_accessor :document
|
|
23
|
+
|
|
24
|
+
# A media object containing an image. Required when type=image.
|
|
25
|
+
# @return [Image]
|
|
26
|
+
attr_accessor :image
|
|
27
|
+
|
|
28
|
+
# This option is used to send List Messages and Reply Buttons. The
|
|
29
|
+
# components of each interactive object generally follow a consistent
|
|
30
|
+
# pattern: header, body, footer, and action. Required when type=interactive.
|
|
31
|
+
# @return [Interactive]
|
|
32
|
+
attr_accessor :interactive
|
|
33
|
+
|
|
34
|
+
# A location object. Required when type=location.
|
|
35
|
+
# @return [Location]
|
|
36
|
+
attr_accessor :location
|
|
37
|
+
|
|
38
|
+
# Messaging service used for the request.
|
|
39
|
+
# @return [String]
|
|
40
|
+
attr_accessor :messaging_product
|
|
41
|
+
|
|
42
|
+
# Currently, you can only send messages to individuals.
|
|
43
|
+
# @return [String]
|
|
44
|
+
attr_accessor :recipient_type
|
|
45
|
+
|
|
46
|
+
# A media object containing a sticker. Currently, we support inbound both
|
|
47
|
+
# and outbound stickers: For outbound, we only support static third-party
|
|
48
|
+
# stickers. For inbound, we support all types of stickers. The sticker needs
|
|
49
|
+
# to be 512x512 pixels and the file’s size needs to be less than 100 KB.
|
|
50
|
+
# Required when type=sticker.
|
|
51
|
+
# @return [Sticker]
|
|
52
|
+
attr_accessor :sticker
|
|
53
|
+
|
|
54
|
+
# A template object. Required when type=template.
|
|
55
|
+
# @return [Template]
|
|
56
|
+
attr_accessor :template
|
|
57
|
+
|
|
58
|
+
# Required for text messages.
|
|
59
|
+
# @return [Text]
|
|
60
|
+
attr_accessor :text
|
|
61
|
+
|
|
62
|
+
# WhatsApp ID or phone number for the person you want to send a message to.
|
|
63
|
+
# @return [String]
|
|
64
|
+
attr_accessor :to
|
|
65
|
+
|
|
66
|
+
# The type of message you want to send.
|
|
67
|
+
# @return [MessageTypeEnum]
|
|
68
|
+
attr_accessor :type
|
|
69
|
+
|
|
70
|
+
# A media object containing a video. Required when type=video.
|
|
71
|
+
# @return [Video]
|
|
72
|
+
attr_accessor :video
|
|
73
|
+
|
|
74
|
+
# A mapping from model property names to API property names.
|
|
75
|
+
def self.names
|
|
76
|
+
@_hash = {} if @_hash.nil?
|
|
77
|
+
@_hash['audio'] = 'audio'
|
|
78
|
+
@_hash['contacts'] = 'contacts'
|
|
79
|
+
@_hash['document'] = 'document'
|
|
80
|
+
@_hash['image'] = 'image'
|
|
81
|
+
@_hash['interactive'] = 'interactive'
|
|
82
|
+
@_hash['location'] = 'location'
|
|
83
|
+
@_hash['messaging_product'] = 'messaging_product'
|
|
84
|
+
@_hash['recipient_type'] = 'recipient_type'
|
|
85
|
+
@_hash['sticker'] = 'sticker'
|
|
86
|
+
@_hash['template'] = 'template'
|
|
87
|
+
@_hash['text'] = 'text'
|
|
88
|
+
@_hash['to'] = 'to'
|
|
89
|
+
@_hash['type'] = 'type'
|
|
90
|
+
@_hash['video'] = 'video'
|
|
91
|
+
@_hash
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# An array for optional fields
|
|
95
|
+
def optionals
|
|
96
|
+
%w[
|
|
97
|
+
audio
|
|
98
|
+
contacts
|
|
99
|
+
document
|
|
100
|
+
image
|
|
101
|
+
interactive
|
|
102
|
+
location
|
|
103
|
+
recipient_type
|
|
104
|
+
sticker
|
|
105
|
+
template
|
|
106
|
+
text
|
|
107
|
+
type
|
|
108
|
+
video
|
|
109
|
+
]
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# An array for nullable fields
|
|
113
|
+
def nullables
|
|
114
|
+
[]
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def initialize(messaging_product = nil,
|
|
118
|
+
to = nil,
|
|
119
|
+
audio = nil,
|
|
120
|
+
contacts = nil,
|
|
121
|
+
document = nil,
|
|
122
|
+
image = nil,
|
|
123
|
+
interactive = nil,
|
|
124
|
+
location = nil,
|
|
125
|
+
recipient_type = 'individual',
|
|
126
|
+
sticker = nil,
|
|
127
|
+
template = nil,
|
|
128
|
+
text = nil,
|
|
129
|
+
type = nil,
|
|
130
|
+
video = nil)
|
|
131
|
+
@audio = audio unless audio == SKIP
|
|
132
|
+
@contacts = contacts unless contacts == SKIP
|
|
133
|
+
@document = document unless document == SKIP
|
|
134
|
+
@image = image unless image == SKIP
|
|
135
|
+
@interactive = interactive unless interactive == SKIP
|
|
136
|
+
@location = location unless location == SKIP
|
|
137
|
+
@messaging_product = messaging_product unless messaging_product == SKIP
|
|
138
|
+
@recipient_type = recipient_type unless recipient_type == SKIP
|
|
139
|
+
@sticker = sticker unless sticker == SKIP
|
|
140
|
+
@template = template unless template == SKIP
|
|
141
|
+
@text = text unless text == SKIP
|
|
142
|
+
@to = to unless to == SKIP
|
|
143
|
+
@type = type unless type == SKIP
|
|
144
|
+
@video = video unless video == SKIP
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Creates an instance of the object from a hash.
|
|
148
|
+
def self.from_hash(hash)
|
|
149
|
+
return nil unless hash
|
|
150
|
+
|
|
151
|
+
# Extract variables from the hash.
|
|
152
|
+
messaging_product =
|
|
153
|
+
hash.key?('messaging_product') ? hash['messaging_product'] : SKIP
|
|
154
|
+
to = hash.key?('to') ? hash['to'] : SKIP
|
|
155
|
+
audio = Audio.from_hash(hash['audio']) if hash['audio']
|
|
156
|
+
# Parameter is an array, so we need to iterate through it
|
|
157
|
+
contacts = nil
|
|
158
|
+
unless hash['contacts'].nil?
|
|
159
|
+
contacts = []
|
|
160
|
+
hash['contacts'].each do |structure|
|
|
161
|
+
contacts << (Contact.from_hash(structure) if structure)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
contacts = SKIP unless hash.key?('contacts')
|
|
166
|
+
document = Document.from_hash(hash['document']) if hash['document']
|
|
167
|
+
image = Image.from_hash(hash['image']) if hash['image']
|
|
168
|
+
interactive = Interactive.from_hash(hash['interactive']) if hash['interactive']
|
|
169
|
+
location = Location.from_hash(hash['location']) if hash['location']
|
|
170
|
+
recipient_type = hash['recipient_type'] ||= 'individual'
|
|
171
|
+
sticker = Sticker.from_hash(hash['sticker']) if hash['sticker']
|
|
172
|
+
template = Template.from_hash(hash['template']) if hash['template']
|
|
173
|
+
text = Text.from_hash(hash['text']) if hash['text']
|
|
174
|
+
type = hash.key?('type') ? hash['type'] : SKIP
|
|
175
|
+
video = Video.from_hash(hash['video']) if hash['video']
|
|
176
|
+
|
|
177
|
+
# Create object from extracted values.
|
|
178
|
+
Message.new(messaging_product,
|
|
179
|
+
to,
|
|
180
|
+
audio,
|
|
181
|
+
contacts,
|
|
182
|
+
document,
|
|
183
|
+
image,
|
|
184
|
+
interactive,
|
|
185
|
+
location,
|
|
186
|
+
recipient_type,
|
|
187
|
+
sticker,
|
|
188
|
+
template,
|
|
189
|
+
text,
|
|
190
|
+
type,
|
|
191
|
+
video)
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# whats_app_cloud_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WhatsAppCloudApi
|
|
7
|
+
# MessageType.
|
|
8
|
+
class MessageTypeEnum
|
|
9
|
+
MESSAGE_TYPE_ENUM = [
|
|
10
|
+
# TODO: Write general description for TEXT
|
|
11
|
+
TEXT = 'text'.freeze,
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for AUDIO
|
|
14
|
+
AUDIO = 'audio'.freeze,
|
|
15
|
+
|
|
16
|
+
# TODO: Write general description for CONTACTS
|
|
17
|
+
CONTACTS = 'contacts'.freeze,
|
|
18
|
+
|
|
19
|
+
# TODO: Write general description for DOCUMENT
|
|
20
|
+
DOCUMENT = 'document'.freeze,
|
|
21
|
+
|
|
22
|
+
# TODO: Write general description for IMAGE
|
|
23
|
+
IMAGE = 'image'.freeze,
|
|
24
|
+
|
|
25
|
+
# TODO: Write general description for INTERACTIVE
|
|
26
|
+
INTERACTIVE = 'interactive'.freeze,
|
|
27
|
+
|
|
28
|
+
# TODO: Write general description for LOCATION
|
|
29
|
+
LOCATION = 'location'.freeze,
|
|
30
|
+
|
|
31
|
+
# TODO: Write general description for STICKER
|
|
32
|
+
STICKER = 'sticker'.freeze,
|
|
33
|
+
|
|
34
|
+
# TODO: Write general description for TEMPLATE
|
|
35
|
+
TEMPLATE = 'template'.freeze,
|
|
36
|
+
|
|
37
|
+
# TODO: Write general description for VIDEO
|
|
38
|
+
VIDEO = 'video'.freeze
|
|
39
|
+
].freeze
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# whats_app_cloud_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WhatsAppCloudApi
|
|
7
|
+
# Name Model.
|
|
8
|
+
class Name < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Full name, as it normally appears.
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_accessor :formatted_name
|
|
15
|
+
|
|
16
|
+
# Full name, as it normally appears.
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_accessor :first_name
|
|
19
|
+
|
|
20
|
+
# Full name, as it normally appears.
|
|
21
|
+
# @return [String]
|
|
22
|
+
attr_accessor :last_name
|
|
23
|
+
|
|
24
|
+
# Full name, as it normally appears.
|
|
25
|
+
# @return [String]
|
|
26
|
+
attr_accessor :middle_name
|
|
27
|
+
|
|
28
|
+
# Full name, as it normally appears.
|
|
29
|
+
# @return [String]
|
|
30
|
+
attr_accessor :suffix
|
|
31
|
+
|
|
32
|
+
# Full name, as it normally appears.
|
|
33
|
+
# @return [String]
|
|
34
|
+
attr_accessor :prefix
|
|
35
|
+
|
|
36
|
+
# A mapping from model property names to API property names.
|
|
37
|
+
def self.names
|
|
38
|
+
@_hash = {} if @_hash.nil?
|
|
39
|
+
@_hash['formatted_name'] = 'formatted_name'
|
|
40
|
+
@_hash['first_name'] = 'first_name'
|
|
41
|
+
@_hash['last_name'] = 'last_name'
|
|
42
|
+
@_hash['middle_name'] = 'middle_name'
|
|
43
|
+
@_hash['suffix'] = 'suffix'
|
|
44
|
+
@_hash['prefix'] = 'prefix'
|
|
45
|
+
@_hash
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# An array for optional fields
|
|
49
|
+
def optionals
|
|
50
|
+
%w[
|
|
51
|
+
first_name
|
|
52
|
+
last_name
|
|
53
|
+
middle_name
|
|
54
|
+
suffix
|
|
55
|
+
prefix
|
|
56
|
+
]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# An array for nullable fields
|
|
60
|
+
def nullables
|
|
61
|
+
[]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def initialize(formatted_name = nil,
|
|
65
|
+
first_name = nil,
|
|
66
|
+
last_name = nil,
|
|
67
|
+
middle_name = nil,
|
|
68
|
+
suffix = nil,
|
|
69
|
+
prefix = nil)
|
|
70
|
+
@formatted_name = formatted_name unless formatted_name == SKIP
|
|
71
|
+
@first_name = first_name unless first_name == SKIP
|
|
72
|
+
@last_name = last_name unless last_name == SKIP
|
|
73
|
+
@middle_name = middle_name unless middle_name == SKIP
|
|
74
|
+
@suffix = suffix unless suffix == SKIP
|
|
75
|
+
@prefix = prefix unless prefix == SKIP
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Creates an instance of the object from a hash.
|
|
79
|
+
def self.from_hash(hash)
|
|
80
|
+
return nil unless hash
|
|
81
|
+
|
|
82
|
+
# Extract variables from the hash.
|
|
83
|
+
formatted_name =
|
|
84
|
+
hash.key?('formatted_name') ? hash['formatted_name'] : SKIP
|
|
85
|
+
first_name = hash.key?('first_name') ? hash['first_name'] : SKIP
|
|
86
|
+
last_name = hash.key?('last_name') ? hash['last_name'] : SKIP
|
|
87
|
+
middle_name = hash.key?('middle_name') ? hash['middle_name'] : SKIP
|
|
88
|
+
suffix = hash.key?('suffix') ? hash['suffix'] : SKIP
|
|
89
|
+
prefix = hash.key?('prefix') ? hash['prefix'] : SKIP
|
|
90
|
+
|
|
91
|
+
# Create object from extracted values.
|
|
92
|
+
Name.new(formatted_name,
|
|
93
|
+
first_name,
|
|
94
|
+
last_name,
|
|
95
|
+
middle_name,
|
|
96
|
+
suffix,
|
|
97
|
+
prefix)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# whats_app_cloud_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WhatsAppCloudApi
|
|
7
|
+
# Org Model.
|
|
8
|
+
class Org < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Name of the contact's company.
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_accessor :company
|
|
15
|
+
|
|
16
|
+
# Name of the contact's department.
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_accessor :department
|
|
19
|
+
|
|
20
|
+
# Contact's business title.
|
|
21
|
+
# @return [String]
|
|
22
|
+
attr_accessor :title
|
|
23
|
+
|
|
24
|
+
# A mapping from model property names to API property names.
|
|
25
|
+
def self.names
|
|
26
|
+
@_hash = {} if @_hash.nil?
|
|
27
|
+
@_hash['company'] = 'company'
|
|
28
|
+
@_hash['department'] = 'department'
|
|
29
|
+
@_hash['title'] = 'title'
|
|
30
|
+
@_hash
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# An array for optional fields
|
|
34
|
+
def optionals
|
|
35
|
+
%w[
|
|
36
|
+
company
|
|
37
|
+
department
|
|
38
|
+
title
|
|
39
|
+
]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# An array for nullable fields
|
|
43
|
+
def nullables
|
|
44
|
+
[]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def initialize(company = nil,
|
|
48
|
+
department = nil,
|
|
49
|
+
title = nil)
|
|
50
|
+
@company = company unless company == SKIP
|
|
51
|
+
@department = department unless department == SKIP
|
|
52
|
+
@title = title unless title == SKIP
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Creates an instance of the object from a hash.
|
|
56
|
+
def self.from_hash(hash)
|
|
57
|
+
return nil unless hash
|
|
58
|
+
|
|
59
|
+
# Extract variables from the hash.
|
|
60
|
+
company = hash.key?('company') ? hash['company'] : SKIP
|
|
61
|
+
department = hash.key?('department') ? hash['department'] : SKIP
|
|
62
|
+
title = hash.key?('title') ? hash['title'] : SKIP
|
|
63
|
+
|
|
64
|
+
# Create object from extracted values.
|
|
65
|
+
Org.new(company,
|
|
66
|
+
department,
|
|
67
|
+
title)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|