ticketing

package module
v0.0.0-...-9b4beb9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

README

Requirements:

  1. Code must be published in Github with a link we can access (use public repo).

  2. Code must compile with some effort on unit tests, doesn't have to be 100%, but it shouldn't be 0%.

  3. Please code this with Golang and gRPC

  4. No persistence layer is required, just store the data in the current session/in memory.

  5. The results can be in the console output from your grpc-server and grpc-client

  6. Depending on the level of authentication, take different actions

App to be coded

Note: All APIs referenced are gRPC APIs, not REST ones.

I want to board a train from London to France. The train ticket will cost $20, regardless of section or seat.

  1. Authenticated APIs should be able to parse a JWT, formatted as if from an OAuth2 server, from the metadata to authenticate a request. No signature validation is required.

  2. Create a public API where you can submit a purchase for a ticket. Details included in the receipt are:

a. From, To, User , Price Paid.

i. User should include first name, last name, email address

b. The user is allocated a seat in the train as a result of the purchase. Assume the train has only 2 sections, section A and section B and each section has 10 seats.

  1. An authenticated API that shows the details of the receipt for the user

  2. An authenticated API that lets an admin view all the users and seats they are allocated by the requested section

  3. An authenticated API to allow an admin or the user to remove the user from the train

  4. An authenticated API to allow an admin or the user to modify the user's seat

Test

Run tests with:

go test -v ./...

CICD

Test action script lives here

API

Ticketing gRPC API can be found here

Documentation

Index

Constants

View Source
const SEAT_COST = 20

Variables

This section is empty.

Functions

func NewMyTicketingServiceHandler

func NewMyTicketingServiceHandler() (string, http.Handler)

Types

type MyTrainTicketingServiceHandler

type MyTrainTicketingServiceHandler struct {
	DiscounCodes map[string]string

	SeatCost float64
	// contains filtered or unexported fields
}

MyTrainTicketingServiceHandler is an implementation of the TrainTicketingServiceHandler interface.

func (*MyTrainTicketingServiceHandler) GetDiscount

func (h *MyTrainTicketingServiceHandler) GetDiscount(discount_code string) (discount float64, err error)

0. populate or setup the database for discount codes 1. fetch the cost for from/to depending on ticket price 2. get discount if exists in DB 3. apply discount if exists 4. update new cost and update ticket and send

func (*MyTrainTicketingServiceHandler) ModifySeat

ModifySeat implements the ModifySeat method of TrainTicketingServiceHandler.

func (*MyTrainTicketingServiceHandler) PurchaseTicket

PurchaseTicket implements the PurchaseTicket method of TrainTicketingServiceHandler.

func (*MyTrainTicketingServiceHandler) RemoveUser

RemoveUser implements the RemoveUser method of TrainTicketingServiceHandler.

func (*MyTrainTicketingServiceHandler) ViewAdminDetails

ViewAdminDetails implements the ViewAdminDetails method of TrainTicketingServiceHandler.

func (*MyTrainTicketingServiceHandler) ViewReceipt

ViewReceipt implements the ViewReceipt method of TrainTicketingServiceHandler.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL