Class: Forem::Services::ArticleService
- Inherits:
-
BaseService
- Object
- BaseService
- Forem::Services::ArticleService
- Defined in:
- lib/forem/services/article_service.rb
Overview
Service for interacting with the Forem Articles API.
Access via Client#articles. All methods inject the client's requestor automatically so no additional configuration is required.
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Article
Create a new article.
-
#latest(params = {}, opts = {}) ⇒ Array<Article>
List the most recently published articles.
-
#list(params = {}, opts = {}) ⇒ Array<Article>
List published articles.
-
#me(params = {}, opts = {}) ⇒ Array<Article>
List articles authored by the authenticated user.
-
#me_all(params = {}, opts = {}) ⇒ Array<Article>
List all articles (published and unpublished) authored by the authenticated user.
-
#me_published(params = {}, opts = {}) ⇒ Array<Article>
List published articles authored by the authenticated user.
-
#me_unpublished(params = {}, opts = {}) ⇒ Array<Article>
List unpublished articles (drafts) authored by the authenticated user.
-
#retrieve(id, opts = {}) ⇒ Article
Retrieve a single article by its numeric ID.
-
#retrieve_by_path(username, slug, opts = {}) ⇒ Article
Retrieve an article by its author username and slug.
-
#search(params = {}, opts = {}) ⇒ Array<Article>
Search articles by keyword.
-
#semantic_search(params = {}, opts = {}) ⇒ Array<Article>
Semantically search articles using Forem's embeddings-based search.
-
#update(id, params = {}, opts = {}) ⇒ Article
Update an existing article.
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from Forem::Services::BaseService
Instance Method Details
#create(params = {}, opts = {}) ⇒ Article
Create a new article.
61 62 63 |
# File 'lib/forem/services/article_service.rb', line 61 def create(params = {}, opts = {}) Article.create(params, opts_with_requestor(opts)) end |
#latest(params = {}, opts = {}) ⇒ Array<Article>
List the most recently published articles.
174 175 176 |
# File 'lib/forem/services/article_service.rb', line 174 def latest(params = {}, opts = {}) Article.latest(params, opts_with_requestor(opts)) end |
#list(params = {}, opts = {}) ⇒ Array<Article>
List published articles.
35 36 37 |
# File 'lib/forem/services/article_service.rb', line 35 def list(params = {}, opts = {}) Article.list(params, opts_with_requestor(opts)) end |
#me(params = {}, opts = {}) ⇒ Array<Article>
List articles authored by the authenticated user.
110 111 112 |
# File 'lib/forem/services/article_service.rb', line 110 def me(params = {}, opts = {}) Article.me(params, opts_with_requestor(opts)) end |
#me_all(params = {}, opts = {}) ⇒ Array<Article>
List all articles (published and unpublished) authored by the authenticated user.
158 159 160 |
# File 'lib/forem/services/article_service.rb', line 158 def me_all(params = {}, opts = {}) Article.me_all(params, opts_with_requestor(opts)) end |
#me_published(params = {}, opts = {}) ⇒ Array<Article>
List published articles authored by the authenticated user.
126 127 128 |
# File 'lib/forem/services/article_service.rb', line 126 def me_published(params = {}, opts = {}) Article.me_published(params, opts_with_requestor(opts)) end |
#me_unpublished(params = {}, opts = {}) ⇒ Array<Article>
List unpublished articles (drafts) authored by the authenticated user.
142 143 144 |
# File 'lib/forem/services/article_service.rb', line 142 def me_unpublished(params = {}, opts = {}) Article.me_unpublished(params, opts_with_requestor(opts)) end |
#retrieve(id, opts = {}) ⇒ Article
Retrieve a single article by its numeric ID.
75 76 77 |
# File 'lib/forem/services/article_service.rb', line 75 def retrieve(id, opts = {}) Article.retrieve(id, opts_with_requestor(opts)) end |
#retrieve_by_path(username, slug, opts = {}) ⇒ Article
Retrieve an article by its author username and slug.
228 229 230 |
# File 'lib/forem/services/article_service.rb', line 228 def retrieve_by_path(username, slug, opts = {}) Article.retrieve_by_path(username, slug, opts_with_requestor(opts)) end |
#search(params = {}, opts = {}) ⇒ Array<Article>
Search articles by keyword.
191 192 193 |
# File 'lib/forem/services/article_service.rb', line 191 def search(params = {}, opts = {}) Article.search(params, opts_with_requestor(opts)) end |
#semantic_search(params = {}, opts = {}) ⇒ Array<Article>
Semantically search articles using Forem's embeddings-based search.
Unlike search (keyword matching), this finds articles whose meaning
is close to the query text. Requires authentication.
213 214 215 |
# File 'lib/forem/services/article_service.rb', line 213 def semantic_search(params = {}, opts = {}) Article.semantic_search(params, opts_with_requestor(opts)) end |