warb 0.1.2 → 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 +4 -4
- data/.rubocop.yml +5 -12
- data/README.md +9 -32
- data/Rakefile +3 -3
- data/docs/README.md +1 -4
- data/docs/components/README.md +1 -4
- data/docs/messages/README.md +1 -2
- data/docs/messages/interactive_call_to_action_url.md +9 -9
- data/docs/messages/interactive_list.md +2 -2
- data/docs/messages/interactive_reply_button.md +9 -9
- data/examples/audio.rb +10 -10
- data/examples/document.rb +34 -34
- data/examples/image.rb +22 -22
- data/examples/interactive_call_to_action_url.rb +46 -46
- data/examples/interactive_list.rb +61 -61
- data/examples/interactive_reply_button.rb +43 -43
- data/examples/location.rb +32 -32
- data/examples/location_request.rb +11 -11
- data/examples/message.rb +8 -8
- data/examples/sticker.rb +10 -10
- data/examples/video.rb +22 -22
- data/examples/webhook.rb +42 -44
- data/lib/warb/client.rb +5 -7
- data/lib/warb/components/action.rb +8 -12
- data/lib/warb/configuration.rb +1 -4
- data/lib/warb/connection.rb +9 -15
- data/lib/warb/dispatcher.rb +3 -4
- data/lib/warb/dispatcher_concern.rb +0 -6
- data/lib/warb/indicator_dispatcher.rb +4 -4
- data/lib/warb/media_dispatcher.rb +10 -10
- data/lib/warb/resources/audio.rb +1 -1
- data/lib/warb/resources/contact.rb +20 -22
- data/lib/warb/resources/document.rb +1 -1
- data/lib/warb/resources/flow.rb +8 -10
- data/lib/warb/resources/image.rb +1 -1
- data/lib/warb/resources/interactive_call_to_action_url.rb +8 -10
- data/lib/warb/resources/interactive_list.rb +5 -7
- data/lib/warb/resources/interactive_reply_button.rb +8 -10
- data/lib/warb/resources/location.rb +1 -11
- data/lib/warb/resources/location_request.rb +3 -5
- data/lib/warb/resources/reaction.rb +1 -1
- data/lib/warb/resources/resource.rb +4 -12
- data/lib/warb/resources/sticker.rb +1 -1
- data/lib/warb/resources/text.rb +3 -21
- data/lib/warb/resources/video.rb +1 -1
- data/lib/warb/utils.rb +1 -3
- data/lib/warb/version.rb +1 -1
- data/lib/warb.rb +31 -50
- metadata +3 -29
- data/docs/components/button.md +0 -61
- data/docs/components/copy_code_button.md +0 -57
- data/docs/components/url_button.md +0 -57
- data/docs/messages/template.md +0 -327
- data/docs/resources/currency.md +0 -22
- data/docs/resources/date_time.md +0 -11
- data/docs/resources/index.md +0 -14
- data/docs/resources/text.md +0 -9
- data/lib/warb/components/button.rb +0 -29
- data/lib/warb/components/component.rb +0 -19
- data/lib/warb/components/copy_code_button.rb +0 -30
- data/lib/warb/components/quick_reply_button.rb +0 -15
- data/lib/warb/components/url_button.rb +0 -30
- data/lib/warb/components/voice_call_button.rb +0 -15
- data/lib/warb/errors.rb +0 -27
- data/lib/warb/language.rb +0 -8
- data/lib/warb/resources/currency.rb +0 -47
- data/lib/warb/resources/date_time.rb +0 -34
- data/lib/warb/resources/template.rb +0 -167
- data/lib/warb/response.rb +0 -33
- data/lib/warb/response_error_handler.rb +0 -42
- data/lib/warb/template_dispatcher.rb +0 -12
data/lib/warb/connection.rb
CHANGED
|
@@ -8,34 +8,28 @@ module Warb
|
|
|
8
8
|
@client = client
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
# rubocop:disable Metrics/ParameterLists
|
|
12
11
|
def send_request(http_method:, endpoint:, url: nil, data: {}, headers: {}, multipart: false,
|
|
13
12
|
endpoint_prefix: :sender_id)
|
|
14
|
-
conn =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Warb::ResponseErrorHandler.new(response.body, response.status).handle
|
|
20
|
-
end
|
|
21
|
-
rescue Faraday::Error => e
|
|
22
|
-
msg = e.response_body || e.message
|
|
23
|
-
raise RequestError, msg
|
|
13
|
+
conn = set_connection(url:, multipart:)
|
|
14
|
+
conn.send(http_method, handle_endpoint(endpoint:, endpoint_prefix:), data, headers)
|
|
15
|
+
rescue StandardError => e
|
|
16
|
+
@client.logger.error e.inspect
|
|
17
|
+
e.response
|
|
24
18
|
end
|
|
25
|
-
# rubocop:enable Metrics/ParameterLists
|
|
26
19
|
|
|
27
20
|
private
|
|
28
21
|
|
|
29
|
-
def
|
|
30
|
-
url ||=
|
|
22
|
+
def set_connection(url:, multipart:)
|
|
23
|
+
url ||= "https://graph.facebook.com/v22.0"
|
|
31
24
|
|
|
32
25
|
Faraday.new(url) do |conn|
|
|
33
26
|
conn.request(:multipart) if multipart
|
|
34
27
|
conn.request(:url_encoded) if multipart
|
|
35
28
|
conn.request(:json)
|
|
36
29
|
conn.response(:json)
|
|
37
|
-
conn.headers[
|
|
30
|
+
conn.headers["Authorization"] = "Bearer #{@client.access_token}" unless @client.access_token.nil?
|
|
38
31
|
conn.adapter(@client.adapter)
|
|
32
|
+
conn.response :raise_error
|
|
39
33
|
end
|
|
40
34
|
end
|
|
41
35
|
|
data/lib/warb/dispatcher.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
1
|
module Warb
|
|
4
2
|
class Dispatcher
|
|
5
3
|
def initialize(klass, client)
|
|
@@ -8,10 +6,11 @@ module Warb
|
|
|
8
6
|
end
|
|
9
7
|
|
|
10
8
|
def dispatch(recipient_number, reply_to: nil, **args, &block)
|
|
11
|
-
resource = block_given? ? @klass.new
|
|
9
|
+
resource = block_given? ? @klass.new.tap(&block) : @klass.new(**args)
|
|
12
10
|
|
|
13
11
|
data = resource.call(recipient_number, reply_to:)
|
|
14
|
-
|
|
12
|
+
|
|
13
|
+
@client.post("messages", data)
|
|
15
14
|
end
|
|
16
15
|
end
|
|
17
16
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
1
|
module Warb
|
|
4
2
|
module DispatcherConcern
|
|
5
3
|
def message
|
|
@@ -58,10 +56,6 @@ module Warb
|
|
|
58
56
|
@contact ||= Dispatcher.new Resources::Contact, dispatcher
|
|
59
57
|
end
|
|
60
58
|
|
|
61
|
-
def template
|
|
62
|
-
@template ||= TemplateDispatcher.new Resources::Template, dispatcher
|
|
63
|
-
end
|
|
64
|
-
|
|
65
59
|
def flow
|
|
66
60
|
@flow ||= Dispatcher.new Resources::Flow, dispatcher
|
|
67
61
|
end
|
|
@@ -7,15 +7,15 @@ module Warb
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def send_typing_indicator(message_id)
|
|
10
|
-
data = common_indicator_params(message_id).merge(typing_indicator: { type:
|
|
10
|
+
data = common_indicator_params(message_id).merge(typing_indicator: { type: "text" })
|
|
11
11
|
|
|
12
|
-
@client.post(
|
|
12
|
+
@client.post("messages", data)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def mark_as_read(message_id)
|
|
16
16
|
data = common_indicator_params(message_id)
|
|
17
17
|
|
|
18
|
-
@client.post(
|
|
18
|
+
@client.post("messages", data)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
private
|
|
@@ -24,7 +24,7 @@ module Warb
|
|
|
24
24
|
{
|
|
25
25
|
messaging_product: Warb::MESSAGING_PRODUCT,
|
|
26
26
|
message_id: message_id,
|
|
27
|
-
status:
|
|
27
|
+
status: "read"
|
|
28
28
|
}
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
1
|
module Warb
|
|
4
2
|
class MediaDispatcher < Dispatcher
|
|
5
|
-
def upload(file_path:, file_type:
|
|
3
|
+
def upload(file_path:, file_type: "text/plain")
|
|
6
4
|
file = Faraday::UploadIO.new(file_path, file_type)
|
|
7
5
|
|
|
8
6
|
data = { file:, messaging_product: Warb::MESSAGING_PRODUCT }
|
|
9
7
|
|
|
10
|
-
@client.post(
|
|
8
|
+
@client.post("media", data, multipart: true).body["id"]
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
def download(file_path:, media_url: nil, media_id: nil)
|
|
14
|
-
media_url ||= retrieve(media_id)[
|
|
12
|
+
media_url ||= retrieve(media_id)["url"]
|
|
15
13
|
|
|
16
14
|
resp = downloaded_media_response(media_url)
|
|
17
15
|
|
|
18
|
-
File.
|
|
16
|
+
File.open(file_path, "wb") do |file|
|
|
17
|
+
file.write(resp.body)
|
|
18
|
+
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def retrieve(media_id)
|
|
@@ -25,9 +25,9 @@ module Warb
|
|
|
25
25
|
def delete(media_id)
|
|
26
26
|
response_body = @client.delete(media_id, endpoint_prefix: nil).body
|
|
27
27
|
|
|
28
|
-
return response_body[
|
|
28
|
+
return response_body["success"] if response_body["success"]
|
|
29
29
|
|
|
30
|
-
response_body[
|
|
30
|
+
response_body["error"]["message"]
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
private
|
|
@@ -36,9 +36,9 @@ module Warb
|
|
|
36
36
|
uri = URI(url)
|
|
37
37
|
|
|
38
38
|
request = Net::HTTP::Get.new(uri)
|
|
39
|
-
request[
|
|
39
|
+
request["Authorization"] = "Bearer #{@client.access_token}"
|
|
40
40
|
|
|
41
|
-
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme ==
|
|
41
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
|
|
42
42
|
http.request(request)
|
|
43
43
|
end
|
|
44
44
|
end
|
data/lib/warb/resources/audio.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
8
|
-
require_relative
|
|
3
|
+
require_relative "../components/address"
|
|
4
|
+
require_relative "../components/name"
|
|
5
|
+
require_relative "../components/email"
|
|
6
|
+
require_relative "../components/org"
|
|
7
|
+
require_relative "../components/phone"
|
|
8
|
+
require_relative "../components/url"
|
|
9
9
|
|
|
10
10
|
module Warb
|
|
11
11
|
module Resources
|
|
@@ -13,7 +13,7 @@ module Warb
|
|
|
13
13
|
attr_accessor :addresses, :emails, :phones, :urls, :name, :org, :birthday
|
|
14
14
|
|
|
15
15
|
def initialize(**params)
|
|
16
|
-
super
|
|
16
|
+
super(**params)
|
|
17
17
|
|
|
18
18
|
@org = @params[:org]
|
|
19
19
|
@name = @params[:name]
|
|
@@ -24,10 +24,9 @@ module Warb
|
|
|
24
24
|
@urls = @params.fetch(:urls, [])
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
# rubocop:disable Metrics/MethodLength
|
|
28
27
|
def build_payload
|
|
29
28
|
{
|
|
30
|
-
type:
|
|
29
|
+
type: "contacts",
|
|
31
30
|
contacts: [
|
|
32
31
|
{
|
|
33
32
|
birthday: birthday,
|
|
@@ -41,50 +40,49 @@ module Warb
|
|
|
41
40
|
]
|
|
42
41
|
}
|
|
43
42
|
end
|
|
44
|
-
# rubocop:enable Metrics/MethodLength
|
|
45
43
|
|
|
46
|
-
def add_address(**params, &)
|
|
44
|
+
def add_address(**params, &block)
|
|
47
45
|
address = Components::Address.new(**params)
|
|
48
46
|
|
|
49
47
|
@addresses << address
|
|
50
48
|
|
|
51
|
-
block_given? ? address.tap(&) : address
|
|
49
|
+
block_given? ? address.tap(&block) : address
|
|
52
50
|
end
|
|
53
51
|
|
|
54
|
-
def add_email(**params, &)
|
|
52
|
+
def add_email(**params, &block)
|
|
55
53
|
email = Components::Email.new(**params)
|
|
56
54
|
|
|
57
55
|
@emails << email
|
|
58
56
|
|
|
59
|
-
block_given? ? email.tap(&) : email
|
|
57
|
+
block_given? ? email.tap(&block) : email
|
|
60
58
|
end
|
|
61
59
|
|
|
62
|
-
def add_phone(**params, &)
|
|
60
|
+
def add_phone(**params, &block)
|
|
63
61
|
phone = Components::Phone.new(**params)
|
|
64
62
|
|
|
65
63
|
@phones << phone
|
|
66
64
|
|
|
67
|
-
block_given? ? phone.tap(&) : phone
|
|
65
|
+
block_given? ? phone.tap(&block) : phone
|
|
68
66
|
end
|
|
69
67
|
|
|
70
|
-
def add_url(**params, &)
|
|
68
|
+
def add_url(**params, &block)
|
|
71
69
|
url = Components::URL.new(**params)
|
|
72
70
|
|
|
73
71
|
@urls << url
|
|
74
72
|
|
|
75
|
-
block_given? ? url.tap(&) : url
|
|
73
|
+
block_given? ? url.tap(&block) : url
|
|
76
74
|
end
|
|
77
75
|
|
|
78
|
-
def build_name(**params, &)
|
|
76
|
+
def build_name(**params, &block)
|
|
79
77
|
@name = Warb::Components::Name.new(**params)
|
|
80
78
|
|
|
81
|
-
block_given? ? @name.tap(&) : @name
|
|
79
|
+
block_given? ? @name.tap(&block) : @name
|
|
82
80
|
end
|
|
83
81
|
|
|
84
|
-
def build_org(**params, &)
|
|
82
|
+
def build_org(**params, &block)
|
|
85
83
|
@org = Warb::Components::Org.new(**params)
|
|
86
84
|
|
|
87
|
-
block_given? ? @org.tap(&) : @org
|
|
85
|
+
block_given? ? @org.tap(&block) : @org
|
|
88
86
|
end
|
|
89
87
|
end
|
|
90
88
|
end
|
data/lib/warb/resources/flow.rb
CHANGED
|
@@ -5,23 +5,22 @@ module Warb
|
|
|
5
5
|
class Flow < Resource
|
|
6
6
|
attr_accessor :flow_id, :screen
|
|
7
7
|
|
|
8
|
-
# rubocop:disable Metrics/MethodLength
|
|
9
8
|
def build_payload
|
|
10
9
|
{
|
|
11
|
-
type:
|
|
10
|
+
type: "interactive",
|
|
12
11
|
interactive: {
|
|
13
|
-
type:
|
|
12
|
+
type: "flow",
|
|
14
13
|
body: {
|
|
15
|
-
text:
|
|
14
|
+
text: "Not shown in draft mode"
|
|
16
15
|
},
|
|
17
16
|
action: {
|
|
18
|
-
name:
|
|
17
|
+
name: "flow",
|
|
19
18
|
parameters: {
|
|
20
|
-
flow_message_version:
|
|
21
|
-
flow_action:
|
|
19
|
+
flow_message_version: "3",
|
|
20
|
+
flow_action: "navigate",
|
|
22
21
|
flow_id: flow_id || @params[:flow_id],
|
|
23
|
-
flow_cta:
|
|
24
|
-
mode:
|
|
22
|
+
flow_cta: "Not shown in draft mode",
|
|
23
|
+
mode: "draft",
|
|
25
24
|
flow_action_payload: {
|
|
26
25
|
screen: screen || @params[:screen]
|
|
27
26
|
}
|
|
@@ -30,7 +29,6 @@ module Warb
|
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
end
|
|
33
|
-
# rubocop:enable Metrics/MethodLength
|
|
34
32
|
end
|
|
35
33
|
end
|
|
36
34
|
end
|
data/lib/warb/resources/image.rb
CHANGED
|
@@ -5,12 +5,11 @@ module Warb
|
|
|
5
5
|
class InteractiveCallToActionUrl < Resource
|
|
6
6
|
attr_accessor :header, :body, :footer, :action
|
|
7
7
|
|
|
8
|
-
# rubocop:disable Metrics/MethodLength
|
|
9
8
|
def build_payload
|
|
10
9
|
{
|
|
11
|
-
type:
|
|
10
|
+
type: "interactive",
|
|
12
11
|
interactive: {
|
|
13
|
-
type:
|
|
12
|
+
type: "cta_url",
|
|
14
13
|
header: header || @params[:header]&.to_h,
|
|
15
14
|
body: {
|
|
16
15
|
text: body || @params[:body]
|
|
@@ -22,28 +21,27 @@ module Warb
|
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
end
|
|
25
|
-
# rubocop:enable Metrics/MethodLength
|
|
26
24
|
|
|
27
|
-
def
|
|
25
|
+
def set_text_header(text)
|
|
28
26
|
@header = Warb::Resources::Text.new(text:).build_header
|
|
29
27
|
end
|
|
30
28
|
|
|
31
|
-
def
|
|
29
|
+
def set_image_header(link: nil)
|
|
32
30
|
@header = Warb::Resources::Image.new(link:).build_header
|
|
33
31
|
end
|
|
34
32
|
|
|
35
|
-
def
|
|
33
|
+
def set_video_header(link: nil)
|
|
36
34
|
@header = Warb::Resources::Video.new(link:).build_header
|
|
37
35
|
end
|
|
38
36
|
|
|
39
|
-
def
|
|
37
|
+
def set_document_header(link: nil, filename: nil)
|
|
40
38
|
@header = Warb::Resources::Document.new(link:, filename:).build_header
|
|
41
39
|
end
|
|
42
40
|
|
|
43
|
-
def build_action(**params, &)
|
|
41
|
+
def build_action(**params, &block)
|
|
44
42
|
@action = Warb::Components::CTAAction.new(**params)
|
|
45
43
|
|
|
46
|
-
block_given? ? @action.tap(&) : @action
|
|
44
|
+
block_given? ? @action.tap(&block) : @action
|
|
47
45
|
end
|
|
48
46
|
end
|
|
49
47
|
end
|
|
@@ -5,12 +5,11 @@ module Warb
|
|
|
5
5
|
class InteractiveList < Resource
|
|
6
6
|
attr_accessor :header, :body, :footer, :action
|
|
7
7
|
|
|
8
|
-
# rubocop:disable Metrics/MethodLength
|
|
9
8
|
def build_payload
|
|
10
9
|
{
|
|
11
|
-
type:
|
|
10
|
+
type: "interactive",
|
|
12
11
|
interactive: {
|
|
13
|
-
type:
|
|
12
|
+
type: "list",
|
|
14
13
|
header: header || @params[:header]&.to_h,
|
|
15
14
|
body: {
|
|
16
15
|
text: body || @params[:body]
|
|
@@ -22,16 +21,15 @@ module Warb
|
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
end
|
|
25
|
-
# rubocop:enable Metrics/MethodLength
|
|
26
24
|
|
|
27
|
-
def
|
|
25
|
+
def set_text_header(text)
|
|
28
26
|
@header = Warb::Resources::Text.new(text:).build_header
|
|
29
27
|
end
|
|
30
28
|
|
|
31
|
-
def build_action(**params, &)
|
|
29
|
+
def build_action(**params, &block)
|
|
32
30
|
@action = Warb::Components::ListAction.new(**params)
|
|
33
31
|
|
|
34
|
-
block_given? ? @action.tap(&) : @action
|
|
32
|
+
block_given? ? @action.tap(&block) : @action
|
|
35
33
|
end
|
|
36
34
|
end
|
|
37
35
|
end
|
|
@@ -5,12 +5,11 @@ module Warb
|
|
|
5
5
|
class InteractiveReplyButton < Resource
|
|
6
6
|
attr_accessor :header, :body, :footer, :action
|
|
7
7
|
|
|
8
|
-
# rubocop:disable Metrics/MethodLength
|
|
9
8
|
def build_payload
|
|
10
9
|
{
|
|
11
|
-
type:
|
|
10
|
+
type: "interactive",
|
|
12
11
|
interactive: {
|
|
13
|
-
type:
|
|
12
|
+
type: "button",
|
|
14
13
|
header: header || @params[:header]&.to_h,
|
|
15
14
|
body: {
|
|
16
15
|
text: body || @params[:body]
|
|
@@ -22,28 +21,27 @@ module Warb
|
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
end
|
|
25
|
-
# rubocop:enable Metrics/MethodLength
|
|
26
24
|
|
|
27
|
-
def
|
|
25
|
+
def set_text_header(text)
|
|
28
26
|
@header = Warb::Resources::Text.new(text:).build_header
|
|
29
27
|
end
|
|
30
28
|
|
|
31
|
-
def
|
|
29
|
+
def set_image_header(media_id: nil, link: nil)
|
|
32
30
|
@header = Warb::Resources::Image.new(media_id:, link:).build_header
|
|
33
31
|
end
|
|
34
32
|
|
|
35
|
-
def
|
|
33
|
+
def set_video_header(media_id: nil, link: nil)
|
|
36
34
|
@header = Warb::Resources::Video.new(media_id:, link:).build_header
|
|
37
35
|
end
|
|
38
36
|
|
|
39
|
-
def
|
|
37
|
+
def set_document_header(media_id: nil, link: nil, filename: nil)
|
|
40
38
|
@header = Warb::Resources::Document.new(media_id:, link:, filename:).build_header
|
|
41
39
|
end
|
|
42
40
|
|
|
43
|
-
def build_action(**params, &)
|
|
41
|
+
def build_action(**params, &block)
|
|
44
42
|
@action = Warb::Components::ReplyButtonAction.new(**params)
|
|
45
43
|
|
|
46
|
-
block_given? ? @action.tap(&) : @action
|
|
44
|
+
block_given? ? @action.tap(&block) : @action
|
|
47
45
|
end
|
|
48
46
|
end
|
|
49
47
|
end
|
|
@@ -5,19 +5,9 @@ module Warb
|
|
|
5
5
|
class Location < Resource
|
|
6
6
|
attr_accessor :latitude, :longitude, :name, :address
|
|
7
7
|
|
|
8
|
-
def build_header
|
|
9
|
-
common_location_params
|
|
10
|
-
end
|
|
11
|
-
|
|
12
8
|
def build_payload
|
|
13
|
-
common_location_params
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def common_location_params
|
|
19
9
|
{
|
|
20
|
-
type:
|
|
10
|
+
type: "location",
|
|
21
11
|
location: {
|
|
22
12
|
latitude: latitude || @params[:latitude],
|
|
23
13
|
longitude: longitude || @params[:longitude],
|
|
@@ -5,22 +5,20 @@ module Warb
|
|
|
5
5
|
class LocationRequest < Resource
|
|
6
6
|
attr_accessor :body_text
|
|
7
7
|
|
|
8
|
-
# rubocop:disable Metrics/MethodLength
|
|
9
8
|
def build_payload
|
|
10
9
|
{
|
|
11
|
-
type:
|
|
10
|
+
type: "interactive",
|
|
12
11
|
interactive: {
|
|
13
|
-
type:
|
|
12
|
+
type: "location_request_message",
|
|
14
13
|
body: {
|
|
15
14
|
text: body_text || @params[:body_text]
|
|
16
15
|
},
|
|
17
16
|
action: {
|
|
18
|
-
name:
|
|
17
|
+
name: "send_location"
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
end
|
|
23
|
-
# rubocop:enable Metrics/MethodLength
|
|
24
22
|
end
|
|
25
23
|
end
|
|
26
24
|
end
|
|
@@ -19,27 +19,19 @@ module Warb
|
|
|
19
19
|
raise NotImplementedError
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def
|
|
22
|
+
def set_text_header
|
|
23
23
|
raise NotImplementedError
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def
|
|
26
|
+
def set_image_header
|
|
27
27
|
raise NotImplementedError
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def
|
|
30
|
+
def set_video_header
|
|
31
31
|
raise NotImplementedError
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def
|
|
35
|
-
raise NotImplementedError
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def add_video_header
|
|
39
|
-
raise NotImplementedError
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def add_document_header
|
|
34
|
+
def set_document_header
|
|
43
35
|
raise NotImplementedError
|
|
44
36
|
end
|
|
45
37
|
|
data/lib/warb/resources/text.rb
CHANGED
|
@@ -3,18 +3,15 @@
|
|
|
3
3
|
module Warb
|
|
4
4
|
module Resources
|
|
5
5
|
class Text < Resource
|
|
6
|
-
attr_accessor :content, :text, :message, :preview_url
|
|
6
|
+
attr_accessor :content, :text, :message, :preview_url
|
|
7
7
|
|
|
8
8
|
def build_header
|
|
9
|
-
{ type:
|
|
10
|
-
parameter_name ||= @params[:parameter_name]
|
|
11
|
-
header[:parameter_name] = parameter_name unless parameter_name.nil?
|
|
12
|
-
end
|
|
9
|
+
{ type: "text", text: message_per_priority }
|
|
13
10
|
end
|
|
14
11
|
|
|
15
12
|
def build_payload
|
|
16
13
|
{
|
|
17
|
-
type:
|
|
14
|
+
type: "text",
|
|
18
15
|
text: {
|
|
19
16
|
preview_url: preview_url || @params[:preview_url],
|
|
20
17
|
body: message_per_priority
|
|
@@ -22,21 +19,6 @@ module Warb
|
|
|
22
19
|
}
|
|
23
20
|
end
|
|
24
21
|
|
|
25
|
-
def build_template_named_parameter(parameter_name)
|
|
26
|
-
{
|
|
27
|
-
type: 'text',
|
|
28
|
-
text: message_per_priority,
|
|
29
|
-
parameter_name: parameter_name
|
|
30
|
-
}
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def build_template_positional_parameter
|
|
34
|
-
{
|
|
35
|
-
type: 'text',
|
|
36
|
-
text: message_per_priority
|
|
37
|
-
}
|
|
38
|
-
end
|
|
39
|
-
|
|
40
22
|
private
|
|
41
23
|
|
|
42
24
|
def message_per_priority
|
data/lib/warb/resources/video.rb
CHANGED
data/lib/warb/utils.rb
CHANGED
data/lib/warb/version.rb
CHANGED