providers

package
v0.0.0-...-8baf154 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// GetPath path for HTTP GET Method which to query for providers
	GetPath = "/providers"
	// SingleGetPath path for HTTP GET Method to query for a single provider
	SingleGetPath = GetPath + "/" + uuidPattern
	// CreatePath path for HTTP POST Method to create a new provider
	CreatePath = "/providers"
	// DeletePath path for HTTP DELETE Method to delete a provider
	DeletePath = "/providers/" + uuidPattern
)
View Source
const (
	// NJTransitType one of supported Provider types
	NJTransitType = "NJTransit"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	Repository *Repository
	// contains filtered or unexported fields
}

Controller handles all provider related requests.

func NewController

func NewController(repo *Repository) Controller

NewController creates new Providers controller

func (*Controller) Create

func (c *Controller) Create(w http.ResponseWriter, r *http.Request)

Create creates a new provider.

func (*Controller) Delete

func (c *Controller) Delete(w http.ResponseWriter, r *http.Request)

Delete deletes provider.

func (*Controller) Get

func (c *Controller) Get(w http.ResponseWriter, r *http.Request)

Get returns one provider.

func (*Controller) GetAll

func (c *Controller) GetAll(w http.ResponseWriter, r *http.Request)

GetAll returns all providers.

type NJTransit

type NJTransit struct {
	OrigStationCode *string `json:"orig_station_code" bson:"orig_station_code"`
	DestStationCode *string `json:"dest_station_code" bson:"dest_station_code"`
}

NJTransit model that represents NJ Transit provider

type Provider

type Provider struct {
	ID        mongo.UUID `json:"_id" bson:"_id"`
	Type      *string    `json:"type" bson:"type"`
	NJTransit *NJTransit `json:"njtransit,omitempty" bson:"njtransit,omitempty"`
}

Provider model that represents providers

type Repository

type Repository struct {
	Mongo *mongo.Client
}

Repository to access providers store

func (*Repository) CreateOne

func (r *Repository) CreateOne(provider Provider) bool

CreateOne creates new provider for specified params

func (*Repository) DeleteAll

func (r *Repository) DeleteAll(uuids []apimongo.UUID) (bool, error)

DeleteAll deletes providers with IDs and returns true if any record was removed

func (*Repository) DeleteOne

func (r *Repository) DeleteOne(uuid apimongo.UUID) (bool, error)

DeleteOne deletes provider with ID and returns true if record was removed

func (*Repository) GetAll

func (r *Repository) GetAll() ([]Provider, error)

GetAll returns all providers

func (*Repository) GetOne

func (r *Repository) GetOne(uuid apimongo.UUID) (*Provider, error)

GetOne returns provider by ID or nil

Jump to

Keyboard shortcuts

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