Skip to content

Commit

Permalink
fix(bookings): add approve and reject routes for recurring instances
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Sep 2, 2024
1 parent 2e85c11 commit 89f4e10
Show file tree
Hide file tree
Showing 2 changed files with 250 additions and 2 deletions.
240 changes: 240 additions & 0 deletions OPENAPI_DOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,126 @@ paths:
schema:
type: string
nullable: true
- name: instance
in: query
description: a recurring instance id
example: "1234567"
required: false
schema:
type: integer
format: Int64
nullable: true
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PlaceOS__Model__Booking'
429:
description: Too Many Requests
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
400:
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
401:
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
403:
description: Forbidden
404:
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
511:
description: Network Authentication Required
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
406:
description: Not Acceptable
content:
application/json:
schema:
$ref: '#/components/schemas/Application__ContentError'
415:
description: Unsupported Media Type
content:
application/json:
schema:
$ref: '#/components/schemas/Application__ContentError'
422:
description: Unprocessable Entity
content:
application/json:
schema:
$ref: '#/components/schemas/Application__ValidationError'
500:
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
405:
description: Method Not Allowed
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
409:
description: Conflict
content:
application/json:
schema:
$ref: '#/components/schemas/Bookings__BookingError'
410:
description: Gone
content:
application/json:
schema:
$ref: '#/components/schemas/Bookings__BookingError'
/api/staff/v1/bookings/{id}/approve/{instance}:
post:
summary: approves a booking (if booking approval is required in an organisation)
tags:
- Bookings
operationId: Bookings_approve{2}
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: Int64
- name: instance
in: path
description: a recurring instance id
example: "1234567"
required: true
schema:
type: integer
format: Int64
nullable: true
- name: utm_source
in: query
description: provided for use with analytics
example: mobile
required: false
schema:
type: string
nullable: true
responses:
200:
description: OK
Expand Down Expand Up @@ -1712,6 +1832,126 @@ paths:
schema:
type: string
nullable: true
- name: instance
in: query
description: a recurring instance id
example: "1234567"
required: false
schema:
type: integer
format: Int64
nullable: true
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PlaceOS__Model__Booking'
429:
description: Too Many Requests
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
400:
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
401:
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
403:
description: Forbidden
404:
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
511:
description: Network Authentication Required
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
406:
description: Not Acceptable
content:
application/json:
schema:
$ref: '#/components/schemas/Application__ContentError'
415:
description: Unsupported Media Type
content:
application/json:
schema:
$ref: '#/components/schemas/Application__ContentError'
422:
description: Unprocessable Entity
content:
application/json:
schema:
$ref: '#/components/schemas/Application__ValidationError'
500:
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
405:
description: Method Not Allowed
content:
application/json:
schema:
$ref: '#/components/schemas/Application__CommonError'
409:
description: Conflict
content:
application/json:
schema:
$ref: '#/components/schemas/Bookings__BookingError'
410:
description: Gone
content:
application/json:
schema:
$ref: '#/components/schemas/Bookings__BookingError'
/api/staff/v1/bookings/{id}/reject/{instance}:
post:
summary: rejects a booking
tags:
- Bookings
operationId: Bookings_reject{2}
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: Int64
- name: instance
in: path
description: a recurring instance id
example: "1234567"
required: true
schema:
type: integer
format: Int64
nullable: true
- name: utm_source
in: query
description: provided for use with analytics
example: mobile
required: false
schema:
type: string
nullable: true
responses:
200:
description: OK
Expand Down
12 changes: 10 additions & 2 deletions src/controllers/bookings.cr
Original file line number Diff line number Diff line change
Expand Up @@ -723,10 +723,14 @@ class Bookings < Application

# approves a booking (if booking approval is required in an organisation)
@[AC::Route::POST("/:id/approve")]
@[AC::Route::POST("/:id/approve/:instance")]
def approve(
@[AC::Param::Info(description: "provided for use with analytics", example: "mobile")]
utm_source : String? = nil
utm_source : String? = nil,
@[AC::Param::Info(description: "a recurring instance id", example: "1234567")]
instance : Int64? = nil
) : Booking
booking.instance = instance
booking.utm_source = utm_source
set_approver(booking, true)

Expand All @@ -738,10 +742,14 @@ class Bookings < Application

# rejects a booking
@[AC::Route::POST("/:id/reject")]
@[AC::Route::POST("/:id/reject/:instance")]
def reject(
@[AC::Param::Info(description: "provided for use with analytics", example: "mobile")]
utm_source : String? = nil
utm_source : String? = nil,
@[AC::Param::Info(description: "a recurring instance id", example: "1234567")]
instance : Int64? = nil
) : Booking
booking.instance = instance
booking.utm_source = utm_source
set_approver(booking, false)
update_booking(booking, "rejected")
Expand Down

0 comments on commit 89f4e10

Please sign in to comment.