项目作者: gosticks

项目描述 :
Mite API helper written in go
高级语言: Go
项目地址: git://github.com/gosticks/go-mite.git
创建时间: 2019-01-27T20:39:50Z
项目社区:https://github.com/gosticks/go-mite

开源协议:GNU General Public License v3.0

下载


Go Report Card License: GPL v3

SimpleMite go API implementation

This library provides easy access to the mite time tracking api (API not fully covered yet…).

Getting Started

  1. // create a mite api instance
  2. // appName should be a descriptive string for you application (e.g. "my-app/v0.1")
  3. miteAPI := NewMiteAPI(username, team, apiKey, appName)
  4. // now you can use the api
  5. customers, errCustomers := mite.GetCustomers(nil)
  6. if errCustomers != nil {
  7. l.Error(errCustomers)
  8. // handle error
  9. }

Available Methods

since this library was created for a specific use case not all API endpoints are implemented yet. But I will try to have a fill API coverage asap. The library provides the following options:

Time Entry (single)

Get single time entry

  1. entry, errEntry := miteAPI.GetTimeEntry(id)

Create Time entry

  1. // create a time entry instance
  2. entry := TimeEntry{...}
  3. // pass that instance to the miteAPI
  4. // mite will create the item in the provided userID.
  5. // if the userID inside cannot be written to (coworker to coworker) the entry will be created in the apiKey user.
  6. resp, err := miteAPI.CreateTimeEntry(entry)

Update Time entry

  1. update := &TimeEntry{
  2. // something you want to chance
  3. }
  4. // send updates to mite
  5. errUpdate := miteAPI.UpdateTimeEntry(id, update)

Delete Time entry

  1. errDelete := miteAPI.DeleteTimeEntry(id)

Time Entries

Get all time entries for a time range
filtersare a map[string]string and will be passed as GET parameters so they can be anything supported by mite
(check mite docs for more info https://mite.yo.lk/en/api/time-entries.html)

  1. // from and to are default golang time.Time instances
  2. entries, errEntries := miteAPI.GetTimeEntries(from, to, filters)

Get grouped time entries
same as get all time entries but the filters support groupBy and the result type is a TimeEntryGroup

  1. groups, errGroups := miteAPI.GetTimeEntriesGroup(from, to, filters)

Customers

Get all customers

  1. customers, errCustomers := miteAPI.GetCustomers(nil)

Get customer by name

  1. customer, err := miteAPI.GetCustomerByName(customerName)

Users

Get all users. When archived is true, the archived users will be returned.

  1. users, errUsers := miteAPI.GetUsers(archived)

Get a user by ID

  1. user, errUser := miteAPI.GetUser(userID)

Account

Get Account

  1. account, errAcc := miteAPI.GetAccount()

Get Myself
Returns the current user

  1. myself, errMyself := miteAPI.GetMyself()

Services

Get a single service by id

  1. service, errService := miteAPI.GetService(id)

Get All services

  1. services, errServices := miteAPI.GetServices(nil)

Project

Get a single project by id

  1. project, errProject := miteAPI.GetProject(id)

Get All projects

  1. projects, errProjects := miteAPI.GetProject(nil)

Create Project

  1. createdProject, err := miteAPI.CreateProject(project)