Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) DeleteByID(m Model) error
- func (c *Client) DeleteRequest(url string) (*http.Response, error)
- func (c *Client) FetchCache() error
- func (c *Client) FetchIfNeeded(m ModelList, args []string) error
- func (c *Client) FetchList(m ModelList, args []string) error
- func (c *Client) GetByID(m Model) error
- func (c *Client) GetRequest(url string) (*http.Response, error)
- func (c *Client) PatchRequest(url string, i interface{}) (*http.Response, error)
- func (c *Client) PostRequest(url string, i interface{}) (*http.Response, error)
- func (c *Client) Request(verb, url string, code int, payload io.Reader) (*http.Response, error)
- type CompaniesList
- type Company
- type Contract
- type ContractsList
- func (cs *ContractsList) GetByID(id int) *Contract
- func (cs *ContractsList) GetByLabel(label string) *Contract
- func (cs *ContractsList) GetColumns() []string
- func (cs *ContractsList) GetDefaultColumns() []string
- func (cs *ContractsList) HasPorcelain() bool
- func (cs *ContractsList) PorcelainPrettyPrint()
- func (cs *ContractsList) PrettyPrint(columns []string)
- func (cs *ContractsList) Slug() string
- type Model
- type ModelList
- type Performance
- func (p *Performance) Augment(c *Client)
- func (p *Performance) DeleteArg() string
- func (p *Performance) FetchContract(c Client) error
- func (p *Performance) FetchRate(c Client) error
- func (p *Performance) FetchTimesheet(c Client) error
- func (p *Performance) GetByID(c Client) error
- func (p *Performance) GetColumn(name string) string
- func (p *Performance) GetID() int
- func (p *Performance) New(c Client) error
- func (p *Performance) Porcelain()
- func (p *Performance) PrettyPrint()
- func (p *Performance) SetID(i int)
- func (p *Performance) Slug() string
- func (p *Performance) Sporcelain() string
- type PerformanceRate
- func (p *PerformanceRate) Augment(c *Client)
- func (p *PerformanceRate) DeleteArg() string
- func (p *PerformanceRate) GetID() int
- func (p *PerformanceRate) PrettyList() string
- func (p *PerformanceRate) PrettyPrint()
- func (p *PerformanceRate) SetID(i int)
- func (p *PerformanceRate) ShortPrint()
- func (p *PerformanceRate) Slug() string
- type PerformanceRatesList
- func (pr *PerformanceRatesList) GetByID(id int) *PerformanceRate
- func (pr *PerformanceRatesList) GetByMultiplier(multiplier string) (*PerformanceRate, error)
- func (pr *PerformanceRatesList) GetColumns() []string
- func (pr *PerformanceRatesList) GetDefaultColumns() []string
- func (pr *PerformanceRatesList) HasPorcelain() bool
- func (pr *PerformanceRatesList) PorcelainPrettyPrint()
- func (pr *PerformanceRatesList) PrettyList() string
- func (pr *PerformanceRatesList) PrettyPrint(columns []string)
- func (pr *PerformanceRatesList) ShortPrint()
- func (pr *PerformanceRatesList) Slug() string
- type PerformanceType
- type PerformancesList
- func (ps *PerformancesList) GetColumn(name string) string
- func (ps *PerformancesList) GetColumns() []string
- func (ps *PerformancesList) GetDefaultColumns() []string
- func (ps *PerformancesList) HasPorcelain() bool
- func (ps *PerformancesList) PorcelainPrettyPrint()
- func (ps *PerformancesList) PrettyPrint(columns []string)
- func (ps *PerformancesList) Slug() string
- type Timesheet
- func (t *Timesheet) Augment(c *Client)
- func (t *Timesheet) DeleteArg() string
- func (t *Timesheet) Get(c Client) error
- func (t *Timesheet) GetByID(c Client) error
- func (t *Timesheet) GetID() int
- func (t *Timesheet) Name() string
- func (t *Timesheet) New(c Client) error
- func (t *Timesheet) PrettyPrint()
- func (t *Timesheet) Release(c Client) error
- func (t *Timesheet) SetID(i int)
- func (t *Timesheet) Slug() string
- type TimesheetsList
- func (ts *TimesheetsList) GetByID(id int) *Timesheet
- func (ts *TimesheetsList) GetColumns() []string
- func (ts *TimesheetsList) GetDefaultColumns() []string
- func (ts *TimesheetsList) HasPorcelain() bool
- func (ts *TimesheetsList) PorcelainPrettyPrint()
- func (ts *TimesheetsList) PrettyPrint(columns []string)
- func (ts *TimesheetsList) Slug() string
- type User
- type UsersList
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Companies = &CompaniesList{}
Companies stores the companies we have in cache or fetched from the server.
var Contracts = &ContractsList{}
Contracts stores the contracts we have in cache or fetched from the server.
var Models = &models{}
Models represents all the lists we can view, edit, etc
var Performances = &PerformancesList{}
Performances stores the performances as we get them from the ninetofiver server
var PerformancesColumns = []string{"day", "contract", "description", "duration", "multiplier", "type", "id"}
PerformancesColumns are all the columns we can show for performances.
PerformancesColumnsDefault is a list of booleans. true means column will be shown by default. Each boolean represents the column at the same place in the PerformancesColumns list.
var PerformancesRates = &PerformanceRatesList{}
PerformancesRates stores the performances rates we get from the cache or the remote server
var Users = &UsersList{}
Users is used to cache the list of Users
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is the nine-to-fiver client, responsible for fetching and update items
func (*Client) DeleteByID ¶
DeleteByID returns the model from the server
func (*Client) DeleteRequest ¶
DeleteRequest will make a DELETE request for a given model and expect error code to be 204
func (*Client) FetchCache ¶
FetchCache will fill the cache with content from localdisk or ninetofiver instance
func (*Client) FetchIfNeeded ¶
FetchIfNeeded fetches a list if it is empty
func (*Client) GetRequest ¶
GetRequest will make a GET request for a given model and expect error code to be 200
func (*Client) PatchRequest ¶
PatchRequest will make a PATCH request for a given model and expect error code to be 200
func (*Client) PostRequest ¶
PostRequest will make a POST request for a given model and expect error code to be 201
type CompaniesList ¶
type CompaniesList struct {
Companies []Company `json:"results"`
}
CompaniesList is a list of companies in the ninetofiver api
func (*CompaniesList) GetColumns ¶
func (cs *CompaniesList) GetColumns() []string
GetColumns returns an empty list because companies are not displayed as a table
func (*CompaniesList) GetDefaultColumns ¶
func (cs *CompaniesList) GetDefaultColumns() []string
GetDefaultColumns returns an empty list because companies are not displayed as a table
func (*CompaniesList) HasPorcelain ¶
func (cs *CompaniesList) HasPorcelain() bool
HasPorcelain returns false because companies do not support PorcelainPrettyPrint
func (*CompaniesList) PorcelainPrettyPrint ¶
func (cs *CompaniesList) PorcelainPrettyPrint()
PorcelainPrettyPrint does nothing for this model
func (*CompaniesList) PrettyPrint ¶
func (cs *CompaniesList) PrettyPrint(columns []string)
PrettyPrint prints companies in a nice way to the console
Example ¶
t := &CompaniesList{ Companies: []Company{ Company{ Name: "Inuits", Country: "BE", }, Company{ Name: "Eskimo", Country: "NL", }, }, } t.PrettyPrint(*new([]string))
Output: Inuits [BE] Eskimo [NL]
func (*CompaniesList) Slug ¶
func (cs *CompaniesList) Slug() string
Slug is used to represent the model in cli
type Company ¶
type Company struct { ID int `json:"id"` Name string `json:"name"` Country string `json:"country"` }
Company is a company as seen in the ninetofiver api
func (*Company) PrettyPrint ¶
func (c *Company) PrettyPrint()
PrettyPrint prints company in a nice way to the console
Example ¶
t := &Company{ Name: "Inuits", Country: "BE", } t.PrettyPrint()
Output: Inuits [BE]
type Contract ¶
type Contract struct { ID int `json:"id"` Label string `json:"label"` CustomerID int `json:"customer"` Customer *Company }
Contract is a contract as seen in the ninetofiver api.
func (*Contract) PrettyLabel ¶
PrettyLabel returns the label of a contract that can be used in CLI etc.. to identify a contract. It contains the customer.
func (*Contract) PrettyPrint ¶
func (c *Contract) PrettyPrint()
PrettyPrint prints contract in a nice way to the console
type ContractsList ¶
type ContractsList struct {
Contracts []Contract `json:"results"`
}
ContractsList is a list of contrats as seen in the ninetofiver api.
func (*ContractsList) GetByID ¶
func (cs *ContractsList) GetByID(id int) *Contract
GetByID returns the contract with the given id
func (*ContractsList) GetByLabel ¶
func (cs *ContractsList) GetByLabel(label string) *Contract
GetByLabel returns the contract with the given label
func (*ContractsList) GetColumns ¶
func (cs *ContractsList) GetColumns() []string
GetColumns returns an empty list because contracts are not displayed as a table
func (*ContractsList) GetDefaultColumns ¶
func (cs *ContractsList) GetDefaultColumns() []string
GetDefaultColumns returns an empty list because contracts are not displayed as a table
func (*ContractsList) HasPorcelain ¶
func (cs *ContractsList) HasPorcelain() bool
HasPorcelain returns false because contracts do not support PorcelainPrettyPrint
func (*ContractsList) PorcelainPrettyPrint ¶
func (cs *ContractsList) PorcelainPrettyPrint()
PorcelainPrettyPrint does nothing for this model
func (*ContractsList) PrettyPrint ¶
func (cs *ContractsList) PrettyPrint(columns []string)
PrettyPrint prints contracts in a nice way to the console
func (*ContractsList) Slug ¶
func (cs *ContractsList) Slug() string
Slug is used to represent the model in cli
type Model ¶
type Model interface { SetID(int) GetID() int DeleteArg() string Augment(*Client) PrettyPrint() Slug() string // contains filtered or unexported methods }
Model is an interface shared by all the models
type ModelList ¶
type ModelList interface { Slug() string GetColumns() []string GetDefaultColumns() []string PrettyPrint([]string) HasPorcelain() bool PorcelainPrettyPrint() // contains filtered or unexported methods }
ModelList is an interface shared by all the models lists
type Performance ¶
type Performance struct { ID int `json:"id"` Type PerformanceType `json:"type"` Timesheet *Timesheet TimesheetID int `json:"timesheet"` ContractID int `json:"contract"` Contract *Contract Day int `json:"day"` Description string `json:"description"` Duration string `json:"duration"` RateID int `json:"performance_type"` Rate *PerformanceRate }
Performance represents one performance we get in the ninetofoiver app
func (*Performance) Augment ¶
func (p *Performance) Augment(c *Client)
Augment populates extra fields of a performance
func (*Performance) DeleteArg ¶
func (p *Performance) DeleteArg() string
DeleteArg returns the args needed to delete a performance
func (*Performance) FetchContract ¶
func (p *Performance) FetchContract(c Client) error
FetchContract fills the contract field of this performance
func (*Performance) FetchRate ¶
func (p *Performance) FetchRate(c Client) error
FetchRate fills the rate field of this performance
func (*Performance) FetchTimesheet ¶
func (p *Performance) FetchTimesheet(c Client) error
FetchTimesheet fills the timesheet field of this performance
func (*Performance) GetByID ¶
func (p *Performance) GetByID(c Client) error
GetByID gets the performance from the server given its it
func (*Performance) GetColumn ¶
func (p *Performance) GetColumn(name string) string
GetColumn returns the content of a column for a performance
func (*Performance) GetID ¶
func (p *Performance) GetID() int
GetID returns the id of the performance
func (*Performance) New ¶
func (p *Performance) New(c Client) error
New creates a new performance on the server
func (*Performance) Porcelain ¶
func (p *Performance) Porcelain()
Porcelain prints out the porcelain version of the performance
func (*Performance) PrettyPrint ¶
func (p *Performance) PrettyPrint()
PrettyPrint prints the performance
func (*Performance) Slug ¶
func (p *Performance) Slug() string
Slug is used to represent the model in cli
func (*Performance) Sporcelain ¶
func (p *Performance) Sporcelain() string
Sporcelain creates a parsable string for the performance. Useful for scripting.
type PerformanceRate ¶
type PerformanceRate struct { ID int `json:"id"` Label string `json:"label"` Multiplier string `json:"multiplier"` }
PerformanceRate represents a Performance Rate in the ninetofiver api.
func (*PerformanceRate) Augment ¶
func (p *PerformanceRate) Augment(c *Client)
Augment populates extra fields of a perf rate
func (*PerformanceRate) DeleteArg ¶
func (p *PerformanceRate) DeleteArg() string
DeleteArg returns what is required on the api side to delete a performance rate
func (*PerformanceRate) GetID ¶
func (p *PerformanceRate) GetID() int
GetID returns the ID of the perf rate
func (*PerformanceRate) PrettyList ¶
func (p *PerformanceRate) PrettyList() string
PrettyList returns a short list of performances rates, used in error messages (when a user specifies an unknown multiplier)
func (*PerformanceRate) PrettyPrint ¶
func (p *PerformanceRate) PrettyPrint()
PrettyPrint prints the performance rate in a nice way.
func (*PerformanceRate) SetID ¶
func (p *PerformanceRate) SetID(i int)
SetID sets the ID of the perf rate
func (*PerformanceRate) ShortPrint ¶
func (p *PerformanceRate) ShortPrint()
ShortPrint the multiplier of the performance rate, and only that.
func (*PerformanceRate) Slug ¶
func (p *PerformanceRate) Slug() string
Slug is used to represent the model in cli
type PerformanceRatesList ¶
type PerformanceRatesList struct {
PerformanceRates []PerformanceRate `json:"results"`
}
PerformanceRatesList represents a list of Performances Rates as we get them from the server.
func (*PerformanceRatesList) GetByID ¶
func (pr *PerformanceRatesList) GetByID(id int) *PerformanceRate
GetByID fills a performance given its ID.
func (*PerformanceRatesList) GetByMultiplier ¶
func (pr *PerformanceRatesList) GetByMultiplier(multiplier string) (*PerformanceRate, error)
GetByMultiplier fills a performance given its multiplier. It will error if multiple performances rates are found with the same multiplier.
func (*PerformanceRatesList) GetColumns ¶
func (pr *PerformanceRatesList) GetColumns() []string
GetColumns returns an empty list because performances rates are not displayed as a table
func (*PerformanceRatesList) GetDefaultColumns ¶
func (pr *PerformanceRatesList) GetDefaultColumns() []string
GetDefaultColumns returns an empty list because Performance rates are not displayed as a table
func (*PerformanceRatesList) HasPorcelain ¶
func (pr *PerformanceRatesList) HasPorcelain() bool
HasPorcelain returns false because performances rates do not support PorcelainPrettyPrint
func (*PerformanceRatesList) PorcelainPrettyPrint ¶
func (pr *PerformanceRatesList) PorcelainPrettyPrint()
PorcelainPrettyPrint does nothing for this model
func (*PerformanceRatesList) PrettyList ¶
func (pr *PerformanceRatesList) PrettyList() string
PrettyList returns a string with all the performances rates displayed as a short list.
func (*PerformanceRatesList) PrettyPrint ¶
func (pr *PerformanceRatesList) PrettyPrint(columns []string)
PrettyPrint prints the performances rates in a nice way.
func (*PerformanceRatesList) ShortPrint ¶
func (pr *PerformanceRatesList) ShortPrint()
ShortPrint prints all the multipliers of the performance rates in the list, and only that.
func (*PerformanceRatesList) Slug ¶
func (pr *PerformanceRatesList) Slug() string
Slug is used to represent the model in cli
type PerformanceType ¶
type PerformanceType int
PerformanceType represents a Performance Type (standby/activity)
const ( // ActivityPerformance represents the Activity Performance type ActivityPerformance PerformanceType = iota // StandbyPerformance represents the Standby Performance Type StandbyPerformance )
func (PerformanceType) String ¶
func (p PerformanceType) String() string
String returns the performance type as a string
func (*PerformanceType) UnmarshalJSON ¶
func (p *PerformanceType) UnmarshalJSON(b []byte) error
UnmarshalJSON returns the performance type as an integer, like we expect it for PerformanceType
type PerformancesList ¶
type PerformancesList struct {
Performances []Performance `json:"results"`
}
PerformancesList represents a list of performances we get from the ninetofiver server
func (*PerformancesList) GetColumn ¶
func (ps *PerformancesList) GetColumn(name string) string
GetColumn returns the header of a column for performances
func (*PerformancesList) GetColumns ¶
func (ps *PerformancesList) GetColumns() []string
GetColumns returns all the available columns in the performances tabular
func (*PerformancesList) GetDefaultColumns ¶
func (ps *PerformancesList) GetDefaultColumns() []string
GetDefaultColumns returns the list of default columns for performances
func (*PerformancesList) HasPorcelain ¶
func (ps *PerformancesList) HasPorcelain() bool
HasPorcelain returns true because contracts do support PorcelainPrettyPrint
func (*PerformancesList) PorcelainPrettyPrint ¶
func (ps *PerformancesList) PorcelainPrettyPrint()
PorcelainPrettyPrint prints out the porcelain version of the performances
func (*PerformancesList) PrettyPrint ¶
func (ps *PerformancesList) PrettyPrint(columns []string)
PrettyPrint prints a list of performances as a table which columns specified as parameter
func (*PerformancesList) Slug ¶
func (ps *PerformancesList) Slug() string
Slug is used to represent the model in cli
type Timesheet ¶
type Timesheet struct { ID int `json:"id"` Year int `json:"year"` Month int `json:"month"` DisplayLabel string `json:"display_label"` Status string `json:"status"` }
Timesheet represents a ninetofiver timesheet
func (*Timesheet) PrettyPrint ¶
func (t *Timesheet) PrettyPrint()
PrettyPrint prints timesheet in a nice way to the console
Example ¶
t := &Timesheet{ Year: 2016, Month: 7, Status: "PENDING", } t.PrettyPrint()
Output: July 2016 [PENDING]
type TimesheetsList ¶
type TimesheetsList struct {
Timesheets []Timesheet `json:"results"`
}
TimesheetsList represents a list of ninetofiver timesheet
func (*TimesheetsList) GetByID ¶
func (ts *TimesheetsList) GetByID(id int) *Timesheet
GetByID returns the timesheet with the given id
func (*TimesheetsList) GetColumns ¶
func (ts *TimesheetsList) GetColumns() []string
GetColumns returns an empty list because timesheets are not displayed as a table
func (*TimesheetsList) GetDefaultColumns ¶
func (ts *TimesheetsList) GetDefaultColumns() []string
GetDefaultColumns returns an empty list because timesheets are not displayed as a table
func (*TimesheetsList) HasPorcelain ¶
func (ts *TimesheetsList) HasPorcelain() bool
HasPorcelain returns false because timesheets do not support PorcelainPrettyPrint
func (*TimesheetsList) PorcelainPrettyPrint ¶
func (ts *TimesheetsList) PorcelainPrettyPrint()
PorcelainPrettyPrint does nothing for this model
func (*TimesheetsList) PrettyPrint ¶
func (ts *TimesheetsList) PrettyPrint(columns []string)
PrettyPrint prints timesheets in a nice way to the console
Example ¶
t := &TimesheetsList{ Timesheets: []Timesheet{ Timesheet{ Year: 2007, Month: 8, Status: "APPROVED", }, Timesheet{ Year: 2016, Month: 7, Status: "PENDING", }, }, } t.PrettyPrint(*new([]string))
Output: August 2007 [APPROVED] July 2016 [PENDING]
func (*TimesheetsList) Slug ¶
func (ts *TimesheetsList) Slug() string
Slug is used to represent the model in cli
type User ¶
type User struct { ID int Username string Email string Groups []string FirstName string `json:"first_name"` LastName string `json:"last_name"` DisplayLabel string IsActive bool Country string Gender string BirthDate string JoinDate string RedmineID int `json:"redmine_id"` }
User represents a ninetofiver user
func (*User) PrettyPrint ¶
func (u *User) PrettyPrint()
PrettyPrint prints user in a nice way to the console
type UsersList ¶
type UsersList struct {
Users []User `json:"results"`
}
UsersList is a list of ninetofiver users
func (*UsersList) GetColumns ¶
GetColumns returns an empty list because users are not displayed as a table
func (*UsersList) GetDefaultColumns ¶
GetDefaultColumns returns an empty list because users are not displayed as a table
func (*UsersList) HasPorcelain ¶
HasPorcelain returns false because users do not support PorcelainPrettyPrint
func (*UsersList) PorcelainPrettyPrint ¶
func (users *UsersList) PorcelainPrettyPrint()
PorcelainPrettyPrint does nothing for this model
func (*UsersList) PrettyPrint ¶
PrettyPrint prints users in a nice way to the console