Documentation ¶
Overview ¶
payments contains the http routes that perform CRUD operations on payments
Index ¶
- type Links
- type Payment
- type PaymentAttributes
- type PaymentRequest
- type PaymentResponse
- type PaymentsResponse
- type PaymentsService
- func (s *PaymentsService) Create(w http.ResponseWriter, r *http.Request)
- func (s *PaymentsService) Delete(w http.ResponseWriter, r *http.Request)
- func (s *PaymentsService) Fetch(w http.ResponseWriter, r *http.Request)
- func (s *PaymentsService) List(w http.ResponseWriter, r *http.Request)
- func (s *PaymentsService) Routes() *chi.Mux
- func (s *PaymentsService) Update(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Payment ¶
type Payment struct { Id string `json:"id"` Type string `json:"type"` Version int `json:"version"` Organisation string `json:"organisation_id"` Attributes PaymentAttributes `json:"attributes"` }
Payment a payment
func NewPaymentFromRepoItem ¶
Converts a repo item into a payment
func NewPaymentsFromRepoItems ¶
PaymentsFromRepoItems converts the given slice of repo items to a list of payments
func (*Payment) ToRepoItem ¶
Converts a payment into something that can be saved into the database
type PaymentAttributes ¶
type PaymentAttributes struct {
Amount string `json:"amount"`
}
Payment attributes captures all detaled information about a payment. Here we are only capturing the Amount, for convenience, and we're leaving out the rest.
func (*PaymentAttributes) Validate ¶
func (pa *PaymentAttributes) Validate() error
Validate does semantic validation on the payment attributes
type PaymentRequest ¶
type PaymentRequest struct {
Payment *Payment `json:"data"`
}
PaymentRequest represents a http request that contains a payment in its field 'data'
type PaymentResponse ¶
PaymentResponse represents a http response that contains a payment in its field 'data' and set of links
type PaymentsResponse ¶
PaymentsResponse represents a http response that contains a list of payments in its field 'data' and a set of links
type PaymentsService ¶
type PaymentsService struct { HttpService // contains filtered or unexported fields }
PaymentsService represents a payments service it defines the routes and the repo to operate with. It inherits fields and functions from util.HttpService
func New ¶
func New(repo Repo, baseUrl string, maxResults int) *PaymentsService
New creates a new PaymentsService with the given repo, base url and maxResults information
func (*PaymentsService) Create ¶
func (s *PaymentsService) Create(w http.ResponseWriter, r *http.Request)
Create a new payment
func (*PaymentsService) Delete ¶
func (s *PaymentsService) Delete(w http.ResponseWriter, r *http.Request)
Delete a payment by id
func (*PaymentsService) Fetch ¶
func (s *PaymentsService) Fetch(w http.ResponseWriter, r *http.Request)
Fetch a payment by id
func (*PaymentsService) List ¶
func (s *PaymentsService) List(w http.ResponseWriter, r *http.Request)
List returns a list of payments. We return finite lists of payments so we need to check the from and to query params, and make sure they make sense. If they are not set, we fallback to defaults.
func (*PaymentsService) Routes ¶
func (s *PaymentsService) Routes() *chi.Mux
Routes returns a router with all routes supported by this service
func (*PaymentsService) Update ¶
func (s *PaymentsService) Update(w http.ResponseWriter, r *http.Request)
Update an existing payment