Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial commit of membership endpoint #20

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 252 additions & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,44 @@ paths:
$ref: '#/components/responses/BadRequest'
"404":
$ref: '#/components/responses/NotFound'
/membership:
post:
summary: Buy a membership
description: Purchase an annual membership.
operationId: buyMembership
tags:
- Memberships
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/BuyMembershipRequest"
examples:
family_entry:
$ref: "#/components/examples/BuyFamilyMembershipRequest"
patron_entry:
$ref: "#/components/examples/BuyPatronMembershipRequest"
benefactor_entry:
$ref: "#/components/examples/BuyBenefactorMembershipRequest"
responses:
"200":
description: Success.
content:
application/json:
schema:
$ref: "#/components/schemas/BuyFamilyMembershipRequestResponse"
examples:
family_entry:
$ref: "#/components/examples/BuyFamilyMembershipResponseExample"
patron_entry:
$ref: "#/components/examples/BuyPatronMembershipResponseExample"
benefactor_entry:
$ref: "#/components/examples/BuyBenefactorMembershipResponseExample"
"400":
$ref: '#/components/responses/BadRequest'
"404":
$ref: '#/components/responses/NotFound'
components:
schemas:
TicketType:
Expand Down Expand Up @@ -245,7 +283,7 @@ components:
type: object
properties:
ticketType:
$ref: "#/components/schemas/TicketType"
$ref: "#/components/schemas/MembershipLevel"
eventId:
description: Unique identifier for a special event. Required if purchasing tickets for the museum's special events.
$ref: "#/components/schemas/EventId"
Expand All @@ -264,6 +302,10 @@ components:
description: Confirmation message after a ticket purchase.
type: string
example: Museum general entry ticket purchased
MembershipMessage:
description: Confirmation message after a membership purchase.
type: string
example: Family membership purchased
TicketId:
description: Unique identifier for museum ticket. Generated when purchased.
type: string
Expand All @@ -273,6 +315,10 @@ components:
description: Unique confirmation code used to verify ticket purchase.
type: string
example: 'ticket-event-a98c8f-7eb12'
MembershipConfirmation:
description: Unique confimation code used to verify membership purchase.
type: string
example: 'family-membership-a1b2c3-4d5e6'
BuyMuseumTicketsResponse:
description: Details for a museum ticket after a successful purchase.
type: object
Expand Down Expand Up @@ -354,6 +400,191 @@ components:
type: number
format: float
example: 25
MembershipLevel:
description: Type of membership for a guest
type: string
enum:
- Family
- Patron
- Benefactor
example: Family
FamilyMembership:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three schemas named *Membership are identical in structure. To ensure consistency, they should be one schema.

description: Benefits of a family membership
type: object
properties:
guests:
description: Number of guests included in membership
type: integer
example: 4
discount:
description: Amount of discount for a family membership
type: float
example: 10%
cost:
description: Annual cost of a membership
type: float
example: 100
PatronMembership:
ription: Benefits of a patron membership
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ription: Benefits of a patron membership
description: Benefits of a patron membership

type: object
properties:
guests:
description: Number of guests included in membership
type: integer
example: 6
discount:
description: Amount of gift shop and cafe discount for a family membership
type: float
example: 20%
cost:
description: Annual cost of a membership
type: float
example: 200
BenefactorMembership:
ription: Benefits of a patron membership
type: object
properties:
guests:
description: Number of guests included in membership
type: integer
example: 10
discount:
description: Amount of gift shop and cafe discount for a family membership
type: float
example: 30%
cost:
description: Annual cost of a membership
type: float
example: 1000
BuyFamilyMembershipRequest:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These identically-structured schemas Buy*MembershipRequest should be a single schema since the requests will all the be same structure of payload, with different details included. Please combine them.

description: Request payload used for purchasing family memberships.
type: object
properties:
membershipLevel:
$ref: "#/components/schemas/MembershipLevel"
startDate:
description: Date that the membership begins.
$ref: "#/components/schemas/Date"
endDate:
description: Date that the membership ends.
$ref: "#/components/schemas/Date"
email:
$ref: "#/components/schemas/Email"
phone:
$ref: "#/components/schemas/Phone"
required:
- membershipLevel
- startDate
- email
BuyPatronMembershipRequest:
description: Request payload used for purchasing family memberships.
type: object
properties:
membershipLevel:
$ref: "#/components/schemas/MembershipLevel"
startDate:
description: Date that the membership begins.
$ref: "#/components/schemas/Date"
endDate:
description: Date that the membership ends.
$ref: "#/components/schemas/Date"
email:
$ref: "#/components/schemas/Email"
phone:
$ref: "#/components/schemas/Phone"
required:
- membershipLevel
- startDate
- email
BuyBenefactorMembershipRequest:
description: Request payload used for purchasing family memberships.
type: object
properties:
membershipLevel:
$ref: "#/components/schemas/MembershipLevel"
startDate:
description: Date that the membership begins.
$ref: "#/components/schemas/Date"
endDate:
description: Date that the membership ends.
$ref: "#/components/schemas/Date"
email:
$ref: "#/components/schemas/Email"
phone:
$ref: "#/components/schemas/Phone"
required:
- membershipLevel
- startDate
- email
BuyFamilyMembershipResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine the Buy*MembershipResponses into a single schema unless some membership types have distinctly different structures. The goal of re-using schemas in an API is to ensure consistency - with these duplicated schemas, it would be easy to change one, or miss changing one, and introduce inconsistency. Since the structure is the same, they should use the same schema.

description: Details for a membership after a successful purchase.
type: object
properties:
message:
$ref: "#/components/schemas/MembershipMessage"
eventName:
$ref: "#/components/schemas/EventName"
ticketId:
$ref: "#/components/schemas/TicketId"
ticketType:
$ref: "#/components/schemas/TicketType"
startDate:
description: Date that the membership starts.
$ref: "#/components/schemas/Date"
confirmationCode:
$ref: "#/components/schemas/MembershipConfirmation"
required:
- message
- ticketId
- ticketType
- startDate
- confirmationCode
BuyPatronMembershipResponse:
description: Details for a patron membership after a successful purchase.
type: object
properties:
message:
$ref: "#/components/schemas/MembershipMessage"
eventName:
$ref: "#/components/schemas/EventName"
ticketId:
$ref: "#/components/schemas/TicketId"
ticketType:
$ref: "#/components/schemas/TicketType"
startDate:
description: Date that the membership starts.
$ref: "#/components/schemas/Date"
confirmationCode:
$ref: "#/components/schemas/MembershipConfirmation"
required:
- message
- ticketId
- ticketType
- startDate
- confirmationCode
BuyBenefactorMembershipResponse:
description: Details for a membership after a successful purchase.
type: object
properties:
message:
$ref: "#/components/schemas/MembershipMessage"
eventName:
$ref: "#/components/schemas/EventName"
ticketId:
$ref: "#/components/schemas/TicketId"
ticketType:
$ref: "#/components/schemas/TicketType"
startDate:
description: Date that the membership starts.
$ref: "#/components/schemas/Date"
confirmationCode:
$ref: "#/components/schemas/MembershipConfirmation"
required:
- message
- ticketId
- ticketType
- startDate
- confirmationCode
CreateSpecialEventRequest:
description: Request payload for creating new special events at the museum.
properties:
Expand Down Expand Up @@ -628,6 +859,24 @@ components:
- date: "2023-09-22"
timeOpen: "10:00"
timeClose: "16:00"
BuyFamilyMembershipExample:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple examples are great to illustrate the different expected data fields when the structures are the same. Thanks for adding these (no changes needed, I'm just happy to see the examples)!

summary: Family Membership
value:
membershipLevel: family
ticketDate: '2024-04-14'
email: [email protected]
BuyPatronMembershipExample:
summary: Patron Membership
value:
membershipLevel: patron
ticketDate: '2024-04-14'
email: [email protected]
BuyBenefactorMembershipExample:
summary: Benefactor Membership
value:
membershipLevel: family
ticketDate: '2024-04-14'
email: [email protected]
parameters:
PaginationPage:
name: page
Expand Down Expand Up @@ -706,5 +955,7 @@ tags:
description: Special events hosted by the museum.
- name: Tickets
description: Museum tickets for general entrance or special events.
- name: Memberships
description: Join the museum to support our mission and save money on repeat visits.
security:
- MuseumPlaceholderAuth: []
Loading