whatsapp-ruby-sdk 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,80 @@
|
|
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
|
+
# UploadMediaRequest Model.
|
8
|
+
class UploadMediaRequest < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# Messaging service used for the request. In this case, use whatsapp.
|
13
|
+
# @return [String]
|
14
|
+
attr_accessor :messaging_product
|
15
|
+
|
16
|
+
# Path to the file stored in your local directory. For example:
|
17
|
+
# "@/local/path/file.jpg".
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :file
|
20
|
+
|
21
|
+
# Type of media file being uploaded. See Supported Media Types for more
|
22
|
+
# information.
|
23
|
+
# Supported options for images are: `image/jpeg`, `image/png`
|
24
|
+
# Supported options for documents are: `text/plain`, `application/pdf`,
|
25
|
+
# `application/vnd.ms-powerpoint`, `application/msword`,
|
26
|
+
# `application/vnd.ms-excel`,
|
27
|
+
# `application/vnd.openxmlformats-officedocument.wordprocessingml.document`,
|
28
|
+
# `application/vnd.openxmlformats-officedocument.presentationml.presentation
|
29
|
+
# `, `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`
|
30
|
+
# Supported options for audio are: `audio/aac`, `audio/mp4`, `audio/mpeg`,
|
31
|
+
# `audio/amr`, `audio/ogg`, `audio/opus`
|
32
|
+
# Supported options for video are: `video/mp4`, `video/3gp`
|
33
|
+
# Supported options for stickers are: `image/webp`
|
34
|
+
# @return [String]
|
35
|
+
attr_accessor :type
|
36
|
+
|
37
|
+
# A mapping from model property names to API property names.
|
38
|
+
def self.names
|
39
|
+
@_hash = {} if @_hash.nil?
|
40
|
+
@_hash['messaging_product'] = 'messaging_product'
|
41
|
+
@_hash['file'] = 'file'
|
42
|
+
@_hash['type'] = 'type'
|
43
|
+
@_hash
|
44
|
+
end
|
45
|
+
|
46
|
+
# An array for optional fields
|
47
|
+
def optionals
|
48
|
+
[]
|
49
|
+
end
|
50
|
+
|
51
|
+
# An array for nullable fields
|
52
|
+
def nullables
|
53
|
+
[]
|
54
|
+
end
|
55
|
+
|
56
|
+
def initialize(messaging_product = nil,
|
57
|
+
file = nil,
|
58
|
+
type = nil)
|
59
|
+
@messaging_product = messaging_product unless messaging_product == SKIP
|
60
|
+
@file = file unless file == SKIP
|
61
|
+
@type = type unless type == SKIP
|
62
|
+
end
|
63
|
+
|
64
|
+
# Creates an instance of the object from a hash.
|
65
|
+
def self.from_hash(hash)
|
66
|
+
return nil unless hash
|
67
|
+
|
68
|
+
# Extract variables from the hash.
|
69
|
+
messaging_product =
|
70
|
+
hash.key?('messaging_product') ? hash['messaging_product'] : SKIP
|
71
|
+
file = hash.key?('file') ? hash['file'] : SKIP
|
72
|
+
type = hash.key?('type') ? hash['type'] : SKIP
|
73
|
+
|
74
|
+
# Create object from extracted values.
|
75
|
+
UploadMediaRequest.new(messaging_product,
|
76
|
+
file,
|
77
|
+
type)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
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
|
+
# UrlObject Model.
|
8
|
+
class UrlObject < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# TODO: Write general description for this method
|
13
|
+
# @return [String]
|
14
|
+
attr_accessor :url
|
15
|
+
|
16
|
+
# TODO: Write general description for this method
|
17
|
+
# @return [PersonalInformationTypeEnum]
|
18
|
+
attr_accessor :type
|
19
|
+
|
20
|
+
# A mapping from model property names to API property names.
|
21
|
+
def self.names
|
22
|
+
@_hash = {} if @_hash.nil?
|
23
|
+
@_hash['url'] = 'url'
|
24
|
+
@_hash['type'] = 'type'
|
25
|
+
@_hash
|
26
|
+
end
|
27
|
+
|
28
|
+
# An array for optional fields
|
29
|
+
def optionals
|
30
|
+
%w[
|
31
|
+
url
|
32
|
+
type
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
# An array for nullable fields
|
37
|
+
def nullables
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize(url = nil,
|
42
|
+
type = nil)
|
43
|
+
@url = url unless url == SKIP
|
44
|
+
@type = type unless type == 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
|
+
url = hash.key?('url') ? hash['url'] : SKIP
|
53
|
+
type = hash.key?('type') ? hash['type'] : SKIP
|
54
|
+
|
55
|
+
# Create object from extracted values.
|
56
|
+
UrlObject.new(url,
|
57
|
+
type)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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
|
+
# VerifyCodeRequest Model.
|
8
|
+
class VerifyCodeRequest < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# The code you received after calling FROM_PHONE_NUMBER_ID/request_code.
|
13
|
+
# @return [String]
|
14
|
+
attr_accessor :code
|
15
|
+
|
16
|
+
# A mapping from model property names to API property names.
|
17
|
+
def self.names
|
18
|
+
@_hash = {} if @_hash.nil?
|
19
|
+
@_hash['code'] = 'code'
|
20
|
+
@_hash
|
21
|
+
end
|
22
|
+
|
23
|
+
# An array for optional fields
|
24
|
+
def optionals
|
25
|
+
[]
|
26
|
+
end
|
27
|
+
|
28
|
+
# An array for nullable fields
|
29
|
+
def nullables
|
30
|
+
[]
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(code = nil)
|
34
|
+
@code = code unless code == SKIP
|
35
|
+
end
|
36
|
+
|
37
|
+
# Creates an instance of the object from a hash.
|
38
|
+
def self.from_hash(hash)
|
39
|
+
return nil unless hash
|
40
|
+
|
41
|
+
# Extract variables from the hash.
|
42
|
+
code = hash.key?('code') ? hash['code'] : SKIP
|
43
|
+
|
44
|
+
# Create object from extracted values.
|
45
|
+
VerifyCodeRequest.new(code)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,68 @@
|
|
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
|
+
# Vertical.
|
8
|
+
class VerticalEnum
|
9
|
+
VERTICAL_ENUM = [
|
10
|
+
# TODO: Write general description for UNDEFINED
|
11
|
+
UNDEFINED = 'UNDEFINED'.freeze,
|
12
|
+
|
13
|
+
# TODO: Write general description for OTHER
|
14
|
+
OTHER = 'OTHER'.freeze,
|
15
|
+
|
16
|
+
# TODO: Write general description for AUTO
|
17
|
+
AUTO = 'AUTO'.freeze,
|
18
|
+
|
19
|
+
# TODO: Write general description for BEAUTY
|
20
|
+
BEAUTY = 'BEAUTY'.freeze,
|
21
|
+
|
22
|
+
# TODO: Write general description for APPAREL
|
23
|
+
APPAREL = 'APPAREL'.freeze,
|
24
|
+
|
25
|
+
# TODO: Write general description for EDU
|
26
|
+
EDU = 'EDU'.freeze,
|
27
|
+
|
28
|
+
# TODO: Write general description for ENTERTAIN
|
29
|
+
ENTERTAIN = 'ENTERTAIN'.freeze,
|
30
|
+
|
31
|
+
# TODO: Write general description for EVENT_PLAN
|
32
|
+
EVENT_PLAN = 'EVENT_PLAN'.freeze,
|
33
|
+
|
34
|
+
# TODO: Write general description for FINANCE
|
35
|
+
FINANCE = 'FINANCE'.freeze,
|
36
|
+
|
37
|
+
# TODO: Write general description for GROCERY
|
38
|
+
GROCERY = 'GROCERY'.freeze,
|
39
|
+
|
40
|
+
# TODO: Write general description for GOVT
|
41
|
+
GOVT = 'GOVT'.freeze,
|
42
|
+
|
43
|
+
# TODO: Write general description for HOTEL
|
44
|
+
HOTEL = 'HOTEL'.freeze,
|
45
|
+
|
46
|
+
# TODO: Write general description for HEALTH
|
47
|
+
HEALTH = 'HEALTH'.freeze,
|
48
|
+
|
49
|
+
# TODO: Write general description for NONPROFIT
|
50
|
+
NONPROFIT = 'NONPROFIT'.freeze,
|
51
|
+
|
52
|
+
# TODO: Write general description for PROF_SERVICES
|
53
|
+
PROF_SERVICES = 'PROF_SERVICES'.freeze,
|
54
|
+
|
55
|
+
# TODO: Write general description for RETAIL
|
56
|
+
RETAIL = 'RETAIL'.freeze,
|
57
|
+
|
58
|
+
# TODO: Write general description for TRAVEL
|
59
|
+
TRAVEL = 'TRAVEL'.freeze,
|
60
|
+
|
61
|
+
# TODO: Write general description for RESTAURANT
|
62
|
+
RESTAURANT = 'RESTAURANT'.freeze,
|
63
|
+
|
64
|
+
# TODO: Write general description for NOT_A_BIZ
|
65
|
+
NOT_A_BIZ = 'NOT_A_BIZ'.freeze
|
66
|
+
].freeze
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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
|
+
# Video Model.
|
8
|
+
class Video < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# The protocol and URL of the media to be sent. Use only with HTTP/HTTPS
|
13
|
+
# URLs. Required when you are not using an uploaded media ID.
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :link
|
16
|
+
|
17
|
+
# Required when you are not using a link. The media object ID.
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :id
|
20
|
+
|
21
|
+
# A mapping from model property names to API property names.
|
22
|
+
def self.names
|
23
|
+
@_hash = {} if @_hash.nil?
|
24
|
+
@_hash['link'] = 'link'
|
25
|
+
@_hash['id'] = 'id'
|
26
|
+
@_hash
|
27
|
+
end
|
28
|
+
|
29
|
+
# An array for optional fields
|
30
|
+
def optionals
|
31
|
+
%w[
|
32
|
+
link
|
33
|
+
id
|
34
|
+
]
|
35
|
+
end
|
36
|
+
|
37
|
+
# An array for nullable fields
|
38
|
+
def nullables
|
39
|
+
[]
|
40
|
+
end
|
41
|
+
|
42
|
+
def initialize(link = nil,
|
43
|
+
id = nil)
|
44
|
+
@link = link unless link == SKIP
|
45
|
+
@id = id unless id == SKIP
|
46
|
+
end
|
47
|
+
|
48
|
+
# Creates an instance of the object from a hash.
|
49
|
+
def self.from_hash(hash)
|
50
|
+
return nil unless hash
|
51
|
+
|
52
|
+
# Extract variables from the hash.
|
53
|
+
link = hash.key?('link') ? hash['link'] : SKIP
|
54
|
+
id = hash.key?('id') ? hash['id'] : SKIP
|
55
|
+
|
56
|
+
# Create object from extracted values.
|
57
|
+
Video.new(link,
|
58
|
+
id)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# whats_app_cloud_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
module WhatsAppCloudApi
|
8
|
+
# A utility that supports dateTime conversion to different formats
|
9
|
+
class DateTimeHelper
|
10
|
+
# Safely converts a DateTime object into a rfc1123 format string
|
11
|
+
# @param [DateTime] The DateTime object
|
12
|
+
# @return [String] The rfc1123 formatted datetime string
|
13
|
+
def self.to_rfc1123(date_time)
|
14
|
+
date_time&.httpdate
|
15
|
+
end
|
16
|
+
|
17
|
+
# Safely converts a map of DateTime objects into a map of rfc1123 format string
|
18
|
+
# @param [hash] a map of DateTime objects
|
19
|
+
# @return [hash] a map of rfc1123 formatted datetime string
|
20
|
+
def self.to_rfc1123_map(date_time, hash, key)
|
21
|
+
return if date_time.nil?
|
22
|
+
|
23
|
+
hash[key] = {}
|
24
|
+
date_time.each do |k, v|
|
25
|
+
hash[key][k] =
|
26
|
+
if v.is_a?(BaseModel)
|
27
|
+
v.to_hash
|
28
|
+
else
|
29
|
+
v.is_a?(DateTime) ? DateTimeHelper.to_rfc1123(v) : v
|
30
|
+
end
|
31
|
+
end
|
32
|
+
hash[key]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Safely converts an array of DateTime objects into an array of rfc1123 format string
|
36
|
+
# @param [Array] an array of DateTime objects
|
37
|
+
# @return [Array] an array of rfc1123 formatted datetime string
|
38
|
+
def self.to_rfc1123_array(date_time, hash, key)
|
39
|
+
return if date_time.nil?
|
40
|
+
|
41
|
+
hash[key] = date_time.map do |v|
|
42
|
+
if v.is_a?(BaseModel)
|
43
|
+
v.to_hash
|
44
|
+
else
|
45
|
+
v.is_a?(DateTime) ? DateTimeHelper.to_rfc1123(v) : v
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Safely converts a DateTime object into a unix format string
|
51
|
+
# @param [DateTime] The DateTime object
|
52
|
+
# @return [String] The unix formatted datetime string
|
53
|
+
def self.to_unix(date_time)
|
54
|
+
date_time.to_time.utc.to_i unless date_time.nil?
|
55
|
+
end
|
56
|
+
|
57
|
+
# Safely converts a map of DateTime objects into a map of unix format string
|
58
|
+
# @param [hash] a map of DateTime objects
|
59
|
+
# @return [hash] a map of unix formatted datetime string
|
60
|
+
def self.to_unix_map(date_time, hash, key)
|
61
|
+
return if date_time.nil?
|
62
|
+
|
63
|
+
hash[key] = {}
|
64
|
+
date_time.each do |k, v|
|
65
|
+
hash[key][k] =
|
66
|
+
if v.is_a?(BaseModel)
|
67
|
+
v.to_hash
|
68
|
+
else
|
69
|
+
v.is_a?(DateTime) ? DateTimeHelper.to_unix(v) : v
|
70
|
+
end
|
71
|
+
end
|
72
|
+
hash[key]
|
73
|
+
end
|
74
|
+
|
75
|
+
# Safely converts an array of DateTime objects into a map of unix format string
|
76
|
+
# @param [hash] an array of DateTime objects
|
77
|
+
# @return [hash] an array of unix formatted datetime string
|
78
|
+
def self.to_unix_array(date_time, hash, key)
|
79
|
+
return if date_time.nil?
|
80
|
+
|
81
|
+
hash[key] = date_time.map do |v|
|
82
|
+
if v.is_a?(BaseModel)
|
83
|
+
v.to_hash
|
84
|
+
else
|
85
|
+
v.is_a?(DateTime) ? DateTimeHelper.to_unix(v) : v
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Safely converts a DateTime object into a rfc3339 format string
|
91
|
+
# @param [DateTime] The DateTime object
|
92
|
+
# @return [String] The rfc3339 formatted datetime string
|
93
|
+
def self.to_rfc3339(date_time)
|
94
|
+
date_time&.rfc3339
|
95
|
+
end
|
96
|
+
|
97
|
+
# Safely converts a map of DateTime objects into a map of rfc1123 format string
|
98
|
+
# @param [hash] a map of DateTime objects
|
99
|
+
# @return [hash] a map of rfc1123 formatted datetime string
|
100
|
+
def self.to_rfc3339_map(date_time, hash, key)
|
101
|
+
return if date_time.nil?
|
102
|
+
|
103
|
+
hash[key] = {}
|
104
|
+
date_time.each do |k, v|
|
105
|
+
hash[key][k] =
|
106
|
+
if v.is_a?(BaseModel)
|
107
|
+
v.to_hash
|
108
|
+
else
|
109
|
+
v.is_a?(DateTime) ? DateTimeHelper.to_rfc3339(v) : v
|
110
|
+
end
|
111
|
+
end
|
112
|
+
hash[key]
|
113
|
+
end
|
114
|
+
|
115
|
+
# Safely converts an array of DateTime objects into an array of rfc1123 format string
|
116
|
+
# @param [Array] an array of DateTime objects
|
117
|
+
# @return [Array] an array of rfc1123 formatted datetime string
|
118
|
+
def self.to_rfc3339_array(date_time, hash, key)
|
119
|
+
return if date_time.nil?
|
120
|
+
|
121
|
+
hash[key] = date_time.map do |v|
|
122
|
+
if v.is_a?(BaseModel)
|
123
|
+
v.to_hash
|
124
|
+
else
|
125
|
+
v.is_a?(DateTime) ? DateTimeHelper.to_rfc3339(v) : v
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# Safely converts a rfc1123 format string into a DateTime object
|
131
|
+
# @param [String] The rfc1123 formatted datetime string
|
132
|
+
# @return [DateTime] A DateTime object
|
133
|
+
def self.from_rfc1123(date_time)
|
134
|
+
DateTime.httpdate(date_time)
|
135
|
+
end
|
136
|
+
|
137
|
+
# Safely converts a unix format string into a DateTime object
|
138
|
+
# @param [String] The unix formatted datetime string
|
139
|
+
# @return [DateTime] A DateTime object
|
140
|
+
def self.from_unix(date_time)
|
141
|
+
Time.at(date_time.to_i).utc.to_datetime
|
142
|
+
end
|
143
|
+
|
144
|
+
# Safely converts a rfc3339 format string into a DateTime object
|
145
|
+
# @param [String] The rfc3339 formatted datetime string
|
146
|
+
# @return [DateTime] A DateTime object
|
147
|
+
def self.from_rfc3339(date_time)
|
148
|
+
# missing timezone information
|
149
|
+
if date_time.end_with?('Z') || date_time.index('+')
|
150
|
+
DateTime.rfc3339(date_time)
|
151
|
+
else
|
152
|
+
DateTime.rfc3339("#{date_time}Z")
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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
|
+
# A utility to allow users to set the content-type for files
|
8
|
+
class FileWrapper
|
9
|
+
attr_reader :content_type, :file
|
10
|
+
|
11
|
+
def initialize(file, content_type: 'application/octet-stream')
|
12
|
+
@file = file
|
13
|
+
@content_type = content_type
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# whats_app_cloud_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
require 'json'
|
8
|
+
require 'faraday'
|
9
|
+
require 'certifi'
|
10
|
+
require 'logging'
|
11
|
+
|
12
|
+
require_relative 'whats_app_cloud_api/api_helper'
|
13
|
+
require_relative 'whats_app_cloud_api/client'
|
14
|
+
|
15
|
+
# Utilities
|
16
|
+
require_relative 'whats_app_cloud_api/utilities/file_wrapper'
|
17
|
+
require_relative 'whats_app_cloud_api/utilities/date_time_helper'
|
18
|
+
|
19
|
+
# Http
|
20
|
+
require_relative 'whats_app_cloud_api/http/http_call_back'
|
21
|
+
require_relative 'whats_app_cloud_api/http/http_client'
|
22
|
+
require_relative 'whats_app_cloud_api/http/faraday_client'
|
23
|
+
require_relative 'whats_app_cloud_api/http/http_method_enum'
|
24
|
+
require_relative 'whats_app_cloud_api/http/http_request'
|
25
|
+
require_relative 'whats_app_cloud_api/http/http_response'
|
26
|
+
require_relative 'whats_app_cloud_api/http/auth/o_auth2'
|
27
|
+
|
28
|
+
# Models
|
29
|
+
require_relative 'whats_app_cloud_api/models/base_model'
|
30
|
+
require_relative 'whats_app_cloud_api/models/get_phone_number_by_id_response'
|
31
|
+
require_relative 'whats_app_cloud_api/models/success_response'
|
32
|
+
require_relative 'whats_app_cloud_api/models/send_message_response'
|
33
|
+
require_relative 'whats_app_cloud_api/models/response_message'
|
34
|
+
require_relative 'whats_app_cloud_api/models/contact'
|
35
|
+
require_relative 'whats_app_cloud_api/models/currency'
|
36
|
+
require_relative 'whats_app_cloud_api/models/parameter'
|
37
|
+
require_relative 'whats_app_cloud_api/models/get_business_profile_id_response'
|
38
|
+
require_relative 'whats_app_cloud_api/models/retrieve_media_url_response'
|
39
|
+
require_relative 'whats_app_cloud_api/models/response_contact'
|
40
|
+
require_relative 'whats_app_cloud_api/models/message'
|
41
|
+
require_relative 'whats_app_cloud_api/models/address'
|
42
|
+
require_relative 'whats_app_cloud_api/models/email_object'
|
43
|
+
require_relative 'whats_app_cloud_api/models/name'
|
44
|
+
require_relative 'whats_app_cloud_api/models/org'
|
45
|
+
require_relative 'whats_app_cloud_api/models/button'
|
46
|
+
require_relative 'whats_app_cloud_api/models/footer'
|
47
|
+
require_relative 'whats_app_cloud_api/models/document'
|
48
|
+
require_relative 'whats_app_cloud_api/models/button_parameter'
|
49
|
+
require_relative 'whats_app_cloud_api/models/component'
|
50
|
+
require_relative 'whats_app_cloud_api/models/date_time_object'
|
51
|
+
require_relative 'whats_app_cloud_api/models/business_profile'
|
52
|
+
require_relative 'whats_app_cloud_api/models/upload_media'
|
53
|
+
require_relative 'whats_app_cloud_api/models/set_two_step_verification_code' \
|
54
|
+
'_request'
|
55
|
+
require_relative 'whats_app_cloud_api/models/phone_object'
|
56
|
+
require_relative 'whats_app_cloud_api/models/register_phone_request'
|
57
|
+
require_relative 'whats_app_cloud_api/models/row'
|
58
|
+
require_relative 'whats_app_cloud_api/models/audio'
|
59
|
+
require_relative 'whats_app_cloud_api/models/url_object'
|
60
|
+
require_relative 'whats_app_cloud_api/models/text'
|
61
|
+
require_relative 'whats_app_cloud_api/models/interactive'
|
62
|
+
require_relative 'whats_app_cloud_api/models/action'
|
63
|
+
require_relative 'whats_app_cloud_api/models/request_verification_code_request'
|
64
|
+
require_relative 'whats_app_cloud_api/models/body'
|
65
|
+
require_relative 'whats_app_cloud_api/models/header'
|
66
|
+
require_relative 'whats_app_cloud_api/models/verify_code_request'
|
67
|
+
require_relative 'whats_app_cloud_api/models/section'
|
68
|
+
require_relative 'whats_app_cloud_api/models/location'
|
69
|
+
require_relative 'whats_app_cloud_api/models/video'
|
70
|
+
require_relative 'whats_app_cloud_api/models/image'
|
71
|
+
require_relative 'whats_app_cloud_api/models/sticker'
|
72
|
+
require_relative 'whats_app_cloud_api/models/template'
|
73
|
+
require_relative 'whats_app_cloud_api/models/language'
|
74
|
+
require_relative 'whats_app_cloud_api/models/update_business_profile_request'
|
75
|
+
require_relative 'whats_app_cloud_api/models/upload_media_request'
|
76
|
+
require_relative 'whats_app_cloud_api/models/quality_rating_enum'
|
77
|
+
require_relative 'whats_app_cloud_api/models/interactive_type_enum'
|
78
|
+
require_relative 'whats_app_cloud_api/models/header_type_enum'
|
79
|
+
require_relative 'whats_app_cloud_api/models/parameter_type_enum'
|
80
|
+
require_relative 'whats_app_cloud_api/models/content_type_enum'
|
81
|
+
require_relative 'whats_app_cloud_api/models/personal_information_type_enum'
|
82
|
+
require_relative 'whats_app_cloud_api/models/message_type_enum'
|
83
|
+
require_relative 'whats_app_cloud_api/models/phone_type_enum'
|
84
|
+
require_relative 'whats_app_cloud_api/models/button_parameter_type_enum'
|
85
|
+
require_relative 'whats_app_cloud_api/models/sub_type_enum'
|
86
|
+
require_relative 'whats_app_cloud_api/models/vertical_enum'
|
87
|
+
require_relative 'whats_app_cloud_api/models/request_verification_code_method' \
|
88
|
+
'_enum'
|
89
|
+
require_relative 'whats_app_cloud_api/models/component_type_enum'
|
90
|
+
|
91
|
+
# Exceptions
|
92
|
+
require_relative 'whats_app_cloud_api/exceptions/api_exception'
|
93
|
+
|
94
|
+
require_relative 'whats_app_cloud_api/configuration'
|
95
|
+
|
96
|
+
# Controllers
|
97
|
+
require_relative 'whats_app_cloud_api/controllers/base_controller'
|
98
|
+
require_relative 'whats_app_cloud_api/controllers/business_profiles_controller'
|
99
|
+
require_relative 'whats_app_cloud_api/controllers/messages_controller'
|
100
|
+
require_relative 'whats_app_cloud_api/controllers/media_controller'
|
101
|
+
require_relative 'whats_app_cloud_api/controllers/phone_numbers_controller'
|
102
|
+
require_relative 'whats_app_cloud_api/controllers/registration_controller'
|
103
|
+
require_relative 'whats_app_cloud_api/controllers/two_step_verification' \
|
104
|
+
'_controller'
|