forecast

package module
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

README

forecast

A Forecast (forecastapp.com) API Client For Go.

Usage

To use the Forecast API, you need:

Next, construct an API:

api := forecast.New(
  "https://api.forecastapp.com",
  "your-accountid-here",
  "your-accesstoken-here"
)

Then, make use of the API. Consult godoc for detailed API documentation.

License

Apache 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToParams added in v1.2.0

func ToParams(values url.Values) string

ToParams formats url.Values as a string

Types

type API

type API struct {
	URL       string
	AccountID string
	// contains filtered or unexported fields
}

API provides access to the forecastapp.com API

func New

func New(url string, accountID string, accessToken string) *API

New returns a API that is authenticated with Forecast

func (*API) Account

func (api *API) Account() (*Account, error)

Account returns information about the current Forecast account

func (*API) Assignments

func (api *API) Assignments() (Assignments, error)

Assignments retrieves all assignments for the Forecast account

func (*API) AssignmentsWithFilter added in v1.2.0

func (api *API) AssignmentsWithFilter(filter AssignmentFilter) (Assignments, error)

AssignmentsWithFilter retrieves all assignments for the Forecast account

func (*API) Clients

func (api *API) Clients() (Clients, error)

Clients retrieves all clients in the Forecast account

func (*API) FutureScheduledHours

func (api *API) FutureScheduledHours(from string) (FutureScheduledHours, error)

FutureScheduledHours returns all future scheduled hours using the supplied date as the starting point

func (*API) FutureScheduledHoursForProject

func (api *API) FutureScheduledHoursForProject(from string, projectid int) (FutureScheduledHours, error)

FutureScheduledHoursForProject returns all future scheduled hours for the given project using the supplied date as the starting point

func (*API) Milestones

func (api *API) Milestones() (Milestones, error)

Milestones returns all milestones in the Forecast account

func (*API) People

func (api *API) People() (People, error)

People returns all people being scheduled in Forecast

func (*API) Person

func (api *API) Person(id int) (*Person, error)

Person returns the person with the requested ID

func (*API) Placeholder added in v1.2.3

func (api *API) Placeholder(id int) (*Placeholder, error)

Placeholder returns the placeholder with the requested ID

func (*API) Placeholders added in v1.2.3

func (api *API) Placeholders() (Placeholders, error)

Placeholders returns all placeholders being scheduled in Forecast

func (*API) Projects

func (api *API) Projects() (Projects, error)

Projects returns the list of projects in the Forecast Account

func (*API) RemainingBudgetedHours

func (api *API) RemainingBudgetedHours() (RemainingBudgetedHours, error)

RemainingBudgetedHours returns the remaining budgeted hours for all Forecast projects

func (*API) RepeatedAssignmentSet

func (api *API) RepeatedAssignmentSet(id int) (*RepeatedAssignmentSet, error)

RepeatedAssignmentSet returns the repeated assignment set for the given id

func (*API) RepeatedAssignmentSets

func (api *API) RepeatedAssignmentSets() (RepeatedAssignmentSets, error)

RepeatedAssignmentSets returns a list of repeated assignment sets

func (*API) Subscription

func (api *API) Subscription() (*Subscription, error)

Subscription returns information about the Forecast account subscription

func (*API) UserConnections

func (api *API) UserConnections() (UserConnections, error)

UserConnections returns all current user connections

func (*API) WhoAmI

func (api *API) WhoAmI() (*CurrentUser, error)

WhoAmI returns the CurrentUser for the logged in Forecast user

type Account

type Account struct {
	ID             int    `json:"id"`
	Name           string `json:"name"`
	WeeklyCapacity int    `json:"weekly_capacity"`
	ColorLabels    []struct {
		Name  string `json:"name"`
		Label string `json:"label"`
	} `json:"color_labels"`
	HarvestSubdomain string `json:"harvest_subdomain"`
	HarvestName      string `json:"harvest_name"`
}

Account is a Forecast account

type Assignment

type Assignment struct {
	ID                      int       `json:"id"`
	StartDate               string    `json:"start_date"`
	EndDate                 string    `json:"end_date"`
	Allocation              int       `json:"allocation"`
	Notes                   string    `json:"notes"`
	UpdatedAt               time.Time `json:"updated_at"`
	UpdatedByID             int       `json:"updated_by_id"`
	ProjectID               int       `json:"project_id"`
	PersonID                int       `json:"person_id"`
	PlaceholderID           int       `json:"placeholder_id"`
	RepeatedAssignmentSetID int       `json:"repeated_assignment_set_id"`
	ActiveOnDaysOff         bool      `json:"active_on_days_off"`
}

Assignment is a Forecast assignment

func (*Assignment) Weekdays added in v1.1.0

func (a *Assignment) Weekdays() int

Weekdays returns the number of working days between the start date and end date of the assignment

func (*Assignment) WorkingDaysBetween added in v1.2.1

func (a *Assignment) WorkingDaysBetween(startDate string, endDate string) int

WorkingDaysBetween calculates the number of assignment days between the given start date and end date

type AssignmentFilter added in v1.2.0

type AssignmentFilter struct {
	ProjectID               int
	PersonID                int
	StartDate               string // Format: YYYY-MM-DD
	EndDate                 string // Format: YYYY-MM-DD
	RepeatedAssignmentSetID int
	State                   string // active or archived
}

AssignmentFilter is used to filter assignments

func (*AssignmentFilter) Values added in v1.2.0

func (filter *AssignmentFilter) Values() url.Values

Values returns the AssignmentFilter as a url.Values result

type Assignments

type Assignments []Assignment

Assignments is a list of assignments

func (Assignments) ToCSV

func (assignments Assignments) ToCSV(w io.Writer) error

ToCSV writes the projects to the supplied writer in CSV format

type Client

type Client struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	HarvestID   int       `json:"harvest_id"`
	Archived    bool      `json:"archived"`
	UpdatedAt   time.Time `json:"updated_at"`
	UpdatedByID int       `json:"updated_by_id"`
}

Client is a client may have one or more projects

type Clients

type Clients []Client

Clients is a list of clients

type CurrentUser

type CurrentUser struct {
	ID         int   `json:"id"`
	AccountIds []int `json:"account_ids"`
}

CurrentUser contains information about the current Forecast user

type FutureScheduledHours

type FutureScheduledHours []FutureScheduledHoursItem

FutureScheduledHours is a list of future scheduled hours items

type FutureScheduledHoursItem

type FutureScheduledHoursItem struct {
	ProjectID  int     `json:"project_id"`
	PersonID   int     `json:"person_id"`
	Allocation float64 `json:"allocation"`
}

FutureScheduledHoursItem is a representation of the future scheduled hours for a project

type Milestone

type Milestone struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	Date        string    `json:"date"`
	UpdatedAt   time.Time `json:"updated_at"`
	UpdatedByID int       `json:"updated_by_id"`
	ProjectID   int       `json:"project_id"`
}

Milestone is a Forecast milestone

type Milestones

type Milestones []Milestone

Milestones is a list of milestones

type People

type People []Person

People is a list of people

type Person

type Person struct {
	ID             int       `json:"id"`
	FirstName      string    `json:"first_name"`
	LastName       string    `json:"last_name"`
	Email          string    `json:"email"`
	Login          string    `json:"login"`
	Admin          bool      `json:"admin"`
	Archived       bool      `json:"archived"`
	Subscribed     bool      `json:"subscribed"`
	AvatarURL      string    `json:"avatar_url"`
	Teams          []string  `json:"teams"`
	UpdatedAt      time.Time `json:"updated_at"`
	UpdatedByID    int       `json:"updated_by_id"`
	HarvestUserID  int       `json:"harvest_user_id"`
	WeeklyCapacity int       `json:"weekly_capacity"`
	WorkingDays    struct {
		Monday    bool `json:"monday"`
		Tuesday   bool `json:"tuesday"`
		Wednesday bool `json:"wednesday"`
		Thursday  bool `json:"thursday"`
		Friday    bool `json:"friday"`
	} `json:"working_days"`
	ColorBlind bool     `json:"color_blind"`
	Roles      []string `json:"roles"`
}

Person is a person who is being scheduled in Forecast

type Placeholder added in v1.2.3

type Placeholder struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	Archived    bool      `json:"archived"`
	Teams       []string  `json:"teams"`
	Roles       []string  `json:"roles"`
	UpdatedAt   time.Time `json:"updated_at"`
	UpdatedByID int       `json:"updated_by_id"`
}

Placeholder is a placeholder who is being scheduled in Forecast

type Placeholders added in v1.2.3

type Placeholders []Placeholder

Placeholders is a list of placeholders

type Project

type Project struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	Color       string    `json:"color"`
	Code        string    `json:"code"`
	Notes       string    `json:"notes"`
	StartDate   string    `json:"start_date"`
	EndDate     string    `json:"end_date"`
	HarvestID   int       `json:"harvest_id"`
	Archived    bool      `json:"archived"`
	UpdatedAt   time.Time `json:"updated_at"`
	UpdatedByID int       `json:"updated_by_id"`
	ClientID    int       `json:"client_id"`
	Tags        []string  `json:"tags"`
}

Project is a Forecast project

type Projects

type Projects []Project

Projects is a list of projects

func (Projects) ToCSV

func (projects Projects) ToCSV(w io.Writer) error

ToCSV writes the projects to the supplied writer in CSV format

type RemainingBudgetedHours

type RemainingBudgetedHours []RemainingBudgetedHoursItem

RemainingBudgetedHours is a list of remaining budgeted hours items

type RemainingBudgetedHoursItem

type RemainingBudgetedHoursItem struct {
	ProjectID    int     `json:"project_id"`
	BudgetBy     string  `json:"budget_by"`
	Hours        float64 `json:"hours"`
	ResponseCode int     `json:"response_code"`
}

RemainingBudgetedHoursItem is an aggregate representing the remaining budgeted hours for the given Forecast project

type RepeatedAssignmentSet

type RepeatedAssignmentSet struct {
	ID             int    `json:"id"`
	FirstStartDate string `json:"first_start_date"`
	LastEndDate    string `json:"last_end_date"`
	AssignmentIds  []int  `json:"assignment_ids"`
}

RepeatedAssignmentSet is a repeated assignment set

type RepeatedAssignmentSets

type RepeatedAssignmentSets []RepeatedAssignmentSet

RepeatedAssignmentSets is a list of repeated assignment sets

type Subscription

type Subscription struct {
	NextBillingDate  string `json:"next_billing_date"`
	Amount           int    `json:"amount"`
	AmountPerPerson  int    `json:"amount_per_person"`
	ReceiptRecipient string `json:"receipt_recipient"`
	Status           string `json:"status"`
	PurchasedPeople  int    `json:"purchased_people"`
	Interval         string `json:"interval"`
	Discounts        struct {
		MonthlyPercentage int `json:"monthly_percentage"`
		YearlyPercentage  int `json:"yearly_percentage"`
	} `json:"discounts"`
	Card struct {
		Brand       string `json:"brand"`
		LastFour    string `json:"last_four"`
		ExpiryMonth int    `json:"expiry_month"`
		ExpiryYear  int    `json:"expiry_year"`
	} `json:"card"`
	Address struct {
		Line1      string `json:"line_1"`
		Line2      string `json:"line_2"`
		City       string `json:"city"`
		State      string `json:"state"`
		PostalCode string `json:"postal_code"`
		Country    string `json:"country"`
	} `json:"address"`
}

Subscription describes the Forecast subscription

type UserConnection

type UserConnection struct {
	ID           int       `json:"id"`
	PersonID     int       `json:"person_id"`
	LastActiveAt time.Time `json:"last_active_at"`
}

UserConnection includes information about currently connected users

type UserConnections

type UserConnections []UserConnection

UserConnections is a list of UserConnection items

Jump to

Keyboard shortcuts

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