1
1
defmodule PlexusWeb.API.V1.RatingController do
2
2
use PlexusWeb , :controller
3
+ use OpenApiSpex.ControllerSpecs
3
4
4
5
alias Plexus.Ratings
6
+ alias PlexusWeb.API.V1.Schemas.RatingResponse
7
+ alias PlexusWeb.API.V1.Schemas.RatingsResponse
5
8
alias PlexusWeb.Params
6
9
7
10
action_fallback PlexusWeb.FallbackController
8
11
12
+ tags [ "ratings" ]
13
+
14
+ operation :index ,
15
+ summary: "List Application Ratings" ,
16
+ parameters: [
17
+ package: [
18
+ in: :path ,
19
+ description: "App Package" ,
20
+ type: :string ,
21
+ required: true ,
22
+ example: "org.thoughtcrime.securesms"
23
+ ] ,
24
+ page: [ in: :query , description: "Page number" , type: :integer , example: 1 ] ,
25
+ limit: [ in: :query , description: "Max results per page" , type: :integer , example: 5 ]
26
+ ] ,
27
+ responses: [
28
+ ok: { "Ratings" , "application/json" , RatingsResponse }
29
+ ]
30
+
9
31
def index ( conn , % { "package" => app_package } = params ) do
10
32
opts =
11
33
[ order_by: [ desc: :app_build_number , desc: :updated_at ] ]
@@ -15,6 +37,8 @@ defmodule PlexusWeb.API.V1.RatingController do
15
37
render ( conn , :index , page: page )
16
38
end
17
39
40
+ operation :create , false
41
+
18
42
def create ( conn , % { "package" => app_package , "rating" => params } ) do
19
43
schema = % {
20
44
android_version: { :string , [ required: true ] } ,
@@ -40,6 +64,28 @@ defmodule PlexusWeb.API.V1.RatingController do
40
64
end
41
65
end
42
66
67
+ operation :show ,
68
+ summary: "Get Application Rating" ,
69
+ parameters: [
70
+ package: [
71
+ in: :path ,
72
+ description: "App Package" ,
73
+ type: :string ,
74
+ required: true ,
75
+ example: "org.thoughtcrime.securesms"
76
+ ] ,
77
+ id: [
78
+ in: :path ,
79
+ description: "Rating Unique Identifier" ,
80
+ type: :string ,
81
+ required: true ,
82
+ example: "72f5d88e-a467-4729-998f-db1edcfad6bc"
83
+ ]
84
+ ] ,
85
+ responses: [
86
+ ok: { "Rating" , "application/json" , RatingResponse }
87
+ ]
88
+
43
89
def show ( conn , % { "id" => id } ) do
44
90
rating = Ratings . get_rating! ( id )
45
91
render ( conn , :show , rating: rating )
0 commit comments