Class: Forem::Follow
- Inherits:
-
APIResource
- Object
- ForemObject
- APIResource
- Forem::Follow
- Defined in:
- lib/forem/resources/follow.rb
Overview
Represents a follow relationship — a user, organization, or tag the authenticated user follows.
The list endpoint returns followed tags only (the route is
/api/follows/tags). The create endpoint follows users and/or
organizations in bulk.
Constant Summary collapse
- OBJECT_NAME =
"follow"- RESOURCE_PATH =
"/api/follows"
Instance Attribute Summary
Attributes inherited from ForemObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Forem::Follow
Follow one or more users and/or organizations on behalf of the authenticated user.
-
.list(params = {}, opts = {}) ⇒ Forem::ListObject<Forem::Follow>
Return a paginated list of tags followed by 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
.create(params = {}, opts = {}) ⇒ Forem::Follow
Follow one or more users and/or organizations on behalf of the authenticated user.
Sends a POST request to /api/follows. The Forem API does not
follow tags through this endpoint (unlike what #list returns). It
accepts:
user_ids:— Arrayof user IDs to follow organization_ids:— Arrayof organization IDs to follow
The response is an outcome summary (e.g.
{"outcome" => "followed 2 users"}), not a full follow record.
If neither param is supplied, the API silently reports
"followed 0 users" — pass user_ids or organization_ids
explicitly.
72 73 74 75 76 |
# File 'lib/forem/resources/follow.rb', line 72 def self.create(params = {}, opts = {}) requestor = opts[:requestor] resp = request(:post, resource_path, params, opts) construct_from(resp.parsed_body, requestor: requestor) end |
.list(params = {}, opts = {}) ⇒ Forem::ListObject<Forem::Follow>
Return a paginated list of tags followed by the authenticated user.
Requires authentication. Sends a GET request to /api/follows/tags
(the list verb is mapped to the tags collection rather than the
base resource path on this endpoint).
43 44 45 |
# File 'lib/forem/resources/follow.rb', line 43 def self.list(params = {}, opts = {}) paginated_list("/api/follows/tags", params, opts) end |