Documentation ¶
Index ¶
- type Client
- type Error
- type Message
- func (m *Message) SetButtonAction(buttonAction string) *Message
- func (m *Message) SetButtonCaption(buttonCaption string) *Message
- func (m *Message) SetCallbackUrl(callbackUrl string) *Message
- func (m *Message) SetImageUrl(imageUrl string) *Message
- func (m *Message) SetMessageType(messageType MessageType) *Message
- func (m *Message) SetReceiver(receiver string) *Message
- func (m *Message) SetSender(sender string) *Message
- func (m *Message) SetSourceType(sourceType MessageSourceType) *Message
- func (m *Message) SetText(text string) *Message
- func (m *Message) SetValidityPeriod(validityPeriod int) *Message
- type MessageReceipt
- type MessageSourceType
- type MessageStatus
- type MessageType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to work with Viber messages.
func (*Client) GetMessageStatus ¶
func (client *Client) GetMessageStatus(messageId int64) (*MessageReceipt, error)
GetMessageStatus returns Viber message status.
type Error ¶
type Error struct { Name string `json:"name"` // Error name Message string `json:"message"` // Error message Code int `json:"code"` // Error code Status int `json:"status"` // Error status }
Error represents error which may occur while working with Viber messages.
type Message ¶
type Message struct { Sender string `json:"source_addr"` // Sender is a message sender (from whom message is sent). Receiver string `json:"destination_addr"` // Receiver is a message receiver (to whom message is sent). MessageType MessageType `json:"message_type"` // Message type is a message type. Text string `json:"text"` // Text is a message in the UTF8 format. ImageUrl string `json:"image"` // ImageUrl is URL of an image for promotional message with button caption and button action. ButtonCaption string `json:"button_caption"` // ButtonCaption is a button caption in the UTF8 format. ButtonAction string `json:"button_action"` // ButtonAction is an URL for transition when the button is pressed. SourceType MessageSourceType `json:"source_type"` // SourceType is a message sending procedure. CallbackUrl string `json:"callback_url"` // CallbackUrl is an URL for message status callback. ValidityPeriod int `json:"validity_period"` // ValidityPeriod is a life time of a message (in seconds). }
Message represents a Viber message.
func (*Message) SetButtonAction ¶
SetButtonAction sets button action (an URL for transition when the button is pressed).
func (*Message) SetButtonCaption ¶
SetButtonCaption sets button caption.
func (*Message) SetCallbackUrl ¶
SetCallbackUrl sets callback URL (an URL for message status callback).
func (*Message) SetImageUrl ¶
SetImageUrl sets image url for promotional message with button caption and button action.
func (*Message) SetMessageType ¶
func (m *Message) SetMessageType(messageType MessageType) *Message
SetMessageType sets message type.
func (*Message) SetReceiver ¶
SetReceiver sets message receiver.
func (*Message) SetSourceType ¶
func (m *Message) SetSourceType(sourceType MessageSourceType) *Message
SetSourceType sets message source type (sending procedure).
func (*Message) SetValidityPeriod ¶
SetValidityPeriod sets message validity period (life time of a message, in seconds).
type MessageReceipt ¶
type MessageReceipt struct { MessageId int64 `json:"message_id"` // Id of the Viber message which status should be got (sent in the last 5 days). Status MessageStatus `json:"status"` // Viber message status }
MessageReceipt represents Id and status of the particular Viber message.
type MessageSourceType ¶
type MessageSourceType uint16
MessageSourceType represents message sending procedure.
const ( Promotional MessageSourceType = iota + 1 Transactional )
type MessageStatus ¶
type MessageStatus uint16
MessageStatus represents Viber message status.
const ( Sent MessageStatus = iota Delivered ErrorStatus Rejected Undelivered Pending Unknown = iota + 20 )
func (MessageStatus) String ¶
func (s MessageStatus) String() string
String returns the message status description.
type MessageType ¶
type MessageType uint16
MessageType represents a Viber message type.
const ( TextOnly MessageType = 106 TextImageButton MessageType = 108 TextOnly2Way MessageType = 206 TextImageButton2Way MessageType = 208 )