facebook-messenger 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbeade2fa81a2b697fa7635b0fbe0e4bead497dadce5191405efa0b1eab4ad3c
4
- data.tar.gz: efadea4a20f49814f28148993b2e87b5ccd310c2d513f8feea4a1f62526118ce
3
+ metadata.gz: ee1571f2dd5f4579a76e761c4145f643bec11dea790dd05b6afd1495f615003b
4
+ data.tar.gz: e8e92206d1fb3158f203a42790efcd4b8097c14d4d27d4a6cfe9ca8caa1418e4
5
5
  SHA512:
6
- metadata.gz: 2222ed8d1a46dab7dd554017ffb7a7a3619476cc688f81ce7acd303d50cec9f7d0da3bbe642bd548502ec62ffafde5516d5fde6cc04f840d22c4123c6b99d2e1
7
- data.tar.gz: 014b6a913f77baf595d2672a97d9c13e8804c63862e7d7fb84ff50f51e5b34ee1fc31da1bf1446ddbe3330cb3d206b88b3871c119556902b63ffc5496b492b1e
6
+ metadata.gz: 224306905134c4d0fbc5b58f513e3ae84d670154573817e88bd5d3e66d16acd530bcadfe22abe2075583616f95e962f8e3d1f0fb46e82d9476fbd44142796797
7
+ data.tar.gz: a506fca934e229704672e0be3a1eaacac90a4dbc59799fe5122432ce75b5d0ae22cc56885301c5b2d40cea8363cfcdb9f940c5f70f3f026531d8d41efbcea8ec
data/README.md CHANGED
@@ -4,9 +4,10 @@
4
4
 
5
5
 
6
6
  [![Gem Version](https://img.shields.io/gem/v/facebook-messenger.svg?style=flat)](https://rubygems.org/gems/facebook-messenger)
7
- [![Build Status](https://img.shields.io/travis/hyperoslo/facebook-messenger.svg?style=flat)](https://travis-ci.org/jgorset/facebook-messenger)
8
- [![Code Climate](https://img.shields.io/codeclimate/github/hyperoslo/facebook-messenger.svg?style=flat)](https://codeclimate.com/github/jgorset/facebook-messenger)
9
- [![Coverage Status](https://img.shields.io/coveralls/hyperoslo/facebook-messenger.svg?style=flat)](https://coveralls.io/r/jgorset/facebook-messenger)
7
+ [![Gem Downloads](https://img.shields.io/gem/dt/facebook-messenger.svg)](https://rubygems.org/gems/facebook-messenger)
8
+ [![Build Status](https://img.shields.io/travis/jgorset/facebook-messenger.svg?style=flat)](https://travis-ci.org/jgorset/facebook-messenger)
9
+ [![Code Climate](https://img.shields.io/codeclimate/maintainability/jgorset/facebook-messenger.svg)](https://codeclimate.com/github/jgorset/facebook-messenger)
10
+ [![Coverage Status](https://coveralls.io/repos/github/jgorset/facebook-messenger/badge.svg?branch=master)](https://coveralls.io/github/jgorset/facebook-messenger?branch=master)
10
11
  [![Documentation Coverage](http://inch-ci.org/github/jgorset/facebook-messenger.svg?branch=master)](http://inch-ci.org/github/jgorset/facebook-messenger)
11
12
 
12
13
  ## Installation
@@ -199,6 +200,23 @@ Bot.on :message_request do |message_request|
199
200
  end
200
201
  ```
201
202
 
203
+ ##### Record instant game progress
204
+
205
+ You can keep track of instant game progress:
206
+
207
+ ```ruby
208
+ Bot.on :game_play do |game_play|
209
+ game_play.sender # => { 'id' => '1008372609250235' }
210
+ game_play.recipient # => { 'id' => '2015573629214912' }
211
+ game_play.sent_at # => 2016-04-22 21:30:36 +0200
212
+ game_play.game # => "<GAME-APP-ID>"
213
+ game_play.player # => "<PLAYER-ID>"
214
+ game_play.context # => { 'context_type' => "<CONTEXT-TYPE:SOLO|THREAD>", 'context_id' => "<CONTEXT-ID>" }
215
+ game_play.score # => 100
216
+ game_play.payload # => "<PAYLOAD>"
217
+ end
218
+ ```
219
+
202
220
  #### Send to Facebook
203
221
 
204
222
  When the human clicks the [Send to Messenger button][send-to-messenger-plugin]
@@ -29,6 +29,7 @@ module Facebook
29
29
  payment
30
30
  policy_enforcement
31
31
  pass_thread_control
32
+ game_play
32
33
  ].freeze
33
34
 
34
35
  class << self
@@ -11,6 +11,7 @@ require 'facebook/messenger/incoming/referral'
11
11
  require 'facebook/messenger/incoming/payment'
12
12
  require 'facebook/messenger/incoming/policy_enforcement'
13
13
  require 'facebook/messenger/incoming/pass_thread_control'
14
+ require 'facebook/messenger/incoming/game_play'
14
15
 
15
16
  module Facebook
16
17
  module Messenger
@@ -33,7 +34,8 @@ module Facebook
33
34
  'message_request' => MessageRequest,
34
35
  'payment' => Payment,
35
36
  'policy_enforcement' => PolicyEnforcement,
36
- 'pass_thread_control' => PassThreadControl
37
+ 'pass_thread_control' => PassThreadControl,
38
+ 'game_play' => GamePlay
37
39
  }.freeze
38
40
 
39
41
  # Parse the given payload and create new object of class related
@@ -0,0 +1,39 @@
1
+ module Facebook
2
+ module Messenger
3
+ module Incoming
4
+ # The GamePlay class represents an incoming Facebook Messenger
5
+ # game_play events.
6
+ # @see https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_game_plays
7
+ class GamePlay
8
+ include Facebook::Messenger::Incoming::Common
9
+
10
+ def game_play
11
+ @messaging['game_play']
12
+ end
13
+
14
+ def payload
15
+ game_play['payload']
16
+ end
17
+
18
+ def score
19
+ game_play['score']
20
+ end
21
+
22
+ def game
23
+ game_play['game_id']
24
+ end
25
+
26
+ def player
27
+ game_play['player_id']
28
+ end
29
+
30
+ def context
31
+ {
32
+ context_id: game_play['context_id'],
33
+ context_type: game_play['context_type']
34
+ }
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -2,6 +2,6 @@ module Facebook
2
2
  module Messenger
3
3
  #
4
4
  # @return [String] Define the version of gem.
5
- VERSION = '1.3.0'.freeze
5
+ VERSION = '1.4.0'.freeze
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook-messenger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Gorset
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-16 00:00:00.000000000 Z
11
+ date: 2019-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -183,6 +183,7 @@ files:
183
183
  - lib/facebook/messenger/incoming/account_linking.rb
184
184
  - lib/facebook/messenger/incoming/common.rb
185
185
  - lib/facebook/messenger/incoming/delivery.rb
186
+ - lib/facebook/messenger/incoming/game_play.rb
186
187
  - lib/facebook/messenger/incoming/message.rb
187
188
  - lib/facebook/messenger/incoming/message_echo.rb
188
189
  - lib/facebook/messenger/incoming/message_request.rb