pyrus

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 20 Imported by: 0

README

pyrusapi-go

GoDoc Widget Go Report codecov test lint

Library to work with Pyrus API v4 written in Golang.

Install

go get github.com/L11R/pyrusapi-go

Quick Start

package main

import (
	"fmt"
	"log"

	"github.com/L11R/pyrusapi-go"
)

func main() {
	c, err := pyrus.NewClient("bot_login", "bot_security_key")
	if err != nil {
		log.Fatalln(err)
	}

	p, err := c.Profile()
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println(p.FirstName)
}

Current status

Forms:

  • GET /forms
  • GET /forms/{form-id}
  • GET /forms/{form-id}/register

Tasks:

  • GET /tasks/{task-id}
  • POST /tasks
  • POST /tasks/{task-id}/comments

Files:

  • POST /files/upload
  • GET /files/download/{file-id}

Catalogs:

  • GET /catalogs
  • GET /catalogs/{catalog-id}
  • PUT /catalogs
  • POST /catalogs/{catalog-id}

Contacts:

  • GET /contacts

Members:

  • GET /members
  • POST /members
  • PUT /members/{member-id}
  • DELETE /members/{member-id}

Lists:

  • GET /lists
  • GET /lists/{list-id}/tasks
  • GET /inbox

Telephony:

  • GET /calls
  • PUT /calls/{call-guid}
  • POST /calls/{call-guid}/event

Webhooks:

  • Use WebhookHandler() (http.HandlerFunc, <-chan Event)

Tests

To test project you have to download sample responses from your organization. I cannot upload my own, because it could contain sensitive information, and I'm too lazy to fake it :)

Set those environment variables and run tests:

PYRUS_LOGIN=login
PYRUS_SECURITY_KEY=securityKey
PYRUS_FORM_ID=123456
PYRUS_TASK_ID=123456
PYRUS_CATALOG_ID=123456
PYRUS_MEMBER_ID=123456
PYRUS_ROLE_ID=123456
PYRUS_LIST_ID=123456
PYRUS_FILE_ID=123456
PYRUS_CALL_GUID=5d8dc3d6-27e7-4cd4-a057-2b4f4d74e0a5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType string

ActionType is a type of action in case of task.

const (
	ActionTypeFinished ActionType = "finished"
	ActionTypeReopened ActionType = "reopened"
)

type AddCallDetailsRequest

type AddCallDetailsRequest struct {
	StartTime       *time.Time          `json:"start_time,omitempty"`
	EndTime         *time.Time          `json:"end_time,omitempty"`
	Rating          int                 `json:"rating,omitempty"`
	DisconnectParty DisconnectPartyType `json:"disconnect_party,omitempty"`
	CallStatus      CallStatusType      `json:"call_status,omitempty"`
	FileGUID        string              `json:"file_guid"`
}

AddCallDetailsRequest is necessary to add call details.

type AnnouncementComment added in v1.0.5

type AnnouncementComment struct {
	ID          int       `json:"id"`
	Text        string    `json:"text"`
	CreateDate  time.Time `json:"create_date"`
	Author      *Person   `json:"author"`
	Attachments []*File   `json:"attachments"`
}

type AnnouncementCommentRequest added in v1.0.5

type AnnouncementCommentRequest struct {
	Text        string     `json:"text"`
	Attachments []*NewFile `json:"attachments,omitempty"`
}

AnnouncementCommentRequest is necessary to create a comment in the announcement.

func (AnnouncementCommentRequest) Validate added in v1.0.5

func (r AnnouncementCommentRequest) Validate() error

Validate allows to validate request before sending.

type AnnouncementRequest added in v1.0.5

type AnnouncementRequest struct {
	Text        string     `json:"text"`
	Attachments []*NewFile `json:"attachments,omitempty"`
}

AnnouncementRequest is necessary to create a task.

func (AnnouncementRequest) Validate added in v1.0.5

func (r AnnouncementRequest) Validate() error

Validate allows to validate request before sending.

type AnnouncementResponse added in v1.0.5

type AnnouncementResponse struct {
	Announcement *AnnouncementWithComments `json:"announcement"`
}

AnnouncementResponse represents a response from Announcement method.

type AnnouncementWithComments added in v1.0.5

type AnnouncementWithComments struct {
	ID          int                    `json:"id"`
	CreateDate  time.Time              `json:"create_date"`
	Author      *Person                `json:"author"`
	Attachments []*File                `json:"attachments"`
	Comments    []*AnnouncementComment `json:"comments"`
	Text        string                 `json:"text"`
}

AnnouncementWithComments represents an announcement with all of its comments.

type Approval

type Approval struct {
	Person         *Person    `json:"person"`
	Step           int        `json:"step"`
	ApprovalChoice ChoiceType `json:"approval_choice"`
}

Approval represents an approval by person. It contains person, step number and choice itself.

type Attachment

type Attachment struct {
	GUID         string `json:"guid,omitempty"`
	RootID       int    `json:"root_id,omitempty"`
	AttachmentID int    `json:"attachment_id,omitempty"`
	URL          string `json:"url,omitempty"`
	Name         string `json:"name,omitempty"`
}

Attachment allows to attach attachments to tasks and comments.

func (Attachment) Validate

func (a Attachment) Validate() error

Validate allows to validate request before sending.

type AuthResponse

type AuthResponse struct {
	AccessToken string `json:"access_token"`
}

AuthResponse represents a response from Auth method.

type CallEventType

type CallEventType string

CallEventType is a type of call event. Only relevant for calls API.

const (
	CallEventTypeShow CallEventType = "show"
)

type CallStatusType

type CallStatusType string

CallStatusType is a type of call. Only relevant for calls API.

const (
	CallStatusTypeAnswered CallStatusType = "answered"
	CallStatusTypeNoAnswer CallStatusType = "no answer"
	CallStatusTypeBusy     CallStatusType = "busy"
	CallStatusTypeError    CallStatusType = "error"
	CallStatusTypeOther    CallStatusType = "other"
)

type CatalogHeader

type CatalogHeader struct {
	Name string            `json:"name"`
	Type CatalogHeaderType `json:"type"`
}

CatalogHeader represents a header of Catalog. For example column "Name" or "Email".

type CatalogHeaderType

type CatalogHeaderType string

CatalogHeaderType is a type of CatalogHeader

const (
	CatalogHeaderTypeText     CatalogHeaderType = "text"
	CatalogHeaderTypeWorkflow CatalogHeaderType = "workflow"
)

type CatalogItem

type CatalogItem struct {
	ItemID  int        `json:"item_id,omitempty"`
	ItemIDs []int      `json:"item_ids,omitempty"`
	Headers []string   `json:"headers,omitempty"`
	Values  []string   `json:"values,omitempty"`
	Rows    [][]string `json:"rows,omitempty"`
}

CatalogItem represents an item of Catalog. It contains headers of catalog and its value.

type CatalogResponse

type CatalogResponse struct {
	CatalogID       int              `json:"catalog_id"`
	Name            string           `json:"name"`
	Version         int              `json:"version"`
	Supervisors     []int            `json:"supervisors"`
	Deleted         bool             `json:"deleted"`
	ExternalVersion int              `json:"external_version"`
	CatalogHeaders  []*CatalogHeader `json:"catalog_headers"`
	Items           []*CatalogItem   `json:"items"`
}

CatalogResponse represents a response from Catalog method.

type CatalogsResponse

type CatalogsResponse struct {
	Catalogs []*CatalogResponse `json:"catalogs"`
}

CatalogsResponse represents a list of available catalogs

type Channel

type Channel struct {
	Type ChannelType  `json:"type"`
	To   *ChannelUser `json:"to"`
	From *ChannelUser `json:"from"`
}

Channel represents an external channel of comments. It allows to mark there to send or from there it was sent.

type ChannelType

type ChannelType string

ChannelType is a type of Channel.

const (
	ChannelTypeEmail     ChannelType = "email"
	ChannelTypeTelegram  ChannelType = "telegram"
	ChannelTypeFacebook  ChannelType = "facebook"
	ChannelTypeVK        ChannelType = "vk"
	ChannelTypeViber     ChannelType = "viber"
	ChannelTypeMobileApp ChannelType = "mobile_app"
	ChannelTypeWebWidget ChannelType = "web_widget"
	ChannelTypeMoySklad  ChannelType = "moy_sklad"
	ChannelTypeZadarma   ChannelType = "zadarma"
	ChannelTypeAmoCRM    ChannelType = "amo_crm"
)

type ChannelUser

type ChannelUser struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

ChannelUser represents a user from Channel. Email is used only for email and Name for everything else.

type CheckmarkType

type CheckmarkType string

CheckmarkType is a type of checkmark. It could be only checked or unchecked.

const (
	CheckmarkTypeChecked   CheckmarkType = "checked"
	CheckmarkTypeUnchecked CheckmarkType = "unchecked"
)

type ChoiceOption

type ChoiceOption struct {
	ChoiceID    int          `json:"choice_id"`
	ChoiceValue string       `json:"choice_value"`
	Fields      []*FormField `json:"fields"`
	Deleted     bool         `json:"deleted"`
}

ChoiceOption represents a choice option of multiple_choice field type.

type ChoiceType

type ChoiceType string

ChoiceType is a type of approval choice in case of task.

const (
	ChoiceTypeApproved     ChoiceType = "approved"
	ChoiceTypeAcknowledged ChoiceType = "acknowledged"
	ChoiceTypeRejected     ChoiceType = "rejected"
	ChoiceTypeRevoked      ChoiceType = "revoked"
	ChoiceTypeWaiting      ChoiceType = "waiting"
)

type Client

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

func NewClient

func NewClient(login, securityKey string, opts ...Option) (*Client, error)

NewClient returns an instance of Client.

func (*Client) AddCallDetails

func (c *Client) AddCallDetails(callGUID string, req *AddCallDetailsRequest) error

AddCallDetails adds call details by call_guid.

func (*Client) Announcement added in v1.0.5

func (c *Client) Announcement(announcementID int) (*AnnouncementResponse, error)

Announcement returns an announcement with all comments.

func (*Client) Auth

func (c *Client) Auth(login, securityKey string) (string, error)

Auth performs authorization and returns access_token.

func (*Client) BlockMember

func (c *Client) BlockMember(memberID int) (*Member, error)

BlockMember blocks a user and returns it.

func (*Client) Catalog

func (c *Client) Catalog(catalogID int) (*CatalogResponse, error)

Catalog returns a catalog with all its elements.

func (*Client) Catalogs

func (c *Client) Catalogs() (*CatalogsResponse, error)

Catalogs returns a list of available catalogs.

func (*Client) CommentAnnouncement added in v1.0.5

func (c *Client) CommentAnnouncement(announcementID int, req *AnnouncementCommentRequest) (*AnnouncementResponse, error)

CommentAnnouncement comments a task and returns it with all comments, including the added one.

func (*Client) CommentTask

func (c *Client) CommentTask(taskID int, req *TaskCommentRequest) (*TaskResponse, error)

CommentTask comments a task and returns it with all comments, including the added one.

func (*Client) Contacts

func (c *Client) Contacts(includeInactive bool) (*ContactsResponse, error)

Contacts returns a list of contacts available to the current user and grouped by organization.

func (*Client) CreateAnnouncement added in v1.0.5

func (c *Client) CreateAnnouncement(req *AnnouncementRequest) (*AnnouncementResponse, error)

CreateAnnouncement creates an announcement and returns it with a comment.

func (*Client) CreateCatalog

func (c *Client) CreateCatalog(name string, headers []string, items []*CatalogItem) (*CatalogResponse, error)

CreateCatalog creates a catalog and returns it with all its elements.

func (*Client) CreateMember

func (c *Client) CreateMember(req *MemberRequest) (*Member, error)

CreateMember creates a user and returns it.

func (*Client) CreateRole

func (c *Client) CreateRole(name string, members []int) (*Role, error)

CreateRole creates a role and returns it.

func (*Client) CreateTask

func (c *Client) CreateTask(req *TaskRequest) (*TaskResponse, error)

CreateTask creates a task and returns it with a comment.

func (*Client) DownloadFile

func (c *Client) DownloadFile(fileID int) (*DownloadResponse, error)

DownloadFile downloads file from Pyrus.

func (*Client) Form

func (c *Client) Form(formID int) (*FormResponse, error)

Form returns a description of form with inputted id.

func (*Client) Forms

func (c *Client) Forms() (*FormsResponse, error)

Forms returns a description of all the forms in which the current user is a manager or a member.

func (*Client) Inbox

func (c *Client) Inbox(itemCount int) (*TaskListResponse, error)

Inbox returns all inbox tasks.

func (*Client) Lists

func (c *Client) Lists() (*ListsResponses, error)

Lists returns all the lists that are available to the user.

func (*Client) Members

func (c *Client) Members() (*MembersResponse, error)

Members returns a list of all organization participants.

func (*Client) Profile

func (c *Client) Profile() (*ProfileResponse, error)

Profile returns a profile of the calling user.

func (*Client) RegisterCall

func (c *Client) RegisterCall(req *RegisterCallRequest) (*RegisterCallResponse, error)

RegisterCall returns the GUID of the incoming call, and the id of the generated request.

func (*Client) RegisterCallEvent

func (c *Client) RegisterCallEvent(callGUID string, eventType CallEventType, extension string) error

RegisterCallEvent registers call event by call_guid.

func (*Client) Registry

func (c *Client) Registry(formID int, req *RegistryRequest) (*FormRegisterResponse, error)

Registry returns the list of tasks that were created based on the specified form. The response only contains general information about the task, like the list of filled form fields and its workflow. You can use Task method to get all task comments.

func (*Client) Roles

func (c *Client) Roles() (*RolesResponse, error)

Roles returns a list of roles.

func (*Client) SyncCatalog

func (c *Client) SyncCatalog(catalogID int, apply bool, headers []string, items []*CatalogItem) (*SyncCatalogResponse, error)

SyncCatalog updates catalog header and items and returns a list of items that have been added, modified, or deleted.

func (*Client) Task

func (c *Client) Task(taskID int) (*TaskResponse, error)

Task returns a task with all comments.

func (*Client) TaskList

func (c *Client) TaskList(listID, itemCount int, includeArchived bool) (*TaskListResponse, error)

TaskList returns all the tasks in the specified list.

func (*Client) UpdateMember

func (c *Client) UpdateMember(memberID int, req *MemberRequest) (*Member, error)

UpdateMember updates a user and returns it.

func (*Client) UpdateRole

func (c *Client) UpdateRole(roleID int, name string, add, remove []int, banned bool) (*Role, error)

UpdateRole updates a role and returns it.

func (*Client) UploadFile

func (c *Client) UploadFile(name string, file io.Reader) (*UploadResponse, error)

UploadFile uploads files for subsequent attachment to tasks. Files that are not referenced by any task are removed after a while.

func (*Client) WebhookHandler

func (c *Client) WebhookHandler() (http.HandlerFunc, <-chan Event)

WebhookHandler returns HTTP handler and channel with Event's. Handler automatically checks X-Pyrus-Sig, parses Event and sends it over channel..

type ContactsResponse

type ContactsResponse struct {
	Organizations []*Organization `json:"organizations"`
}

ContactsResponse represents a response from Contacts method.

type DisconnectPartyType

type DisconnectPartyType string

DisconnectPartyType is a type of disconnect party. Only relevant for calls API.

const (
	DisconnectPartyTypeAgent  DisconnectPartyType = "agent"
	DisconnectPartyTypeClient DisconnectPartyType = "client"
	DisconnectPartyTypeError  DisconnectPartyType = "error"
	DisconnectPartyTypeOther  DisconnectPartyType = "other"
)

type DownloadResponse

type DownloadResponse struct {
	Filename string
	RawFile  []byte `json:"raw_file"`
}

DownloadResponse represents a response from DownloadFile method.

type Error

type Error struct {
	Code        ErrorCode `json:"error_code"`
	Description string    `json:"error"`

	// Returns in case of 404
	Message string `json:"Message"`
}

Error is a standard error returned by Pyrus API in case of any problem with request.

func (Error) Error

func (e Error) Error() string

Error returns error as a human readable string

type ErrorCode

type ErrorCode string

ErrorCode is an "enum" for error codes. More about errors at: https://pyrus.com/en/help/api/errors-and-limits

const (
	// ErrServerError is internal server error.
	// You are not supposed to see this error,
	// however if it persists for more than 10 minutes you may want to contact Pyrus team support.
	ErrServerError ErrorCode = "server_error"
	// ErrInvalidCredentials returns in case of invalid login or security key.
	ErrInvalidCredentials ErrorCode = "invalid_credentials"
	// ErrTokenNotSpecified returns if access_token was not specified in request.
	// Library sets access_token so you cannot get this error unless you are doing request by yourself.
	ErrTokenNotSpecified ErrorCode = "token_not_specified"
	// ErrRevokedToken returns if access_token has been revoked.
	ErrRevokedToken ErrorCode = "revoked_token"
	// ErrExpiredToken returns if access_token has expired.
	ErrExpiredToken ErrorCode = "expired_token"
	// ErrInvalidToken returns if access_token is invalid.
	ErrInvalidToken ErrorCode = "invalid_token"
	// ErrAuthorizationError returns in case of unknown authorization error.
	ErrAuthorizationError ErrorCode = "authorization_error"
	// ErrAccountBlocked returns if user account that executed the request is blocked.
	// You should contact your company’s administrator.
	ErrAccountBlocked ErrorCode = "account_blocked"
	// ErrInvalidFieldID returns if the field with the specified identifier does not exist in the form.
	// Please verify input parameters.
	ErrInvalidFieldID ErrorCode = "invalid_field_id"
	// ErrDeletedField returns if the field with the specified identifier has been deleted from the form.
	// Please verify input parameters.
	ErrDeletedField ErrorCode = "deleted_field"
	// ErrInvalidFieldName returns if the field with the specified name does not exist in the form.
	// Please verify input parameters.
	ErrInvalidFieldName ErrorCode = "invalid_field_name"
	// ErrInvalidFieldIDName returns if the field with the specified identifier and name does not exist or has been deleted.
	// Please verify input parameters.
	ErrInvalidFieldIDName ErrorCode = "invalid_field_id_name"
	// ErrNonUniqueName returns if the field name is not unique within the form.
	// Please use the form field identifier to write value into it.
	ErrNonUniqueName ErrorCode = "non_unique_name"
	// ErrFieldIdentityMissing returns if the form field identity (id or name) is not specified in the request.
	ErrFieldIdentityMissing ErrorCode = "field_identity_missing"
	// ErrDuplicateField returns in case of you are trying to modify the same field multiple times in one request.
	ErrDuplicateField ErrorCode = "duplicate_field"
	// ErrInvalidCatalogID returns if the catalog with the id specified in the form template does not exist.
	ErrInvalidCatalogID ErrorCode = "invalid_catalog_id"
	// ErrInvalidCatalogItemName returns if the item with the specified name does not exist in the catalog.
	ErrInvalidCatalogItemName ErrorCode = "invalid_catalog_item_name"
	// ErrNonUniqueCatalogItemName returns if there are multiple items with the specified name in the catalog.
	// Please use item identifier to set a value.
	ErrNonUniqueCatalogItemName ErrorCode = "non_unique_catalog_item_name"
	// ErrInvalidCatalogItemID returns if the item with the specified id does not exist in the catalog.
	ErrInvalidCatalogItemID ErrorCode = "invalid_catalog_item_id"
	// ErrCatalogItemIDNameMismatch returns if the item with the specified identifier doesn't have a specified value.
	ErrCatalogItemIDNameMismatch ErrorCode = "catalog_item_id_name_mismatch"
	// ErrInvalidEmail returns if the person with that specified email address does not exist.
	ErrInvalidEmail ErrorCode = "invalid_email"
	// ErrNonUniqueEmail returns if there are multiple persons with that specified email.
	ErrNonUniqueEmail ErrorCode = "non_unique_email"
	// ErrInvalidPersonID returns if the person with the specified id was not found.
	ErrInvalidPersonID ErrorCode = "invalid_person_id"
	// ErrInvalidPersonIDEmail returns if the person with the specified identifier has another email.
	ErrInvalidPersonIDEmail ErrorCode = "invalid_person_id_email"
	// ErrFormHasNoTask returns if there is no task with the specified id created based on the specified form template id.
	ErrFormHasNoTask ErrorCode = "form_has_no_task"
	// ErrUnrecognizedAttachmentID returns in case of invalid unique identifier of attachment.
	// User has no attachment with specified id.
	ErrUnrecognizedAttachmentID ErrorCode = "unrecognized_attachment_id"
	// ErrRequiredFieldMissing returns if one of the required form fields is missing.
	// The error description will indicate which one.
	ErrRequiredFieldMissing ErrorCode = "required_field_missing"
	// ErrTypeIsNotSupported returns if this field type does not support the writing of values.
	ErrTypeIsNotSupported ErrorCode = "type_is_not_supported"
	// ErrCatalogIdentityMissing means that catalog item_id must be specified in order to write value into the catalog field.
	ErrCatalogIdentityMissing ErrorCode = "catalog_identity_missing"
	// ErrIncorrectParametersCount points at incorrect parameter count for the selected filter operator.
	ErrIncorrectParametersCount ErrorCode = "incorrect_parameters_count"
	// ErrFilterTypeIsNotSupported returns if this field type is not supported as a filter value.
	ErrFilterTypeIsNotSupported ErrorCode = "filter_type_is_not_supported"
	// ErrStepFieldDoesNotExists return if there are no step fields in the form.
	// You can't filter this form by step number.
	ErrStepFieldDoesNotExists ErrorCode = "step_field_does_not_exists"
	// ErrCatalogItemIDMissing means that catalog item_id must be specified in order to write value.
	ErrCatalogItemIDMissing ErrorCode = "catalog_item_id_missing"
	// ErrPersonIdentityMissing means that person id or email must be specified in order to write value.
	ErrPersonIdentityMissing ErrorCode = "person_identity_missing"
	// ErrEitherDueDateOrDueCanBeSet returns if you set both due_date and due.
	ErrEitherDueDateOrDueCanBeSet ErrorCode = "either_due_date_or_due_can_be_set"
	// ErrNegativeDuration returns if you are trying to send negative duration.
	ErrNegativeDuration ErrorCode = "negative_duration"
	// ErrDurationIsTooLong returns if you are trying to send more than year duration.
	ErrDurationIsTooLong ErrorCode = "duration_is_too_long"
	// ErrDueMissing returns if duration was sent without due.
	ErrDueMissing ErrorCode = "due_missing"
	// ErrScheduledDateInPast returns if you are trying to schedule task in the past.
	ErrScheduledDateInPast ErrorCode = "scheduled_date_in_past"
	// ErrCannotAddFormProject returns if you are trying to attach a task to a form project or a form's subproject.
	ErrCannotAddFormProject ErrorCode = "cannot_add_form_project"
	// ErrFormTemplateCantBeRemovedFromTask returns because form template list can't be removed from the task.
	ErrFormTemplateCantBeRemovedFromTask ErrorCode = "form_template_cant_be_removed_from_task"
	// ErrNoFileInRequest returns if there are no files in the request.
	ErrNoFileInRequest ErrorCode = "no_file_in_request"
	// ErrTooLargeRequestLength returns if the file you are attaching exceeds the maximum allowable size (250MB).
	ErrTooLargeRequestLength ErrorCode = "too_large_request_length"
	// ErrRequiredParameterMissing returns if one of the required request parameters is missing.
	// The error description will indicate which one.
	ErrRequiredParameterMissing ErrorCode = "required_parameter_missing"
	// ErrTooManyTaskSteps returns if the maximum allowed number of task steps has been exceeded.
	ErrTooManyTaskSteps ErrorCode = "too_many_task_steps"
	// ErrInvalidValueFormat returns if the provided value can't be converted to the field type.
	// The error description will indicate the type and value.
	ErrInvalidValueFormat ErrorCode = "invalid_value_format"
	// ErrTooManyComments returns if the maximum allowed number of task comments exceeded (10000).
	ErrTooManyComments ErrorCode = "too_many_comments"
	// ErrInvalidStepNumber returns if you have passed a negative step number or zero.
	ErrInvalidStepNumber ErrorCode = "invalid_step_number"
	// ErrTaskLimitExceeded returns if the maximum allowed number of tasks for your organization exceeded.
	ErrTaskLimitExceeded ErrorCode = "task_limit_exceeded"
	// ErrFieldIsInTable returns if the field you are trying to change is a part of the table.
	// You can modify it only by modifying the table.
	ErrFieldIsInTable ErrorCode = "field_is_in_table"
	// ErrRequiredTableFieldMissing returns if the required field inside table is not filled.
	// The error text will contain the name of the table, the field name and the line number.
	ErrRequiredTableFieldMissing ErrorCode = "required_table_field_missing"
	// ErrDepartmentCatalogCanNotBeModified returns because you can not modify department catalog using public API.
	ErrDepartmentCatalogCanNotBeModified ErrorCode = "department_catalog_can_not_be_modified"
	// ErrCatalogDuplicateRows returns because catalog contains duplicate rows.
	// Remove them and try request again.
	ErrCatalogDuplicateRows ErrorCode = "catalog_duplicate_rows"
	// ErrEmptyCatalogHeaders returns because catalog headers can not be empty.
	ErrEmptyCatalogHeaders ErrorCode = "empty_catalog_headers"
	// ErrCanNotModifyDeletedCatalog returns because you are trying to update a catalog that was deleted.
	ErrCanNotModifyDeletedCatalog ErrorCode = "can_not_modify_deleted_catalog"
	// ErrCanNotModifyFirstColumn returns because you can not modify the first column in the catalog.
	ErrCanNotModifyFirstColumn ErrorCode = "can_not_modify_first_column"
	// ErrCatalogHeadersItemsMismatch returns because headers and values mismatch.
	ErrCatalogHeadersItemsMismatch ErrorCode = "catalog_headers_items_mismatch"
	// ErrTooManyCatalogItems returns if the maximum allowed catalog items count exceeded (15000).
	ErrTooManyCatalogItems ErrorCode = "too_many_catalog_items"
	// ErrCatalogItemMaxLengthExceeded returns if the maximum catalog item length exceeded (500).
	ErrCatalogItemMaxLengthExceeded ErrorCode = "catalog_item_max_length_exceeded"
	// ErrCatalogDuplicateHeaders returns because catalog contains duplicate headers.
	// Remove them and try request again.
	ErrCatalogDuplicateHeaders ErrorCode = "catalog_duplicate_headers"
	// ErrFormIDMissing returns if you are trying to pass empty form_id.
	ErrFormIDMissing ErrorCode = "form_id_missing"
	// ErrTextMissing returns if you are trying to pass empty text.
	ErrTextMissing ErrorCode = "text_missing"
	// ErrInvalidJSON returns if the request body is not a valid JSON.
	ErrInvalidJSON ErrorCode = "invalid_json"
	// ErrEmptyBody returns if the request body can't be empty.
	ErrEmptyBody ErrorCode = "empty_body"
	// ErrAccessDeniedProject returns because access to the requested project is denied.
	// Make sure that the user has all the required permissions.
	ErrAccessDeniedProject ErrorCode = "access_denied_project"
	// ErrAccessDeniedTask returns because access to the requested task is denied.
	// Make sure that the user has all the required permissions.
	ErrAccessDeniedTask ErrorCode = "access_denied_task"
	// ErrAccessDeniedCloseTask returns if you don't have enough permissions to close the task.
	ErrAccessDeniedCloseTask ErrorCode = "access_denied_close_task"
	// ErrAccessDeniedReopenTask returns if you don't have enough permissions to reopen the task.
	ErrAccessDeniedReopenTask ErrorCode = "access_denied_reopen_task"
	// ErrAccessDeniedCatalog returns because access to the requested catalog is denied.
	// Make sure that thw user has all the required permissions.
	ErrAccessDeniedCatalog ErrorCode = "access_denied_catalog"
	// ErrAccessDeniedForm returns because access to the requested form is denied.
	// Make sure that the user has all the required permissions.
	ErrAccessDeniedForm ErrorCode = "access_denied_form"
	// ErrAccessDeniedPerson returns if you can't collaborate with the specified person.
	// Make sure that you have this person in your contact list or send them an invitation.
	ErrAccessDeniedPerson ErrorCode = "access_denied_person"
	// ErrTooManyRequests returns if you have reached the limit of requests per 10 minutes.
	// Please wait and try again later.
	ErrTooManyRequests ErrorCode = "too_many_requests"
	// ErrEmptyFile returns if you are trying to upload empty files.
	ErrEmptyFile ErrorCode = "empty_file"
	// ErrBadMultipartContent returns if you are trying to send bad body.
	ErrBadMultipartContent ErrorCode = "bad_multipart_content"
	// ErrInvalidTableRow returns because you cannot reset rows that have been deleted, or have not been created.
	ErrInvalidTableRow ErrorCode = "invalid_table_row"
	// ErrCannotAddExternalUser returns because an employee from another organization cannot be added to the task.
	ErrCannotAddExternalUser ErrorCode = "cannot_add_external_user"
	// ErrUnrecognizedIntegrationGUID returns if an integration with this id does not exist.
	ErrUnrecognizedIntegrationGUID ErrorCode = "unrecognized_integration_guid"
	// ErrUnrecognizedCallGUID returns if a call with this id does not exist.
	ErrUnrecognizedCallGUID ErrorCode = "unrecognized_call_guid"
	// ErrUnsupportedAttachmentFormat returns if the attachment has unknown or unsupported audio extension.
	ErrUnsupportedAttachmentFormat ErrorCode = "unsupported_attachment_format"
)

type Event

type Event struct {
	Event       string            `json:"event"`
	AccessToken string            `json:"access_token"`
	TaskID      int               `json:"task_id"`
	UserID      int               `json:"user_id"`
	Task        *TaskWithComments `json:"task"`
}

Event represents an event received from webhook.

type FieldType

type FieldType string

FieldType is a type of Form field.

const (
	FieldTypeText         FieldType = "text"
	FieldTypeMoney        FieldType = "money"
	FieldTypeNumber       FieldType = "number"
	FieldTypeDate         FieldType = "date"
	FieldTypeTime         FieldType = "time"
	FieldTypeCheckmark    FieldType = "checkmark"
	FieldTypeDueDate      FieldType = "due_date"
	FieldTypeDueDateTime  FieldType = "due_date_time"
	FieldTypeEmail        FieldType = "email"
	FieldTypePhone        FieldType = "phone"
	FieldTypeFlag         FieldType = "flag"
	FieldTypeStep         FieldType = "step"
	FieldTypeStatus       FieldType = "status"
	FieldTypeCreationDate FieldType = "creation_date"
	FieldTypeNote         FieldType = "note"

	FieldTypeCatalog        FieldType = "catalog"
	FieldTypeFile           FieldType = "file"
	FieldTypePerson         FieldType = "person"
	FieldTypeAuthor         FieldType = "author"
	FieldTypeTable          FieldType = "table"
	FieldTypeMultipleChoice FieldType = "multiple_choice"
	FieldTypeTitle          FieldType = "title"
	FieldTypeFormLink       FieldType = "form_link"
	FieldTypeProject        FieldType = "project"
)

type File

type File struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	Size    int    `json:"size"`
	MD5     string `json:"md5"`
	URL     string `json:"url"`
	Version int    `json:"version"`
	RootID  int    `json:"root_id"`
}

File represents an attachment to the task. It could be a part of filled form or comment.

type FlagType

type FlagType string

FlagType is a type of flag. While checkmark could be only checked or unchecked, flag could also has none state.

const (
	FlagTypeNone      FlagType = "none"
	FlagTypeChecked   FlagType = "checked"
	FlagTypeUnchecked FlagType = "unchecked"
)

type FormField

type FormField struct {
	ID    int            `json:"id,omitempty"`
	Type  FieldType      `json:"type,omitempty"`
	Name  string         `json:"name,omitempty"`
	Info  *FormFieldInfo `json:"info,omitempty"`
	Value interface{}    `json:"value,omitempty"`
	// ParentID returns if field has parent
	ParentID int `json:"parent_id,omitempty"`
	// RowID returns if field is in table
	RowID int `json:"row_id,omitempty"`
}

FormField is a Form field. Forms consist of fields. They could usually have tree structure, so often you will have to use type assertion.

func (*FormField) UnmarshalJSON

func (f *FormField) UnmarshalJSON(b []byte) error

UnmarshalJSON is a custom unmarshaler to create a tree of form fields.

func (FormField) Validate

func (f FormField) Validate() error

Validate allows to validate request before sending.

type FormFieldInfo

type FormFieldInfo struct {
	// RequiredStep indicates a step number where a field becomes required for filling
	RequiredStep int `json:"required_step"`
	// ImmutableStep indicates a step number from which the user can't change a field value
	ImmutableStep int `json:"immutable_step"`
	// Options return for a multiple_choice field
	Options []*ChoiceOption `json:"options,omitempty"`
	// CatalogID returns for a catalog field
	CatalogID int `json:"catalog_id,omitempty"`
	// Columns return for a table field
	Columns []*FormField `json:"columns,omitempty"`
	// Fields return for a title field
	Fields []*FormField `json:"fields,omitempty"`
	// DecimalPlaces return for a number field
	DecimalPlaces int `json:"decimal_places,omitempty"`
	// MultipleChoice returns a flag indicating that multiple values can be selected in Catalog field
	MultipleChoice bool `json:"multiple_choice,omitempty"`
	// Code returns code of a field
	Code string `json:"code,omitempty"`
}

FormFieldInfo could contain additional field information

type FormLink struct {
	TaskIDs []int  `json:"task_ids"`
	Subject string `json:"subject"`
}

FormLink represents a form field (official docs doesn't explain what exactly it is).

type FormRegisterResponse

type FormRegisterResponse struct {
	Tasks []*Task `json:"tasks"`
	CSV   string  `json:"csv"`
}

FormRegisterResponse represents a response from Registry method.

type FormResponse

type FormResponse struct {
	ID              int            `json:"id"`
	Name            string         `json:"name"`
	Steps           map[int]string `json:"steps"`
	Fields          []*FormField   `json:"fields"`
	DeletedOrClosed bool           `json:"deleted_or_closed"`
	PrintForms      []PrintForm    `json:"print_forms"`
	Folder          []string       `json:"folder"`
}

FormResponse represents a response from Form method.

type FormsResponse

type FormsResponse struct {
	Forms []*FormResponse `json:"forms"`
}

FormsResponse represents a response from Forms method.

type IClient

type IClient interface {
	Auth(login, securityKey string) (string, error)
	Forms() (*FormsResponse, error)
	Form(formID int) (*FormResponse, error)
	Registry(formID int, req *RegistryRequest) (*FormRegisterResponse, error)
	Task(taskID int) (*TaskResponse, error)
	CreateTask(req *TaskRequest) (*TaskResponse, error)
	CommentTask(taskID int, req *TaskCommentRequest) (*TaskResponse, error)
	Announcement(announcementID int) (*AnnouncementResponse, error)
	CreateAnnouncement(req *AnnouncementRequest) (*AnnouncementResponse, error)
	CommentAnnouncement(announcementID int, req *AnnouncementCommentRequest) (*AnnouncementResponse, error)
	UploadFile(name string, file io.Reader) (*UploadResponse, error)
	DownloadFile(fileID int) (*DownloadResponse, error)
	Catalogs() (*CatalogsResponse, error)
	Catalog(catalogID int) (*CatalogResponse, error)
	CreateCatalog(name string, headers []string, items []*CatalogItem) (*CatalogResponse, error)
	SyncCatalog(catalogID int, apply bool, headers []string, items []*CatalogItem) (*SyncCatalogResponse, error)
	Contacts(includeInactive bool) (*ContactsResponse, error)
	Members() (*MembersResponse, error)
	CreateMember(req *MemberRequest) (*Member, error)
	UpdateMember(memberID int, req *MemberRequest) (*Member, error)
	BlockMember(memberID int) (*Member, error)
	Roles() (*RolesResponse, error)
	CreateRole(name string, members []int) (*Role, error)
	UpdateRole(roleID int, name string, add, remove []int, banned bool) (*Role, error)
	Profile() (*ProfileResponse, error)
	Lists() (*ListsResponses, error)
	TaskList(listID, itemCount int, includeArchived bool) (*TaskListResponse, error)
	Inbox(itemCount int) (*TaskListResponse, error)
	RegisterCall(req *RegisterCallRequest) (*RegisterCallResponse, error)
	AddCallDetails(callGUID string, req *AddCallDetailsRequest) error
	RegisterCallEvent(callGUID string, eventType CallEventType, extension string) error
	WebhookHandler() (http.HandlerFunc, <-chan Event)
}

IClient is the main interface. Provided to implement dummy implementations useful for testing.

type ListsResponses

type ListsResponses struct {
	Lists []*TaskList `json:"lists"`
}

ListsResponses represents a response from Lists method.

type Logger

type Logger interface {
	Error(msg string, err error)
}

Logger allows you to pass own logger implementation that the library will use. By default logger is turned off. Pass *zap.Logger instance to WithZapLogger or you own with more generic WithLogger.

type Member

type Member struct {
	ID             int        `json:"id"`
	FirstName      string     `json:"first_name"`
	LastName       string     `json:"last_name"`
	Email          string     `json:"email"`
	Type           PersonType `json:"type"`
	ExternalID     string     `json:"external_id"`
	DepartmentID   int        `json:"department_id"`
	DepartmentName string     `json:"department_name"`
	Banned         bool       `json:"banned"`
	Position       string     `json:"position"`
	Skype          string     `json:"skype"`
	Phone          string     `json:"phone"`
}

Member represents a member of organization.

type MemberRequest

type MemberRequest struct {
	FirstName    string `json:"first_name,omitempty"`
	LastName     string `json:"last_name,omitempty"`
	Email        string `json:"email,omitempty"`
	Position     string `json:"position,omitempty"`
	DepartmentID int    `json:"department_id,omitempty"`
	Skype        string `json:"skype,omitempty"`
	Phone        string `json:"phone,omitempty"`
}

MemberRequest is necessary to create and update Member.

type MembersResponse

type MembersResponse struct {
	Members []*Member `json:"members"`
}

MembersResponse represents a response from Members method.

type MultipleChoice

type MultipleChoice struct {
	ChoiceIDs   []int        `json:"choice_ids,omitempty"`
	ChoiceNames []string     `json:"choice_names,omitempty"`
	Fields      []*FormField `json:"fields,omitempty"`
	ChoiceID    int          `json:"choice_id,omitempty"`
}

MultipleChoice represents a form field with multiple choice dropdown menu.

type NewFile added in v1.0.5

type NewFile struct {
	// GUID is an uploaded file GUID
	GUID string `json:"guid,omitempty"`
	// RootID is an existing file ID to create new version (optional)
	RootID int `json:"root_id,omitempty"`
	// AttachmentID is existing file ID
	AttachmentID int `json:"attachment_id,omitempty"`
	// URL existing file URL
	URL string `json:"url,omitempty"`
	// Name is link name (optional)
	Name string `json:"name,omitempty"`
}

type Option

type Option func(*Client)

Option helps to create an option for Client.

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithEventBufferSize

func WithEventBufferSize(size int) Option

WithEventBufferSize allows to override default buffer size of Event chan used by Webhook engine.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient allows to override http.DefaultClient and use your own.

func WithLogger

func WithLogger(l Logger) Option

WithLogger allows to log errors with own logger.

func WithZapLogger

func WithZapLogger(l *zap.Logger) Option

WithZapLogger allows to pass ready *zap.Logger instance for error logging.

type Organization

type Organization struct {
	ID                  int       `json:"organization_id"`
	Name                string    `json:"name"`
	Persons             []*Person `json:"persons"`
	Roles               []*Role   `json:"roles"`
	DepartmentCatalogID int       `json:"department_catalog_id"`
}

Organization represents organization with persons and roles of it.

type Person

type Person struct {
	ID             int        `json:"id,omitempty"`
	FirstName      string     `json:"first_name,omitempty"`
	LastName       string     `json:"last_name,omitempty"`
	Email          string     `json:"email,omitempty"`
	Type           PersonType `json:"type,omitempty"`
	DepartmentID   int        `json:"department_id,omitempty"`
	DepartmentName string     `json:"department_name,omitempty"`
}

Person represents a user of Pyrus.

func (Person) Validate

func (p Person) Validate() error

Validate allows to validate request before sending.

type PersonType

type PersonType string

PersonType is a type of Person.

const (
	PersonTypeUser PersonType = "user"
	PersonTypeBot  PersonType = "bot"
	PersonTypeRole PersonType = "role"
)

type PrintForm

type PrintForm struct {
	ID   int    `json:"print_form_id"`
	Name string `json:"print_form_name"`
}

type ProfileResponse

type ProfileResponse struct {
	PersonID       int    `json:"person_id"`
	FirstName      string `json:"first_name"`
	LastName       string `json:"last_name"`
	Email          string `json:"email"`
	Locale         string `json:"locale"`
	OrganizationID int    `json:"organization_id"`
}

ProfileResponse represents a response from Profile method.

type RegisterCallRequest

type RegisterCallRequest struct {
	To              string `json:"to,omitempty"`
	From            string `json:"from"`
	Extension       string `json:"extension,omitempty"`
	IntegrationGUID string `json:"integration_guid"`
	CallGUID        string `json:"call_guid,omitempty"`
	TaskID          int    `json:"task_id,omitempty"`
}

RegisterCallRequest is necessary to register a call.

func (RegisterCallRequest) Validate

func (r RegisterCallRequest) Validate() error

Validate allows to validate request before sending.

type RegisterCallResponse

type RegisterCallResponse struct {
	CallGUID string `json:"call_guid"`
	TaskID   string `json:"task_id"`
}

RegisterCallResponse represents a response from RegisterCall method.

type RegistryRequest

type RegistryRequest struct {
	FieldFilters map[int]string `json:"-"`

	Steps           int        `json:"steps,omitempty"`
	IncludeArchived bool       `json:"include_archived,omitempty"`
	FieldIDs        []int      `json:"field_ids,omitempty"`
	Format          string     `json:"format,omitempty"`
	Delimiter       string     `json:"delimiter,omitempty"`
	Encoding        string     `json:"encoding,omitempty"`
	SimpleFormat    bool       `json:"simple_format,omitempty"`
	ModifiedBefore  *time.Time `json:"modified_before,omitempty"`
	ModifiedAfter   *time.Time `json:"modified_after,omitempty"`
	CreatedBefore   *time.Time `json:"created_before,omitempty"`
	CreatedAfter    *time.Time `json:"created_after,omitempty"`
	ClosedBefore    *time.Time `json:"closed_before,omitempty"`
	ClosedAfter     *time.Time `json:"closed_after,omitempty"`
	TaskIDs         []int      `json:"task_ids,omitempty"`
}

RegistryRequest is helpful to get a registry of tasks.

func (*RegistryRequest) MarshalJSON

func (r *RegistryRequest) MarshalJSON() ([]byte, error)

MarshalJSON is a custom RegistryRequest marshaller that allows to merge the main struct and a map of field filters.

type Role

type Role struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	MemberIDs  []int  `json:"member_ids"`
	ExternalID int    `json:"external_id"`
	Banned     bool   `json:"banned"`
}

Role represents role and its members.

type RolesResponse

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

RolesResponse represents a response from Roles method.

type StatusType

type StatusType string

StatusType is a type of status in case of task.

const (
	StatusTypeOpen   StatusType = "open"
	StatusTypeClosed StatusType = "closed"
)

type Subscriber

type Subscriber struct {
	Person         *Person    `json:"person"`
	ApprovalChoice ChoiceType `json:"approval_choice"`
}

Subscriber represents a person who can watch for task updates, but doesn't participate in the process of approval.

type SyncCatalogResponse

type SyncCatalogResponse struct {
	Apply          bool             `json:"apply"`
	Added          []*CatalogItem   `json:"added"`
	Deleted        []*CatalogItem   `json:"deleted"`
	Updated        []*CatalogItem   `json:"updated"`
	CatalogHeaders []*CatalogHeader `json:"catalog_headers"`
}

SyncCatalogResponse represents a response from SyncCatalog method.

type Table

type Table []*TableRow

Table represents a table. In our case it's just a slice of table rows.

type TableRow

type TableRow struct {
	RowID  int          `json:"row_id"`
	Cells  []*FormField `json:"cells,omitempty"`
	Delete bool         `json:"delete,omitempty"`
}

TableRow is an element of table.

type Task

type Task struct {
	*TaskHeader

	Attachments          []*File       `json:"attachments"`
	ListIDs              []int         `json:"list_ids"`
	ParentTaskID         int           `json:"parent_task_id"`
	LinkedTaskIDs        []int         `json:"linked_task_ids"`
	LastNoteID           int           `json:"last_note_id"`
	Subject              string        `json:"subject"`
	ScheduledDate        string        `json:"scheduled_date"`
	ScheduledDatetimeUTC *time.Time    `json:"scheduled_datetime_utc"`
	Subscribers          []*Subscriber `json:"subscribers"`

	DueDate      string     `json:"due_date"`
	Due          *time.Time `json:"due"`
	Duration     int        `json:"duration"`
	Participants []*Person  `json:"participants"`

	FormID      int           `json:"form_id"`
	Fields      []*FormField  `json:"fields,omitempty"`
	Approvals   [][]*Approval `json:"approvals"`
	CurrentStep int           `json:"current_step"`
}

Task represents a task without comments.

type TaskComment

type TaskComment struct {
	ID                     int        `json:"id"`
	Text                   string     `json:"text"`
	Mentions               []int      `json:"mentions"`
	CreateDate             time.Time  `json:"create_date"`
	Author                 *Person    `json:"author"`
	Attachments            []*File    `json:"attachments"`
	Action                 ActionType `json:"action"`
	AddedListIDs           []int      `json:"added_list_ids"`
	RemovedListIDs         []int      `json:"removed_list_ids"`
	CommentAsRoles         []*Role    `json:"comment_as_roles"`
	Subject                string     `json:"subject"`
	ScheduledDate          string     `json:"scheduled_date"`
	ScheduledDatetimeUTC   *time.Time `json:"scheduled_datetime_utc"`
	CancelSchedule         bool       `json:"cancel_schedule"`
	SpentMinutes           int        `json:"spent_minutes"`
	SubscribersAdded       []*Person  `json:"subscribers_added"`
	SubscribersRemoved     []*Person  `json:"subscribers_removed"`
	SubscribersRerequested []*Person  `json:"subscribers_rerequested"`
	SkipSatisfaction       bool       `json:"skip_satisfaction"`
	ReplyNoteID            *int       `json:"reply_note_id"`

	ReassignedTo        *Person    `json:"reassigned_to"`
	ParticipantsAdded   []*Person  `json:"participants_added"`
	ParticipantsRemoved []*Person  `json:"participants_removed"`
	DueDate             string     `json:"due_date"`
	Due                 *time.Time `json:"due"`
	Duration            int        `json:"duration"`

	FieldUpdates         []*FormField  `json:"field_updates"`
	ApprovalChoice       ChoiceType    `json:"approval_choice"`
	ApprovalStep         int           `json:"approval_step"`
	ResetToStep          int           `json:"reset_to_step"`
	ChangedStep          int           `json:"changed_step"`
	ApprovalsAdded       [][]*Approval `json:"approvals_added"`
	ApprovalsRemoved     [][]*Approval `json:"approvals_removed"`
	ApprovalsRerequested [][]*Approval `json:"approvals_rerequested"`
	Channel              *Channel      `json:"channel"`
}

TaskComment represents a comment from task. Comment is not only the text, it contains all the updates of tasks: field updates, approvals, reassignments, etc.

type TaskCommentRequest

type TaskCommentRequest struct {
	Text                   string        `json:"text,omitempty"`
	Subject                string        `json:"subject,omitempty"`
	DueDate                string        `json:"due_date,omitempty"`
	Due                    *time.Time    `json:"due,omitempty"`
	Duration               int           `json:"duration,omitempty"`
	Action                 ActionType    `json:"action,omitempty"`
	ApprovalChoice         ChoiceType    `json:"approval_choice,omitempty"`
	ReassignTo             *Person       `json:"reassign_to,omitempty"`
	ApprovalsAdded         [][]*Person   `json:"approvals_added,omitempty"`
	ApprovalsRemoved       [][]*Person   `json:"approvals_removed,omitempty"`
	ApprovalsRerequested   [][]*Person   `json:"approvals_rerequested,omitempty"`
	SubscribersAdded       []*Person     `json:"subscribers_added,omitempty"`
	SubscribersRemoved     []*Person     `json:"subscribers_removed,omitempty"`
	SubscribersRerequested []*Person     `json:"subscribers_rerequested,omitempty"`
	ParticipantsAdded      []*Person     `json:"participants_added,omitempty"`
	ParticipantsRemoved    []*Person     `json:"participants_removed,omitempty"`
	FieldUpdates           []*FormField  `json:"field_updates,omitempty"`
	Attachments            []*Attachment `json:"attachments,omitempty"`
	AddedListIDs           []int         `json:"added_list_ids,omitempty"`
	RemovedListIDs         []int         `json:"removed_list_ids,omitempty"`
	ScheduledDate          string        `json:"scheduled_date,omitempty"`
	ScheduledDatetimeUTC   *time.Time    `json:"scheduled_datetime_utc,omitempty"`
	CancelSchedule         bool          `json:"cancel_schedule,omitempty"`
	Channel                *Channel      `json:"channel,omitempty"`
	SpentMinutes           int           `json:"spent_minutes,omitempty"`
}

TaskCommentRequest is necessary to create a comment in the task.

func (TaskCommentRequest) Validate

func (r TaskCommentRequest) Validate() error

Validate allows to validate request before sending.

type TaskHeader

type TaskHeader struct {
	ID               int        `json:"id"`
	CreateDate       time.Time  `json:"create_date"`
	LastModifiedDate *time.Time `json:"last_modified_date"`
	CloseDate        *time.Time `json:"close_date"`
	Author           *Person    `json:"author"`

	Text        string  `json:"text"`
	Responsible *Person `json:"responsible"`
	DueDate     string  `json:"due_date"`
}

TaskHeader represents only basic information about a task.

type TaskList

type TaskList struct {
	ID       int         `json:"id"`
	Name     string      `json:"name"`
	Children []*TaskList `json:"children"`
}

TaskList represents a list of tasks.

type TaskListResponse

type TaskListResponse struct {
	Tasks   []*TaskHeader `json:"tasks"`
	HasMode bool          `json:"has_mode"`
}

TaskListResponse represents a response from TaskList method.

type TaskRequest

type TaskRequest struct {
	Text                 string        `json:"text,omitempty"`
	Responsible          *Person       `json:"responsible,omitempty"`
	DueDate              string        `json:"due_date,omitempty"`
	Due                  *time.Time    `json:"due,omitempty"`
	Duration             int           `json:"duration,omitempty"`
	Subject              string        `json:"subject,omitempty"`
	Participants         []*Person     `json:"participants,omitempty"`
	Subscribers          []*Person     `json:"subscribers,omitempty"`
	ParentTaskID         int           `json:"parent_task_id,omitempty"`
	ListIDs              []int         `json:"list_ids,omitempty"`
	Attachments          []*Attachment `json:"attachments,omitempty"`
	ScheduledDate        string        `json:"scheduled_date,omitempty"`
	ScheduledDatetimeUTC *time.Time    `json:"scheduled_datetime_utc,omitempty"`
	Approvals            [][]*Person   `json:"approvals,omitempty"`
	FormID               int           `json:"form_id,omitempty"`
	Fields               []*FormField  `json:"fields,omitempty"`
	FillDefaults         bool          `json:"fill_defaults,omitempty"`
}

TaskRequest is necessary to create a task.

func (TaskRequest) Validate

func (r TaskRequest) Validate() error

Validate allows to validate request before sending.

type TaskResponse

type TaskResponse struct {
	Task *TaskWithComments `json:"task"`
}

TaskResponse represents a response from Task method.

type TaskWithComments

type TaskWithComments struct {
	*Task

	Comments []*TaskComment `json:"comments,omitempty"`
}

TaskWithComments represents a task with all of its comments.

type Title

type Title struct {
	Checkmark CheckmarkType `json:"checkmark"`
	Fields    []*FormField  `json:"fields"`
}

Title represents a form field title (official docs doesn't explain what exactly it is).

type UploadResponse

type UploadResponse struct {
	GUID    string `json:"guid"`
	MD5Hash string `json:"md5_hash"`
}

UploadResponse represents a response from UploadFile method.

Jump to

Keyboard shortcuts

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