Class: MessageQuickly::Api::AccountLink

Inherits:
Base
  • Object
show all
Defined in:
lib/message_quickly/api/account_link.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client, #initialize

Constructor Details

This class inherits a constructor from MessageQuickly::Api::Base

Class Method Details

.page_scoped_id(account_linking_token) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/message_quickly/api/account_link.rb', line 5

def self.page_scoped_id()
  # curl -X GET "https://graph.facebook.com/v2.6/me?access_token=PAGE_ACCESS_TOKEN    #   &fields=recipient    #   &account_linking_token=ACCOUNT_LINKING_TOKEN"

  # {
  #   "id": "PAGE_ID",
  #   "recipient": "PSID"
  # }
  AccountLink.new.page_scoped_id()
end


22
23
24
25
26
27
28
29
30
31
# File 'lib/message_quickly/api/account_link.rb', line 22

def self.(page_scoped_id)
  # curl -X POST -H "Content-Type: application/json" -d '{
  #    "psid":"PSID"
  # }' "https://graph.facebook.com/v2.6/me/unlink_accounts?access_token=PAGE_ACCESS_TOKEN"

  # {
  #   "result": "unlink account success"
  # }
  AccountLink.new.(page_scoped_id)
end

Instance Method Details

#page_scoped_id(account_linking_token) ⇒ Object



17
18
19
20
# File 'lib/message_quickly/api/account_link.rb', line 17

def page_scoped_id()
  json = @client.get("me", { fields: 'recipient', account_linking_token:  })
  json['recipient']
end


33
34
35
36
# File 'lib/message_quickly/api/account_link.rb', line 33

def (page_scoped_id)
  json = @client.post("me/unlink_accounts", { psid: page_scoped_id })
  json['result'] == "unlink account success"
end