api

package
v0.0.0-...-17a26c4 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmptyBody         = "body of the request is empty"
	InvalidBody       = "body of the request is invalid"
	UnableToParseBody = "enable to parse request body"
	NoParamsFound     = "no parameters found on request"
)

Package wide error messages

View Source
const (
	CreateCustomer         = "create_customer"
	UpdateCustomer         = "update_customer"
	DeleteCustomer         = "delete_customer"
	CustomerLogin          = "customer_login"
	FindCustomer           = "find_customer"
	FindCustomerByUserName = "find_customer_by_user_name"

	UnableToCreateCustomer = "Unable to create a customer"
	UnableToUpdateCustomer = "Unable to update a customer"
	UnableToDeleteCustomer = "Unable to delete a customer"
	UnableToLoginCustomer  = "Unable to login the customer"
	UnableToFindCustomer   = "Unable to find the customer(s)"
)

Constants for error messages and request names

View Source
const (
	SubmitDiagnosticRequest                  = "submit_diagnostic_request"
	UnableToSubmitDiagnosticRequest          = "unable to submit diagnostic request"
	DiagnosticRequestByID                    = "diagnostic_request_by_id"
	DiagnosticRequestsByVetOrgID             = "diagnotistic_requests_by_vetorg_id"
	DiagnosticRequestsByUserID               = "diagnotistic_requests_by_user_id"
	DiagnosticRequestsByCustomerID           = "diagnotistic_requests_by_customer_id"
	DiagnosticRequestsByVetOrgIDAndDateRange = "diagnostic_requests_by_vetorg_id_and_date_range"
	UnableToParseParams                      = "unable to parse request parameters(s)"
	ErrorFetchingDiagnosticRequests          = "error occurred attempting to retrieve diagnostic request(s)"
	ErrorFetchingVetOrg                      = "error occurred attempting to retrieve vetOrg"
	ErrorFetchingUser                        = "error occurred attempting to retrieve user"
	ErrorFetchingCustomer                    = "error occurred attempting to retrieve customer"
)

Constants for error messages and request naming

View Source
const (
	CreateUser         = "create_user"
	UpdateUser         = "update_user"
	DeleteUser         = "delete_user"
	Login              = "login"
	FindUser           = "find_user"
	FindUserByUserName = "find_user_by_user_name"

	UnableToCreateUser = "unable to create a user"
	UnableToUpdateUser = "unable to update a user"
	UnableToDeleteUser = "unable to delete a user"
	UnableToLoginUser  = "unable to login the user"
	UnableToFindUser   = "unable to find the user(s)"
)

Constants for error messages and requests

Variables

View Source
var CustomerRoutes = rata.Routes{
	{Path: "/customers", Method: rata.POST, Name: CreateCustomer},
	{Path: "/customers", Method: rata.PUT, Name: UpdateCustomer},
	{Path: "/customers", Method: rata.DELETE, Name: DeleteCustomer},
	{Path: "/customers/login", Method: rata.POST, Name: CustomerLogin},
	{Path: "/customers/:customer_id", Method: rata.GET, Name: FindCustomer},
	{Path: "/customers/user_name/:user_name", Method: rata.GET, Name: FindCustomerByUserName},
}

CustomerRoutes are the REST endpoint routes for the customer REST interface

View Source
var DiagnosticRequestRoutes = rata.Routes{
	{Path: "/diagnosticrequests", Method: rata.POST, Name: SubmitDiagnosticRequest},
	{Path: "/diagnosticrequests/:request_id", Method: rata.GET, Name: DiagnosticRequestByID},
	{Path: "/diagnosticrequests/vetorg/:vetorg_id", Method: rata.GET, Name: DiagnosticRequestsByVetOrgID},
	{Path: "/diagnosticrequests/vetorg/:vetorg_id/start/:start_date/end/:end_date", Method: rata.GET, Name: DiagnosticRequestsByVetOrgIDAndDateRange},
	{Path: "/diagnosticrequests/user/:user_id", Method: rata.GET, Name: DiagnosticRequestsByUserID},
	{Path: "/diagnosticrequests/customer/:customer_id", Method: rata.GET, Name: DiagnosticRequestsByCustomerID},
}

DiagnosticRequestRoutes are the REST endpoint routes for the diagnostic requests REST interface

View Source
var UserRoutes = rata.Routes{
	{Path: "/users", Method: rata.POST, Name: CreateUser},
	{Path: "/users", Method: rata.PUT, Name: UpdateUser},
	{Path: "/users", Method: rata.DELETE, Name: DeleteUser},
	{Path: "/users/login", Method: rata.POST, Name: Login},
	{Path: "/users/:user_id", Method: rata.GET, Name: FindUser},
	{Path: "/users/username/:user_name", Method: rata.GET, Name: FindUserByUserName},
}

UserRoutes are the REST endpoint routes for the user REST interface

Functions

func NewCustomerHandler

func NewCustomerHandler(customerService CustomerService) (http.Handler, error)

NewCustomerHandler provides the factory function to create the REST interface for customer actions

func NewDiagnosticRequestHandler

func NewDiagnosticRequestHandler(
	diagnosticRequestService DiagnosticRequestService,
	vetOrgService VetOrgService,
	userService UserService,
	customerService CustomerService,
) (http.Handler, error)

NewDiagnosticRequestHandler provides the factory function to create the REST interface for report requests

func NewUserHandler

func NewUserHandler(userService UserService) (http.Handler, error)

NewUserHandler provides the factory function to create the REST interface for user actions

Types

type CustomerServer

type CustomerServer struct {
	CustomerService CustomerService
}

CustomerServer struct allows the CustomerService injection into the REST handler

func (*CustomerServer) CreateCustomer

func (customerServer *CustomerServer) CreateCustomer(writer http.ResponseWriter, request *http.Request)

CreateCustomer is the REST endpoint function that allows for the creation of customers in the system

func (*CustomerServer) CustomerLogin

func (customerServer *CustomerServer) CustomerLogin(writer http.ResponseWriter, request *http.Request)

CustomerLogin handles the request to log in a Customer to the system

func (*CustomerServer) DeleteCustomer

func (customerServer *CustomerServer) DeleteCustomer(writer http.ResponseWriter, request *http.Request)

DeleteCustomer handles the request to delete a Customer from the system

func (*CustomerServer) FindCustomer

func (customerServer *CustomerServer) FindCustomer(writer http.ResponseWriter, request *http.Request)

FindCustomer handles the request to find a Customer by their customer id

func (*CustomerServer) FindCustomerByUserName

func (customerServer *CustomerServer) FindCustomerByUserName(writer http.ResponseWriter, request *http.Request)

FindCustomerByUserName handles the request to find a Customer by their customer name

func (*CustomerServer) UpdateCustomer

func (customerServer *CustomerServer) UpdateCustomer(writer http.ResponseWriter, request *http.Request)

UpdateCustomer handles the request for updating a Customer on the system

type CustomerService

type CustomerService interface {
	CreateCustomer(ctx context.Context, user model.Customer) (*model.Customer, error)
	UpdateCustomer(ctx context.Context, user model.Customer) (*model.Customer, error)
	DeleteCustomer(ctx context.Context, user model.Customer) error
	UpdatePassword(ctx context.Context, user model.Customer, password string) (*model.Customer, error)

	Login(ctx context.Context, userName string, password string) (*model.Customer, error)

	FindCustomerByUserName(ctx context.Context, userName string) (*model.Customer, error)
	FindCustomerByID(ctx context.Context, userID uint) (*model.Customer, error)
	FindCustomerByVetOrg(ctx context.Context, vetOrg model.VetOrg) ([]model.Customer, error)
}

CustomerService provides the business operations for maintaining users within the application

type DiagnosticReportService

type DiagnosticReportService interface {
	SubmitDiagnosticReport(ctx context.Context, diagReport model.DiagnosticReport) (*model.DiagnosticReport, error)

	FindReportByDateRange(ctx context.Context, start time.Time, end time.Time, vetOrg model.VetOrg) ([]model.DiagnosticReport, error)
	FindReportByID(ctx context.Context, reportID uint) (*model.DiagnosticReport, error)
	FindReportByVetOrg(ctx context.Context, vetOrg model.VetOrg) ([]model.DiagnosticReport, error)
	FindReportByUser(ctx context.Context, user model.User) ([]model.DiagnosticReport, error)
	FindReportByCustomer(ctx context.Context, customer model.Customer) ([]model.DiagnosticReport, error)
}

DiagnosticReportService provides the business operations for providing diagnostic reports

type DiagnosticRequestServer

type DiagnosticRequestServer struct {
	DiagnosticRequestService DiagnosticRequestService
	VetOrgService            VetOrgService
	UserService              UserService
	CustomerService          CustomerService
}

DiagnosticRequestServer struct allows the DiagnosticReportService injection into the REST handler

func (*DiagnosticRequestServer) FindDiagnotisticRequest

func (diagnosticRequestServer *DiagnosticRequestServer) FindDiagnotisticRequest(writer http.ResponseWriter, request *http.Request)

FindDiagnotisticRequest is a handler that handles searches for diagstic requests by ID

func (*DiagnosticRequestServer) FindDiagnotisticRequestByCustomer

func (diagnosticRequestServer *DiagnosticRequestServer) FindDiagnotisticRequestByCustomer(writer http.ResponseWriter, request *http.Request)

FindDiagnotisticRequestByCustomer is a handler that handles searches for diagnostic requests by Customer

func (*DiagnosticRequestServer) FindDiagnotisticRequestByDateRange

func (diagnosticRequestServer *DiagnosticRequestServer) FindDiagnotisticRequestByDateRange(writer http.ResponseWriter, request *http.Request)

FindDiagnotisticRequestByDateRange is a handler that handles searches for diagnostic requests by VetOrg and date range

func (*DiagnosticRequestServer) FindDiagnotisticRequestByUser

func (diagnosticRequestServer *DiagnosticRequestServer) FindDiagnotisticRequestByUser(writer http.ResponseWriter, request *http.Request)

FindDiagnotisticRequestByUser is a handler that handles searches for diagnostic requests by User

func (*DiagnosticRequestServer) FindDiagnotisticRequestByVetOrg

func (diagnosticRequestServer *DiagnosticRequestServer) FindDiagnotisticRequestByVetOrg(writer http.ResponseWriter, request *http.Request)

FindDiagnotisticRequestByVetOrg is a handler that handles searches for diagnostic requests by VetOrg

func (*DiagnosticRequestServer) SubmitDiagnosticRequest

func (diagnosticRequestServer *DiagnosticRequestServer) SubmitDiagnosticRequest(writer http.ResponseWriter, request *http.Request)

SubmitDiagnosticRequest is the REST function that allows for the creation of a report request

type DiagnosticRequestService

type DiagnosticRequestService interface {
	SubmitDiagnosticRequest(ctx context.Context, diagReq model.DiagnosticRequest) (*model.DiagnosticRequest, error)

	FindRequestByDateRange(ctx context.Context, start time.Time, end time.Time, vetOrg model.VetOrg) ([]model.DiagnosticRequest, error)
	FindRequestByID(ctx context.Context, requestID uint) (*model.DiagnosticRequest, error)
	FindRequestByVetOrg(ctx context.Context, vetOrg model.VetOrg) ([]model.DiagnosticRequest, error)
	FindRequestByUser(ctx context.Context, user model.User) ([]model.DiagnosticRequest, error)
	FindRequestByCustomer(ctx context.Context, customer model.Customer) ([]model.DiagnosticRequest, error)
}

DiagnosticRequestService provides the business operations for requesting diagnostic reports

type UserServer

type UserServer struct {
	UserService UserService
}

UserServer struct allows the UserService injection into the REST handler

func (*UserServer) CreateUser

func (userServer *UserServer) CreateUser(writer http.ResponseWriter, request *http.Request)

CreateUser is the REST endpoint function that allows for the creation of users in the system

func (*UserServer) DeleteUser

func (userServer *UserServer) DeleteUser(writer http.ResponseWriter, request *http.Request)

DeleteUser takes care of handling the api request for deleting a User

func (*UserServer) FindUser

func (userServer *UserServer) FindUser(writer http.ResponseWriter, request *http.Request)

FindUser handles the api request to find a user by their user id

func (*UserServer) FindUserByUserName

func (userServer *UserServer) FindUserByUserName(writer http.ResponseWriter, request *http.Request)

FindUserByUserName handles the request to find a user by their username

func (*UserServer) Login

func (userServer *UserServer) Login(writer http.ResponseWriter, request *http.Request)

Login handles the api request to log in to the system

func (*UserServer) UpdateUser

func (userServer *UserServer) UpdateUser(writer http.ResponseWriter, request *http.Request)

UpdateUser takes care of the api request to update a User in the system

type UserService

type UserService interface {
	CreateUser(ctx context.Context, user model.User) (*model.User, error)
	UpdateUser(ctx context.Context, user model.User) (*model.User, error)
	DeleteUser(ctx context.Context, user model.User) error
	UpdatePassword(ctx context.Context, user model.User, password string) (*model.User, error)

	Login(ctx context.Context, userName string, password string) (*model.User, error)

	FindUserByUserName(ctx context.Context, userName string) (*model.User, error)
	FindUserByID(ctx context.Context, userID uint) (*model.User, error)
}

UserService provides the business operations for maintaining users within the application

type VetOrgService

type VetOrgService interface {
	CreateVetOrg(ctx context.Context, vetOrg model.VetOrg) (*model.VetOrg, error)
	UpdateVetOrg(ctx context.Context, vetOrg model.VetOrg) (*model.VetOrg, error)
	DeleteVetOrg(ctx context.Context, vetOrg model.VetOrg) error

	AddCustomerToVetOrg(ctx context.Context, user model.Customer, vetOrg model.VetOrg) (*model.Customer, error)
	RemoveCustomerFromVetOrg(ctx context.Context, user model.Customer, vetOrg model.VetOrg) (*model.Customer, error)

	FindVetOrgByName(ctx context.Context, orgName string) ([]model.VetOrg, error)
	FindVetOrgByID(ctx context.Context, orgID uint) (*model.VetOrg, error)
}

VetOrgService provides the business operations for maintaining veterinary practices within the application

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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