Class: Funky::Connection::API Private

Inherits:
Base
  • Object
show all
Defined in:
lib/funky/connections/api.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Methods inherited from Base

get_http_request, response_for

Class Method Details

.app_id ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/funky/connections/api.rb', line 31

def self.app_id
  Funky.configuration.app_id
end

.app_secret ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
# File 'lib/funky/connections/api.rb', line 35

def self.app_secret
  Funky.configuration.app_secret
end

.batch_request(ids:, fields:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
18
19
20
21
22
23
# File 'lib/funky/connections/api.rb', line 15

def self.batch_request(ids:, fields:)
  uri = URI::HTTPS.build host: host,
    path: "/",
    query: "include_headers=false&access_token=#{app_id}%7C#{app_secret}"
  batch = create_batch_for ids, fields
  http_request = post_http_request uri
  http_request.set_form_data batch: batch.to_json
  response_for(http_request, uri)
end

.create_batch_for(ids, fields) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
46
47
# File 'lib/funky/connections/api.rb', line 43

def self.create_batch_for(ids, fields)
  ids.map do |id|
    {"method":"GET", "relative_url": "/v2.6/#{id}?fields=#{fields}"}
  end
end

.host ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/funky/connections/api.rb', line 27

def self.host
  'graph.facebook.com'
end

.post_http_request(uri) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/funky/connections/api.rb', line 39

def self.post_http_request(uri)
  Net::HTTP::Post.new uri
end

.request(id:, fields:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
# File 'lib/funky/connections/api.rb', line 8

def self.request(id:, fields:)
  uri = URI::HTTPS.build host: host,
    path: "/v2.6/#{id}",
    query: "access_token=#{app_id}%7C#{app_secret}&fields=#{fields}"
  response_for(get_http_request(uri), uri)
end