1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.PleromaScrobbleOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Reference
8 alias OpenApiSpex.Schema
9 alias Pleroma.Web.ApiSpec.Schemas.Account
10 alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
12 import Pleroma.Web.ApiSpec.Helpers
14 def open_api_operation(action) do
15 operation = String.to_existing_atom("#{action}_operation")
16 apply(__MODULE__, operation, [])
19 def create_operation do
22 summary: "Creates a new Listen activity for an account",
23 security: [%{"oAuth" => ["write"]}],
24 operationId: "PleromaAPI.ScrobbleController.create",
25 requestBody: request_body("Parameters", create_request(), requried: true),
27 200 => Operation.response("Scrobble", "application/json", scrobble())
32 def index_operation do
35 summary: "Requests a list of current and recent Listen activities for an account",
36 operationId: "PleromaAPI.ScrobbleController.index",
38 %Reference{"$ref": "#/components/parameters/accountIdOrNickname"} | pagination_params()
40 security: [%{"oAuth" => ["read"]}],
43 Operation.response("Array of Scrobble", "application/json", %Schema{
51 defp create_request do
56 title: %Schema{type: :string, description: "The title of the media playing"},
57 album: %Schema{type: :string, description: "The album of the media playing"},
58 artist: %Schema{type: :string, description: "The artist of the media playing"},
59 length: %Schema{type: :integer, description: "The length of the media playing"},
61 allOf: [VisibilityScope],
63 description: "Scrobble visibility"
67 "title" => "Some Title",
68 "artist" => "Some Artist",
69 "album" => "Some Album",
79 id: %Schema{type: :string},
81 title: %Schema{type: :string, description: "The title of the media playing"},
82 album: %Schema{type: :string, description: "The album of the media playing"},
83 artist: %Schema{type: :string, description: "The artist of the media playing"},
86 description: "The length of the media playing",
89 created_at: %Schema{type: :string, format: :"date-time"}
93 "account" => Account.schema().example,
94 "title" => "Some Title",
95 "artist" => "Some Artist",
96 "album" => "Some Album",
98 "created_at" => "2019-09-28T12:40:45.000Z"