country

package
v0.0.0-...-2cbf9d5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package country contains country related CRUD functionality.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is used when a specific country is requested but does not exist.
	ErrNotFound = errors.New("not found")

	// ErrInvalidID occurs when an ID is not in a valid form.
	ErrInvalidID = errors.New("ID is not in its proper form")

	// ErrForbidden occurs when a user tries to do something that is forbidden to them according to our access control policies.
	ErrForbidden = errors.New("attempted action is not allowed")
)

Functions

This section is empty.

Types

type Country

type Country struct {
	// contains filtered or unexported fields
}

Country manages the set of API's for country access.

func New

func New(log *log.Logger, db *sqlx.DB) Country

New constructs a Country for api access.

func (Country) Query

func (c Country) Query(ctx context.Context, traceID string, pageNumber int, rowsPerPage int) ([]Info, error)

Query retrieves a list of active countries from the database.

func (Country) QueryByCode

func (c Country) QueryByCode(ctx context.Context, traceID string, claims auth.Claims, countryCode string) (Info, error)

QueryByCode gets the specified country from the database.

func (Country) ToggleActive

func (c Country) ToggleActive(ctx context.Context, traceID string, claims auth.Claims, countryCode string) error

ToggleActive toggles the activation state of a country in the database.

type Info

type Info struct {
	CountryCode  string `db:"code" json:"code"`
	GNID         int    `db:"gnid" json:"gnid"`
	Name         string `db:"name" json:"name"`
	CurrencyCode string `db:"currency_code" json:"currency_code"`
	CurrencyName string `db:"currency_name" json:"currency_name"`
	Active       bool   `db:"active" json:"active"`
}

Jump to

Keyboard shortcuts

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