Class: Forem::Follower
- Inherits:
-
APIResource
- Object
- ForemObject
- APIResource
- Forem::Follower
- Defined in:
- lib/forem/resources/follower.rb
Overview
Represents a user who follows the authenticated user.
A Follower record describes a user that has subscribed to the authenticated user's content. Only listing is supported — you cannot create or delete follower relationships through this resource directly.
Requires authentication. Default: 80 per page.
Note: the list endpoint hits /api/followers/users (not /api/followers),
and the default page size is 80 (larger than most other resources).
Constant Summary collapse
- OBJECT_NAME =
"follower"- RESOURCE_PATH =
"/api/followers"
Instance Attribute Summary
Attributes inherited from ForemObject
Class Method Summary collapse
-
.list(params = {}, opts = {}) ⇒ Forem::ListObject<Forem::Follower>
Return a paginated list of users who follow the authenticated user.
Methods inherited from APIResource
#refresh, resource_path, #resource_url
Methods inherited from ForemObject
#==, #[], #[]=, construct_from, cursor_list, #initialize, #inspect, #method_missing, paginated_list, #respond_to_missing?, #to_hash
Methods included from APIOperations::Request
Constructor Details
This class inherits a constructor from Forem::ForemObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Forem::ForemObject
Class Method Details
.list(params = {}, opts = {}) ⇒ Forem::ListObject<Forem::Follower>
Return a paginated list of users who follow the authenticated user.
Requires authentication. Default: 80 per page.
Sends a GET request to /api/followers/users.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/forem/resources/follower.rb', line 42 def self.list(params = {}, opts = {}) requestor = opts[:requestor] resp = request(:get, "/api/followers/users", params, opts) data = (resp.parsed_body || []).map { |item| construct_from(item) } per_page = params[:per_page] || params["per_page"] || 80 page = params[:page] || params["page"] || 1 ListObject.new( data: data, current_page: page.to_i, per_page: per_page.to_i, resource_class: self, filters: params.reject { |k, _| [:page, :per_page, "page", "per_page"].include?(k) }, requestor: requestor ) end |