Documentation ¶
Index ¶
- Constants
- Variables
- type Ani
- type CallHistories
- type CallHistory
- type CallHistoryRequest
- type Callback
- type CallbackRequest
- type Cdr
- type Client
- func (c *Client) CreateCallback(extensionID uint32, callback CallbackRequest) (*Callback, error)
- func (c *Client) CreateEvent(extensionId uint32, event CreateEventRequest) (*Event, error)
- func (c *Client) CreateExtension(clientID string, extensionCreateRequest ExtensionCreateRequest) (*Extension, error)
- func (c *Client) DeleteEvent(extensionId uint32, eventId int) error
- func (c *Client) DeleteExtension(clientID string, extensionID uint32) error
- func (c *Client) DeleteRecord(clientID string, recordUUID string) error
- func (c *Client) GetAccessToken() (*TokenResponse, error)
- func (c *Client) GetAllDID(clientID string) (*[]Did, error)
- func (c *Client) GetCallHistories(clientID string, callHistoryRequest CallHistoryRequest) (*CallHistories, error)
- func (c *Client) GetCallHistory(clientID string, callId string) (*CallHistory, error)
- func (c *Client) GetEvents(extensionId uint32) (*[]Event, error)
- func (c *Client) GetExtension(clientID string, extensionID uint16) (*Extension, error)
- func (c *Client) GetExtensionAni(extensionID uint16) (*Ani, error)
- func (c *Client) GetExtensions(clientID string, typeExtensions *string, page *int) (*[]Extension, error)
- func (c *Client) GetQualityRate(clientID string, request QualityRateRequest) (*[]QualityRate, error)
- func (c *Client) GetRecord(clientID string, recordUUID string) (*mem.File, error)
- func (c *Client) GetRecordStorageUrl(clientID string, recordUUID string) (*RecordStorageUrl, error)
- func (c *Client) GetRecords(clientID string, recordsRequest RecordsRequest) (*[]RecordInfo, error)
- func (c *Client) GetSounds(clientID string, request SoundsRequest) (*[]Sound, error)
- func (c *Client) GetWsSipUri(user string) string
- func (c *Client) NewRequest(method, url string, payload interface{}) (*http.Request, error)
- func (c *Client) ResetAccessToken() error
- func (c *Client) Send(req *http.Request, v interface{}) error
- func (c *Client) SendWithAuth(req *http.Request, v interface{}) error
- func (c *Client) SetAccessToken(token string, expiresIn expirationTime)
- func (c *Client) SetExtensionAni(extensionID uint32, aniNumber string) (*Ani, error)
- func (c *Client) SetHTTPClient(client *http.Client)
- func (c *Client) SetLogger(logger FieldLogger)
- func (c *Client) UpdatePhone(extensionID uint32, phoneProps PhoneProperties) error
- func (c *Client) WsHost() string
- func (c *Client) WsServers() []string
- type CreateEventRequest
- type Did
- type ErrorResponse
- type Event
- type Extension
- type ExtensionCreateRequest
- type FieldLogger
- type JSONTime
- type Logger
- type LogrusLogger
- type PhoneProperties
- type QualityRate
- type QualityRateRequest
- type RecordInfo
- type RecordStorageUrl
- type RecordsRequest
- type Sound
- type SoundsRequest
- type TokenResponse
Constants ¶
const ( // Host points to the API Host = "https://altapi.telphin.ru" // Host points to the storage HostStorage = "https://storage.telphin.ru" // Websocket host WsHost = "sipproxy.telphin.ru" // RequestNewTokenBeforeExpiresIn is used by SendWithAuth and try to get new Token when it's about to expire RequestNewTokenBeforeExpiresIn = time.Duration(60) * time.Second )
const ( HangupDispositionCalleeBye = "callee_bye" // трубку положила принимающая сторона HangupDispositionCallerBye = "caller_bye" // трубку положила вызывающая сторона HangupDispositionCallerCancel = "caller_cancel" // вызывающая сторона отказалась ждать ответа HangupDispositionCalleeRefuse = "callee_refuse" // принимающая сторона отказалась отвечать (была занята, отсутствовала регистрация и т.п.) HangupDispositionInternalCancel = "internal_cancel" // вызов завершен сервером (обычно таймаут вызова или при пачке вызовов кто-то снял трубку) )
const ( CallResultBusy = "busy" CallResultAnswered = "answered" CallResultNotAnswered = "not answered" CallResultFailed = "failed" CallResultRejected = "rejected" CallResultBridged = "bridged" CallCdrResultBusy = "busy" CallCdrResultAnswered = "answered" CallCdrResultNotAnswered = "not answered" CallCdrResultAnsweredElsewhere = "answered elsewhere" CallCdrResultFailed = "failed" CallCdrResultRejected = "rejected" CallCdrResultVoicemail = "voicemail" )
const ( EventStatusCalling = "CALLING" // поступил вызов EventStatusAnswer = "ANSWER" // вызов был отвечен EventStatusBusy = "BUSY" // вызов получил сигнал "занято" EventStatusNoAnswer = "NOANSWER" // звонок не отвечен (истек таймер ожидания на сервере) EventStatusCancel = "CANCEL" // звонящий отменил вызов до истечения таймера ожидания на сервере EventStatusCongestion = "CONGESTION" // произошла ошибка во время вызова )
const ( EventTypeDialIn = "dial-in" EventTypeDialOut = "dial-out" EventTypeAnswer = "answer" EventTypeHangup = "hangup" )
const ( FlowIn = "in" FlowOut = "out" FlowTransfer = "transfer" )
const ( ExtensionTypePhone = "phone" ExtensionTypeIVR = "ivr" ExtensionTypeQueue = "queue" )
const ( OrderDesc = "desc" OrderAsc = "asc" )
Variables ¶
var TelphinStorageHostRegexp = regexp.MustCompile(`^` + HostStorage)
Functions ¶
This section is empty.
Types ¶
type Ani ¶
type Ani struct {
Default string `json:"default"` // Установленный ani, если не установлен - None
}
See: https://ringme-confluence.atlassian.net/wiki/spaces/RAL/pages/832602113/ani
type CallHistories ¶
type CallHistories struct { Page uint32 `json:"page"` PerPage uint32 `json:"per_page"` Order string `json:"order"` CallHistory []CallHistory `json:"call_history"` }
type CallHistory ¶
type CallHistory struct { UUID string `json:"call_uuid"` Flow string `json:"flow"` InitTime *JSONTime `json:"init_time_gmt"` StartTime *JSONTime `json:"start_time_gmt"` BridgedTime *JSONTime `json:"bridged_time_gmt"` HangupTime *JSONTime `json:"hangup_time_gmt"` Duration uint32 `json:"duration"` Bridged bool `json:"bridged"` BridgedDuration uint32 `json:"bridged_duration"` ExtensionID uint32 `json:"extension_id"` From string `json:"from_username"` To string `json:"to_username"` Result string `json:"result"` HangupCause string `json:"hangup_cause"` HangupDisposition *string `json:"hangup_disposition,omitempty"` Cdr *[]Cdr `json:"cdr"` }
func (*CallHistory) HasAnsweredExtensionPhoneTypeCdr ¶
func (c *CallHistory) HasAnsweredExtensionPhoneTypeCdr() bool
func (*CallHistory) HasExtensionPhoneTypeCdr ¶
func (c *CallHistory) HasExtensionPhoneTypeCdr() bool
func (*CallHistory) HasExtensionPhoneTypeWithRecords ¶
func (c *CallHistory) HasExtensionPhoneTypeWithRecords() bool
func (*CallHistory) HasTransferredCdr ¶
func (c *CallHistory) HasTransferredCdr() bool
type CallHistoryRequest ¶
type CallbackRequest ¶
type CallbackRequest struct { SrcNum []string `json:"src_num"` DstNum string `json:"dst_num"` AllowPublicTransfer bool `json:"allow_public_transfer"` CallDuration *int `json:"call_duration"` AnnounceSoundID *int `json:"announce_sound_id"` DstAnnounceSoundID *int `json:"dst_announce_sound_id"` CallerIDName *string `json:"caller_id_name"` CallerIDNumber *string `json:"caller_id_number"` DstAni *string `json:"dst_ani"` DstDtmf *string `json:"dst_dtmf"` SrcCallerIDName *string `json:"src_caller_id_name"` SrcCallerIDNumber *string `json:"src_caller_id_number"` TransferAfterDstHangup *string `json:"transfer_after_dst_hangup"` TransferAfterSrcHangup *string `json:"transfer_after_src_hangup"` WaitForPickup *int `json:"wait_for_pickup"` }
type Cdr ¶
type Cdr struct { ExtensionType string `json:"extension_type"` RecordUUID *string `json:"record_uuid"` Result string `json:"result"` HangupCause string `json:"hangup_cause"` HangupDisposition *string `json:"hangup_disposition,omitempty"` Duration int `json:"duration"` InitTime *JSONTime `json:"init_time_gmt"` StartTime *JSONTime `json:"start_time_gmt"` HangupTime *JSONTime `json:"hangup_time_gmt"` Flow string `json:"flow"` ExtensionID uint32 `json:"extension_id"` From string `json:"from_username"` To string `json:"to_username"` }
type Client ¶
type Client struct { sync.Mutex Client *http.Client ClientID string Secret string Host string Token *TokenResponse Logger FieldLogger // contains filtered or unexported fields }
func (*Client) CreateCallback ¶
func (c *Client) CreateCallback(extensionID uint32, callback CallbackRequest) (*Callback, error)
Endpoint: POST /api/ver1.0/extension/{extension_id}/callback/
func (*Client) CreateEvent ¶
func (c *Client) CreateEvent(extensionId uint32, event CreateEventRequest) (*Event, error)
Endpoint: POST /extension/{extension_id}/event/
func (*Client) CreateExtension ¶
func (c *Client) CreateExtension(clientID string, extensionCreateRequest ExtensionCreateRequest) (*Extension, error)
Endpoint: POST /client/{client_id}/extension
func (*Client) DeleteEvent ¶
Endpoint: GET /extension/{extension_id}/event/{id}
func (*Client) DeleteExtension ¶
Endpoint: DELETE /client/{client_id}/extension/{extension_id}
func (*Client) DeleteRecord ¶ added in v0.1.4
Endpoint: DELETE /client/{client_id}/record/{record_uuid}
func (*Client) GetAccessToken ¶
func (c *Client) GetAccessToken() (*TokenResponse, error)
GetAccessToken returns struct of TokenResponse No need to call SetAccessToken to apply new access token for current Client Endpoint: POST /oauth/token
func (*Client) GetCallHistories ¶
func (c *Client) GetCallHistories(clientID string, callHistoryRequest CallHistoryRequest) (*CallHistories, error)
Endpoint: GET /client/{client_id}/call_history/
func (*Client) GetCallHistory ¶
func (c *Client) GetCallHistory(clientID string, callId string) (*CallHistory, error)
Endpoint: GET /client/{client_id}/call_history/{callId}
func (*Client) GetExtension ¶
Endpoint: GET /client/{client_id}/extension/{extension_id}
func (*Client) GetExtensionAni ¶
Endpoint: GET /extension/{extension_id}/ani/
func (*Client) GetExtensions ¶
func (c *Client) GetExtensions(clientID string, typeExtensions *string, page *int) (*[]Extension, error)
Endpoint: GET /client/{client_id}/extension/
func (*Client) GetQualityRate ¶ added in v0.0.4
func (c *Client) GetQualityRate(clientID string, request QualityRateRequest) (*[]QualityRate, error)
GET /api/ver1.0/client/{client_id}/quality_rate/
func (*Client) GetRecordStorageUrl ¶
func (c *Client) GetRecordStorageUrl(clientID string, recordUUID string) (*RecordStorageUrl, error)
Endpoint: GET /client/{client_id}/record/{record_uuid}/storage_url/
func (*Client) GetRecords ¶ added in v0.1.4
func (c *Client) GetRecords(clientID string, recordsRequest RecordsRequest) (*[]RecordInfo, error)
Endpoint: GET /client/{client_id}/record/
func (*Client) GetSounds ¶ added in v0.1.6
func (c *Client) GetSounds(clientID string, request SoundsRequest) (*[]Sound, error)
Endpoint: GET /client/{client_id}/sound/
func (*Client) GetWsSipUri ¶
func (*Client) NewRequest ¶
NewRequest constructs a request Convert payload to a JSON
func (*Client) Send ¶
Send makes a request to the API, the response body will be unmarshaled into v, or if v is an io.Writer, the response will be written to it without decoding
func (*Client) SendWithAuth ¶
SendWithAuth makes a request to the API and apply OAuth2 header automatically.
func (*Client) SetAccessToken ¶
SetAccessToken sets saved token to current client
func (*Client) SetExtensionAni ¶
Endpoint: PUT /extension/{extension_id}/ani/
func (*Client) SetHTTPClient ¶
SetHTTPClient sets *http.Client to current client
func (*Client) UpdatePhone ¶
func (c *Client) UpdatePhone(extensionID uint32, phoneProps PhoneProperties) error
Endpoint: PUT /extension/{extension_id}/phone
type CreateEventRequest ¶
type Did ¶
type Did struct { ID uint32 `json:"id"` // Идентификатор внешнего номера Name string `json:"name"` // Имя внешнего номера, то есть сам номер Domain string `json:"domain"` // Домен внешнего номера ClientID uint32 `json:"client_id"` // Идентификатор клиента, которому назначен внешний номер ExtensionID uint32 `json:"extension_id"` // Идентификатор добавочного, которому назначен внешний номер }
See: https://ringme-confluence.atlassian.net/wiki/spaces/RAL/pages/20414492/did
type ErrorResponse ¶
ErrorResponse a typed error returned by http Handlers and used for choosing error handlers
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type Extension ¶
type Extension struct { ID uint32 `json:"id"` // Уникальный идентификатор добавочного Status string `json:"status"` // Статус добавочного: 'active' - активен, 'blocked' - заблокирован Name string `json:"name"` // префикс_клиента*имя_добавочного или просто имя_добавочного(в этом случчае префикс будет дописан автоматически) Type string `json:"type"` // Тип добавочного: 'phone', 'queue', 'ivr', 'fax' Label string `json:"label"` // Display Name добавочного. Отображается на вызываемом терминале при исходящих вызовах (если поддерживается) }
See: https://ringme-confluence.atlassian.net/wiki/spaces/RAL/pages/17367181/extension
type ExtensionCreateRequest ¶
type ExtensionCreateRequest struct { Status string `json:"status"` // Статус добавочного: 'active' - активен, 'blocked' - заблокирован Name string `json:"name"` // префикс_клиента*имя_добавочного или просто имя_добавочного(в этом случчае префикс будет дописан автоматически) Type string `json:"type"` // Тип добавочного: 'phone', 'queue', 'ivr', 'fax' Label string `json:"label,omitempty"` // Display Name добавочного. Отображается на вызываемом терминале при исходящих вызовах (если поддерживается) }
type FieldLogger ¶
type FieldLogger interface { Logger WithField(string, interface{}) FieldLogger WithFields(map[string]interface{}) FieldLogger }
FieldLogger interface
type JSONTime ¶
func (JSONTime) MarshalJSON ¶
func (*JSONTime) UnmarshalJSON ¶
imeplement Marshaler und Unmarshalere interface
type Logger ¶
type Logger interface { Info(args ...interface{}) Infof(format string, args ...interface{}) Error(args ...interface{}) }
Logger interface TODO: remove logrus
type LogrusLogger ¶
type LogrusLogger struct {
logrus.FieldLogger
}
func WrapLogrus ¶
func WrapLogrus(logger logrus.FieldLogger) *LogrusLogger
func (LogrusLogger) WithField ¶
func (l LogrusLogger) WithField(s string, i interface{}) FieldLogger
WithField returns a new Logger with the field added
func (LogrusLogger) WithFields ¶
func (l LogrusLogger) WithFields(m map[string]interface{}) FieldLogger
WithFields returns a new Logger with the fields added
type PhoneProperties ¶
type PhoneProperties struct { Password string `json:"password"` // Задает пароль для авторизации на sip-сервере AllowWebrtc bool `json:"allow_webrtc"` // Если установлено значение "true", то позволяет добавочному работать через WebRTC RecordEnabled bool `json:"record_enabled"` // Включить запись разговоров RecordTransfer bool `json:"record_transfer"` // Включить запись в том числе и переадресованных вызовов }
type QualityRate ¶ added in v0.0.4
type QualityRateRequest ¶ added in v0.0.4
type RecordInfo ¶ added in v0.1.4
type RecordStorageUrl ¶
type RecordStorageUrl struct {
RecordUrl string `json:"record_url"`
}
type RecordsRequest ¶ added in v0.1.4
type SoundsRequest ¶ added in v0.1.6
type TokenResponse ¶
type TokenResponse struct { // RefreshToken string `json:"refresh_token"` Token string `json:"access_token"` Type string `json:"token_type"` ExpiresIn expirationTime `json:"expires_in"` }
TokenResponse is for API response for the /oauth2/token endpoint