Structure
ArticlesUseCase
public struct ArticlesUseCase: UseCase
Use cases for Articles.
Initializers
Methods
getArticles(author:feeder:favorited:tag:offset:limit:readingUserId:)
public func getArticles( author: String? = nil, feeder: Int? = nil, favorited username: String? = nil, tag: String? = nil, offset: Int? = nil, limit: Int? = nil, readingUserId: Int? = nil) -> Future<MultipleArticlesResponse>
This use case has work of article search.
It is not considered that multiple conditions are passed at the same time.
Parameters
Name | Type | Description |
---|---|---|
author | String? |
Please pass the id of author with Int. |
feeder | Int? |
Please pass the Id of the user who owns the feed with Int. |
username | String? |
Please pass the username of the user doing the favorite with String. |
tag | String? |
Please pass the tag with string. |
offset | Int? |
When specifying offset, put Int here. |
limit | Int? |
When specifying limit, put Int here. |
readingUserId | Int? |
Please pass the id of the user reading the article. |
Returns
The Future
that returns MultipleArticlesResponse
.
getArticle(slug:readingUserId:)
public func getArticle( slug: String, readingUserId: Int? ) -> Future<SingleArticleResponse>
This use case has work of receiving the slug and get article.
-
parameters
- slug: Please pass the slug of the article you want to read.
- readingUserId: Please pass the id of the user reading the article.
Returns
The Future
that returns SingleArticleResponse
.
postArticle(_:author:)
public func postArticle(_ article: NewArticle, author userId: Int ) -> Future<SingleArticleResponse>
This use case has work of article posting.
Parameters
Name | Type | Description |
---|---|---|
article | NewArticle |
Please pass the content of the article to be posted with |
userId | Int |
Please pass the id of author with Int. |
Returns
The Future
that returns SingleArticleResponse
. That's what you just posted.
updateArticle(slug:title:description:body:tagList:readingUserId:)
public func updateArticle( slug: String, title: String?, description: String?, body: String?, tagList: [String]?, readingUserId: Int? ) -> Future<SingleArticleResponse>
This use case has work of article updating.
Extras
I might have wanted to reduce the dependency on a particular type, but it was okay to use a domain model here. 😇
Parameters
Name | Type | Description |
---|---|---|
slug | String |
Please pass the slug of the article to be updated. |
title | String? |
Please pass the title of the article. Nil means unspecified. |
description | String? |
Please pass the description of the article. Nil means unspecified. |
body | String? |
Please pass the body of the article. Nil means unspecified. |
tagList | [String]? |
Please pass the tags of the article. Nil means unspecified. |
readingUserId | Int? |
Please pass the id of the user reading the article. |
Returns
The Future
that returns SingleArticleResponse
. That is what you just updated.
deleteArticle(slug:)
public func deleteArticle( slug: String ) -> Future<Void>
This use case has work of article deleteing.
Parameters
Name | Type | Description |
---|---|---|
slug | String |
Please pass the slug of the article to be deleted. |
Returns
The Future
that returns Void
.
favorite(by:for:)
public func favorite(by userId: Int, for articleSlug: String) -> Future<SingleArticleResponse>
This use case has work of favorite for article.
Parameters
Name | Type | Description |
---|---|---|
userId | Int |
Please pass the id of the user do the favorite. |
articleSlug | String |
Please pass the slug of favorite article. |
Returns
The Future
that returns SingleArticleResponse
.
unfavorite(by:for:)
public func unfavorite(by userId: Int, for articleSlug: String) -> Future<SingleArticleResponse>
This use case has work of unfavorite for article.
Parameters
Name | Type | Description |
---|---|---|
userId | Int |
Please pass the id of the user do the unfavorite. |
articleSlug | String |
Please pass the slug of unfavorite article. |
Returns
The Future
that returns SingleArticleResponse
.
getComments(slug:)
public func getComments( slug: String ) -> Future<MultipleCommentsResponse>
This use case has work of get comments from article.
Parameters
Name | Type | Description |
---|---|---|
slug | String |
Please pass the slug of the commented article. |
Returns
The Future
that returns MultipleCommentsResponse
.
postComment(slug:body:author:)
public func postComment( slug: String, body: String, author: Int ) -> Future<SingleCommentResponse>
This use case has work of post comment to article.
Parameters
Name | Type | Description |
---|---|---|
slug | String |
Please pass the slug of articles to comment. |
body | String |
Please pass the body of the comment. |
author | Int |
Please pass the id of the author. |
Returns
The Future
that returns SingleCommentResponse
.
deleteComment(slug:id:)
public func deleteComment( slug: String, id: Int ) -> Future<Void>
This use case has work of delete comment to article.
Parameters
Name | Type | Description |
---|---|---|
slug | String |
Please pass the slug of articles to uncomment. |
id | Int |
Please pass the id of the comment. |
Returns
The Future
that returns Void
.