1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.AccountOperation do
6 alias OpenApiSpex.Operation
7 alias Pleroma.Web.ApiSpec.Helpers
8 alias Pleroma.Web.ApiSpec.Schemas.Account
9 alias Pleroma.Web.ApiSpec.Schemas.AccountCreateRequest
10 alias Pleroma.Web.ApiSpec.Schemas.AccountCreateResponse
11 alias Pleroma.Web.ApiSpec.Schemas.AccountUpdateCredentialsRequest
13 @spec open_api_operation(atom) :: Operation.t()
14 def open_api_operation(action) do
15 operation = String.to_existing_atom("#{action}_operation")
16 apply(__MODULE__, operation, [])
19 @spec create_operation() :: Operation.t()
20 def create_operation do
23 summary: "Register an account",
25 "Creates a user and account records. Returns an account access token for the app that initiated the request. The app should save this token for later, and should wait for the user to confirm their account by clicking a link in their email inbox.",
26 operationId: "AccountController.create",
27 requestBody: Helpers.request_body("Parameters", AccountCreateRequest, required: true),
29 200 => Operation.response("Account", "application/json", AccountCreateResponse)
34 def verify_credentials_operation do
37 description: "Test to make sure that the user token works.",
38 summary: "Verify account credentials",
39 operationId: "AccountController.verify_credentials",
40 security: [%{"oAuth" => ["read:accounts"]}],
42 200 => Operation.response("Account", "application/json", Account)
47 def update_credentials_operation do
50 summary: "Update account credentials",
51 description: "Update the user's display and preferences.",
52 operationId: "AccountController.update_credentials",
53 security: [%{"oAuth" => ["write:accounts"]}],
55 Helpers.request_body("Parameters", AccountUpdateCredentialsRequest, required: true),
57 200 => Operation.response("Account", "application/json", Account)
62 def relationships_operation do
70 def statuses_operation do
74 def followers_operation do
78 def following_operation, do: :ok
79 def lists_operation, do: :ok
80 def follow_operation, do: :ok
81 def unfollow_operation, do: :ok
82 def mute_operation, do: :ok
83 def unmute_operation, do: :ok
84 def block_operation, do: :ok
85 def unblock_operation, do: :ok
86 def follows_operation, do: :ok
87 def mutes_operation, do: :ok
88 def blocks_operation, do: :ok
89 def endorsements_operation, do: :ok