harvest

package
Version: v0.0.0-...-74a2b18 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LibraryVersion   = "1"
	DefaultBaseURL   = "https://api.harvestapp.com/v2/"
	UserAgent        = "becoded/go-harvest/v" + LibraryVersion
	DefaultMediaType = "application/json"
)

Variables

View Source
var ErrBaseURLMissingSlash = errors.New("BaseURL must have a trailing slash")
View Source
var ErrDateParse = errors.New(`ErrDateParse: should be a string formatted as "2006-01-02"`)
View Source
var ErrTimeParse = errors.New(`ErrTimeParse: should be a string formatted as "15:04"`)

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range or equal to 202 Accepted. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

The error type will be *RateLimitError for rate limit exceeded errors, and *TwoFactorAuthError for two-factor authentication errors.

func Float64

func Float64(v float64) *float64

Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it.

func Int64

func Int64(v int64) *int64

Int64 is a helper routine that allocates a new int value to store v and returns a pointer to it.

func Ints64

func Ints64(v []int64) *[]int64

Ints64 is a helper routine that allocates a new int slice to store v and returns a pointer to it.

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

func Stringify

func Stringify(message interface{}) string

Stringify attempts to create a reasonable string representation of types in the Harvest library. It does things like resolve pointers to their values and omits struct fields with nil values.

func TimeTimeP

func TimeTimeP(v time.Time) *time.Time

TimeTimeP is a helper routine that allocates a new time.Time value to store v and returns a pointer to it.

Types

type APIClient

type APIClient struct {

	// Base URL for API requests. Defaults to the public Harvest API.
	// BaseURL should always be specified with a trailing slash.
	BaseURL *url.URL

	AccountID string

	// User agent used when communicating with the Harvest API.
	UserAgent string

	// Services used for talking to different parts of the Harvest API.
	Client    *ClientService
	Company   *CompanyService
	Project   *ProjectService
	Task      *TaskService
	User      *UserService
	Estimate  *EstimateService
	Invoice   *InvoiceService
	Timesheet *TimesheetService
	Role      *RoleService
	// contains filtered or unexported fields
}

A APIClient manages communication with the Harvest API.

func NewAPIClient

func NewAPIClient(httpClient *http.Client) *APIClient

NewAPIClient returns a new Harvest API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).

func (*APIClient) Do

func (c *APIClient) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If rate limit is exceeded and reset time is in the future, Do returns *RateLimitError immediately without making a network API call.

The provided ctx must be non-nil. If it is canceled or times out, ctx.Err() will be returned.

func (*APIClient) NewRequest

func (c *APIClient) NewRequest(
	ctx context.Context,
	method,
	urlStr string,
	body interface{},
) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type AbuseRateLimitError

type AbuseRateLimitError struct {
	Response *http.Response // HTTP response that caused this error
	Message  string         `json:"message"` // error message

	// RetryAfter is provided with some abuse rate limit errors. If present,
	// it is the amount of time that the client should wait before retrying.
	// Otherwise, the client should try again later (after an unspecified amount of time).
	RetryAfter *time.Duration
}

AbuseRateLimitError occurs when Harvest returns 429 Too many requests response with the "documentation_url" field value equal to "https://help.getharvest.com/api-v2/introduction/overview/general/#rate-limiting".

func (*AbuseRateLimitError) Error

func (r *AbuseRateLimitError) Error() string

type Client

type Client struct {
	// Unique ID for the client.
	ID *int64 `json:"id,omitempty"`
	// A textual description of the client.
	Name *string `json:"name,omitempty"`
	// Whether the client is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
	// The physical address for the client.
	Address *string `json:"address,omitempty"`
	// The currency code associated with this client.
	Currency *string `json:"currency,omitempty"`
	// Date and time the client was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the client was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (Client) String

func (c Client) String() string

type ClientContact

type ClientContact struct {
	// Unique ID for the contact.
	ID *int64 `json:"id,omitempty"`
	// An object containing the contact’s client id and name.
	Client *Client `json:"client,omitempty"`
	// The title of the contact.
	Title *string `json:"title,omitempty"`
	// The first name of the contact.
	FirstName *string `json:"first_name,omitempty"`
	// The last name of the contact.
	LastName *string `json:"last_name,omitempty"`
	// The contact’s email address.
	Email *string `json:"email,omitempty"`
	// The contact’s office phone number.
	PhoneOffice *string `json:"phone_office,omitempty"`
	// The contact’s mobile phone number.
	PhoneMobile *string `json:"phone_mobile,omitempty"`
	// The contact’s fax number.
	Fax *string `json:"fax,omitempty"`
	// Date and time the contact was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the contact was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (ClientContact) String

func (p ClientContact) String() string

type ClientContactCreateRequest

type ClientContactCreateRequest struct {
	// required	The ID of the client associated with this contact.
	ClientID *int64 `json:"client_id"`
	// optional	The title of the contact.
	Title *string `json:"title,omitempty"`
	// required	The first name of the contact.
	FirstName *string `json:"first_name"`
	// optional	The last name of the contact.
	LastName *string `json:"last_name,omitempty"`
	// optional	The contact’s email address.
	Email *string `json:"email,omitempty"`
	// optional	The contact’s office phone number.
	PhoneOffice *string `json:"phone_office,omitempty"`
	// optional	The contact’s mobile phone number.
	PhoneMobile *string `json:"phone_mobile,omitempty"`
	// optional	The contact’s fax number.
	Fax *string `json:"fax,omitempty"`
}

type ClientContactList

type ClientContactList struct {
	ClientContacts []*ClientContact `json:"contacts"`

	Pagination
}

func (ClientContactList) String

func (p ClientContactList) String() string

type ClientContactListOptions

type ClientContactListOptions struct {
	// Only return contacts belonging to the client with the given ID.
	ClientID int64 `url:"client_id,omitempty"`
	// Only return contacts that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type ClientContactUpdateRequest

type ClientContactUpdateRequest struct {
	// required	The ID of the client associated with this contact.
	ClientID *int64 `json:"client_id,omitempty"`
	// optional	The title of the contact.
	Title *string `json:"title,omitempty"`
	// required	The first name of the contact.
	FirstName *string `json:"first_name,omitempty"`
	// optional	The last name of the contact.
	LastName *string `json:"last_name,omitempty"`
	// optional	The contact’s email address.
	Email *string `json:"email,omitempty"`
	// optional	The contact’s office phone number.
	PhoneOffice *string `json:"phone_office,omitempty"`
	// optional	The contact’s mobile phone number.
	PhoneMobile *string `json:"phone_mobile,omitempty"`
	// optional	The contact’s fax number.
	Fax *string `json:"fax,omitempty"`
}

type ClientCreateRequest

type ClientCreateRequest struct {
	// required	A textual description of the client.
	Name *string `json:"name"`
	// optional	Whether the client is active, or archived. Defaults to true.
	IsActive *bool `json:"is_active,omitempty"`
	// optional	A textual representation of the client’s physical address. May include new line characters.
	Address *string `json:"address,omitempty"`
	// optional	The currency used by the client.
	// If not provided, the company’s currency will be used. See a list of supported currencies
	Currency *string `json:"currency,omitempty"`
}

type ClientList

type ClientList struct {
	Clients []*Client `json:"clients"`

	Pagination
}

func (ClientList) String

func (c ClientList) String() string

type ClientListOptions

type ClientListOptions struct {
	// Pass true to only return active projects and false to return inactive projects.
	IsActive bool `url:"is_active,omitempty"`
	// Only return projects that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type ClientService

type ClientService service

ClientService handles communication with the client related methods of the Harvest API.

Harvest API docs: https://help.getharvest.com/api-v2/clients-api/clients/clients/

func (*ClientService) Create

Create creates a new client object. Returns a client object and a 201 Created response code if the call succeeded.

func (*ClientService) CreateClientContact

func (s *ClientService) CreateClientContact(
	ctx context.Context,
	data *ClientContactCreateRequest,
) (*ClientContact, *http.Response, error)

func (*ClientService) Delete

func (s *ClientService) Delete(ctx context.Context, clientID int64) (*http.Response, error)

Delete deletes a specific client. Deleting a client is only possible if it has no projects, invoices, or estimates associated with it. Returns a 200 OK response code if the call succeeded.

func (*ClientService) DeleteClientContact

func (s *ClientService) DeleteClientContact(ctx context.Context, contactID int64) (*http.Response, error)

func (*ClientService) Get

func (s *ClientService) Get(ctx context.Context, clientID int64) (*Client, *http.Response, error)

Get retrieves the client with the given ID. Returns a client object and a 200 OK response code if a valid identifier was provided.

func (*ClientService) GetContact

func (s *ClientService) GetContact(ctx context.Context, clientContactID int64) (*ClientContact, *http.Response, error)

func (*ClientService) List

List returns a list of your clients. The clients are returned sorted by creation date, with the most recently created clients appearing first.

func (*ClientService) ListContacts

func (*ClientService) Update

func (s *ClientService) Update(
	ctx context.Context,
	clientID int64,
	data *ClientUpdateRequest,
) (*Client, *http.Response, error)

Update updates the specific client by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Returns a client object and a 200 OK response code if the call succeeded.

func (*ClientService) UpdateClientContact

func (s *ClientService) UpdateClientContact(
	ctx context.Context,
	contactID int64,
	data *ClientContactUpdateRequest,
) (*ClientContact, *http.Response, error)

type ClientUpdateRequest

type ClientUpdateRequest struct {
	// A textual description of the client.
	Name *string `json:"name,omitempty"`
	// Whether the client is active, or archived. Defaults to true.
	IsActive *bool `json:"is_active,omitempty"`
	// A textual representation of the client’s physical address. May include new line characters.
	Address *string `json:"address,omitempty"`
	// The currency used by the client.
	// If not provided, the company’s currency will be used. See a list of supported currencies
	Currency *string `json:"currency,omitempty"`
}

type Company

type Company struct {
	// The Harvest URL for the company.
	BaseURI *string `json:"base_uri,omitempty"`
	// The Harvest domain for the company.
	FullDomain *string `json:"full_domain,omitempty"`
	// The name of the company.
	Name *string `json:"name,omitempty"`
	// Whether the company is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
	// The week day used as the start of the week. Returns one of: Saturday, Sunday, or Monday.
	WeekStartDay *string `json:"week_start_day,omitempty"`
	// Whether time is tracked via duration or start and end times.
	WantsTimestampTimers *bool `json:"wants_timestamp_timers,omitempty"`
	// The format used to display time in Harvest. Returns either decimal or hours_minutes.
	TimeFormat *string `json:"time_format,omitempty"`
	// The type of plan the company is on. Examples: trial, free, or simple-v4
	PlanType *string `json:"plan_type,omitempty"`
	// Used to represent whether the company is using a 12-hour or 24-hour clock. Returns either 12h or 24h.
	Clock *string `json:"clock,omitempty"`
	// Symbol *used `json:"Symbol,omitempty"` //when *formatting `json:"when,omitempty"` //decimals.
	DecimalSymbol *string `json:"decimal_symbol,omitempty"`
	// Separator *used `json:"Separator,omitempty"` //when formatting numbers.
	ThousandsSeparator *string `json:"thousands_separator,omitempty"`
	// The color scheme being used in the Harvest web client.
	ColorScheme *string `json:"color_scheme,omitempty"`
	// Whether the expense module is enabled.
	ExpenseFeature *bool `json:"expense_feature,omitempty"`
	// Whether the invoice module is enabled.
	InvoiceFeature *bool `json:"invoice_feature,omitempty"`
	// Whether the estimate module is enabled.
	EstimateFeature *bool `json:"estimate_feature,omitempty"`
	// Whether *the `json:"Whether,omitempty"` //approval module is enabled.
	ApprovalFeature *bool `json:"approval_feature,omitempty"`
}

func (Company) String

func (c Company) String() string

type CompanyService

type CompanyService service

CompanyService handles communication with the company related methods of the Harvest API.

Harvest API docs: https://help.getharvest.com/api-v2/company-api/company/company/

func (*CompanyService) Get

type Date

type Date struct {
	time.Time
}

func DateP

func DateP(v Date) *Date

DateP is a helper routine that allocates a new Date value to store v and returns a pointer to it.

func (*Date) EncodeValues

func (t *Date) EncodeValues(key string, v *url.Values) error

func (Date) Equal

func (t Date) Equal(u Date) bool

Equal reports whether t and u are equal based on time.Equal.

func (Date) String

func (t Date) String() string

func (*Date) UnmarshalJSON

func (t *Date) UnmarshalJSON(data []byte) (err error)

type Error

type Error struct {
	// resource on which the error occurred
	Resource string `json:"resource"`
	// field on which the error occurred
	Field string `json:"field"`
	// validation error code
	Code string `json:"code"`
	// Message describing the error. Errors with Code == "custom" will always have this set.
	Message string `json:"message"`
}

An Error reports more details on an individual error in an ErrorResponse.

func (*Error) Error

func (e *Error) Error() string

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
	Message  string         `json:"message"` // error message
	Errors   []Error        `json:"errors"`  // more detail on individual errors

	Block *struct {
		Reason string `json:"reason,omitempty"`
	} `json:"block,omitempty"`

	DocumentationURL string `json:"documentation_url,omitempty"`
}

An ErrorResponse reports one or more errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Estimate

type Estimate struct {
	// Unique ID for the estimate.
	ID *int64 `json:"id,omitempty"`
	// An object containing estimate’s client id and name.
	Client *Client `json:"client,omitempty"`
	// Array of estimate line items.
	LineItems *[]EstimateLineItem `json:"line_items,omitempty"`
	// An object containing the id and name of the person that created the estimate.
	Creator *User `json:"creator,omitempty"`
	// Used to build a URL to the public web invoice for your client:
	// https://{ACCOUNT_SUBDOMAIN}.harvestapp.com/client/invoices/abc123456
	ClientKey *string `json:"client_key,omitempty"`
	// If no value is set, the number will be automatically generated.
	Number *string `json:"number,omitempty"`
	// The purchase order number.
	PurchaseOrder *string `json:"purchase_order,omitempty"`
	// The total amount for the estimate, including any discounts and taxes.
	Amount *float64 `json:"amount,omitempty"`
	// This percentage is applied to the subtotal, including line items and discounts.
	Tax *float64 `json:"tax,omitempty"`
	// The first amount of tax included, calculated from tax. If no tax is defined, this value will be null.
	TaxAmount *float64 `json:"tax_amount,omitempty"`
	// This percentage is applied to the subtotal, including line items and discounts.
	Tax2 *float64 `json:"tax2,omitempty"`
	// The amount calculated from tax2.
	Tax2Amount *float64 `json:"tax2_amount,omitempty"`
	// This percentage is subtracted from the subtotal.
	Discount *float64 `json:"discount,omitempty"`
	// The amount calcuated from discount.
	DiscountAmount *float64 `json:"discount_amount,omitempty"`
	// The estimate subject.
	Subject *string `json:"subject,omitempty"`
	// Any additional notes included on the estimate.
	Notes *string `json:"notes,omitempty"`
	// The currency code associated with this estimate.
	Currency *string `json:"currency,omitempty"`
	// Date the estimate was issued.
	IssueDate *Date `json:"issue_date,omitempty"`
	// Date and time the estimate was sent.
	SentAt *time.Time `json:"sent_at,omitempty"`
	// Date and time the estimate was accepted.
	AcceptedAt *time.Time `json:"accepted_at,omitempty"`
	// Date and time the estimate was declined.
	DeclinedAt *time.Time `json:"declined_at,omitempty"`
	// Date and time the estimate was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the estimate was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (Estimate) String

func (p Estimate) String() string

type EstimateEventTypeRequest

type EstimateEventTypeRequest struct {
	EventType string `json:"event_type"`
}

type EstimateItemCategory

type EstimateItemCategory struct {
	// Unique ID for the estimate item category.
	ID *int64 `json:"id,omitempty"`
	// The name of the estimate item category.
	Name *string `json:"name,omitempty"`
	// Date and time the estimate item category was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the estimate item category was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (EstimateItemCategory) String

func (p EstimateItemCategory) String() string

type EstimateItemCategoryList

type EstimateItemCategoryList struct {
	EstimateItemCategories []*EstimateItemCategory `json:"estimate_item_categories"`

	Pagination
}

func (EstimateItemCategoryList) String

func (p EstimateItemCategoryList) String() string

type EstimateItemCategoryListOptions

type EstimateItemCategoryListOptions struct {
	// Only return estimate item categories that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type EstimateItemCategoryRequest

type EstimateItemCategoryRequest struct {
	Name *string `json:"name,omitempty"` // required	The name of the estimate item category.
}

type EstimateLineItem

type EstimateLineItem struct {
	// Unique ID for the line item.
	ID *int64 `json:"id,omitempty"`
	// The name of an estimate item category.
	Kind *string `json:"kind,omitempty"`
	// Text description of the line item.
	Description *string `json:"description,omitempty"`
	// The unit quantity of the item.
	Quantity *int64 `json:"quantity,omitempty"`
	// The individual price per unit.
	UnitPrice *float64 `json:"unit_price,omitempty"`
	// The line item subtotal (quantity * unit_price).
	Amount *float64 `json:"amount,omitempty"`
	// Whether the estimate’s tax percentage applies to this line item.
	Taxed *bool `json:"taxed,omitempty"`
	// Whether the estimate’s tax2 percentage applies to this line item.
	Taxed2 *bool `json:"taxed2,omitempty"`
}

type EstimateList

type EstimateList struct {
	Estimates []*Estimate `json:"estimates"`

	Pagination
}

func (EstimateList) String

func (p EstimateList) String() string

type EstimateListOptions

type EstimateListOptions struct {
	// Only return estimates belonging to the client with the given ID.
	ClientID int64 `url:"client_id,omitempty"`
	// Only return estimates that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type EstimateMessage

type EstimateMessage struct {
	// Unique ID for the message.
	ID *int64 `json:"id,omitempty"`
	// Name of the user that created the message.
	SentBy *string `json:"sent_by,omitempty"`
	// Email of the user that created the message.
	SentByEmail *string `json:"sent_by_email,omitempty"`
	// Name of the user that the message was sent from.
	SentFrom *string `json:"sent_from,omitempty"`
	// Email of the user that message was sent from.
	SentFromEmail *string `json:"sent_from_email,omitempty"`
	// Array of estimate message recipients.
	Recipients *[]EstimateMessageRecipient `json:"recipients,omitempty"`
	// The message subject.
	Subject *string `json:"subject,omitempty"`
	// The message body.
	Body *string `json:"body,omitempty"`
	// Whether to email a copy of the message to the current user.
	SendMeACopy *bool `json:"send_me_a_copy,omitempty"`
	// The type of estimate event that occurred with the message: send, accept, decline, re-open, view, or invoice.
	EventType *bool `json:"event_type,omitempty"`
	// Date and time the message was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the message was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (EstimateMessage) String

func (p EstimateMessage) String() string

type EstimateMessageCreateRequest

type EstimateMessageCreateRequest struct {
	// required	Array of recipient parameters. See below for details.
	Recipients *[]EstimateMessageRecipientCreateRequest `json:"recipients,omitempty"`
	// optional	The message subject.
	Subject *string `json:"subject,omitempty"`
	// optional	The message body.
	Body *string `json:"body,omitempty"`
	// optional	If set to true, a copy of the message email will be sent to the current user. Defaults to false.
	SendMeACopy *bool `json:"send_me_a_copy,omitempty"`
	// optional	If provided, runs an event against the estimate. Options: “accept”, “decline”, “re-open”, or “send”.
	EventType *string `json:"event_type,omitempty"`
}

type EstimateMessageList

type EstimateMessageList struct {
	Estimates []*Estimate `json:"estimates"`

	Pagination
}

func (EstimateMessageList) String

func (p EstimateMessageList) String() string

type EstimateMessageListOptions

type EstimateMessageListOptions struct {
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type EstimateMessageRecipient

type EstimateMessageRecipient struct {
	// Name of the message recipient.
	Name *string `json:"name,omitempty"`
	// Email of the message recipient.
	Email *string `json:"email,omitempty"`
}

type EstimateMessageRecipientCreateRequest

type EstimateMessageRecipientCreateRequest struct {
	// optional	Name of the message recipient.
	Name *string `json:"name,omitempty"`
	// required	Email of the message recipient.
	Email *string `json:"email"`
}

type EstimateService

type EstimateService service

EstimateService handles communication with the issue related methods of the Harvest API.

Harvest API docs: https://help.getharvest.com/api-v2/estimates-api/estimates/estimates/

func (*EstimateService) CreateEstimateMessage

func (s *EstimateService) CreateEstimateMessage(
	ctx context.Context,
	data *EstimateMessageCreateRequest,
) (*EstimateMessage, *http.Response, error)

func (*EstimateService) CreateItemCategory

func (*EstimateService) DeleteEstimateMessage

func (s *EstimateService) DeleteEstimateMessage(
	ctx context.Context,
	estimateID,
	estimateMessageID int64,
) (*http.Response, error)

func (*EstimateService) DeleteItemCategory

func (s *EstimateService) DeleteItemCategory(
	ctx context.Context,
	estimateItemCategoryID int64,
) (*http.Response, error)

func (*EstimateService) Get

func (s *EstimateService) Get(ctx context.Context, estimateID int64) (*Estimate, *http.Response, error)

func (*EstimateService) GetItemCategory

func (s *EstimateService) GetItemCategory(
	ctx context.Context,
	estimateItemCategoryID int64,
) (*EstimateItemCategory, *http.Response, error)

func (*EstimateService) List

func (*EstimateService) ListEstimateMessages

func (s *EstimateService) ListEstimateMessages(
	ctx context.Context,
	estimateID int64,
	opt *EstimateMessageListOptions,
) (*EstimateList, *http.Response, error)

func (*EstimateService) ListItemCategories

func (*EstimateService) MarkAsAccepted

func (s *EstimateService) MarkAsAccepted(
	ctx context.Context,
	estimateID int64,
) (*EstimateMessage, *http.Response, error)

func (*EstimateService) MarkAsDeclined

func (s *EstimateService) MarkAsDeclined(
	ctx context.Context,
	estimateID int64,
) (*EstimateMessage, *http.Response, error)

func (*EstimateService) MarkAsReopen

func (s *EstimateService) MarkAsReopen(
	ctx context.Context,
	estimateID int64,
) (*EstimateMessage, *http.Response, error)

func (*EstimateService) MarkAsSent

func (s *EstimateService) MarkAsSent(
	ctx context.Context,
	estimateID int64,
) (*EstimateMessage, *http.Response, error)

func (*EstimateService) SendEvent

func (s *EstimateService) SendEvent(
	ctx context.Context,
	estimateID int64,
	data *EstimateEventTypeRequest,
) (*EstimateMessage, *http.Response, error)

func (*EstimateService) UpdateItemCategory

func (s *EstimateService) UpdateItemCategory(
	ctx context.Context,
	estimateItemCategoryID int64,
	data *EstimateItemCategoryRequest,
) (*EstimateItemCategory, *http.Response, error)

type EventTypeRequest

type EventTypeRequest struct {
	EventType string `json:"event_type"`
}

type Expense

type Expense struct {
	// Unique ID for the expense.
	ID *int64 `json:"id,omitempty"`
	// An object containing the expense’s client id, name, and currency.
	Client *Client `json:"client,omitempty"`
	// An object containing the expense’s project id, name, and code.
	Project *Project `json:"project,omitempty"`
	// An object containing the expense’s expense category id, name, unit_price, and unit_name.
	ExpenseCategory *ExpenseCategory `json:"expense_category,omitempty"`
	// An object containing the id and name of the user that recorded the expense.
	User *User `json:"user,omitempty"`
	// A user assignment object of the user that recorded the expense.
	UserAssignment *ProjectUserAssignment `json:"user_assignment,omitempty"`
	// An object containing the expense’s receipt URL and file name.
	Receipt *Receipt `json:"receipt,omitempty"`
	// Once the expense has been invoiced, this field will include the associated invoice’s id and number.
	Invoice *Invoice `json:"invoice,omitempty"`
	// Textual notes used to describe the expense.
	Notes *string `json:"notes,omitempty"`
	// Whether the expense is billable or not.
	Billable *bool `json:"billable,omitempty"`
	// Whether the expense has been approved or closed for some other reason.
	IsClosed *bool `json:"is_closed,omitempty"`
	// Whether the expense has been been invoiced, approved, or the project or person related to the expense is archived.
	IsLocked *bool `json:"is_locked,omitempty"`
	// Whether or not the expense has been marked as invoiced.
	IsBilled *bool `json:"is_billed,omitempty"`
	// An explanation of why the expense has been locked.
	LockedReason *string `json:"locked_reason,omitempty"`
	// Date the expense occurred.
	SpentDate *Date `json:"spent_date,omitempty"`
	// Date and time the expense was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the expense was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (Expense) String

func (p Expense) String() string

type ExpenseCategory

type ExpenseCategory struct {
	// Unique ID for the expense category.
	ID *int64 `json:"id,omitempty"`
	// The name of the expense category.
	Name *string `json:"name,omitempty"`
	// The unit name of the expense category.
	UnitName *string `json:"unit_name,omitempty"`
	// The unit price of the expense category.
	UnitPrice *float64 `json:"unit_price,omitempty"`
	// Whether the expense category is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
	// Date and time the expense category was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the expense category was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (ExpenseCategory) String

func (p ExpenseCategory) String() string

type ExpenseCategoryList

type ExpenseCategoryList struct {
	ExpenseCategories []*ExpenseCategory `json:"invoice_item_categories"`

	Pagination
}

func (ExpenseCategoryList) String

func (p ExpenseCategoryList) String() string

type ExpenseCategoryListOptions

type ExpenseCategoryListOptions struct {
	// Pass true to only return active expense categories and false to return inactive expense categories.
	IsActive *bool `url:"is_active,omitempty"`
	// Only return expense categories that have been updated since the given date and time.
	UpdatedSince *time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type ExpenseCategoryRequest

type ExpenseCategoryRequest struct {
	// required	The name of the expense category.
	Name *string `json:"name,omitempty"`
	// optional	The unit name of the expense category.
	UnitName *string `json:"unit_name,omitempty"`
	// optional	The unit price of the expense category.
	UnitPrice *float64 `json:"unit_price,omitempty"`
	// optional	Whether the expense category is active or archived. Defaults to true.
	IsActive *bool `json:"is_active,omitempty"`
}

type ExpenseCreateRequest

type ExpenseCreateRequest struct {
	// optional	The ID of the user associated with this expense. Defaults to the ID of the currently authenticated user.
	UserID *int64 `json:"user_id,omitempty"`
	// required	The ID of the project associated with this expense.
	ProjectID *int64 `json:"project_id"`
	// required	The ID of the expense category this expense is being tracked against.
	ExpenseCategoryID *int64 `json:"expense_category_id"`
	// required	Date the expense occurred.
	SpentDate *Date `json:"spent_date"`
	// *optional	The quantity of units to use in calculating the total_cost of the expense.
	Units *int64 `json:"units,omitempty"`
	// *optional	The total amount of the expense.
	TotalCost *float64 `json:"total_cost,omitempty"`
	// optional	Textual notes used to describe the expense.
	Notes *string `json:"notes,omitempty"`
	// optional	Whether this expense is billable or not. Defaults to true.
	Billable *bool `json:"billable,omitempty"`
}

type ExpenseList

type ExpenseList struct {
	Expenses []*Expense `json:"expenses"`

	Pagination
}

func (ExpenseList) String

func (p ExpenseList) String() string

type ExpenseListOptions

type ExpenseListOptions struct {
	// Only return expenses belonging to the user with the given ID.
	UserID *int64 `url:"user_id,omitempty"`
	// Only return expenses belonging to the client with the given ID.
	ClientID *int64 `url:"client_id,omitempty"`
	// Only return expenses belonging to the project with the given ID.
	ProjectID *int64 `url:"project_id,omitempty"`
	// Pass true to only return expenses that have been invoiced and
	// false to return expenses that have not been invoiced.
	IsBilled *bool `url:"is_billed,omitempty"`
	// Only return expenses that have been updated since the given date and time.
	UpdatedSince *time.Time `url:"updated_since,omitempty"`
	// Only return expenses with a spent_date on or after the given date.
	From *Date `url:"from,omitempty"`
	// Only return expenses with a spent_date on or before the given date.
	To *Date `url:"to,omitempty"`

	ListOptions
}

type ExpenseService

type ExpenseService service

ExpenseService handles communication with the issue related methods of the Harvest API.

Harvest API docs: https://help.getharvest.com/api-v2/expenses-api/expenses/expenses/

func (*ExpenseService) Create

func (*ExpenseService) CreateExpenseCategory

func (s *ExpenseService) CreateExpenseCategory(
	ctx context.Context,
	data *ExpenseCategoryRequest,
) (*ExpenseCategory, *http.Response, error)

func (*ExpenseService) Delete

func (s *ExpenseService) Delete(ctx context.Context, expenseID int64) (*http.Response, error)

func (*ExpenseService) DeleteExpenseCategory

func (s *ExpenseService) DeleteExpenseCategory(
	ctx context.Context,
	expenseCategoryID int64,
) (*http.Response, error)

func (*ExpenseService) Get

func (s *ExpenseService) Get(ctx context.Context, expenseID int64) (*Expense, *http.Response, error)

func (*ExpenseService) GetExpenseCategory

func (s *ExpenseService) GetExpenseCategory(
	ctx context.Context,
	expenseCategoryID int64,
) (*ExpenseCategory, *http.Response, error)

func (*ExpenseService) List

func (*ExpenseService) ListExpenseCategories

func (s *ExpenseService) ListExpenseCategories(
	ctx context.Context,
	opt *ExpenseCategoryListOptions,
) (*ExpenseCategoryList, *http.Response, error)

func (*ExpenseService) Update

func (s *ExpenseService) Update(
	ctx context.Context,
	expenseID int64,
	data *ExpenseUpdateRequest,
) (*Expense, *http.Response, error)

func (*ExpenseService) UpdateExpenseCategory

func (s *ExpenseService) UpdateExpenseCategory(
	ctx context.Context,
	expenseCategoryID int64,
	data *ExpenseCategoryRequest,
) (*ExpenseCategory, *http.Response, error)

type ExpenseUpdateRequest

type ExpenseUpdateRequest struct {
	// The ID of the project associated with this expense.
	ProjectID *int64 `json:"project_id,omitempty"`
	// The ID of the expense category this expense is being tracked against.
	ExpenseCategoryID *int64 `json:"expense_category_id,omitempty"`
	// Date the expense occurred.
	SpentDate *Date `json:"spent_date,omitempty"`
	// The quantity of units to use in calculating the total_cost of the expense.
	Units *int64 `json:"units,omitempty"`
	// The total amount of the expense.
	TotalCost *float64 `json:"total_cost,omitempty"`
	// Textual notes used to describe the expense.
	Notes *string `json:"notes,omitempty"`
	// Whether this expense is billable or not. Defaults to true.
	Billable *bool `json:"billable,omitempty"`
	// TO DO add receipt file
	// A receipt file to attach to the expense. If including a receipt, you must submit a multipart/form-data request.
	// Receipt *file `json:"receipt,omitempty"`
	// Whether an attached expense receipt should be deleted. Pass true to delete the expense receipt.
	DeleteReceipt *bool `json:"delete_receipt,omitempty"`
}

type ExternalReference

type ExternalReference struct {
	ID             *string `json:"id,omitempty"`
	GroupID        *string `json:"group_id,omitempty"`
	Permalink      *string `json:"permalink,omitempty"`
	Service        *string `json:"service,omitempty"`
	ServiceIconURL *string `json:"service_icon_url,omitempty"`
}

type Invoice

type Invoice struct {
	// Unique ID for the invoice.
	ID *int64 `json:"id,omitempty"`
	// An object containing invoice’s client id and name.
	Client *Client `json:"client,omitempty"`
	// Array of invoice line items.
	LineItems *[]InvoiceLineItem `json:"line_items,omitempty"`
	// An object containing the associated estimate’s id.
	Estimate *Estimate `json:"estimate,omitempty"`
	// retainer *object `json:"retainer,omitempty"` // An object containing the associated retainer’s id.
	// An object containing the id and name of the person that created the invoice.
	Creator *User `json:"creator,omitempty"`
	// Used to build a URL to the public web invoice for your client:
	// https://{ACCOUNT_SUBDOMAIN}.harvestapp.com/client/invoices/abc123456
	ClientKey *string `json:"client_key,omitempty"`
	// If no value is set, the number will be automatically generated.
	Number *string `json:"number,omitempty"`
	// The purchase order number.
	PurchaseOrder *string `json:"purchase_order,omitempty"`
	// The total amount for the invoice, including any discounts and taxes.
	Amount *float64 `json:"amount,omitempty"`
	// The total amount due at this time for this invoice.
	DueAmount *float64 `json:"due_amount,omitempty"`
	// This percentage is applied to the subtotal, including line items and discounts.
	Tax *float64 `json:"tax,omitempty"`
	// The first amount of tax included, calculated from tax. If no tax is defined, this value will be null.
	TaxAmount *float64 `json:"tax_amount,omitempty"`
	// This percentage is applied to the subtotal, including line items and discounts.
	Tax2 *float64 `json:"tax2,omitempty"`
	// The amount calculated from tax2.
	Tax2Amount *float64 `json:"tax2_amount,omitempty"`
	// This percentage is subtracted from the subtotal.
	Discount *float64 `json:"discount,omitempty"`
	// The amount calcuated from discount.
	DiscountAmount *float64 `json:"discount_amount,omitempty"`
	// The invoice subject.
	Subject *string `json:"subject,omitempty"`
	// Any additional notes included on the invoice.
	Notes *string `json:"notes,omitempty"`
	// The currency code associated with this invoice.
	Currency *string `json:"currency,omitempty"`
	// Start of the period during which time entries and expenses were added to this invoice.
	PeriodStart *Date `json:"period_start,omitempty"`
	// End of the period during which time entries and expenses were added to this invoice.
	PeriodEnd *Date `json:"period_end,omitempty"`
	// Date the invoice was issued.
	IssueDate *Date `json:"issue_date,omitempty"`
	// Date the invoice is due.
	DueDate *Date `json:"due_date,omitempty"`
	// Date and time the invoice was sent.
	SentAt *time.Time `json:"sent_at,omitempty"`
	// Date and time the invoice was paid.
	PaidAt *time.Time `json:"paid_at,omitempty"`
	// Date and time the invoice was closed.
	ClosedAt *time.Time `json:"closed_at,omitempty"`
	// Date and time the invoice was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the invoice was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (Invoice) String

func (p Invoice) String() string

type InvoiceCreateRequest

type InvoiceCreateRequest struct {
	// required	The ID of the client this invoice belongs to.
	ClientID *int64 `json:"client_id"`
	// optional	The ID of the retainer associated with this invoice.
	RetainerID *int64 `json:"retainer_id,omitempty"`
	// optional	The ID of the estimate associated with this invoice.
	EstimateID *int64 `json:"estimate_id,omitempty"`
	// optional	If no value is set, the number will be automatically generated.
	Number *string `json:"number,omitempty"`
	// optional	The purchase order number.
	PurchaseOrder *string `json:"purchase_order,omitempty"`
	// optional	This percentage is applied to the subtotal, including line items and discounts.
	// Example: use 10.0 for 10.0%.
	Tax *float64 `json:"tax,omitempty"`
	// optional	This percentage is applied to the subtotal, including line items and discounts.
	// Example: use 10.0 for 10.0%.
	Tax2 *float64 `json:"tax2,omitempty"`
	// optional	This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.
	Discount *float64 `json:"discount,omitempty"`
	// optional	The invoice subject.
	Subject *string `json:"subject,omitempty"`
	// optional	Any additional notes to include on the invoice.
	Notes *string `json:"notes,omitempty"`
	// optional	The currency used by the invoice.
	// If not provided, the client’s currency will be used. See a list of supported currencies
	Currency *string `json:"currency,omitempty"`
	// optional	Date the invoice was issued. Defaults to today’s date.
	IssueDate *Date `json:"issue_date,omitempty"`
	// optional	Date the invoice is due. Defaults to the issue_date.
	DueDate *Date `json:"due_date,omitempty"`
	// optional	Array of line item parameters
	LineItems *[]InvoiceLineItemRequest `json:"line_items,omitempty"`
	// optional	An line items import object
	LineItemsImport *[]InvoiceLineItemImportRequest `json:"line_items_import,omitempty"`
}

type InvoiceItemCategory

type InvoiceItemCategory struct {
	// Unique ID for the invoice item category.
	ID *int64 `json:"id,omitempty"`
	// The name of the invoice item category.
	Name *string `json:"name,omitempty"`
	// Whether this invoice item category is used for billable hours when generating an invoice.
	UseAsService *bool `json:"use_as_service,omitempty"`
	// Whether this invoice item category is used for expenses when generating an invoice.
	UseAsExpense *bool `json:"use_as_expense,omitempty"`
	// Date and time the invoice item category was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the invoice item category was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (InvoiceItemCategory) String

func (p InvoiceItemCategory) String() string

type InvoiceItemCategoryList

type InvoiceItemCategoryList struct {
	InvoiceItemCategories []*InvoiceItemCategory `json:"invoice_item_categories"`

	Pagination
}

func (InvoiceItemCategoryList) String

func (p InvoiceItemCategoryList) String() string

type InvoiceItemCategoryListOptions

type InvoiceItemCategoryListOptions struct {
	// Only return invoice item categories that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type InvoiceItemCategoryRequest

type InvoiceItemCategoryRequest struct {
	// required	The name of the invoice item category.
	Name *string `json:"name,omitempty"`
}

type InvoiceLineItem

type InvoiceLineItem struct {
	// Unique ID for the line item.
	ID *int64 `json:"id,omitempty"`
	// An object containing the associated project’s id, name, and code.
	Project *Project `json:"project,omitempty"`
	// The name of an invoice item category.
	Kind *string `json:"kind,omitempty"`
	// Text description of the line item.
	Description *string `json:"description,omitempty"`
	// The unit quantity of the item.
	Quantity *int16 `json:"quantity,omitempty"`
	// The individual price per unit.
	UnitPrice *float64 `json:"unit_price,omitempty"`
	// The line item subtotal (quantity * unit_price).
	Amount *float64 `json:"amount,omitempty"`
	// Whether the invoice’s tax percentage applies to this line item.
	Taxed *bool `json:"taxed,omitempty"`
	// Whether the invoice’s tax2 percentage applies to this line item.
	Taxed2 *bool `json:"taxed2,omitempty"`
}

type InvoiceLineItemImportExpenseRequest

type InvoiceLineItemImportExpenseRequest struct {
	// required	How to summarize the expenses per line item. Options: project, category, people, or detailed.
	SummaryType *string `json:"summary_type"`
	// optional	Start date for included expenses.
	// Must be provided if to is present. If neither from or to are provided, all unbilled expenses will be included.
	From *Date `json:"from,omitempty"`
	// optional	End date for included expenses.
	// Must be provided if from is present. If neither from or to are provided, all unbilled expenses will be included.
	To *Date `json:"to,omitempty"`
	// optional	If set to true, a PDF containing an expense report with receipts will be attached to the invoice.
	// Defaults to false.
	AttachReceipt *bool `json:"attach_receipt,omitempty"`
}

type InvoiceLineItemImportRequest

type InvoiceLineItemImportRequest struct {
	// required	An array of the client’s project IDs you’d like to include time/expenses from.
	ProjectIds *[]int64 `json:"project_ids"`
	// optional	A time import object.
	Time *InvoiceLineItemImportTimeRequest `json:"time,omitempty"`
	// optional	An expense import object.
	Expenses *InvoiceLineItemImportExpenseRequest `json:"expenses,omitempty"`
}

type InvoiceLineItemImportTimeRequest

type InvoiceLineItemImportTimeRequest struct {
	// required	How to summarize the time entries per line item. Options: project, task, people, or detailed.
	SummaryType *string `json:"summary_type"`
	// optional	Start date for included time entries.
	// Must be provided if to is present. If neither from or to are provided,
	// all unbilled time entries will be included.
	From *Date `json:"from,omitempty"`
	// optional	End date for included time entries.
	// Must be provided if from is present. If neither from or to are provided,
	// all unbilled time entries will be included.
	To *Date `json:"to,omitempty"`
}

type InvoiceLineItemRequest

type InvoiceLineItemRequest struct {
	// Unique ID for the line item.
	ID *int64 `json:"id,omitempty"`
	// optional	The ID of the project associated with this line item.
	ProjectID *int64 `json:"project_id,omitempty"`
	// required	The name of an invoice item category.
	Kind *string `json:"kind"`
	// optional	Text description of the line item.
	Description *string `json:"description,omitempty"`
	// optional	The unit quantity of the item. Defaults to 1.
	Quantity *int64 `json:"quantity,omitempty"`
	// required	The individual price per unit.
	UnitPrice *float64 `json:"unit_price"`
	// optional	Whether the invoice’s tax percentage applies to this line item. Defaults to false.
	Taxed *bool `json:"taxed,omitempty"`
	// optional	Whether the invoice’s tax2 percentage applies to this line item. Defaults to false.
	Taxed2 *bool `json:"taxed2,omitempty"`
	// optional	Delete an invoice line item
	Destroy *bool `json:"_destroy,omitempty"`
}

type InvoiceList

type InvoiceList struct {
	Invoices []*Invoice `json:"invoices"`

	Pagination
}

func (InvoiceList) String

func (p InvoiceList) String() string

type InvoiceListOptions

type InvoiceListOptions struct {
	// Only return invoices belonging to the client with the given ID.
	ClientID int64 `url:"client_id,omitempty"`
	// Only return invoices associated with the project with the given ID.
	ProjectID int64 `url:"project_id,omitempty"`
	// Only return invoices that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type InvoiceMessage

type InvoiceMessage struct {
	// Unique ID for the message.
	ID *int64 `json:"id,omitempty"`
	// Name of the user that created the message.
	SentBy *string `json:"sent_by,omitempty"`
	// Email of the user that created the message.
	SentByEmail *string `json:"sent_by_email,omitempty"`
	// Name of the user that the message was sent from.
	SentFrom *string `json:"sent_from,omitempty"`
	// Email of the user that message was sent from.
	SentFromEmail *string `json:"sent_from_email,omitempty"`
	// Array of invoice message recipients.
	Recipients *[]InvoiceMessageRecipient `json:"recipients,omitempty"`
	// The message subject.
	Subject *string `json:"subject,omitempty"`
	// The message body.
	Body *string `json:"body,omitempty"`
	// Whether to include a link to the client invoice in the message body. Not used when thank_you is true.
	IncludeLinkToClientInvoice *bool `json:"include_link_to_client_invoice,omitempty"`
	// Whether to attach the invoice PDF to the message email.
	AttachPdf *bool `json:"attach_pdf,omitempty"`
	// Whether to email a copy of the message to the current user.
	SendMeACopy *bool `json:"send_me_a_copy,omitempty"`
	// Whether this is a thank you message.
	ThankYou *bool `json:"thank_you,omitempty"`
	// The type of invoice event that occurred with the message: send, close, draft, re-open, or view.
	EventType *bool `json:"event_type,omitempty"`
	// Whether this is a reminder message.
	Reminder *bool `json:"reminder,omitempty"`
	// The date the reminder email will be sent.
	SendReminderOn *Date `json:"send_reminder_on,omitempty"`
	// Date and time the message was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the message was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (InvoiceMessage) String

func (p InvoiceMessage) String() string

type InvoiceMessageCreateRequest

type InvoiceMessageCreateRequest struct {
	// required	Array of recipient parameters. See below for details.
	Recipients *[]InvoiceMessageRecipient `json:"recipients"`
	// optional	The message subject.
	Subject *string `json:"subject,omitempty"`
	// optional	The message body.
	Body *string `json:"body,omitempty"`
	// optional	If set to true, a link to the client invoice URL will be included in the message email.
	// Defaults to false. Ignored when thank_you is set to true.
	IncludeLinkToClientInvoice *bool `json:"include_link_to_client_invoice,omitempty"`
	// optional	If set to true, a PDF of the invoice will be attached to the message email. Defaults to false.
	AttachPdf *bool `json:"attach_pdf,omitempty"`
	// optional	If set to true, a copy of the message email will be sent to the current user. Defaults to false.
	SendMeACopy *bool `json:"send_me_a_copy,omitempty"`
	// optional	If set to true, a thank you message email will be sent. Defaults to false.
	ThankYou *bool `json:"thank_you,omitempty"`
	// optional	If provided, runs an event against the invoice. Options: close, draft, re-open, or send.
	EventType *bool `json:"event_type,omitempty"`
}

type InvoiceMessageList

type InvoiceMessageList struct {
	Invoices []*Invoice `json:"invoices"`

	Pagination
}

func (InvoiceMessageList) String

func (p InvoiceMessageList) String() string

type InvoiceMessageListOptions

type InvoiceMessageListOptions struct {
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type InvoiceMessageRecipient

type InvoiceMessageRecipient struct {
	// Name of the message recipient.
	Name *string `json:"name,omitempty"`
	// Email of the message recipient.
	Email *string `json:"email"`
}

type InvoicePayment

type InvoicePayment struct {
	// Unique ID for the payment.
	ID *int64 `json:"id,omitempty"`
	// The amount of the payment.
	Amount *string `json:"amount,omitempty"`
	// Date and time the payment was made.
	PaidAt *time.Time `json:"paid_at,omitempty"`
	// The name of the person who recorded the payment.
	RecordedBy *string `json:"recorded_by,omitempty"`
	// The email of the person who recorded the payment.
	RecordedByEmail *string `json:"recorded_by_email,omitempty"`
	// Any notes associated with the payment.
	Notes *string `json:"notes,omitempty"`
	// Either the card authorization or PayPal transaction ID.
	TransactionID *string `json:"transaction_id,omitempty"`
	// The payment gateway id and name used to process the payment.
	PaymentGateway *PaymentGateway `json:"payment_gateway,omitempty"`
	// Date and time the payment was recorded.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the payment was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (InvoicePayment) String

func (p InvoicePayment) String() string

type InvoicePaymentList

type InvoicePaymentList struct {
	InvoicePayments []*InvoicePayment `json:"invoice_payments"`

	Pagination
}

func (InvoicePaymentList) String

func (p InvoicePaymentList) String() string

type InvoicePaymentListOptions

type InvoicePaymentListOptions struct {
	// Only return invoice payments that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type InvoicePaymentRequest

type InvoicePaymentRequest struct {
	// required The amount of the payment.
	Amount *float64 `json:"amount"`
	// optional Date and time the payment was made. Pass either paid_at or paid_date, but not both.
	PaidAt *time.Time `json:"paid_at,omitempty"`
	// optional	Date the payment was made. Pass either paid_at or paid_date, but not both.
	PaidDate *Date `json:"paid_date,omitempty"`
	// optional Any notes to be associated with the payment.
	Notes *string `json:"notes,omitempty"`
}

type InvoiceService

type InvoiceService service

InvoiceService handles communication with the issue related methods of the Harvest API.

Harvest API docs: https://help.getharvest.com/api-v2/invoices-api/invoices/invoices/

func (*InvoiceService) Create

func (*InvoiceService) CreateInvoiceMessage

func (s *InvoiceService) CreateInvoiceMessage(
	ctx context.Context,
	invoiceID int64,
	data *InvoiceMessageCreateRequest,
) (*InvoiceMessage, *http.Response, error)

func (*InvoiceService) CreateItemCategory

func (*InvoiceService) CreatePayment

func (s *InvoiceService) CreatePayment(
	ctx context.Context,
	invoiceID int64,
	data *InvoicePaymentRequest,
) (*InvoicePayment, *http.Response, error)

func (*InvoiceService) Delete

func (s *InvoiceService) Delete(ctx context.Context, invoiceID int64) (*http.Response, error)

func (*InvoiceService) DeleteInvoiceMessage

func (s *InvoiceService) DeleteInvoiceMessage(
	ctx context.Context,
	invoiceID,
	invoiceMessageID int64,
) (*http.Response, error)

func (*InvoiceService) DeleteInvoicePayment

func (s *InvoiceService) DeleteInvoicePayment(
	ctx context.Context,
	invoiceID,
	invoicePaymentID int64,
) (*http.Response, error)

func (*InvoiceService) DeleteItemCategory

func (s *InvoiceService) DeleteItemCategory(ctx context.Context, invoiceItemCategoryID int64) (*http.Response, error)

func (*InvoiceService) Get

func (s *InvoiceService) Get(ctx context.Context, invoiceID int64) (*Invoice, *http.Response, error)

func (*InvoiceService) GetItemCategory

func (s *InvoiceService) GetItemCategory(
	ctx context.Context,
	invoiceItemCategoryID int64,
) (*InvoiceItemCategory, *http.Response, error)

func (*InvoiceService) List

func (*InvoiceService) ListInvoiceMessages

func (s *InvoiceService) ListInvoiceMessages(
	ctx context.Context,
	invoiceID int64,
	opt *InvoiceMessageListOptions,
) (*InvoiceList, *http.Response, error)

func (*InvoiceService) ListItemCategories

func (*InvoiceService) ListPayments

func (s *InvoiceService) ListPayments(
	ctx context.Context,
	invoiceID int64,
	opt *InvoicePaymentListOptions,
) (*InvoicePaymentList, *http.Response, error)

func (*InvoiceService) MarkAsClosed

func (s *InvoiceService) MarkAsClosed(ctx context.Context, invoiceID int64) (*InvoiceMessage, *http.Response, error)

func (*InvoiceService) MarkAsDraft

func (s *InvoiceService) MarkAsDraft(ctx context.Context, invoiceID int64) (*InvoiceMessage, *http.Response, error)

func (*InvoiceService) MarkAsReopen

func (s *InvoiceService) MarkAsReopen(ctx context.Context, invoiceID int64) (*InvoiceMessage, *http.Response, error)

func (*InvoiceService) MarkAsSent

func (s *InvoiceService) MarkAsSent(
	ctx context.Context,
	invoiceID int64,
) (*InvoiceMessage, *http.Response, error)

func (*InvoiceService) SendEvent

func (s *InvoiceService) SendEvent(
	ctx context.Context,
	invoiceID int64,
	data *EventTypeRequest,
) (*InvoiceMessage, *http.Response, error)

func (*InvoiceService) Update

func (s *InvoiceService) Update(
	ctx context.Context,
	invoiceID int64,
	data *InvoiceUpdateRequest,
) (*Invoice, *http.Response, error)

func (*InvoiceService) UpdateItemCategory

func (s *InvoiceService) UpdateItemCategory(
	ctx context.Context,
	invoiceItemCategoryID int64,
	data *InvoiceItemCategoryRequest,
) (*InvoiceItemCategory, *http.Response, error)

type InvoiceUpdateRequest

type InvoiceUpdateRequest struct {
	// The ID of the client this invoice belongs to.
	ClientID *int64 `json:"client_id,omitempty"`
	// The ID of the retainer associated with this invoice.
	RetainerID *int64 `json:"retainer_id,omitempty"`
	// The ID of the estimate associated with this invoice.
	EstimateID *int64 `json:"estimate_id,omitempty"`
	// If no value is set, the number will be automatically generated.
	Number *string `json:"number,omitempty"`
	// The *purchase `json:"The,omitempty"` // order number.
	PurchaseOrder *string `json:"purchase_order,omitempty"`
	// This percentage is applied to the subtotal, including line items and discounts.Example: use 10.0 for 10.0%.
	Tax *float64 `json:"tax,omitempty"`
	// This percentage is applied to the subtotal, including line items and discounts.Example: use 10.0 for 10.0%.
	Tax2 *float64 `json:"tax2,omitempty"`
	// This percentage is subtracted from the subtotal.Example: use 10.0 for 10.0%.
	Discount *float64 `json:"discount,omitempty"`
	// The *invoice `json:"The,omitempty"` // subject.
	Subject *string `json:"subject,omitempty"`
	// Any additional notes to include on the invoice.
	Notes *string `json:"notes,omitempty"`
	// The currency used by the invoice.If not provided,
	// the client’s currency will be used.See a list of supported currencies
	Currency *string `json:"currency,omitempty"`
	// Date the invoice was issued.
	IssueDate *Date `json:"issue_date,omitempty"`
	// Date the invoice is due.
	DueDate *Date `json:"due_date,omitempty"`
	// Array of line item parameters
	LineItems *[]InvoiceLineItemRequest `json:"line_items,omitempty"`
}

type ListOptions

type ListOptions struct {
	// For paginated result sets, page of results to retrieve.
	Page int `url:"page,omitempty"`

	// For paginated result sets, the number of results to include per page.
	// The number of records to return per page. Can range between 1 and 100. (Default: 100)
	PerPage int `url:"per_page,omitempty"`
}

ListOptions specifies the optional parameters to various List methods that support pagination.

type MyProjectAssignmentListOptions

type MyProjectAssignmentListOptions struct {
	ListOptions
}
type PageLinks struct {
	First    *string `json:"first,omitempty"`
	Next     *string `json:"next,omitempty"`
	Previous *string `json:"previous,omitempty"`
	Last     *string `json:"last,omitempty"`
}

type Pagination

type Pagination struct {
	PerPage      *int       `json:"per_page,omitempty"`
	TotalPages   *int       `json:"total_pages,omitempty"`
	TotalEntries *int       `json:"total_entries,omitempty"`
	NextPage     *int       `json:"next_page,omitempty"`
	PreviousPage *int       `json:"previous_page,omitempty"`
	Page         *int       `json:"page,omitempty"`
	Links        *PageLinks `json:"links,omitempty"`
}

type PaymentGateway

type PaymentGateway struct {
	ID   *int64  `json:"id,omitempty"`
	Name *string `json:"name,omitempty"`
}

func (PaymentGateway) String

func (p PaymentGateway) String() string

type Project

type Project struct {
	// Unique ID for the project.
	ID *int64 `json:"id,omitempty"`
	// An object containing the project’s client id, name, and currency.
	Client *Client `json:"client,omitempty"`
	// Unique name for the project.
	Name *string `json:"name,omitempty"`
	// The code associated with the project.
	Code *string `json:"code,omitempty"`
	// Whether the project is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
	// Whether the project is billable or not.
	IsBillable *bool `json:"is_billable,omitempty"`
	// Whether the project is a fixed-fee project or not.
	IsFixedFee *bool `json:"is_fixed_fee,omitempty"`
	// The method by which the project is invoiced.
	BillBy *string `json:"bill_by,omitempty"`
	// Rate for projects billed by Project Hourly Rate.
	HourlyRate *float64 `json:"hourly_rate,omitempty"`
	// The budget in hours for the project when budgeting by time.
	Budget *float64 `json:"budget,omitempty"`
	// The method by which the project is budgeted.
	BudgetBy *string `json:"budget_by,omitempty"`
	// Whether project managers should be notified when the project goes over budget.
	NotifyWhenOverBudget *bool `json:"notify_when_over_budget,omitempty"`
	// Percentage value used to trigger over budget email alerts.
	OverBudgetNotificationPercentage *float64 `json:"over_budget_notification_percentage,omitempty"`
	// Date of last over budget notification. If none have been sent, this will be null.
	OverBudgetNotificationDate *Date `json:"over_budget_notification_date,omitempty"`
	// Option to show project budget to all employees. Does not apply to Total Project Fee projects.
	ShowBudgetToAll *bool `json:"show_budget_to_all,omitempty"`
	// The monetary budget for the project when budgeting by money.
	CostBudget *float64 `json:"cost_budget,omitempty"`
	// Option for budget of Total Project Fees projects to include tracked expenses.
	CostBudgetIncludeExpenses *bool `json:"cost_budget_include_expenses,omitempty"`
	// The amount you plan to invoice for the project. Only used by fixed-fee projects.
	Fee *float64 `json:"fee,omitempty"`
	// Project notes.
	Notes *string `json:"notes,omitempty"`
	// Date the project was started.
	StartsOn *Date `json:"starts_on,omitempty"`
	// Date the project will end.
	EndsOn *Date `json:"ends_on,omitempty"`
	// Date and time the project was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the project was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (Project) String

func (p Project) String() string

type ProjectList

type ProjectList struct {
	Projects []*Project `json:"projects"`

	Pagination
}

func (ProjectList) String

func (p ProjectList) String() string

type ProjectListOptions

type ProjectListOptions struct {
	// Pass true to only return active projects and false to return inactive projects.
	IsActive bool `url:"is_active,omitempty"`
	// Only return projects belonging to the client with the given ID.
	ClientID int64 `url:"client_id,omitempty"`
	// Only return projects that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type ProjectService

type ProjectService service

ProjectService handles communication with the issue related methods of the Harvest API.

Harvest API docs: https://help.getharvest.com/api-v2/projects-api/projects/projects/

func (*ProjectService) CreateTaskAssignment

func (s *ProjectService) CreateTaskAssignment(
	ctx context.Context,
	projectID int64,
	data *ProjectTaskAssignmentCreateRequest,
) (*ProjectTaskAssignment, *http.Response, error)

func (*ProjectService) Get

func (s *ProjectService) Get(ctx context.Context, projectID int64) (*Project, *http.Response, error)

func (*ProjectService) GetMyProjectAssignments

func (*ProjectService) GetTaskAssignment

func (s *ProjectService) GetTaskAssignment(
	ctx context.Context,
	projectID int64,
	taskAssignmentID int64,
) (*ProjectTaskAssignment, *http.Response, error)

func (*ProjectService) GetUserAssignment

func (s *ProjectService) GetUserAssignment(
	ctx context.Context,
	projectID int64,
	userAssignmentID int64,
) (*ProjectUserAssignment, *http.Response, error)

func (*ProjectService) List

func (*ProjectService) ListProjectAssignments

func (*ProjectService) ListTaskAssignments

func (*ProjectService) ListUserAssignments

type ProjectTaskAssignment

type ProjectTaskAssignment struct {
	// Unique ID for the task assignment.
	ID *int64 `json:"id,omitempty"`
	// An object containing the id and name of the associated task.
	Task *Task `json:"task,omitempty"`
	// Whether the task assignment is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
	// Whether the task assignment is billable or not.
	// For example: if set to true, all time tracked on this project for the associated task will be marked as billable.
	Billable *bool `json:"billable,omitempty"`
	// Rate used when the project’s bill_by is Tasks.
	HourlyRate *float64 `json:"hourly_rate,omitempty"`
	// Budget used when the project’s budget_by is task or task_fees.
	Budget *float64 `json:"budget,omitempty"`
	// Date and time the task assignment was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the task assignment was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (ProjectTaskAssignment) String

func (p ProjectTaskAssignment) String() string

type ProjectTaskAssignmentCreateRequest

type ProjectTaskAssignmentCreateRequest struct {
	// required The ID of the task to associate with the project.
	TaskID *int64 `json:"task_id"`
	// optional Whether the task assignment is active or archived. Defaults to true
	IsActive *bool `json:"is_active,omitempty"`
	// optional Whether the task assignment is billable or not. Defaults to false.
	Billable *bool `json:"billable,omitempty"`
	// optional Rate used when the project’s bill_by is Tasks.
	// Defaults to null when billing by task hourly rate, otherwise 0.
	HourlyRate *float64 `json:"hourly_rate,omitempty"`
	// optional Budget used when the project’s budget_by is task or task_fees.
	Budget *float64 `json:"budget,omitempty"`
}

type ProjectTaskAssignmentList

type ProjectTaskAssignmentList struct {
	TaskAssignments []*ProjectTaskAssignment `json:"task_assignments"`

	Pagination
}

func (ProjectTaskAssignmentList) String

func (p ProjectTaskAssignmentList) String() string

type ProjectTaskAssignmentListOptions

type ProjectTaskAssignmentListOptions struct {
	// Pass true to only return active projects and false to return inactive projects.
	IsActive bool `url:"is_active,omitempty"`
	// Only return projects belonging to the client with the given ID.
	ClientID int64 `url:"client_id,omitempty"`
	// Only return projects that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type ProjectUserAssignment

type ProjectUserAssignment struct {
	// Unique ID for the user assignment.
	ID *int64 `json:"id,omitempty"`
	// An object containing the id and name of the associated user.
	User *User `json:"user,omitempty"`
	// Whether the user assignment is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
	// Determines if the user has project manager permissions for the project.
	IsProjectManager *bool `json:"is_project_manager,omitempty"`
	// Rate used when the project’s bill_by is People.
	HourlyRate *float64 `json:"hourly_rate,omitempty"`
	// Budget used when the project’s budget_by is person.
	Budget *float64 `json:"budget,omitempty"`
	// Date and time the user assignment was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the user assignment was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (ProjectUserAssignment) String

func (p ProjectUserAssignment) String() string

type ProjectUserAssignmentList

type ProjectUserAssignmentList struct {
	UserAssignments []*ProjectUserAssignment `json:"user_assignments"`

	Pagination
}

func (ProjectUserAssignmentList) String

func (p ProjectUserAssignmentList) String() string

type ProjectUserAssignmentListOptions

type ProjectUserAssignmentListOptions struct {
	// Pass true to only return active projects and false to return inactive projects.
	IsActive bool `url:"is_active,omitempty"`
	// Only return projects belonging to the client with the given ID.
	ClientID int64 `url:"client_id,omitempty"`
	// Only return projects that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type Rate

type Rate struct {
	// The number of requests per hour the client is currently limited to.
	Limit int `json:"limit"`

	// The number of remaining requests the client can make this hour.
	Remaining int `json:"remaining"`
}

Rate represents the rate limit for the current client.

func (Rate) String

func (r Rate) String() string

type RateLimitError

type RateLimitError struct {
	Rate     Rate           // Rate specifies last known rate limit for the client
	Response *http.Response // HTTP response that caused this error
	Message  string         `json:"message"` // error message
}

RateLimitError occurs when Harvest returns 429 Forbidden response with a rate limit remaining value of 0, and error message starts with "API rate limit exceeded for ".

func (*RateLimitError) Error

func (r *RateLimitError) Error() string

type RateLimits

type RateLimits struct {
	// 100 requests per 15 seconds
	// Harvest API docs: https://help.getharvest.com/api-v2/introduction/overview/general/#rate-limiting
	Core *Rate `json:"core"`
}

RateLimits represents the rate limits for the current client.

func (RateLimits) String

func (r RateLimits) String() string

type Receipt

type Receipt struct {
	URL         *string `json:"url,omitempty"`
	FileName    *string `json:"file_name,omitempty"`
	FileSize    *int64  `json:"file_size,omitempty"`
	ContentType *string `json:"content_type,omitempty"`
}

func (Receipt) String

func (p Receipt) String() string

type Role

type Role struct {
	ID        *int64     `json:"id,omitempty"`         // Unique ID for the role.
	Name      *string    `json:"name,omitempty"`       // The name of the role.
	UserIDs   *[]int64   `json:"user_ids,omitempty"`   // of integers	The IDs of the users assigned to this role.
	CreatedAt *time.Time `json:"created_at,omitempty"` // Date and time the role was created.
	UpdatedAt *time.Time `json:"updated_at,omitempty"` // Date and time the role was last updated.
}

func (Role) String

func (p Role) String() string

type RoleCreateRequest

type RoleCreateRequest struct {
	Name    *string  `json:"name"`               // required	The name of the role.
	UserIds *[]int64 `json:"user_ids,omitempty"` // The IDs of the users assigned to this role.
}

type RoleList

type RoleList struct {
	Roles []*Role `json:"roles"`

	Pagination
}

func (RoleList) String

func (p RoleList) String() string

type RoleListOptions

type RoleListOptions struct {
	ListOptions
}

type RoleService

type RoleService service

RoleService handles communication with the issue related methods of the Harvest API.

Harvest API docs: https://help.getharvest.com/api-v2/roles-api/roles/roles/

func (*RoleService) Create

func (s *RoleService) Create(ctx context.Context, data *RoleCreateRequest) (*Role, *http.Response, error)

func (*RoleService) Delete

func (s *RoleService) Delete(ctx context.Context, roleID int64) (*http.Response, error)

func (*RoleService) Get

func (s *RoleService) Get(ctx context.Context, roleID int64) (*Role, *http.Response, error)

func (*RoleService) List

func (*RoleService) Update

func (s *RoleService) Update(
	ctx context.Context,
	roleID int64,
	data *RoleUpdateRequest,
) (*Role, *http.Response, error)

type RoleUpdateRequest

type RoleUpdateRequest struct {
	Name    *string  `json:"name,omitempty"`     // The name of the role.
	UserIds *[]int64 `json:"user_ids,omitempty"` // The IDs of the users assigned to this role.
}

type Task

type Task struct {
	// Unique ID for the task.
	ID *int64 `json:"id,omitempty"`
	// The name of the task.
	Name *string `json:"name,omitempty"`
	// Used in determining whether default tasks should be marked billable when creating a new project.
	BillableByDefault *bool `json:"billable_by_default,omitempty"`
	// The hourly rate to use for this task when it is added to a project.
	DefaultHourlyRate *float64 `json:"default_hourly_rate,omitempty"`
	// Whether this task should be automatically added to future projects.
	IsDefault *bool `json:"is_default,omitempty"`
	// Whether this task is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
	// Date and time the task was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the task was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (Task) String

func (c Task) String() string

type TaskCreateRequest

type TaskCreateRequest struct {
	// required	The name of the task.
	Name *string `json:"name"`
	// optional	Used in determining whether default tasks should be marked billable when creating a new project.
	// Defaults to true.
	BillableByDefault *bool `json:"billable_by_default,omitempty"`
	// optional	The default hourly rate to use for this task when it is added to a project. Defaults to 0.
	DefaultHourlyRate *float64 `json:"default_hourly_rate,omitempty"`
	// optional	Whether this task should be automatically added to future projects. Defaults to false.
	IsDefault *bool `json:"is_default,omitempty"`
	// optional	Whether this task is active or archived. Defaults to true.
	IsActive *bool `json:"is_active,omitempty"`
}

type TaskList

type TaskList struct {
	Tasks []*Task `json:"tasks"`

	Pagination
}

func (TaskList) String

func (c TaskList) String() string

type TaskListOptions

type TaskListOptions struct {
	// Pass true to only return active projects and false to return inactive projects.
	IsActive bool `url:"is_active,omitempty"`
	// Only return projects that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type TaskService

type TaskService service

TaskService handles communication with the task related methods of the Harvest API.

Harvest API docs: https://help.getharvest.com/api-v2/tasks-api/tasks/tasks/

func (*TaskService) Create

func (s *TaskService) Create(ctx context.Context, data *TaskCreateRequest) (*Task, *http.Response, error)

func (*TaskService) Delete

func (s *TaskService) Delete(ctx context.Context, taskID int64) (*http.Response, error)

func (*TaskService) Get

func (s *TaskService) Get(ctx context.Context, taskID int64) (*Task, *http.Response, error)

func (*TaskService) List

func (*TaskService) Update

func (s *TaskService) Update(
	ctx context.Context,
	taskID int64,
	data *TaskUpdateRequest,
) (*Task, *http.Response, error)

type TaskUpdateRequest

type TaskUpdateRequest struct {
	// The name of the task.
	Name *string `json:"name,omitempty"`
	// Used in determining whether default tasks should be marked billable when creating a new project.
	BillableByDefault *bool `json:"billable_by_default,omitempty"`
	// The default hourly rate to use for this task when it is added to a project.
	DefaultHourlyRate *float64 `json:"default_hourly_rate,omitempty"`
	// Whether this task should be automatically added to future projects.
	IsDefault *bool `json:"is_default,omitempty"`
	// Whether this task is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
}

type Time

type Time struct {
	time.Time
}

func TimeP

func TimeP(v Time) *Time

TimeP is a helper routine that allocates a new Time value to store v and returns a pointer to it.

func (*Time) EncodeValues

func (t *Time) EncodeValues(key string, v *url.Values) error

func (Time) Equal

func (t Time) Equal(u Time) bool

Equal reports whether t and u are equal based on time.Equal.

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() ([]byte, error)

func (Time) String

func (t Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

type TimeEntry

type TimeEntry struct {
	// Unique ID for the time entry.
	ID *int64 `json:"id,omitempty"`
	// Date of the time entry.
	SpentDate *Date `json:"spent_date,omitempty"`
	// An object containing the id and name of the associated user.
	User *User `json:"user,omitempty"`
	// A user assignment object of the associated user.
	UserAssignment *ProjectUserAssignment `json:"user_assignment,omitempty"`
	// An object containing the id and name of the associated client.
	Client *Client `json:"client,omitempty"`
	// An object containing the id and name of the associated project.
	Project *Project `json:"project,omitempty"`
	// An object containing the id and name of the associated task.
	Task *Task `json:"task,omitempty"`
	// A task assignment object of the associated task.
	TaskAssignment *ProjectTaskAssignment `json:"task_assignment,omitempty"`
	// An object containing the id, group_id, permalink, service, and service_icon_url
	// of the associated external reference.
	ExternalReference *ExternalReference `json:"external_reference,omitempty"`
	// Once the time entry has been invoiced, this field will include the associated invoice’s id and number.
	Invoice *Invoice `json:"invoice,omitempty"`
	// Number of (decimal time) hours tracked in this time entry.
	Hours *float64 `json:"hours,omitempty"`
	// Number of (decimal time) hours tracked in this time entry used in summary reports and invoices.
	// This value is rounded according to the Time Rounding setting in your Preferences.
	RoundedHours *float64 `json:"rounded_hours,omitempty"`
	// Notes attached to the time entry.
	Notes *string `json:"notes,omitempty"`
	// Whether or not the time entry has been locked.
	IsLocked *bool `json:"is_locked,omitempty"`
	// Why the time entry has been locked.
	LockedReason *string `json:"locked_reason,omitempty"`
	// Whether or not the time entry has been approved via Timesheet Approval.
	IsClosed *bool `json:"is_closed,omitempty"`
	// Whether or not the time entry has been marked as invoiced.
	IsBilled *bool `json:"is_billed,omitempty"`
	// Date and time the timer was started (if tracking by duration).
	TimerStartedAt *time.Time `json:"timer_started_at,omitempty"`
	// Time the time entry was started (if tracking by start/end times).
	StartedTime *Time `json:"started_time,omitempty"`
	// Time the time entry was ended (if tracking by start/end times).
	EndedTime *Time `json:"ended_time,omitempty"`
	// Whether or not the time entry is currently running.
	IsRunning *bool `json:"is_running,omitempty"`
	// Whether or not the time entry is billable.
	Billable *bool `json:"billable,omitempty"`
	// Whether or not the time entry counts towards the project budget.
	Budgeted *bool `json:"budgeted,omitempty"`
	// The billable rate for the time entry.
	BillableRate *float64 `json:"billable_rate,omitempty"`
	// The cost rate for the time entry.
	CostRate *float64 `json:"cost_rate,omitempty"`
	// Date and time the time entry was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the time entry was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (TimeEntry) String

func (p TimeEntry) String() string

type TimeEntryCreateViaDuration

type TimeEntryCreateViaDuration struct {
	// optional	The ID of the user to associate with the time entry. Defaults to the currently authenticated user’s ID.
	UserID *int64 `json:"user_id,omitempty"`
	// required	The ID of the project to associate with the time entry.
	ProjectID *int64 `json:"project_id"`
	// required	The ID of the task to associate with the time entry.
	TaskID *int64 `json:"task_id"`
	// required	The ISO 8601 formatted date the time entry was spent.
	SpentDate *Date `json:"spent_date"`
	// optional	The current amount of time tracked.
	// If provided, the time entry will be created with the specified hours and is_running will be set to false.
	// If not provided, hours will be set to 0.0 and is_running will be set to true.
	Hours *float64 `json:"hours,omitempty"`
	// optional	Any notes to be associated with the time entry.
	Notes *string `json:"notes,omitempty"`
}

type TimeEntryCreateViaStartEndTime

type TimeEntryCreateViaStartEndTime struct {
	// optional	The ID of the user to associate with the time entry. Defaults to the currently authenticated user’s ID.
	UserID *int64 `json:"user_id,omitempty"`
	// required	The ID of the project to associate with the time entry.
	ProjectID *int64 `json:"project_id"`
	// required	The ID of the task to associate with the time entry.
	TaskID *int64 `json:"task_id"`
	// required	The ISO 8601 formatted date the time entry was spent.
	SpentDate *Date `json:"spent_date"`
	// optional	The time the entry started. Defaults to the current time. Example: “8:00am”.
	StartedTime *Time `json:"started_time,omitempty"`
	// optional	The time the entry ended. If provided, is_running will be set to false.
	// If not provided, is_running will be set to true.
	EndedTime *Time `json:"ended_time,omitempty"`
	// optional	Any notes to be associated with the time entry.
	Notes *string `json:"notes,omitempty"`
}

type TimeEntryList

type TimeEntryList struct {
	TimeEntries []*TimeEntry `json:"time_entries"`

	Pagination
}

func (TimeEntryList) String

func (p TimeEntryList) String() string

type TimeEntryListOptions

type TimeEntryListOptions struct {
	// Only return time entries belonging to the user with the given ID.
	UserID *int64 `url:"user_id,omitempty"`
	// Only return time entries belonging to the client with the given ID.
	ClientID *int64 `url:"client_id,omitempty"`
	// Only return time entries belonging to the project with the given ID.
	ProjectID *int64 `url:"project_id,omitempty"`
	// Pass true to only return time entries that have been invoiced and false to return time
	// entries that have not been invoiced.
	IsBilled *bool `url:"is_billed,omitempty"`
	// Pass true to only return running time entries and false to return non-running time entries.
	IsRunning *bool `url:"is_running,omitempty"`
	// Only return time entries that have been updated since the given date and time.*/
	UpdatedSince *time.Time `url:"updated_since,omitempty"`
	// Only return time entries with a spent_date on or after the given date.
	From *Date `url:"from,omitempty"`
	// Only return time entries with a spent_date on or before the given date.
	To *Date `url:"to,omitempty"`

	ListOptions
}

type TimeEntryUpdate

type TimeEntryUpdate struct {
	// required	The ID of the project to associate with the time entry.
	ProjectID *int64 `json:"project_id"`
	// required	The ID of the task to associate with the time entry.
	TaskID *int64 `json:"task_id"`
	// required	The ISO 8601 formatted date the time entry was spent.
	SpentDate *Date `json:"spent_date"`
	// optional	The time the entry started. Defaults to the current time. Example: “8:00am”.
	StartedTime *Time `json:"started_time,omitempty"`
	// optional	The time the entry ended. If provided, is_running will be set to false.
	// If not provided, is_running will be set to true.
	EndedTime *Time `json:"ended_time,omitempty"`
	// optional	The current amount of time tracked.
	// If provided, the time entry will be created with the specified hours and is_running will be set to false.
	// If not provided, hours will be set to 0.0 and is_running will be set to true.
	Hours *float64 `json:"hours,omitempty"`
	// optional	Any notes to be associated with the time entry.
	Notes *string `json:"notes,omitempty"`
}

type TimesheetService

type TimesheetService service

TimeEntryService handles communication with the issue related methods of the Harvest API.

Harvest API docs: https://help.getharvest.com/api-v2/timesheets-api/timesheets/time-entries/

func (*TimesheetService) CreateTimeEntryViaDuration

func (s *TimesheetService) CreateTimeEntryViaDuration(
	ctx context.Context,
	data *TimeEntryCreateViaDuration,
) (*TimeEntry, *http.Response, error)

func (*TimesheetService) CreateTimeEntryViaStartEndTime

func (s *TimesheetService) CreateTimeEntryViaStartEndTime(
	ctx context.Context,
	data *TimeEntryCreateViaStartEndTime,
) (*TimeEntry, *http.Response, error)

func (*TimesheetService) DeleteTimeEntry

func (s *TimesheetService) DeleteTimeEntry(ctx context.Context, timeEntryID int64) (*http.Response, error)

func (*TimesheetService) Get

func (s *TimesheetService) Get(ctx context.Context, timeEntryID int64) (*TimeEntry, *http.Response, error)

func (*TimesheetService) List

func (*TimesheetService) RestartTimeEntry

func (s *TimesheetService) RestartTimeEntry(
	ctx context.Context,
	timeEntryID int64,
) (*TimeEntry, *http.Response, error)

func (*TimesheetService) StopTimeEntry

func (s *TimesheetService) StopTimeEntry(ctx context.Context, timeEntryID int64) (*TimeEntry, *http.Response, error)

func (*TimesheetService) UpdateTimeEntry

func (s *TimesheetService) UpdateTimeEntry(
	ctx context.Context,
	timeEntryID int64,
	data *TimeEntryUpdate,
) (*TimeEntry, *http.Response, error)

type User

type User struct {
	// Unique ID for the user.
	ID *int64 `json:"id,omitempty"`
	// The first name of the user.
	FirstName *string `json:"first_name,omitempty"`
	// The last name of the user.
	LastName *string `json:"last_name,omitempty"`
	// The email address of the user.
	Email *string `json:"email,omitempty"`
	// The telephone number for the user.
	Telephone *string `json:"telephone,omitempty"`
	// The user's timezone.
	Timezone *string `json:"timezone,omitempty"`
	// Whether the user should be automatically added to future projects.
	HasAccessToAllFutureProjects *bool `json:"has_access_to_all_future_projects,omitempty"`
	// Whether the user is a contractor or an employee.
	IsContractor *bool `json:"is_contractor,omitempty"`
	// Whether the user has admin permissions.
	IsAdmin *bool `json:"is_admin,omitempty"`
	// Whether the user has project manager permissions.
	IsProjectManager *bool `json:"is_project_manager,omitempty"`
	// Whether the user can see billable rates on projects. Only applicable to project managers.
	CanSeeRates *bool `json:"can_see_rates,omitempty"`
	// Whether the user can create projects. Only applicable to project managers.
	CanCreateProjects *bool `json:"can_create_projects,omitempty"`
	// Whether the user can create invoices. Only applicable to project managers.
	CanCreateInvoices *bool `json:"can_create_invoices,omitempty"`
	// Whether the user is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
	// The number of hours per week this person is available to work in seconds.
	// For example, if a person's capacity is 35 hours, the API will return 126000 seconds.
	WeeklyCapacity *int `json:"weekly_capacity,omitempty"`
	// The billable rate to use for this user when they are added to a project.
	DefaultHourlyRate *float64 `json:"default_hourly_rate,omitempty"`
	// The cost rate to use for this user when calculating a project's costs vs billable amount.
	CostRate *float64 `json:"cost_rate,omitempty"`
	// of strings	The role names assigned to this person.
	Roles *[]string `json:"roles,omitempty"`
	// The URL to the user's avatar image.
	AvatarURL *string `json:"avatar_url,omitempty"`
	// Date and time the user was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the user was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (User) String

func (c User) String() string

type UserCreateRequest

type UserCreateRequest struct {
	// required	The first name of the user.
	FirstName *string `json:"first_name"`
	// required	The last name of the user.
	LastName *string `json:"last_name"`
	// required	The email address of the user.
	Email *string `json:"email"`
	// optional	The telephone number for the user.
	Telephone *string `json:"telephone,omitempty"`
	// optional	The user's timezone. Defaults to the company's timezone. See a list of supported time zones.
	Timezone *string `json:"timezone,omitempty"`
	// optional	Whether the user should be automatically added to future projects. Defaults to false.
	HasAccessToAllFutureProjects *bool `json:"has_access_to_all_future_projects,omitempty"`
	// optional	Whether the user is a contractor or an employee. Defaults to false.
	IsContractor *bool `json:"is_contractor,omitempty"`
	// optional	Whether the user has admin permissions. Defaults to false.
	IsAdmin *bool `json:"is_admin,omitempty"`
	// optional	Whether the user has project manager permissions. Defaults to false.
	IsProjectManager *bool `json:"is_project_manager,omitempty"`
	// optional	Whether the user can see billable rates on projects.
	// Only applicable to project managers. Defaults to false.
	CanSeeRates *bool `json:"can_see_rates,omitempty"`
	// optional	Whether the user can create projects. Only applicable to project managers. Defaults to false.
	CanCreateProjects *bool `json:"can_create_projects,omitempty"`
	// optional	Whether the user can create invoices. Only applicable to project managers. Defaults to false.
	CanCreateInvoices *bool `json:"can_create_invoices,omitempty"`
	// optional	Whether the user is active or archived. Defaults to true.
	IsActive *bool `json:"is_active,omitempty"`
	// optional	The number of hours per week this person is available to work in seconds.
	// Defaults to 126000 seconds (35 hours).
	WeeklyCapacity *int `json:"weekly_capacity,omitempty"`
	// optional	The billable rate to use for this user when they are added to a project. Defaults to 0.
	DefaultHourlyRate *float64 `json:"default_hourly_rate,omitempty"`
	// optional	The cost rate to use for this user when calculating a project's costs vs billable amount. Defaults to 0.
	CostRate *float64 `json:"cost_rate,omitempty"`
	// of strings	optional	The role names assigned to this person.
	Roles []*string `json:"roles,omitempty"`
}

type UserList

type UserList struct {
	Users []*User `json:"users"`

	Pagination
}

func (UserList) String

func (c UserList) String() string

type UserListOptions

type UserListOptions struct {
	// Pass true to only return active projects and false to return inactive projects.
	IsActive bool `url:"is_active,omitempty"`
	// Only return projects that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type UserProjectAssignment

type UserProjectAssignment struct {
	// Unique ID for the project assignment.
	ID *int64 `json:"id,omitempty"`
	// Whether the project assignment is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
	// Determines if the user has project manager permissions for the project.
	IsProjectManager *bool `json:"is_project_manager,omitempty"`
	// Rate used when the project’s bill_by is People.
	HourlyRate *float64 `json:"hourly_rate,omitempty"`
	// Budget used when the project’s budget_by is person.
	Budget *float64 `json:"budget,omitempty"`
	// Date and time the project assignment was created.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Date and time the project assignment was last updated.
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
	// An object containing the assigned project id, name, and code.
	Project *Project `json:"project,omitempty"`
	// An object containing the project’s client id and name.
	Client *Client `json:"client,omitempty"`
	// Array of task assignment objects associated with the project.
	TaskAssignments *[]ProjectTaskAssignment `json:"task_assignments,omitempty"`
}

func (UserProjectAssignment) String

func (p UserProjectAssignment) String() string

type UserProjectAssignmentList

type UserProjectAssignmentList struct {
	UserAssignments []*UserProjectAssignment `json:"project_assignments"`

	Pagination
}

func (UserProjectAssignmentList) String

func (p UserProjectAssignmentList) String() string

type UserProjectAssignmentListOptions

type UserProjectAssignmentListOptions struct {
	// Only return projects that have been updated since the given date and time.
	UpdatedSince time.Time `url:"updated_since,omitempty"`

	ListOptions
}

type UserService

type UserService service

UserService handles communication with the user related methods of the Harvest API.

Harvest API docs: https://help.getharvest.com/api-v2/users-api/users/users/

func (*UserService) Create

func (s *UserService) Create(ctx context.Context, data *UserCreateRequest) (*User, *http.Response, error)

func (*UserService) Current

func (s *UserService) Current(ctx context.Context) (*User, *http.Response, error)

func (*UserService) Delete

func (s *UserService) Delete(ctx context.Context, userID int64) (*http.Response, error)

func (*UserService) Get

func (s *UserService) Get(ctx context.Context, userID int64) (*User, *http.Response, error)

func (*UserService) List

func (*UserService) Update

func (s *UserService) Update(
	ctx context.Context,
	userID int64,
	data *UserUpdateRequest,
) (*User, *http.Response, error)

type UserUpdateRequest

type UserUpdateRequest struct {
	// The first name of the user. Can't be updated if the user is inactive.
	FirstName *string `json:"first_name,omitempty"`
	// The last name of the user. Can't be updated if the user is inactive.
	LastName *string `json:"last_name,omitempty"`
	// The email address of the user. Can't be updated if the user is inactive.
	Email *string `json:"email,omitempty"`
	// The telephone number for the user.
	Telephone *string `json:"telephone,omitempty"`
	// The user's timezone. Defaults to the company's timezone. See a list of supported time zones.
	Timezone *string `json:"timezone,omitempty"`
	// Whether the user should be automatically added to future projects.
	HasAccessToAllFutureProjects *bool `json:"has_access_to_all_future_projects,omitempty"`
	// Whether the user is a contractor or an employee.
	IsContractor *bool `json:"is_contractor,omitempty"`
	// Whether the user has admin permissions.
	IsAdmin *bool `json:"is_admin,omitempty"`
	// Whether the user has project manager permissions.
	IsProjectManager *bool `json:"is_project_manager,omitempty"`
	// Whether the user can see billable rates on projects. Only applicable to project managers.
	CanSeeRates *bool `json:"can_see_rates,omitempty"`
	// Whether the user can create projects. Only applicable to project managers.
	CanCreateProjects *bool `json:"can_create_projects,omitempty"`
	// Whether the user can create invoices. Only applicable to project managers.
	CanCreateInvoices *bool `json:"can_create_invoices,omitempty"`
	// Whether the user is active or archived.
	IsActive *bool `json:"is_active,omitempty"`
	// The number of hours per week this person is available to work in seconds.
	WeeklyCapacity *int `json:"weekly_capacity,omitempty"`
	// The billable rate to use for this user when they are added to a project.
	DefaultHourlyRate *float64 `json:"default_hourly_rate,omitempty"`
	// The cost rate to use for this user when calculating a project's costs vs billable amount.
	CostRate *float64 `json:"cost_rate,omitempty"`
	// of strings	The role names assigned to this person.
	Roles []*string `json:"roles,omitempty"`
}

Jump to

Keyboard shortcuts

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