Class: Forem::Services::OrganizationService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/forem/services/organization_service.rb

Overview

Service for interacting with the Forem Organizations API.

Access via Client#organizations. All methods inject the client's requestor automatically so no additional configuration is required.

Examples:

client = Forem::Client.new("your-api-key")
orgs = client.organizations.list
org  = client.organizations.retrieve(7)

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 = {}) ⇒ Organization

Create a new organization.

Examples:

client.organizations.create(
  name: "Acme Corp",
  username: "acme",
  summary: "We make everything."
)

Parameters:

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

    organization attributes

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

    per-request options

Options Hash (params):

  • :name (String)

    display name of the organization

  • :username (String)

    unique username / slug

  • :summary (String)

    short description

  • :url (String)

    website URL

  • :location (String)

    location string

  • :tech_stack (String)

    technology stack description

Returns:

See Also:



52
53
54
# File 'lib/forem/services/organization_service.rb', line 52

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

#delete(id, opts = {}) ⇒ nil

Delete an organization.

Examples:

client.organizations.delete(7)

Parameters:

  • id (Integer, String)

    the organization ID to delete

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

    per-request options

Returns:

  • (nil)

    returns nil on success

See Also:



98
99
100
# File 'lib/forem/services/organization_service.rb', line 98

def delete(id, opts = {})
  Organization.delete(id, opts_with_requestor(opts))
end

#list(params = {}, opts = {}) ⇒ Array<Organization>

List all organizations.

Examples:

client.organizations.list(per_page: 25)

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:



28
29
30
# File 'lib/forem/services/organization_service.rb', line 28

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

#retrieve(id, opts = {}) ⇒ Organization

Retrieve a single organization by its numeric ID.

Examples:

client.organizations.retrieve(7)

Parameters:

  • id (Integer, String)

    the organization ID

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

    per-request options

Returns:

See Also:



66
67
68
# File 'lib/forem/services/organization_service.rb', line 66

def retrieve(id, opts = {})
  Organization.retrieve(id, opts_with_requestor(opts))
end

#update(id, params = {}, opts = {}) ⇒ Organization

Update an existing organization.

Examples:

client.organizations.update(7, summary: "Updated description.")

Parameters:

  • id (Integer, String)

    the organization ID to update

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

    organization attributes to change

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

    per-request options

Options Hash (params):

  • :name (String)

    new display name

  • :summary (String)

    new description

  • :url (String)

    new website URL

Returns:

See Also:



84
85
86
# File 'lib/forem/services/organization_service.rb', line 84

def update(id, params = {}, opts = {})
  Organization.update(id, params, opts_with_requestor(opts))
end