api

package
v0.0.0-...-78411ff Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package api provides a client for Glass Factory public APIs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeResponse

func DecodeResponse(target interface{}, res *http.Response) error

DecodeResponse decodes the body of res into target. If there is no body, target is unchanged.

func NewClient

func NewClient(ctx context.Context, settings *Settings) (*http.Client, string, error)

NewClient returns a new HTTP client with Glass Factory authentication

Types

type AuthTransport

type AuthTransport struct {
	UserEmail        string
	UserToken        string
	AccountSubdomain string
}

AuthTransport for the HTTP client provides the custom authentication headers

func (AuthTransport) RoundTrip

func (trans AuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip authorizes the request with HTTP Basic Auth

type ClientDetailsCall

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

ClientDetailsCall represents a request to Client Details API

func (*ClientDetailsCall) Do

Do executes the request and parses results

type ClientDetailsResponse

type ClientDetailsResponse struct {
	Client *model.Client
}

ClientDetailsResponse represents a response from Client Details API

type ClientListCall

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

ClientListCall represents a request to List Account's Clients API

func (*ClientListCall) Do

Do executes the request and parses results

func (*ClientListCall) Options

func (c *ClientListCall) Options() RequestOptions

Options returns request options with defaults

type ClientListResponse

type ClientListResponse struct {
	Clients []*model.Client
}

ClientListResponse represents a response from List Account's Clients API

type ClientService

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

ClientService is used for calling the Glass Factory client APIs

func NewClientService

func NewClientService(s *Service) *ClientService

NewClientService initialises a new ClientService

func (*ClientService) All

func (r *ClientService) All(opts ...RequestOption) ([]*model.Client, error)

All returns all clients in the Glass Factory account

func (*ClientService) Details

func (r *ClientService) Details(clientID int) *ClientDetailsCall

Details returns client details from Glass Factory

func (*ClientService) Get

func (r *ClientService) Get(clientID int, opts ...RequestOption) (*model.Client, error)

Get returns a client from Glass Factory

func (*ClientService) List

func (r *ClientService) List(opts ...RequestOption) *ClientListCall

List returns a list of clients in the Glass Factory account

type MemberDetailsCall

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

MemberDetailsCall represents a request to Member Details API

func (*MemberDetailsCall) Do

Do executes the request and parses results

type MemberDetailsResponse

type MemberDetailsResponse struct {
	Member *model.Member
}

MemberDetailsResponse represents a response from Member Details API

type MemberListCall

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

MemberListCall represents a request to List Staff Members API

func (*MemberListCall) Do

Do executes the request and parses results

func (*MemberListCall) Options

func (c *MemberListCall) Options() RequestOptions

Options returns request options with defaults

type MemberListResponse

type MemberListResponse struct {
	Members []*model.Member
	Status  string
}

MemberListResponse represents a response from List Staff Members API

type MemberReportsService

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

MemberReportsService provides methods for fetching time report data from Glass Factory

func NewMemberReportsService

func NewMemberReportsService(m *MemberService) *MemberReportsService

NewMemberReportsService creates a new MemberReportsService

func (*MemberReportsService) GetTimeReportsBetweenDates

func (r *MemberReportsService) GetTimeReportsBetweenDates(userID int, start time.Time, end time.Time, opts ...TimeReportOption) ([]*model.MemberTimeReport, error)

GetTimeReportsBetweenDates returns Glass Factory member time reports between given dates

func (*MemberReportsService) TimeReport

func (r *MemberReportsService) TimeReport(userID int, start time.Time, end time.Time, opts ...TimeReportOption) *MemberTimeReportCall

TimeReport queries Glass Factory and returns member time reports for the given time period

func (*MemberReportsService) TimeReportsBetweenDates

func (r *MemberReportsService) TimeReportsBetweenDates(userID int, start time.Time, end time.Time, opts ...TimeReportOption) *MemberTimeReportCalls

TimeReportsBetweenDates creates MemberTimeReportCalls to be used for fetching member time reports between the given dates

type MemberService

type MemberService struct {
	Reports *MemberReportsService
	// contains filtered or unexported fields
}

MemberService is used for calling the Glass Factory member APIs

func NewMemberService

func NewMemberService(s *Service) *MemberService

NewMemberService initialises a new MemberService

func (*MemberService) Active

func (r *MemberService) Active(opts ...RequestOption) ([]*model.Member, error)

Active returns all active members in the Glass Factory account

func (*MemberService) All

func (r *MemberService) All(opts ...RequestOption) ([]*model.Member, error)

All returns all members in the Glass Factory account

func (*MemberService) Details

func (r *MemberService) Details(userID int) *MemberDetailsCall

Details returns member details from Glass Factory

func (*MemberService) FindByEmail deprecated

func (r *MemberService) FindByEmail(email string, opts ...RequestOption) (*model.Member, error)

FindByEmail lists all members in the Glass Factory account and looks for a member with matching email address.

Deprecated: Filter members outside the service.

func (*MemberService) Get

func (r *MemberService) Get(userID int, opts ...RequestOption) (*model.Member, error)

Get returns a member from Glass Factory by their user ID

func (*MemberService) GetActive deprecated

func (r *MemberService) GetActive(opts ...RequestOption) ([]*model.Member, error)

GetActive returns all active members in the Glass Factory account

Deprecated: Use MemberService.Active()

func (*MemberService) List

func (r *MemberService) List(opts ...RequestOption) *MemberListCall

List returns a list of staff members in the Glass Factory account

func (*MemberService) ListActive deprecated

func (r *MemberService) ListActive() *MemberListCall

ListActive returns a list of active staff members in the Glass Factory account

Deprecated: You should call MemberService.List(WithStatus("active")) instead.

func (*MemberService) ListArchived deprecated

func (r *MemberService) ListArchived() *MemberListCall

ListArchived returns a list of archived staff members in the Glass Factory account

Deprecated: You should call MemberService.List(WithStatus("archived")) instead.

func (*MemberService) SearchActive deprecated

func (r *MemberService) SearchActive(term string) *MemberListCall

SearchActive returns a list of active users matching the search term.

Deprecated: You should call MemberService.List() directly with WithTerm(term) and WithStatus("active")) options instead.

type MemberTimeReportCall

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

MemberTimeReportCall is used for fetching time reports for given time period from Glass Factory

func (*MemberTimeReportCall) Do

Do executes the MemberTimeReportCall and returns MemberTimeReportResponse with the time report data

func (*MemberTimeReportCall) Options

Options returns request options with defaults

type MemberTimeReportCalls

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

MemberTimeReportCalls is used for fetching multiple time reports from Glass Factory

func (*MemberTimeReportCalls) Append

Append additional MemberTimeReportCall to the list of calls

func (*MemberTimeReportCalls) Do

Do executes all the queries in MemberTimeReportCalls

type MemberTimeReportResponse

type MemberTimeReportResponse struct {
	Reports []*model.MemberTimeReport
}

MemberTimeReportResponse contains the time reports returned from Glass Factory

type ProjectDetailsCall

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

ProjectDetailsCall represents a request to Project Details API

func (*ProjectDetailsCall) Do

Do executes the request and parses results

type ProjectDetailsResponse

type ProjectDetailsResponse struct {
	Project *model.Project
}

ProjectDetailsResponse represents a response from Project Details API

type ProjectListCall

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

ProjectListCall represents a request to List Account's PRojects API

func (*ProjectListCall) Do

Do executes the request and parses results

func (*ProjectListCall) Options

func (c *ProjectListCall) Options() RequestOptions

Options returns request options with defaults

type ProjectListResponse

type ProjectListResponse struct {
	Projects []*model.Project
}

ProjectListResponse represents a response from List Account's PRojects API

type ProjectService

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

ProjectService is used for calling the Glass Factory project APIs

func NewProjectService

func NewProjectService(s *Service) *ProjectService

NewProjectService initialises a new ProjectService

func (*ProjectService) All

func (r *ProjectService) All(opts ...RequestOption) ([]*model.Project, error)

All returns all projects in the Glass Factory account

func (*ProjectService) Details

func (r *ProjectService) Details(projectID int) *ProjectDetailsCall

Details returns project details from Glass Factory

func (*ProjectService) Get

func (r *ProjectService) Get(projectID int, opts ...RequestOption) (*model.Project, error)

Get returns a project from Glass Factory

func (*ProjectService) List

func (r *ProjectService) List(opts ...RequestOption) *ProjectListCall

List returns a list of projects in the Glass Factory account

type RequestOption

type RequestOption interface {
	// contains filtered or unexported methods
}

RequestOption overrides behavior of the service requests

func WithCache

func WithCache(cache bool) RequestOption

WithCache returns requests using cache

func WithStatus

func WithStatus(status string) RequestOption

WithStatus returns requests matching given status

func WithTerm

func WithTerm(term string) RequestOption

WithTerm returns requests matching the search term

type RequestOptions

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

RequestOptions represent the available options on the service requests

func NewRequestOptions

func NewRequestOptions(opts []RequestOption) *RequestOptions

NewRequestOptions returns RequestOptions with defaults

type Service

type Service struct {
	BasePath string // Base URL for the API

	Client  *ClientService
	Member  *MemberService
	Project *ProjectService
	// contains filtered or unexported fields
}

Service is used for calling Glass Factory APIs

func NewService

func NewService(ctx context.Context, settings *Settings) (*Service, error)

NewService creates a new Service.

func (*Service) GetCurrentMember

func (s *Service) GetCurrentMember() (*model.Member, error)

GetCurrentMember returns a member matching the user email address in settings

type Settings

type Settings struct {
	UserEmail        string
	UserToken        string
	AccountSubdomain string
}

Settings for the HTTP client

func NewSettings

func NewSettings(account string, email string, token string) (*Settings, error)

NewSettings creates new Settings for API authentication and validates them

func (*Settings) Validate

func (s *Settings) Validate() error

Validate returns an error if any settings are missing

type TimeReportOption

type TimeReportOption interface {
	// contains filtered or unexported methods
}

TimeReportOption overrides behavior of TimeReport

func FetchRelated

func FetchRelated() TimeReportOption

FetchRelated fetches the related data into the results

func WithClient

func WithClient(clientID int) TimeReportOption

WithClient returns time reports matching the given client

func WithOffice

func WithOffice(officeID int) TimeReportOption

WithOffice returns time reports matching the given office

func WithProject

func WithProject(projectID int) TimeReportOption

WithProject returns time reports matching the given project

func WithProjects

func WithProjects(projectIDs []int) TimeReportOption

WithProjects returns time reports matching the given projects

type TimeReportOptions

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

TimeReportOptions represent the options that can be used when generating member time reports

func NewTimeReportOptions

func NewTimeReportOptions(opts []TimeReportOption) *TimeReportOptions

NewTimeReportOptions returns TimeReportOptions with defaults

Jump to

Keyboard shortcuts

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