2020-05-13 09:06:25 -06:00
# Pleroma: A lightweight social networking server
2022-02-25 23:11:42 -07:00
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
2020-05-13 09:06:25 -06:00
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ApiSpec.PleromaAccountOperation do
alias OpenApiSpex.Operation
2022-01-18 06:57:48 -07:00
alias OpenApiSpex.Schema
2022-01-10 13:35:55 -07:00
alias Pleroma.Web.ApiSpec.AccountOperation
2020-05-13 09:06:25 -06:00
alias Pleroma.Web.ApiSpec.Schemas.AccountRelationship
alias Pleroma.Web.ApiSpec.Schemas.ApiError
alias Pleroma.Web.ApiSpec.Schemas.FlakeID
alias Pleroma.Web.ApiSpec.StatusOperation
import Pleroma.Web.ApiSpec.Helpers
def open_api_operation ( action ) do
operation = String . to_existing_atom ( " #{ action } _operation " )
apply ( __MODULE__ , operation , [ ] )
end
def confirmation_resend_operation do
% Operation {
2021-02-03 05:38:59 -07:00
tags : [ " Account credentials " ] ,
summary : " Resend confirmation email " ,
description : " Expects `email` or `nickname`. " ,
2020-05-13 09:06:25 -06:00
operationId : " PleromaAPI.AccountController.confirmation_resend " ,
parameters : [
Operation . parameter ( :email , :query , :string , " Email of that needs to be verified " ,
example : " cofe@cofe.io "
) ,
Operation . parameter (
:nickname ,
:query ,
:string ,
" Nickname of user that needs to be verified " ,
example : " cofefe "
)
] ,
responses : %{
204 = > no_content_response ( )
}
}
end
def favourites_operation do
% Operation {
2021-02-03 05:38:59 -07:00
tags : [ " Retrieve account information " ] ,
summary : " Favorites " ,
description :
" Only returns data if the user has opted into sharing it. See `hide_favorites` in [Update account credentials]( # operation/AccountController.update_credentials). " ,
2020-05-13 09:06:25 -06:00
operationId : " PleromaAPI.AccountController.favourites " ,
parameters : [ id_param ( ) | pagination_params ( ) ] ,
security : [ %{ " oAuth " = > [ " read:favourites " ] } ] ,
responses : %{
200 = >
Operation . response (
" Array of Statuses " ,
" application/json " ,
StatusOperation . array_of_statuses ( )
) ,
403 = > Operation . response ( " Forbidden " , " application/json " , ApiError ) ,
404 = > Operation . response ( " Not Found " , " application/json " , ApiError )
}
}
end
2021-11-29 04:43:29 -07:00
def endorsements_operation do
% Operation {
tags : [ " Retrieve account information " ] ,
summary : " Endorsements " ,
description : " Returns endorsed accounts " ,
operationId : " PleromaAPI.AccountController.endorsements " ,
2022-01-10 13:35:55 -07:00
parameters : [ with_relationships_param ( ) , id_param ( ) ] ,
2021-11-29 04:43:29 -07:00
responses : %{
200 = >
Operation . response (
" Array of Accounts " ,
" application/json " ,
AccountOperation . array_of_accounts ( )
) ,
404 = > Operation . response ( " Not Found " , " application/json " , ApiError )
}
}
end
2020-05-13 09:06:25 -06:00
def subscribe_operation do
% Operation {
2021-02-03 05:38:59 -07:00
tags : [ " Account actions " ] ,
summary : " Subscribe " ,
description : " Receive notifications for all statuses posted by the account. " ,
2020-05-13 09:06:25 -06:00
operationId : " PleromaAPI.AccountController.subscribe " ,
parameters : [ id_param ( ) ] ,
security : [ %{ " oAuth " = > [ " follow " , " write:follows " ] } ] ,
responses : %{
200 = > Operation . response ( " Relationship " , " application/json " , AccountRelationship ) ,
404 = > Operation . response ( " Not Found " , " application/json " , ApiError )
}
}
end
def unsubscribe_operation do
% Operation {
2021-02-03 05:38:59 -07:00
tags : [ " Account actions " ] ,
summary : " Unsubscribe " ,
description : " Stop receiving notifications for all statuses posted by the account. " ,
2020-05-13 09:06:25 -06:00
operationId : " PleromaAPI.AccountController.unsubscribe " ,
parameters : [ id_param ( ) ] ,
security : [ %{ " oAuth " = > [ " follow " , " write:follows " ] } ] ,
responses : %{
200 = > Operation . response ( " Relationship " , " application/json " , AccountRelationship ) ,
404 = > Operation . response ( " Not Found " , " application/json " , ApiError )
}
}
end
2022-01-18 06:57:48 -07:00
def birthdays_operation do
% Operation {
tags : [ " Retrieve account information " ] ,
summary : " Birthday reminders " ,
description : " Birthday reminders about users you follow. " ,
operationId : " PleromaAPI.AccountController.birthdays " ,
parameters : [
Operation . parameter (
:day ,
:query ,
% Schema { type : :integer } ,
" Day of users' birthdays "
) ,
Operation . parameter (
:month ,
:query ,
% Schema { type : :integer } ,
" Month of users' birthdays "
)
] ,
security : [ %{ " oAuth " = > [ " read:accounts " ] } ] ,
responses : %{
200 = >
Operation . response ( " Accounts " , " application/json " , AccountOperation . array_of_accounts ( ) )
}
}
end
2020-05-13 09:06:25 -06:00
defp id_param do
Operation . parameter ( :id , :path , FlakeID , " Account ID " ,
example : " 9umDrYheeY451cQnEe " ,
required : true
)
end
end