2024-11-15 17:29:56 +00:00
|
|
|
# Copyright (C) 2024 Manuel Bustillo
|
|
|
|
|
2024-12-28 18:37:47 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-11-15 18:28:45 +01:00
|
|
|
require 'swagger_helper'
|
|
|
|
|
2024-12-28 18:07:22 +01:00
|
|
|
RSpec.describe 'groups' do
|
2024-11-30 19:57:08 +01:00
|
|
|
path '/{slug}/groups' do
|
2024-11-15 18:28:45 +01:00
|
|
|
get('list groups') do
|
2024-11-16 02:16:19 +01:00
|
|
|
tags 'Groups'
|
2024-11-15 19:42:59 +01:00
|
|
|
produces 'application/json'
|
2024-11-30 19:57:08 +01:00
|
|
|
parameter Swagger::Schema::SLUG
|
2024-11-15 18:28:45 +01:00
|
|
|
response(200, 'successful') do
|
2024-11-15 19:42:59 +01:00
|
|
|
schema type: :array,
|
2024-12-28 18:07:22 +01:00
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
required: %i[id name icon parent_id color attendance],
|
|
|
|
properties: {
|
|
|
|
id: { type: :string, format: :uuid, required: true },
|
|
|
|
name: { type: :string },
|
|
|
|
icon: { type: :string, example: 'pi pi-crown', description: 'The CSS classes used by the icon' },
|
|
|
|
parent_id: { type: :string, format: :uuid },
|
|
|
|
color: { type: :string, pattern: '^#(?:[0-9a-fA-F]{3}){1,2}$' },
|
|
|
|
attendance: {
|
|
|
|
type: :object,
|
|
|
|
required: %i[total considered invited confirmed declined tentative],
|
|
|
|
properties: {
|
|
|
|
total: { type: :integer, minimum: 0, description: 'Total number of guests in any status' },
|
|
|
|
considered: { type: :integer, minimum: 0 },
|
|
|
|
invited: { type: :integer, minimum: 0 },
|
|
|
|
confirmed: { type: :integer, minimum: 0 },
|
|
|
|
declined: { type: :integer, minimum: 0 },
|
|
|
|
tentative: { type: :integer, minimum: 0 }
|
|
|
|
}
|
|
|
|
}
|
2024-11-15 19:42:59 +01:00
|
|
|
}
|
2024-12-28 18:07:22 +01:00
|
|
|
}
|
2024-11-16 02:16:19 +01:00
|
|
|
xit
|
2024-11-15 18:28:45 +01:00
|
|
|
end
|
2024-11-30 14:24:02 +01:00
|
|
|
regular_api_responses
|
2024-11-15 18:28:45 +01:00
|
|
|
end
|
2024-12-08 11:30:38 +01:00
|
|
|
|
|
|
|
post('create group') do
|
|
|
|
tags 'Groups'
|
|
|
|
consumes 'application/json'
|
|
|
|
produces 'application/json'
|
|
|
|
parameter Swagger::Schema::SLUG
|
|
|
|
parameter name: :body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
required: %i[group],
|
|
|
|
properties: {
|
|
|
|
group: {
|
|
|
|
type: :object,
|
|
|
|
required: %i[name],
|
|
|
|
properties: Swagger::Schema::GROUP
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response(201, 'created') do
|
|
|
|
schema type: :object, properties: {
|
|
|
|
id: { type: :string, format: :uuid, required: true },
|
|
|
|
**Swagger::Schema::GROUP
|
|
|
|
}
|
|
|
|
|
|
|
|
xit
|
|
|
|
end
|
|
|
|
regular_api_responses
|
|
|
|
end
|
|
|
|
|
|
|
|
path '/{slug}/groups/{id}' do
|
|
|
|
put('update group') do
|
|
|
|
tags 'Groups'
|
|
|
|
consumes 'application/json'
|
|
|
|
produces 'application/json'
|
|
|
|
parameter Swagger::Schema::SLUG
|
|
|
|
parameter name: :id, in: :path, type: :string, format: :uuid
|
|
|
|
parameter name: :body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
required: %i[group],
|
|
|
|
properties: {
|
|
|
|
group: {
|
|
|
|
type: :object,
|
|
|
|
required: %i[name],
|
|
|
|
properties: Swagger::Schema::GROUP
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response(200, 'updated') do
|
|
|
|
schema type: :object, properties: {
|
|
|
|
id: { type: :string, format: :uuid, required: true },
|
|
|
|
**Swagger::Schema::GROUP
|
|
|
|
}
|
|
|
|
|
|
|
|
xit
|
|
|
|
end
|
|
|
|
regular_api_responses
|
|
|
|
end
|
|
|
|
|
|
|
|
delete('delete group') do
|
|
|
|
tags 'Groups'
|
|
|
|
produces 'application/json'
|
|
|
|
parameter Swagger::Schema::SLUG
|
|
|
|
parameter name: :id, in: :path, type: :string, format: :uuid
|
2024-12-28 18:07:22 +01:00
|
|
|
|
|
|
|
response_empty200
|
2024-12-08 11:30:38 +01:00
|
|
|
regular_api_responses
|
|
|
|
end
|
|
|
|
end
|
2024-11-15 18:28:45 +01:00
|
|
|
end
|
|
|
|
end
|