messenger_client 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/messenger_client/client.rb +22 -14
- data/lib/messenger_client/menu.rb +0 -2
- data/lib/messenger_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff07568123e58ad73684f2dce0b4026553cad618
|
4
|
+
data.tar.gz: b37605c98b827b030002682eef0833bb1850e0d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef412c0646b4ca7f976b034c52931be12cdc60ba1c17082c5ec7c50877e9df168ed14d4d8fda69ade4e18cf7c808795e5097adf66e01e574e1702ed6df4679bb
|
7
|
+
data.tar.gz: 6da52d83c5638e13bd721f384719f75ca1f5deaf58f6785d2f0dee77b9513c60c155bb7191c4ed5698fde165b5591c12a7f8f1d2617f5d7ac2b606f00a254909
|
@@ -1,20 +1,15 @@
|
|
1
1
|
module MessengerClient
|
2
2
|
class Client
|
3
|
-
URL_TEMPLATE = "https://graph.facebook.com/v2.6/me
|
3
|
+
URL_TEMPLATE = "https://graph.facebook.com/v2.6/me/%s"
|
4
4
|
|
5
5
|
def initialize(page_access_token)
|
6
6
|
@page_access_token = page_access_token
|
7
7
|
@logger = MessengerClient::Config.logger
|
8
8
|
end
|
9
9
|
|
10
|
-
def setup_menu(buttons)
|
11
|
-
menu = Menu.new(buttons)
|
12
|
-
post(menu.to_json)
|
13
|
-
end
|
14
|
-
|
15
10
|
def get_started(postback="get_started")
|
16
11
|
gs = GetStarted.new(postback)
|
17
|
-
|
12
|
+
profile_post(gs.to_json)
|
18
13
|
end
|
19
14
|
|
20
15
|
def text(recipient_id:, text:)
|
@@ -83,8 +78,8 @@ module MessengerClient
|
|
83
78
|
}
|
84
79
|
payload.merge!(message: data) unless data.nil?
|
85
80
|
payload.merge!(opts)
|
86
|
-
res = Typhoeus.post(
|
87
|
-
@logger.debug(
|
81
|
+
res = Typhoeus.post(message_url, body: json(payload), params: { access_token: @page_access_token }, headers: headers)
|
82
|
+
@logger.debug(message_url) if ENV["DEBUG"]
|
88
83
|
@logger.debug(json(payload)) if ENV["DEBUG"]
|
89
84
|
@logger.debug(res.body) if ENV["DEBUG"]
|
90
85
|
@logger.debug(res.headers) if ENV["DEBUG"]
|
@@ -92,8 +87,17 @@ module MessengerClient
|
|
92
87
|
end
|
93
88
|
|
94
89
|
def post(payload)
|
95
|
-
res = Typhoeus.post(
|
96
|
-
@logger.debug(
|
90
|
+
res = Typhoeus.post(message_url, body: json(payload), params: { access_token: @page_access_token }, headers: headers)
|
91
|
+
@logger.debug(message_url) if ENV["DEBUG"]
|
92
|
+
@logger.debug(json(payload)) if ENV["DEBUG"]
|
93
|
+
@logger.debug(res.body) if ENV["DEBUG"]
|
94
|
+
@logger.debug(res.headers) if ENV["DEBUG"]
|
95
|
+
res
|
96
|
+
end
|
97
|
+
|
98
|
+
def profile_post(payload)
|
99
|
+
res = Typhoeus.post(profile_url, body: json(payload), params: { access_token: @page_access_token }, headers: headers)
|
100
|
+
@logger.debug(profile_url) if ENV["DEBUG"]
|
97
101
|
@logger.debug(json(payload)) if ENV["DEBUG"]
|
98
102
|
@logger.debug(res.body) if ENV["DEBUG"]
|
99
103
|
@logger.debug(res.headers) if ENV["DEBUG"]
|
@@ -102,8 +106,12 @@ module MessengerClient
|
|
102
106
|
|
103
107
|
private
|
104
108
|
|
105
|
-
def
|
106
|
-
URL_TEMPLATE %
|
109
|
+
def message_url
|
110
|
+
URL_TEMPLATE % "messages"
|
111
|
+
end
|
112
|
+
|
113
|
+
def profile_url
|
114
|
+
URL_TEMPLATE % "messenger_profile"
|
107
115
|
end
|
108
116
|
|
109
117
|
def json(payload)
|
@@ -112,7 +120,7 @@ module MessengerClient
|
|
112
120
|
|
113
121
|
def headers
|
114
122
|
{ 'Accept-Encoding' => 'application/json',
|
115
|
-
'Content-Type'
|
123
|
+
'Content-Type' => 'application/json' }
|
116
124
|
end
|
117
125
|
end
|
118
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: messenger_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Cruz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|