Class: FbPageApi::Edge::Base
- Inherits:
-
Object
- Object
- FbPageApi::Edge::Base
- Defined in:
- lib/fb_page_api/edge/base.rb
Direct Known Subclasses
AdminLabel, AdminNote, Conversation, LabelUser, Message, User
Instance Attribute Summary collapse
-
#custom_request_fields ⇒ Object
Returns the value of attribute custom_request_fields.
-
#next_url ⇒ Object
Returns the value of attribute next_url.
-
#page_access_token ⇒ Object
Returns the value of attribute page_access_token.
-
#page_after ⇒ Object
Returns the value of attribute page_after.
-
#page_before ⇒ Object
Returns the value of attribute page_before.
-
#page_id ⇒ Object
Returns the value of attribute page_id.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
Instance Method Summary collapse
- #collection(*args) ⇒ Object
- #create(*args) ⇒ Object
- #delete(object_id) ⇒ Object
- #get(object_id) ⇒ Object
-
#initialize(options = { parent_id: Config.page_id, page_access_token: Config.page_access_token }) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(options = { parent_id: Config.page_id, page_access_token: Config.page_access_token }) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 |
# File 'lib/fb_page_api/edge/base.rb', line 6 def initialize( = { parent_id: Config.page_id, page_access_token: Config.page_access_token }) self.page_access_token = [:page_access_token] self.parent_id = [:parent_id] self.custom_request_fields = [:custom_request_fields] || [] end |
Instance Attribute Details
#custom_request_fields ⇒ Object
Returns the value of attribute custom_request_fields.
4 5 6 |
# File 'lib/fb_page_api/edge/base.rb', line 4 def custom_request_fields @custom_request_fields end |
#next_url ⇒ Object
Returns the value of attribute next_url.
4 5 6 |
# File 'lib/fb_page_api/edge/base.rb', line 4 def next_url @next_url end |
#page_access_token ⇒ Object
Returns the value of attribute page_access_token.
4 5 6 |
# File 'lib/fb_page_api/edge/base.rb', line 4 def page_access_token @page_access_token end |
#page_after ⇒ Object
Returns the value of attribute page_after.
4 5 6 |
# File 'lib/fb_page_api/edge/base.rb', line 4 def page_after @page_after end |
#page_before ⇒ Object
Returns the value of attribute page_before.
4 5 6 |
# File 'lib/fb_page_api/edge/base.rb', line 4 def page_before @page_before end |
#page_id ⇒ Object
Returns the value of attribute page_id.
4 5 6 |
# File 'lib/fb_page_api/edge/base.rb', line 4 def page_id @page_id end |
#parent_id ⇒ Object
Returns the value of attribute parent_id.
4 5 6 |
# File 'lib/fb_page_api/edge/base.rb', line 4 def parent_id @parent_id end |
Instance Method Details
#collection(*args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fb_page_api/edge/base.rb', line 12 def collection(*args) = args. @collection = [] begin rs = http_request(:get, self.next_url || api_endpoint, query: body_params()) data = rs.parsed_response['data'] if data.present? @collection = @collection | data if rs.parsed_response['paging'].present? if rs.parsed_response['paging']['cursors'].present? self.page_after = rs.parsed_response['paging']['cursors']['after'] self.next_url = nil elsif rs.parsed_response['paging']['next'].present? self.next_url = rs.parsed_response['paging']['next'] self.page_after = nil else data = [] end else data = [] end end end while data.present? @collection end |
#create(*args) ⇒ Object
46 47 48 49 |
# File 'lib/fb_page_api/edge/base.rb', line 46 def create(*args) = args. http_request(:post, api_endpoint, query: body_params()).parsed_response end |
#delete(object_id) ⇒ Object
42 43 44 |
# File 'lib/fb_page_api/edge/base.rb', line 42 def delete(object_id) http_request(:delete, object_api_endpoint(object_id), query: body_params).parsed_response end |
#get(object_id) ⇒ Object
38 39 40 |
# File 'lib/fb_page_api/edge/base.rb', line 38 def get(object_id) http_request(:get, object_api_endpoint(object_id), query: body_params).parsed_response end |