Class: Forem::Organization
- Inherits:
-
APIResource
- Object
- ForemObject
- APIResource
- Forem::Organization
- Extended by:
- APIOperations::Create, APIOperations::List, APIOperations::Retrieve, APIOperations::Update
- Includes:
- APIOperations::Delete, APIOperations::Save
- Defined in:
- lib/forem/resources/organization.rb
Overview
Represents a Forem organization (a group account that can publish articles).
Organizations are team or company accounts on a Forem instance. They support full CRUD operations and expose sub-collection endpoints for listing their members and articles. Organizations can be retrieved by either numeric ID or username slug.
Available operations (via mixins):
- +List+ — GET /api/organizations (default: 10 per page)
- +Create+ — POST /api/organizations
- +Retrieve+ — GET /api/organizations/:id_or_username
- +Update+ — PUT /api/organizations/:id
- +Delete+ — instance-level delete
- +Save+ — instance-level save (create or update)
Constant Summary collapse
- OBJECT_NAME =
"organization"- RESOURCE_PATH =
"/api/organizations"
Instance Attribute Summary
Attributes inherited from ForemObject
Instance Method Summary collapse
-
#articles(params = {}, opts = {}) ⇒ Array<Forem::Article>
Return articles published under this organization.
-
#users(params = {}, opts = {}) ⇒ Array<Forem::User>
Return the members of this organization.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::Retrieve
Methods included from APIOperations::Update
Methods included from APIOperations::Save
Methods included from APIOperations::Delete
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
Instance Method Details
#articles(params = {}, opts = {}) ⇒ Array<Forem::Article>
Return articles published under this organization.
Sends a GET request to /api/organizations/:id/articles.
74 75 76 77 |
# File 'lib/forem/resources/organization.rb', line 74 def articles(params = {}, opts = {}) resp = request(:get, "#{resource_url}/articles", params, opts) (resp.parsed_body || []).map { |item| Forem::Article.construct_from(item) } end |
#users(params = {}, opts = {}) ⇒ Array<Forem::User>
Return the members of this organization.
Sends a GET request to /api/organizations/:id/users.
56 57 58 59 |
# File 'lib/forem/resources/organization.rb', line 56 def users(params = {}, opts = {}) resp = request(:get, "#{resource_url}/users", params, opts) (resp.parsed_body || []).map { |item| Forem::User.construct_from(item) } end |