appsettings

package
v5.2.0--beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: MIT Imports: 13 Imported by: 5

Documentation

Overview

Package appsettings implements functions for changing settings of the app.

App settings are anything that changes functionality of the app.

Index

Constants

This section is empty.

Variables

View Source
var ErrAppSettingsDoNotExist = errors.New("appsettings: info does not exist")

ErrAppSettingsDoNotExist is thrown when no app settings exist yet

Functions

func GenerateAPIKey

func GenerateAPIKey(w http.ResponseWriter, r *http.Request)

GenerateAPIKey creates a new api key and saves it to the datastore the key is also returned to update the gui limit api key length so it is easier to use multiple calls to this func will "rotate" the api key

func GetAPI

func GetAPI(w http.ResponseWriter, r *http.Request)

GetAPI is used when viewing the data in the gui or on a receipt

func SaveAPI

func SaveAPI(w http.ResponseWriter, r *http.Request)

SaveAPI saves new or updates existing company info in the datastore

func SaveDefaultInfo

func SaveDefaultInfo(c context.Context) error

SaveDefaultInfo sets some default data when a company first starts using this app This func is called when the initial super admin is created.

Types

type Settings

type Settings struct {
	RequireCustomerID bool   `json:"require_cust_id"` //is the customer id field required when adding a new card
	CustomerIDFormat  string `json:"cust_id_format"`  //the format of the customer id from a CRM system.  This shows up in the gui.
	CustomerIDRegex   string `json:"cust_id_regex"`   //the regex to check the customer id against.
	ReportTimezone    string `json:"report_timezone"` //the tz database name of the timezone we want to show reports and receipt times in
	APIKey            string `json:"api_key"`         //the api key to access this app to automatically charge cards

	//fields not used in cloud datastore
	ID int64 `json:"sqlite_user_id"`
}

Settings is used for setting or getting the app settings from the datastore

func Get

func Get(r *http.Request) (Settings, error)

Get actually retrienves the information from the datastore putting this into a separate func cleans up code elsewhere

Jump to

Keyboard shortcuts

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