amocrm

package module
v0.0.0-...-8f7dd66 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 13 Imported by: 1

README

amocrm

Documentation

Overview

Example (GetAuthURL)
package main

import (
	"fmt"
	"time"

	"github.com/2010kira2010/amocrm"
)

var env = struct {
	clientID     string
	clientSecret string
	redirectURL  string
}{
	clientID:     "CLIENT_ID",
	clientSecret: "CLIENT_SECRET",
	redirectURL:  "REDIRECT_URI",
}

func main() {
	// Initialize amoCRM API Client.
	amoCRM := amocrm.New(env.clientID, env.clientSecret, env.redirectURL)

	// Save this random state as a session identifier to verify
	// user identity when they are redirected back with code.
	// Set required mode parameter: "post_message" or "popup".
	state := amocrm.RandomState()
	mode := amocrm.PostMessageMode

	// Redirect user to authorization URL.
	authURL, err := amoCRM.AuthorizeURL(state, mode)
	if err != nil {
		fmt.Println("Failed to Get auth url:", err)
		return
	}

	fmt.Println("Redirect user to this URL:")
	fmt.Println(authURL)
}
Output:

Example (GetCurrentAccount)
package main

import (
	"fmt"
	"time"

	"github.com/2010kira2010/amocrm"
)

var (
	env = struct {
		clientID     string
		clientSecret string
		redirectURL  string
	}{
		clientID:     "CLIENT_ID",
		clientSecret: "CLIENT_SECRET",
		redirectURL:  "REDIRECT_URI",
	}

	storage = struct {
		domain       string
		accessToken  string
		refreshToken string
		tokenType    string
		expiresAt    time.Time
	}{
		domain:       "example.amocrm.ru",
		accessToken:  "access_token",
		refreshToken: "refresh_token",
		tokenType:    "bearer",
		expiresAt:    time.Now(),
	}
)

func main() {
	// Initialize amoCRM API Client.
	amoCRM := amocrm.New(env.clientID, env.clientSecret, env.redirectURL)

	// Retrieve domain from storage.
	if err := amoCRM.SetDomain(storage.domain); err != nil {
		fmt.Println("set domain:", err)
		return
	}

	// Retrieve token from storage.
	token := amocrm.NewToken(storage.accessToken, storage.refreshToken, storage.tokenType, storage.expiresAt)
	if err := amoCRM.SetToken(token); err != nil {
		fmt.Println("set token:", err)
		return
	}

	// Set up accounts request config.
	cfg := amocrm.AccountsConfig{
		Relations: []string{
			amocrm.WithUUID,
			amocrm.WithVersion,
			amocrm.WithAmojoID,
			amocrm.WithTaskTypes,
			amocrm.WithUserGroups,
			amocrm.WithAmojoRights,
			amocrm.WithDatetimeSettings,
		},
	}

	// Fetch current accounts with AccountsRepository.
	account, err := amoCRM.Accounts().Current(cfg)
	if err != nil {
		fmt.Println("fetch current accounts:", err)
		return
	}

	fmt.Println("current accounts:", account)
}
Output:

Example (GetTokenByCode)
package main

import (
	"fmt"
	"time"

	"github.com/2010kira2010/amocrm"
)

var env = struct {
	clientID     string
	clientSecret string
	redirectURL  string
}{
	clientID:     "CLIENT_ID",
	clientSecret: "CLIENT_SECRET",
	redirectURL:  "REDIRECT_URI",
}

func main() {
	// Initialize amoCRM API Client.
	amoCRM := amocrm.New(env.clientID, env.clientSecret, env.redirectURL)

	// Use the accounts domain and authorization code that are
	// pushed to the redirect URL as "referer" and "code GET
	// parameters respectively. AccessTokenByCode will do the
	// handshake to retrieve tokens.
	domain := "example.amocrm.ru"
	authCode := "def502000ba3e1724cac79...92146f93b70fd4ca31"

	// Set amoCRM API accounts domain.
	if err := amoCRM.SetDomain(domain); err != nil {
		fmt.Println("set domain:", err)
		return
	}

	// Exchange authorization code for token.
	token, err := amoCRM.TokenByCode(authCode)
	if err != nil {
		fmt.Println("Get token by code:", err)
		return
	}

	// Store received token.
	fmt.Println("access_token:", token.AccessToken())
	fmt.Println("refresh_token:", token.RefreshToken())
	fmt.Println("token_type:", token.TokenType())
	fmt.Println("expires_at:", token.ExpiresAt().Unix())
}
Output:

Index

Examples

Constants

View Source
const (
	PostMessageMode = "post_message"
	PopupMode       = "popup"
)

PostMessageMode and PopupMode are the only options for amoCRM OAuth2.0 "mode" request parameter.

View Source
const (
	WithUUID             = "uuid"
	WithVersion          = "version"
	WithAmojoID          = "amojo_id"
	WithTaskTypes        = "task_types"
	WithUserGroups       = "users_groups"
	WithAmojoRights      = "amojo_rights"
	WithDatetimeSettings = "datetime_settings"
)

Account relations.

Variables

This section is empty.

Functions

func RandomState

func RandomState() string

RandomState generates a new random state.

Types

type Account

type Account struct {
	ID                      int    `json:"id,omitempty"`
	Name                    string `json:"name,omitempty"`
	Subdomain               string `json:"subdomain,omitempty"`
	CreatedAt               int    `json:"created_at,omitempty"`
	CreatedBy               int    `json:"created_by,omitempty"`
	UpdatedAt               int    `json:"updated_at,omitempty"`
	UpdatedBy               int    `json:"updated_by,omitempty"`
	CurrentUserID           int    `json:"current_user_id,omitempty"`
	Country                 string `json:"country,omitempty"`
	Currency                string `json:"currency,omitempty"`
	CustomersMode           string `json:"customers_mode,omitempty"`
	IsUnsortedOn            bool   `json:"is_unsorted_on,omitempty"`
	MobileFeatureVersion    int    `json:"mobile_feature_version,omitempty"`
	IsLossReasonEnabled     bool   `json:"is_loss_reason_enabled,omitempty"`
	IsHelpbotEnabled        bool   `json:"is_helpbot_enabled,omitempty"`
	IsTechnicalAccount      bool   `json:"is_technical_account,omitempty"`
	ContactNameDisplayOrder int    `json:"contact_name_display_order,omitempty"`
	AmojoID                 string `json:"amojo_id,omitempty"`
	UUID                    string `json:"uuid,omitempty"`
	Version                 int    `json:"version,omitempty"`
	Links                   struct {
		Self struct {
			Href string `json:"href,omitempty"`
		} `json:"self,omitempty"`
	} `json:"_links,omitempty"`
	Embedded struct {
		AmojoRights struct {
			CanDirect       bool `json:"can_direct,omitempty"`
			CanCreateGroups bool `json:"can_create_groups,omitempty"`
		} `json:"amojo_rights,omitempty"`
		UsersGroups []struct {
			ID   int         `json:"id,omitempty"`
			Name string      `json:"name,omitempty"`
			UUID interface{} `json:"uuid,omitempty"`
		} `json:"users_groups,omitempty"`
		TaskTypes []struct {
			ID     int         `json:"id,omitempty"`
			Name   string      `json:"name,omitempty"`
			Color  interface{} `json:"color,omitempty"`
			IconID interface{} `json:"icon_id,omitempty"`
			Code   string      `json:"code,omitempty"`
		} `json:"task_types,omitempty"`
		DatetimeSettings struct {
			DatePattern      string `json:"date_pattern,omitempty"`
			ShortDatePattern string `json:"short_date_pattern,omitempty"`
			ShortTimePattern string `json:"short_time_pattern,omitempty"`
			DateFormat       string `json:"date_format,omitempty"`
			TimeFormat       string `json:"time_format,omitempty"`
			Timezone         string `json:"timezone,omitempty"`
			TimezoneOffset   string `json:"timezone_offset,omitempty"`
		} `json:"datetime_settings,omitempty"`
	} `json:"_embedded,omitempty"`
}

Account represents amoCRM Account entity json DTO.

type Accounts

type Accounts interface {
	Current(cfg AccountsConfig) (*Account, error)
}

Accounts describes methods available for Accounts entity.

type AccountsConfig

type AccountsConfig struct {
	Relations []string
}

Use AccountsConfig to set account parameters.

type Call

type Call struct {
	Direction         string `json:"direction"`                     // Направление звонка. inbound – входящий, outbound – исходящий. Обязательный параметр
	Uniq              string `json:"uniq,omitempty"`                // Уникальный идентификатор звонка. Необязательный параметр
	Duration          int    `json:"duration"`                      // Длительность звонка в секундах. Обязательный параметр
	Source            string `json:"source"`                        // Источник звонка. Обязательный параметр
	Link              string `json:"link,omitempty"`                // Ссылка на запись звонка. Необязательный параметр
	Phone             string `json:"phone"`                         // Номер телефона, по которому будет произведен поиск. Обязательный параметр
	CallResult        string `json:"call_result,omitempty"`         // Результат звонка. Необязательный параметр
	CallStatus        int    `json:"call_status,omitempty"`         // Статус звонка. Доступные варианты: 1 – оставил сообщение, 2 – перезвонить позже, 3 – нет на месте, 4 – разговор состоялся, 5 – неверный номер, 6 – Не дозвонился, 7 – номер занят. Необязательный параметр
	ResponsibleUserID int    `json:"responsible_user_id,omitempty"` // ID пользователя, ответственного за звонок
	CreatedBy         int    `json:"created_by,omitempty"`          // ID пользователя, создавший звонок
	UpdatedBy         int    `json:"updated_by,omitempty"`          // ID пользователя, изменивший звонок
	CreatedAt         int    `json:"created_at,omitempty"`          // Дата создания звонка, передается в Unix Timestamp
	UpdatedAt         int    `json:"updated_at,omitempty"`          // Дата изменения звонка, передается в Unix Timestamp
	RequestID         string `json:"request_id,omitempty"`          // Поле, которое вернется вам в ответе без изменений и не будет сохранено. Необязательный параметр
}

type CallError

type CallError struct {
	Detail    string `json:"detail,omitempty"`
	RequestID string `json:"request_id,omitempty"`
	Status    int    `json:"status,omitempty"`
	Title     string `json:"title,omitempty"`
}

type Calls

type Calls interface {
	Create(calls []Call) ([]ContactOne, []CallError, error)
}

Calls describes methods available for Calls entity

type Client

type Client interface {
	AuthorizeURL(state, mode string) (*url.URL, error)
	TokenByCode(code string) (Token, error)
	LoadTokenOrAuthorize(code string) error
	CheckToken() error
	SetToken(token Token) error
	SetDomain(domain string) error
	Accounts() Accounts
	Leads() Leads
	Contacts() Contacts
	Companies() Companies
	Pipelines() Pipelines
	Calls() Calls
	EventsV2() EventsV2
}

Provider is a wrapper for authorization and making requests.

func New

func New(clientID, clientSecret, redirectURL string) Client

New allocates and returns a new amoCRM API Client.

func NewWithStorage

func NewWithStorage(tokenStorage TokenStorage, clientID, clientSecret, redirectURL string) Client

type Companies

type Companies interface {
	GetСompany(companieID string) (*CompanyOne, error, int)
	GetCompanies(values url.Values) (*CompaniesArr, error, int)
	Create(сompanies []CompanyOne) ([]CompanyOne, error, int)
	Update(сompanies []CompanyOne) ([]CompanyOne, error, int)
}

type CompaniesArr

type CompaniesArr struct {
	Page     int `json:"_page,omitempty"`
	Embedded struct {
		Companies []struct {
			ID                 int                `json:"id,omitempty"`
			Name               string             `json:"name,omitempty"`
			ResponsibleUserID  int                `json:"responsible_user_id,omitempty"`
			GroupID            int                `json:"group_id,omitempty"`
			CreatedBy          int                `json:"created_by,omitempty"`
			UpdatedBy          int                `json:"updated_by,omitempty"`
			CreatedAt          int                `json:"created_at,omitempty"`
			UpdatedAt          int                `json:"updated_at,omitempty"`
			ClosedAt           interface{}        `json:"closed_at,omitempty"`
			ClosestTaskAt      interface{}        `json:"closest_task_at,omitempty"`
			IsDeleted          bool               `json:"is_deleted,omitempty"`
			CustomFieldsValues []CustomsFields    `json:"custom_fields_values,omitempty"`
			AccountID          int                `json:"account_id,omitempty"`
			Embedded           *CompaniesEmbedded `json:"_embedded,omitempty"`
		} `json:"companies,omitempty"`
	} `json:"_embedded,omitempty"`
}

type CompaniesEmbedded

type CompaniesEmbedded struct {
	Tags []FieldValues `json:"tags,omitempty"`
}

type CompanyOne

type CompanyOne struct {
	ID                 int                `json:"id,omitempty"`
	Name               string             `json:"name,omitempty"`
	ResponsibleUserID  int                `json:"responsible_user_id,omitempty"`
	GroupID            int                `json:"group_id,omitempty"`
	CreatedBy          int                `json:"created_by,omitempty"`
	UpdatedBy          int                `json:"updated_by,omitempty"`
	CreatedAt          int                `json:"created_at,omitempty"`
	UpdatedAt          int                `json:"updated_at,omitempty"`
	ClosedAt           interface{}        `json:"closed_at,omitempty"`
	ClosestTaskAt      interface{}        `json:"closest_task_at,omitempty"`
	IsDeleted          bool               `json:"is_deleted,omitempty"`
	CustomFieldsValues []CustomsFields    `json:"custom_fields_values,omitempty"`
	AccountID          int                `json:"account_id,omitempty"`
	Embedded           *CompaniesEmbedded `json:"_embedded,omitempty"`
}

type ContactOne

type ContactOne struct {
	ID                 int               `json:"id,omitempty"`
	Name               string            `json:"name,omitempty"`
	FirstName          string            `json:"first_name,omitempty"`
	LastName           string            `json:"last_name,omitempty"`
	Price              int               `json:"price,omitempty"`
	ResponsibleUserID  int               `json:"responsible_user_id,omitempty"`
	GroupID            int               `json:"group_id,omitempty"`
	StatusID           int               `json:"status_id,omitempty"`
	PipelineID         int               `json:"pipeline_id,omitempty"`
	LossReasonID       interface{}       `json:"loss_reason_id,omitempty"`
	CreatedBy          int               `json:"created_by,omitempty"`
	UpdatedBy          int               `json:"updated_by,omitempty"`
	CreatedAt          int               `json:"created_at,omitempty"`
	UpdatedAt          int               `json:"updated_at,omitempty"`
	ClosedAt           interface{}       `json:"closed_at,omitempty"`
	ClosestTaskAt      interface{}       `json:"closest_task_at,omitempty"`
	IsDeleted          bool              `json:"is_deleted,omitempty"`
	CustomFieldsValues []CustomsFields   `json:"custom_fields_values,omitempty"`
	Score              interface{}       `json:"score,omitempty"`
	AccountID          int               `json:"account_id,omitempty"`
	LaborCost          interface{}       `json:"labor_cost,omitempty"`
	Embedded           *ContactsEmbedded `json:"_embedded,omitempty"`
}

type Contacts

type Contacts interface {
	GetContact(contactID string) (*ContactOne, error, int)
	GetContacts(values url.Values) (*ContactsArr, error, int)
	Create(contacts []ContactOne) ([]ContactOne, error, int)
	Update(contacts []ContactOne) ([]ContactOne, error, int)
}

type ContactsArr

type ContactsArr struct {
	Page     int `json:"_page,omitempty"`
	Embedded struct {
		Contacts []struct {
			ID                 int               `json:"id,omitempty"`
			Name               string            `json:"name,omitempty"`
			FirstName          string            `json:"first_name,omitempty"`
			LastName           string            `json:"last_name,omitempty"`
			ResponsibleUserID  int               `json:"responsible_user_id,omitempty"`
			GroupID            int               `json:"group_id,omitempty"`
			CreatedBy          int               `json:"created_by,omitempty"`
			UpdatedBy          int               `json:"updated_by,omitempty"`
			CreatedAt          int               `json:"created_at,omitempty"`
			UpdatedAt          int               `json:"updated_at,omitempty"`
			ClosestTaskAt      interface{}       `json:"closest_task_at,omitempty"`
			IsDeleted          bool              `json:"is_deleted,omitempty"`
			IsUnsorted         bool              `json:"is_unsorted,omitempty"`
			CustomFieldsValues []CustomsFields   `json:"custom_fields_values,omitempty"`
			AccountID          int               `json:"account_id,omitempty"`
			Embedded           *ContactsEmbedded `json:"_embedded,omitempty"`
		} `json:"contacts,omitempty"`
	} `json:"_embedded,omitempty"`
}

type ContactsEmbedded

type ContactsEmbedded struct {
	Tags []FieldValues `json:"tags,omitempty"`
}

type CustomsField

type CustomsField struct {
	ID        int    `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	Type      string `json:"type,omitempty"`
	AccountID int    `json:"account_id,omitempty"`
	Code      string `json:"code,omitempty"`
	Sort      int    `json:"sort,omitempty"`
	IsAPIOnly bool   `json:"is_api_only,omitempty"`
	Enums     []struct {
		ID    int    `json:"id,omitempty"`
		Value string `json:"value,omitempty"`
		Sort  int    `json:"sort,omitempty"`
	} `json:"enums,omitempty"`
}

type CustomsFields

type CustomsFields struct {
	FieldID   int                   `json:"field_id,omitempty"`
	FieldName string                `json:"field_name,omitempty"`
	FieldCode interface{}           `json:"field_code,omitempty"`
	FieldType string                `json:"field_type,omitempty"`
	Values    []CustomsFieldsValues `json:"values,omitempty"`
}

type CustomsFieldsValues

type CustomsFieldsValues struct {
	Value    interface{} `json:"value,omitempty"`
	EnumId   interface{} `json:"enum_id,omitempty"`
	EnumCode interface{} `json:"enum_code,omitempty"`
}

type Event

type Event struct {
	Type        string `json:"type"`         // Тип уведомления – phone_call
	PhoneNumber string `json:"phone_number"` // Номер телефона на который поступает звонок. Можно передавать в любом формате
	Users       []int  `json:"users"`        // Пользователи для которых будет отправлено уведомление. Если не передавать этот параметр, то уведомление будет отправлено для всех пользователей
}

type EventAdd

type EventAdd struct {
	Add []Event `json:"add"`
}

type EventEmbeddedItem

type EventEmbeddedItem struct {
	ElementID   int    `json:"element_id"`
	ElementType int    `json:"element_type"`
	UID         string `json:"uid"`
	PhoneNumber string `json:"phone_number"`
}

type EventsV2

type EventsV2 interface {
	Add(events []Event) ([]EventEmbeddedItem, error)
}

Events describes methods available for Events entity

type FieldValues

type FieldValues map[string]interface{}

type GrantType

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

type JSONFileTokenStorage

type JSONFileTokenStorage struct {
	File string
}

func (JSONFileTokenStorage) GetToken

func (self JSONFileTokenStorage) GetToken() (Token, error)

func (JSONFileTokenStorage) SetToken

func (self JSONFileTokenStorage) SetToken(token Token) error

type JSONToken

type JSONToken struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	TokenType    string    `json:"token_type"`
	ExpiresAt    time.Time `json:"expires_at"`
}

type LeadEmbedded

type LeadEmbedded struct {
	Tags      []FieldValues `json:"tags,omitempty"`
	Companies []FieldValues `json:"companies,omitempty"`
	Contacts  []FieldValues `json:"contacts,omitempty"`
}

type LeadOne

type LeadOne struct {
	ID                 int             `json:"id,omitempty"`
	Name               string          `json:"name,omitempty"`
	Price              int             `json:"price,omitempty"`
	ResponsibleUserID  int             `json:"responsible_user_id,omitempty"`
	GroupID            int             `json:"group_id,omitempty"`
	StatusID           int             `json:"status_id,omitempty"`
	PipelineID         int             `json:"pipeline_id,omitempty"`
	LossReasonID       interface{}     `json:"loss_reason_id,omitempty"`
	CreatedBy          int             `json:"created_by,omitempty"`
	UpdatedBy          int             `json:"updated_by,omitempty"`
	CreatedAt          int             `json:"created_at,omitempty"`
	UpdatedAt          int             `json:"updated_at,omitempty"`
	ClosedAt           interface{}     `json:"closed_at,omitempty"`
	ClosestTaskAt      interface{}     `json:"closest_task_at,omitempty"`
	IsDeleted          bool            `json:"is_deleted,omitempty"`
	CustomFieldsValues []CustomsFields `json:"custom_fields_values,omitempty"`
	Score              interface{}     `json:"score,omitempty"`
	AccountID          int             `json:"account_id,omitempty"`
	LaborCost          interface{}     `json:"labor_cost,omitempty"`
	Embedded           *LeadEmbedded   `json:"_embedded,omitempty"`
}

type Leads

type Leads interface {
	GetLead(leadID string) (*LeadOne, error, int)
	GetListCustomFieldsLeads(fieldID string) (*CustomsField, error, int)
	GetLeads(values url.Values) (*LeadsArr, error, int)
	Create(leads []LeadOne) ([]LeadOne, error, int)
	Update(leads []LeadOne) ([]LeadOne, error, int)
	AddNotes(notes []Notes) ([]Notes, error, int)
}

Leads describes methods available for Leads entity.

type LeadsArr

type LeadsArr struct {
	Page  int `json:"_page,omitempty"`
	Links struct {
		Self struct {
			Href string `json:"href,omitempty"`
		} `json:"self,omitempty"`
	} `json:"_links,omitempty"`
	Embedded struct {
		Leads []struct {
			ID                 int             `json:"id,omitempty"`
			Name               string          `json:"name,omitempty"`
			Price              int             `json:"price,omitempty"`
			ResponsibleUserID  int             `json:"responsible_user_id,omitempty"`
			GroupID            int             `json:"group_id,omitempty"`
			StatusID           int             `json:"status_id,omitempty"`
			PipelineID         int             `json:"pipeline_id,omitempty"`
			LossReasonID       interface{}     `json:"loss_reason_id,omitempty"`
			CreatedBy          int             `json:"created_by,omitempty"`
			UpdatedBy          int             `json:"updated_by,omitempty"`
			CreatedAt          int             `json:"created_at,omitempty"`
			UpdatedAt          int             `json:"updated_at,omitempty"`
			ClosedAt           int             `json:"closed_at,omitempty"`
			ClosestTaskAt      interface{}     `json:"closest_task_at,omitempty"`
			IsDeleted          bool            `json:"is_deleted,omitempty"`
			CustomFieldsValues []CustomsFields `json:"custom_fields_values,omitempty"`
			Score              interface{}     `json:"score,omitempty"`
			AccountID          int             `json:"account_id,omitempty"`
			LaborCost          interface{}     `json:"labor_cost,omitempty"`
			Embedded           *LeadEmbedded   `json:"_embedded,omitempty"`
		} `json:"leads,omitempty"`
	} `json:"_embedded,omitempty"`
}

type Notes

type Notes struct {
	ID                int         `json:"id,omitempty"`
	EntityID          int         `json:"entity_id,omitempty"`
	CreatedBy         int         `json:"created_by,omitempty"`
	UpdatedBy         int         `json:"updated_by,omitempty"`
	CreatedAt         int         `json:"created_at,omitempty"`
	UpdatedAt         int         `json:"updated_at,omitempty"`
	ResponsibleUserID int         `json:"responsible_user_id,omitempty"`
	GroupID           int         `json:"group_id,omitempty"`
	NoteType          string      `json:"note_type,omitempty"`
	Params            NotesParams `json:"params,omitempty"`
}

type NotesParams

type NotesParams struct {
	Text            string `json:"text,omitempty"`
	Link            string `json:"link,omitempty"`
	Uniq            string `json:"uniq,omitempty"`
	Duration        int    `json:"duration,omitempty"`
	Source          string `json:"source,omitempty"`
	CallResponsible int    `json:"call_responsible,omitempty"`
	Service         string `json:"service,omitempty"`
	Status          string `json:"status,omitempty"`
	Address         string `json:"address,omitempty"`
	Longitude       string `json:"longitude,omitempty"`
	Latitude        string `json:"latitude,omitempty"`
	Phone           string `json:"phone,omitempty"`
	VersionUUID     string `json:"version_uuid,omitempty"`
	FileUUID        string `json:"file_uuid,omitempty"`
	FileName        string `json:"file_name,omitempty"`
}

type PipelineOne

type PipelineOne struct {
	ID           int                `json:"id,omitempty"`
	Name         string             `json:"name,omitempty"`
	Sort         int                `json:"sort,omitempty"`
	IsMain       bool               `json:"is_main,omitempty"`
	IsUnsortedOn bool               `json:"is_unsorted_on,omitempty"`
	IsArchive    bool               `json:"is_archive,omitempty"`
	AccountID    int                `json:"account_id,omitempty"`
	Embedded     *PipelinesEmbedded `json:"_embedded,omitempty"`
}

type PipelineStatuses

type PipelineStatuses struct {
	TotalItems int `json:"_total_items,omitempty"`
	Embedded   struct {
		Statuses []struct {
			ID         int    `json:"id,omitempty"`
			Name       string `json:"name,omitempty"`
			Sort       int    `json:"sort,omitempty"`
			IsEditable bool   `json:"is_editable,omitempty"`
			PipelineID int    `json:"pipeline_id,omitempty"`
			Color      string `json:"color,omitempty"`
			Type       int    `json:"type,omitempty"`
			AccountID  int    `json:"account_id,omitempty"`
		} `json:"statuses,omitempty"`
	} `json:"_embedded,omitempty"`
}

type Pipelines

type Pipelines interface {
	GetPipeline(pipelineID string) (*PipelineOne, error, int)
	GetPipelineStatuses(pipelineID string) (*PipelineStatuses, error, int)
	GetPipelines(values url.Values) (*PipelinesArr, error, int)
}

Pipelines describes methods available for Pipelines entity.

type PipelinesArr

type PipelinesArr struct {
	TotalItems int `json:"_total_items,omitempty"`
	Embedded   struct {
		Pipelines []struct {
			ID           int                `json:"id,omitempty"`
			Name         string             `json:"name,omitempty"`
			Sort         int                `json:"sort,omitempty"`
			IsMain       bool               `json:"is_main,omitempty"`
			IsUnsortedOn bool               `json:"is_unsorted_on,omitempty"`
			IsArchive    bool               `json:"is_archive,omitempty"`
			AccountID    int                `json:"account_id,omitempty"`
			Embedded     *PipelinesEmbedded `json:"_embedded,omitempty"`
		} `json:"pipelines,omitempty"`
	} `json:"_embedded,omitempty"`
}

type PipelinesEmbedded

type PipelinesEmbedded struct {
	Statuses []struct {
		ID         int    `json:"id,omitempty"`
		Name       string `json:"name,omitempty"`
		Sort       int    `json:"sort,omitempty"`
		IsEditable bool   `json:"is_editable,omitempty"`
		PipelineID int    `json:"pipeline_id,omitempty"`
		Color      string `json:"color,omitempty"`
		Type       int    `json:"type,omitempty"`
		AccountID  int    `json:"account_id,omitempty"`
	} `json:"statuses,omitempty"`
}

type Token

type Token interface {
	AccessToken() string
	RefreshToken() string
	ExpiresAt() time.Time
	TokenType() string
	Expired() bool
}

GetToken stores a set of GetToken, RefreshToken and meta data.

func NewToken

func NewToken(accessToken, refreshToken, tokenType string, expiresAt time.Time) Token

NewToken allocates and returns a new TokenSource.

type TokenStorage

type TokenStorage interface {
	SetToken(Token) error
	GetToken() (Token, error)
}

Jump to

Keyboard shortcuts

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