client

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DateTimeFormat = "2006-01-02"

DateTimeFormat represents date format

View Source
const DayDateFormat = "Mon, 2006-01-02"

DayDateFormat represents day and date format

Variables

This section is empty.

Functions

This section is empty.

Types

type Activities

type Activities []Activity

Activities represents a list of activities.

func (Activities) Names

func (acts Activities) Names() []string

Names returns activity names.

func (Activities) Valid

func (acts Activities) Valid(name string) (int64, bool)

Valid checks whether activity with provided name parameter exists. If yes, returns its ID and true as second parameter; if not, return false as second parameter.

type Activity

type Activity struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

Activity represents Redmine activity for time that's being tracked.

type Client

type Client struct {
	HTTPClient *http.Client
	UserAgent  string
}

Client is main HTTP client for communication with Redmine server.

func (*Client) AddTimeEntry

func (c *Client) AddTimeEntry(entry TimeEntryPost) (*TimeEntry, error)

AddTimeEntry adds new time entry.

func (*Client) DeleteTimeEntry

func (c *Client) DeleteTimeEntry(id int) error

DeleteTimeEntry deletes time entry with requested ID.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do does the same as http.Client.Do() but also set response to provided v value.

func (*Client) GetActivities

func (c *Client) GetActivities() (Activities, error)

GetActivities fetches all Activities that can be entered in time entry record. Project specific activities cannot be fetched with this method.

func (*Client) GetIssue

func (c *Client) GetIssue(id int64) (*Issue, error)

GetIssue fetches issue with requested ID.

func (*Client) GetIssues

func (c *Client) GetIssues(queryParams string) ([]Issue, error)

GetIssues fetches issues with rules defined in queryParams.

func (*Client) GetMyIssues

func (c *Client) GetMyIssues() ([]Issue, error)

GetMyIssues fetches issues assigned only to currently logged user.

func (*Client) GetMyRelatedIssues added in v0.3.0

func (c *Client) GetMyRelatedIssues() ([]Issue, error)

GetMyRelatedIssues fetches issues assigned to currently logged user.

func (*Client) GetMyWatchedIssues

func (c *Client) GetMyWatchedIssues() ([]Issue, error)

GetMyWatchedIssues fetches issues that currently logged user watches.

func (*Client) GetProject

func (c *Client) GetProject(id int64) (*Project, error)

GetProject fetches project with requested ID.

func (*Client) GetProjects

func (c *Client) GetProjects() ([]Project, error)

GetProjects fetches all projects viewable by currently logged user.

func (*Client) GetSearchResults

func (c *Client) GetSearchResults(query string, offset, limit int) ([]SearchItem, int, error)

GetSearchResults returns search results for given query, offset and limit.

func (*Client) GetTimeEntries

func (c *Client) GetTimeEntries(queryParams string) ([]TimeEntry, error)

GetTimeEntries fetches time entries for requested queryParams

func (*Client) GetTimeEntry added in v0.2.0

func (c *Client) GetTimeEntry(id int) (*TimeEntry, error)

GetTimeEntry fetches time entry for given ID.

func (*Client) GetUser

func (c *Client) GetUser() (*User, error)

GetUser fetches data of currently logged user.

func (*Client) NewAuthRequest

func (c *Client) NewAuthRequest(ctx context.Context, username, password string) (*http.Request, error)

NewAuthRequest fetches user credentials for given username and password. Method uses simple basic authentication.

func (*Client) UpdateTimeEntry added in v0.2.0

func (c *Client) UpdateTimeEntry(id int, entry TimeEntryPost) error

UpdateTimeEntry updates time entry.

type DateTime

type DateTime struct {
	time.Time
}

DateTime custom representation of date.

func NewDateTime

func NewDateTime(time time.Time) *DateTime

NewDateTime creates new DateTime for specific time.Time.

func (DateTime) MarshalJSON

func (t DateTime) MarshalJSON() ([]byte, error)

MarshalJSON override

func (*DateTime) UnmarshalJSON

func (t *DateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON override

type Issue

type Issue struct {
	ID          int64  `json:"id"`
	Project     entity `json:"project"`
	Subject     string `json:"subject"`
	Description string `json:"description"`
}

Issue correspond with issue in Redmine.

func (*Issue) URL added in v0.1.1

func (i *Issue) URL() string

URL returns issue URL.

type Project

type Project struct {
	ID          int64     `json:"id"`
	Name        string    `json:"name"`
	Identifier  string    `json:"identifier"`
	Description string    `json:"description"`
	Status      int       `json:"status"`
	CreatedOn   time.Time `json:"created_on"`
	Parent      *entity   `json:"parent"`
}

Project represents Redmine project model.

func (*Project) URL added in v0.1.1

func (p *Project) URL() string

URL returns project URL.

type SearchItem

type SearchItem struct {
	ID          int    `json:"id"`
	Title       string `json:"title"`
	Type        string `json:"type"`
	URL         string `json:"url"`
	Description string `json:"description"`
	DateTime    string `json:"datetime"`
}

SearchItem represents Redmine search item model.

type TimeEntry

type TimeEntry struct {
	ID        int64     `json:"id"`
	Project   entity    `json:"project"`
	Issue     entityID  `json:"issue"`
	User      entity    `json:"user"`
	Activity  entity    `json:"activity"`
	Hours     float64   `json:"hours"`
	Comments  string    `json:"comments"`
	SpentOn   DateTime  `json:"spent_on"`
	CreatedOn time.Time `json:"created_on"`
	UpdatedOn time.Time `json:"updated_on"`
}

TimeEntry represents Redmine time entry model.

func (TimeEntry) PrintTable

func (te TimeEntry) PrintTable()

PrintTable prints table in suitable format.

type TimeEntryPost

type TimeEntryPost struct {
	IssueID    int      `json:"issue_id,omitempty"`
	ProjectID  int      `json:"project_id,omitempty"`
	SpentOn    DateTime `json:"spent_on,omitempty"`
	Hours      float32  `json:"hours,omitempty"`
	ActivityID int      `json:"activity_id,omitempty"`
	Comments   string   `json:"comments,omitempty"`
}

TimeEntryPost represents data which should be placed to request body while creating a new time entry.

type User

type User struct {
	ID        int64  `json:"id"`
	Username  string `json:"login"`
	FirstName string `json:"firstname"`
	LastName  string `json:"lastname"`
	Email     string `json:"mail"`
	APIKey    string `json:"api_key"`
}

User represents user model in Redmine.

type UserAPIResponse added in v0.2.0

type UserAPIResponse struct {
	User User `json:"user"`
}

UserAPIResponse response when user is being fetched.

Jump to

Keyboard shortcuts

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