b24

package module
v0.0.0-...-26bf638 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

README

go-bitrix24

BX24 API Library

go-bitrix24 is a Rest API for Bitrix24. You can manage your application with this library. It contains almost every API request B24 provides with support of CRUD operations.

Quick Start / Installation

To get started with go-bitrix24, you'll need to do the following:

  • Install the latest version of Go.
  • Install the go-bitrix24 package using go get.
  • Use the go-bitrix24 package in your Go code.
  • Here's an example of how to install the package:
go get github.com/whatcrm/go-bitrix24

Models

go-bitrix24 includes a package for working with models, which allows you to use just the API and create your own models. This means you can create your own structs and use them with our go-bitrix24 package, even if you don't want to use every field from amoCRM's entities.

Here's the link to Models package and example of how to install the package.

go get github.com/whatcrm/go-bitrix24/models

Features

  • Lightweight and easy-to-use
  • Supersonic performance thanks to the Fiber web framework
  • Comprehensive CRUD for working with Bitrix24

Ecosystem / Documentations

Contributors

go-bitrix24 is maintained by WhatCRM Organization. If you'd like to contribute to the project, please reach out to us via Issues.

Documentation

Index

Constants

View Source
const (
	Auth = "auth"

	UserAdmin = "user.admin.json"

	PlacementBind   = "placement.bind"
	PlacementUnBind = "placement.unbind"

	CrmContactGet    = "crm.contact.get"
	CrmContactList   = "crm.contact.list"
	CrmContactAdd    = "crm.contact.add"
	CrmContactUpdate = "crm.contact.update"

	CrmLeadGet    = "crm.lead.get"
	CrmLeadAdd    = "crm.lead.add"
	CrmLeadList   = "crm.lead.list"
	CrmLeadUpdate = "crm.lead.update"

	CrmDealAdd    = "crm.deal.add"
	CrmDealGet    = "crm.deal.get"
	CrmDealList   = "crm.deal.list"
	CrmDealUpdate = "crm.deal.update"

	CrmCompanyGet    = "crm.company.get"
	CrmCompanyAdd    = "crm.company.add"
	CrmCompanyList   = "crm.company.list"
	CrmCompanyUpdate = "crm.company.update"

	EventBind   = "event.bind.json"
	EventUnBind = "event.unbind.json"

	UserFieldTypeAdd       = "userfieldtype.add"
	UserFieldTypeDelete    = "userfieldtype.delete"
	CrmContactUserFieldAdd = "crm.contact.userfield.add"
	CrmLeadUserFieldAdd    = "crm.lead.userfield.add"
	CrmDealUserFieldAdd    = "crm.deal.userfield.add"
	CrmCompanyUserFieldAdd = "crm.company.userfield.add"

	CrmContactUserFieldList = "crm.contact.userfield.list"
	CrmLeadUserFieldList    = "crm.lead.userfield.list"
	CrmDealUserFieldList    = "crm.deal.userfield.list"
	CrmCompanyUserFieldList = "crm.company.userfield.list"

	CrmContactUserFieldDelete = "crm.contact.userfield.delete"
	CrmLeadUserFieldDelete    = "crm.lead.userfield.delete"
	CrmDealUserFieldDelete    = "crm.deal.userfield.delete"
	CrmCompanyUserFieldDelete = "crm.company.userfield.delete"

	UserFieldConfigList   = "userfieldconfig.list"
	UserFieldConfigDelete = "userfieldconfig.delete"

	BizprocRobotAdd  = "bizproc.robot.add"
	BizprocRobotDel  = "bizproc.robot.delete"
	BizProcEventSend = "bizproc.event.send"

	CrmDuplicatesFindByComm = "crm.duplicate.findbycomm"

	CrmItemGet = "crm.item.get"
)
View Source
const (
	OnAppUninstall = "ONAPPUNINSTALL"

	CallCard = "CALL_CARD"

	CrmContact               = "CRM_CONTACT"
	CrmContactListMenu       = "CRM_CONTACT_LIST_MENU"
	CrmContactDetailTab      = "CRM_CONTACT_DETAIL_TAB"
	CrmContactDetailActivity = "CRM_CONTACT_DETAIL_ACTIVITY"

	CrmLead               = "CRM_LEAD"
	CrmLeadListMenu       = "CRM_LEAD_LIST_MENU"
	CrmLeadDetailTab      = "CRM_LEAD_DETAIL_TAB"
	CrmLeadDetailActivity = "CRM_LEAD_DETAIL_ACTIVITY"

	CrmDeal               = "CRM_DEAL"
	CrmDealListMenu       = "CRM_DEAL_LIST_MENU"
	CrmDealDetailTab      = "CRM_DEAL_DETAIL_TAB"
	CrmDealDetailActivity = "CRM_DEAL_DETAIL_ACTIVITY"

	CrmCompany               = "CRM_COMPANY"
	CrmCompanyListMenu       = "CRM_COMPANY_LIST_MENU"
	CrmCompanyDetailTab      = "CRM_COMPANY_DETAIL_TAB"
	CrmCompanyDetailActivity = "CRM_COMPANY_DETAIL_ACTIVITY"
)
View Source
const AccessDenied = "Access denied"
View Source
const UnableToGetApplicationByToken = "Unable to get application by token"

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	ClientID     string
	ClientSecret string
	Domain       string
	Auth         string
	Debug        bool
	// FallbackAuth is a function designed to handle cases of Access Denied errors.
	FallbackRefreshToken string
}

func NewAPI

func NewAPI(clientID, clientSecret string) *API

func (*API) CallBind

func (b24 *API) CallBind(event, handler string) (MainResult, error)

func (*API) CallUnBind

func (b24 *API) CallUnBind(event, handler string) (UnBind, error)

func (*API) Create

func (b24 *API) Create() *Create

func (*API) Delete

func (b24 *API) Delete() *Delete

func (*API) Get

func (b24 *API) Get() *Get

func (*API) IsAdmin

func (b24 *API) IsAdmin() (MainResult, error)

func (*API) PlacementBind

func (b24 *API) PlacementBind(title, handler, placement string) (MainResult, error)

func (*API) PlacementUnBind

func (b24 *API) PlacementUnBind(handler, placement string) (UnBind, error)

func (*API) RobotsEventSend

func (b24 *API) RobotsEventSend(in *RequestParams) (*MainResult, error)

func (*API) SetFallback

func (b24 *API) SetFallback(fallbackRefresh string)

func (*API) SetOptions

func (b24 *API) SetOptions(domain, auth string, debug bool) error

func (*API) Update

func (b24 *API) Update() *Update

type Bool

type Bool struct {
	Name    string `json:"name"`
	Type    string `json:"type"`
	Default string `json:"default,omitempty"`
}

type Create

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

func (*Create) Companies

func (c *Create) Companies(in *models.UpdateFields) (resp UFResult, err error)

func (*Create) Contacts

func (c *Create) Contacts(in *models.UpdateFields) (UFResult, error)

func (*Create) Deals

func (c *Create) Deals(in *models.UpdateFields) (UFResult, error)

func (*Create) Leads

func (c *Create) Leads(in *models.UpdateFields) (UFResult, error)

func (*Create) Robots

func (c *Create) Robots(in any) (*MainResult, error)

func (*Create) TokenUPD

func (c *Create) TokenUPD(refreshToken string) (UpdatedTokens, error)

func (*Create) UserField

func (c *Create) UserField(in *models.UserField, baseURL string) (UFResult, error)

func (*Create) UserFieldType

func (c *Create) UserFieldType(in *models.UserField) (MainResult, error)

type Delete

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

func (*Delete) Robots

func (c *Delete) Robots(code string) (*MainResult, error)

func (*Delete) UserField

func (c *Delete) UserField(id string, baseURL string) (MainResult, error)

func (*Delete) UserFieldConfig

func (c *Delete) UserFieldConfig(in *RequestParams) (MainResult, error)

func (*Delete) UserFieldType

func (c *Delete) UserFieldType(in *models.UserField) (MainResult, error)

type DuplicatesNotFound

type DuplicatesNotFound struct {
	Result any         `json:"result"`
	Time   models.Time `json:"time"`
}

type DuplicatesParams

type DuplicatesParams struct {
	Type       string   `json:"type"`
	Values     []string `json:"values"`      // phones or emails < 20
	EntityType string   `json:"entity_type"` // LEAD, CONTACT, COMPANY - if empty - all
}

type DuplicatesResponse

type DuplicatesResponse struct {
	CONTACT []int `json:"CONTACT,omitempty"`
	LEAD    []int `json:"LEAD,omitempty"`
	COMPANY []int `json:"COMPANY,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

type Get

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

func (*Get) Companies

func (c *Get) Companies(id string) (out []models.CompanyResult, err error)

func (*Get) Contacts

func (c *Get) Contacts(contactID string) (out []models.ContactResult, err error)

func (*Get) Deals

func (c *Get) Deals(id string) (out []models.DealResult, err error)

func (*Get) FindDuplicates

func (c *Get) FindDuplicates(in *DuplicatesParams) (out DuplicatesResponse, err error)

func (*Get) Invoices

func (c *Get) Invoices(id string) (models.InvoiceResult, error)

func (*Get) Leads

func (c *Get) Leads(id string) (lead []models.LeadResult, err error)

func (*Get) UserField

func (c *Get) UserField(baseURL string) (UserfieldList, error)

func (*Get) UserFieldConfig

func (c *Get) UserFieldConfig(in *RequestParams) (UserFieldConfig, error)

type MainResult

type MainResult struct {
	Result bool        `json:"result"`
	Time   models.Time `json:"time"`
}

type Options

type Options struct {
	Work  string `json:"work"`
	Home  string `json:"home"`
	Mob   string `json:"mob"`
	Other string `json:"other"`
}

type Properties

type Properties struct {
	Select *Select `json:"select,omitempty"`
	String *String `json:"string,omitempty"`
}

type RequestParams

type RequestParams struct {
	// Update Token
	RefreshToken string `json:"refresh_token,omitempty"`

	// Entity ID
	ID           string `json:"ID,omitempty"`
	Id           string `json:"id,omitempty"`
	EntityTypeID string `json:"entityTypeId"`

	// Regular Params
	Title       string `json:"TITLE,omitempty"`
	Description string `json:"DESCRIPTION,omitempty"`
	Placement   string `json:"PLACEMENT,omitempty"`
	Handler     string `json:"HANDLER,omitempty"`

	// Event
	Event         string `json:"EVENT,omitempty"`
	AuthType      int    `json:"auth_type,omitempty"`
	EventType     string `json:"event_type,omitempty"` // offline online
	AuthConnector string `json:"auth_connector,omitempty"`

	// Robot params + handler
	Code             string      `json:"CODE,omitempty"`
	AuthUserID       int         `json:"AUTH_USER_ID,omitempty"`
	Name             string      `json:"NAME,omitempty"`
	Properties       *Properties `json:"PROPERTIES,omitempty"`
	EventToken       string      `json:"EVENT_TOKEN,omitempty"`
	UseSubscription  string      `json:"USE_SUBSCRIPTION,omitempty"`
	ReturnProperties *Properties `json:"RETURN_PROPERTIES,omitempty"`
	ReturnValues     any         `json:"RETURN_VALUES,omitempty"`

	ModuleID string `json:"moduleId"`
}

type Select

type Select struct {
	Default string `json:"Default,omitempty"`
	Name    string `json:"Name"`
	Type    string `json:"Type"`
	Options any    `json:"Options,omitempty"`
}

type String

type String struct {
	Name        string `json:"Name"`
	Type        string `json:"Type"`
	Default     string `json:"Default,omitempty"`
	Description string `json:"Description,omitempty"`
	Required    string `json:"Required,omitempty"`
	Multiple    string `json:"Multiple,omitempty"`
}

type UFConfigResult

type UFConfigResult struct {
	Fields []UFR `json:"fields"`
}

type UFR

type UFR struct {
	ID        string `json:"ID"`
	FieldName string `json:"FIELD_NAME"`
	Entity    string `json:"ENTITY_ID"`
}

type UFResult

type UFResult struct {
	Result int         `json:"result"`
	Time   models.Time `json:"time"`
}

type UnBind

type UnBind struct {
	Result struct {
		Count int `json:"count"`
	} `json:"result"`
	Time models.Time `json:"time,omitempty"`
}

type Update

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

func (*Update) Companies

func (c *Update) Companies(id string, in *models.UpdateFields) (MainResult, error)

func (*Update) Contacts

func (c *Update) Contacts(id string, in *models.UpdateFields) (MainResult, error)

func (*Update) Deals

func (c *Update) Deals(id string, in *models.UpdateFields) (MainResult, error)

func (*Update) Leads

func (c *Update) Leads(id string, in *models.UpdateFields) (MainResult, error)

type UpdatedTokens

type UpdatedTokens struct {
	AccessToken    string `json:"access_token"`
	ClientEndpoint string `json:"client_endpoint"`
	Domain         string `json:"domain"`
	ExpiresIn      int    `json:"expires_in"`
	MemberID       string `json:"member_id"`
	RefreshToken   string `json:"refresh_token"`
	Scope          string `json:"scope"`
	ServerEndpoint string `json:"server_endpoint"`
	Status         string `json:"status"`
}

type UserFieldConfig

type UserFieldConfig struct {
	Result UFConfigResult `json:"result"`
	Total  int            `json:"total"`
	Time   models.Time    `json:"time"`
}

type UserfieldList

type UserfieldList struct {
	Result []UFR       `json:"result"`
	Total  int         `json:"total"`
	Time   models.Time `json:"time"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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