Domain Documentation

Structure Articles​Use​Case

public struct ArticlesUseCase: UseCase  

Use cases for Articles.

Initializers

init()

public init()  

Default initializer.

Methods

get​Articles(author:​feeder:​favorited:​tag:​offset:​limit:​reading​User​Id:​)

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

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.

reading​User​Id Int?

Please pass the id of the user reading the article.

Returns

The Future that returns MultipleArticlesResponse.

get​Article(slug:​reading​User​Id:​)

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.

post​Article(_:​author:​)

public func postArticle(_ article: NewArticle, author userId: Int ) -> Future<SingleArticleResponse>  

This use case has work of article posting.

Parameters

article New​Article

Please pass the content of the article to be posted with NewArticle.

user​Id Int

Please pass the id of author with Int.

Returns

The Future that returns SingleArticleResponse. That's what you just posted.

update​Article(slug:​title:​description:​body:​tag​List:​reading​User​Id:​)

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

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.

tag​List [String]?

Please pass the tags of the article. Nil means unspecified.

reading​User​Id Int?

Please pass the id of the user reading the article.

Returns

The Future that returns SingleArticleResponse. That is what you just updated.

delete​Article(slug:​)

public func deleteArticle( slug: String ) -> Future<Void>  

This use case has work of article deleteing.

Parameters

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

user​Id Int

Please pass the id of the user do the favorite.

article​Slug 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

user​Id Int

Please pass the id of the user do the unfavorite.

article​Slug String

Please pass the slug of unfavorite article.

Returns

The Future that returns SingleArticleResponse.

get​Comments(slug:​)

public func getComments( slug: String ) -> Future<MultipleCommentsResponse>  

This use case has work of get comments from article.

Parameters

slug String

Please pass the slug of the commented article.

Returns

The Future that returns MultipleCommentsResponse.

post​Comment(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

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.

delete​Comment(slug:​id:​)

public func deleteComment( slug: String, id: Int ) -> Future<Void>  

This use case has work of delete comment to article.

Parameters

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.