Class: Forem::Services::FollowService

Inherits:
BaseService show all
Defined in:
lib/forem/services/follow_service.rb

Overview

Service for interacting with the Forem Follows API.

Lists the tags the authenticated user follows, and follows users or organizations in bulk.

Examples:

client = Forem::Client.new("your-api-key")
followed_tags = client.follows.list
client.follows.create(user_ids: [42, 99])

See Also:

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Forem::Services::BaseService

Instance Method Details

#create(params = {}, opts = {}) ⇒ Forem::Follow

Follow one or more users and/or organizations.

The Forem API takes flat user_ids and/or organization_ids arrays — not a wrapped follows: key, despite the resource name. Tags are not followed through this endpoint.

Examples:

Follow users in bulk

client.follows.create(user_ids: [42, 99])

Follow organizations

client.follows.create(organization_ids: [7])

Combined

client.follows.create(user_ids: [42], organization_ids: [7])

Parameters:

  • params (Hash) (defaults to: {})

    follow attributes

  • opts (Hash) (defaults to: {})

    per-request options

Options Hash (params):

  • :user_ids (Array<Integer>)

    user IDs to follow

  • :organization_ids (Array<Integer>)

    org IDs to follow

Returns:

  • (Forem::Follow)

    outcome object (e.g. #<Forem::Follow {"outcome" => "followed 2 users"}>).

See Also:



56
57
58
# File 'lib/forem/services/follow_service.rb', line 56

def create(params = {}, opts = {})
  Follow.create(params, opts_with_requestor(opts))
end

#list(params = {}, opts = {}) ⇒ Forem::ListObject<Forem::Follow>

List tags followed by the authenticated user.

Examples:

client.follows.list

Parameters:

  • params (Hash) (defaults to: {})

    query parameters

  • opts (Hash) (defaults to: {})

    per-request options

Options Hash (params):

  • :page (Integer)

    page number (default: 1)

  • :per_page (Integer)

    number of results per page

Returns:

See Also:



29
30
31
# File 'lib/forem/services/follow_service.rb', line 29

def list(params = {}, opts = {})
  Follow.list(params, opts_with_requestor(opts))
end