Documentation
¶
Overview ¶
Package ippanel is an official library for working with ippanel sms api. brief documentation for ippanel sms api provided at http://docs.ippanel.com
Index ¶
- Constants
- Variables
- func ParseErrors(res *BaseResponse) error
- type BaseResponse
- type Error
- type FieldErr
- type FieldErrs
- type InboxMessage
- type Ippanel
- func (sms *Ippanel) CreatePattern(pattern string, isShared bool) (*Pattern, error)
- func (sms *Ippanel) FetchInbox(pp ListParams) ([]InboxMessage, *PaginationInfo, error)
- func (sms *Ippanel) FetchStatuses(bulkID int64, pp ListParams) ([]MessageRecipient, *PaginationInfo, error)
- func (sms *Ippanel) GetCredit() (float64, error)
- func (sms *Ippanel) GetMessage(bulkID int64) (*Message, error)
- func (sms *Ippanel) Send(originator string, recipients []string, message string) (int64, error)
- func (sms *Ippanel) SendPattern(patternCode string, originator string, recipient string, ...) (int64, error)
- type ListParams
- type Message
- type MessageConfirmState
- type MessageRecipient
- type MessageStatus
- type MessageType
- type PaginationInfo
- type Pattern
- type PatternStatus
- type ResponseCode
Constants ¶
const ( // ClientVersion is used in User-Agent request header to provide server with API level. ClientVersion = "1.0.1" // Endpoint points you to Ippanel REST API. Endpoint = "http://rest.ippanel.com/v1" )
Variables ¶
var ( // ErrUnexpectedResponse is used when there was an internal server error and nothing can be done at this point. ErrUnexpectedResponse = errors.New("The Ippanel API is currently unavailable") )
Functions ¶
Types ¶
type BaseResponse ¶
type BaseResponse struct { Status string `json:"status"` Code ResponseCode `json:"code"` Data json.RawMessage `json:"data"` Meta *PaginationInfo `json:"meta"` }
BaseResponse base response model
type Error ¶
type Error struct { Code ResponseCode Message interface{} }
Error general service error
type InboxMessage ¶
type InboxMessage struct { Number string `json:"number"` Message string `json:"message"` Sender string `json:"sender"` CreatedAt time.Time `json:"time"` Type string `json:"type"` }
InboxMessage inbox message
type Ippanel ¶
Ippanel ...
func (*Ippanel) CreatePattern ¶
CreatePattern create new pattern
func (*Ippanel) FetchInbox ¶
func (sms *Ippanel) FetchInbox(pp ListParams) ([]InboxMessage, *PaginationInfo, error)
FetchInbox fetch inbox messages list
func (*Ippanel) FetchStatuses ¶
func (sms *Ippanel) FetchStatuses(bulkID int64, pp ListParams) ([]MessageRecipient, *PaginationInfo, error)
FetchStatuses get message recipients statuses
func (*Ippanel) GetMessage ¶
GetMessage get a message by bulk_id
type ListParams ¶
ListParams ...
type Message ¶
type Message struct { BulkID int64 `json:"bulk_id"` Number string `json:"number"` Message string `json:"message"` Status MessageStatus `json:"status"` Type MessageType `json:"type"` ConfirmState MessageConfirmState `json:"confirm_state"` CreatedAt time.Time `json:"created_at"` SentAt time.Time `json:"sent_at"` RecipientsCount int64 `json:"recipients_count"` ValidRecipientsCount int64 `json:"valid_recipients_count"` Page int64 `json:"page"` Cost float64 `json:"cost"` PaybackCost float64 `json:"payback_cost"` Description string `json:"description"` }
Message message model
type MessageConfirmState ¶
type MessageConfirmState string
MessageConfirmState message confirm state
const ( // MessageConfirmeStatePending pending MessageConfirmeStatePending MessageConfirmState = "pending" // MessageConfirmeStateConfirmed confirmed MessageConfirmeStateConfirmed MessageConfirmState = "confirmed" // MessageConfirmeStateRejected rejected MessageConfirmeStateRejected MessageConfirmState = "rejected" )
type MessageRecipient ¶
MessageRecipient message recipient status
type MessageStatus ¶
type MessageStatus string
MessageStatus message status
const ( // MessageStatusActive ... MessageStatusActive MessageStatus = "active" )
TODO: Add other message status codes
type MessageType ¶
type MessageType string
MessageType message type
const ( // MessageTypeNormal normal message MessageTypeNormal MessageType = "normal" )
TODO: Add other message types
type PaginationInfo ¶
type PaginationInfo struct { Total int64 `json:"total"` Limit int64 `json:"limit"` Page int64 `json:"page"` Pages int64 `json:"pages"` Prev *string `json:"prev"` Next *string `json:"next"` }
PaginationInfo ...
type Pattern ¶
type Pattern struct { Code string `json:"code"` Status PatternStatus `json:"status"` Message string `json:"message"` }
Pattern pattern
type PatternStatus ¶
type PatternStatus string
PatternStatus ...
const ( // PatternStatusActive active PatternStatusActive PatternStatus = "active" // PatternStatusInactive inactive PatternStatusInactive PatternStatus = "inactive" // PatternStatusPending pending PatternStatusPending PatternStatus = "pending" )
type ResponseCode ¶
type ResponseCode string
ResponseCode api response code error type
const ( // ErrCredential error when executing repository query ErrCredential ResponseCode = "10001" // ErrMessageBodyIsEmpty message body is empty ErrMessageBodyIsEmpty ResponseCode = "10002" // ErrUserLimitted user is limited ErrUserLimitted ResponseCode = "10003" // ErrNumberNotAssignedToYou line not assigned to you ErrNumberNotAssignedToYou ResponseCode = "10004" // ErrRecipientsEmpty recipients is empty ErrRecipientsEmpty ResponseCode = "10005" // ErrCreditNotEnough credit not enough ErrCreditNotEnough ResponseCode = "10006" // ErrNumberNotProfitForBulkSend line not profit for bulk send ErrNumberNotProfitForBulkSend ResponseCode = "10007" // ErrNumberDeactiveTemp line deactivated temporally ErrNumberDeactiveTemp ResponseCode = "10008" // ErrMaximumRecipientExceeded maximum recipients number exceeded ErrMaximumRecipientExceeded ResponseCode = "10009" // ErrGatewayOffline gateway is offline ErrGatewayOffline ResponseCode = "10010" // ErrNoPricing pricing not defined for user ErrNoPricing ResponseCode = "10011" // ErrTicketIsInvalid ticket is invalid ErrTicketIsInvalid ResponseCode = "10012" // ErrAccessDenied access denied ErrAccessDenied ResponseCode = "10013" // ErrPatternIsInvalid pattern is invalid ErrPatternIsInvalid ResponseCode = "10014" // ErrPatternParamettersInvalid pattern parameters is invalid ErrPatternParamettersInvalid ResponseCode = "10015" // ErrPatternIsInactive pattern is inactive ErrPatternIsInactive ResponseCode = "10016" // ErrPatternRecipientInvalid pattern recipient invalid ErrPatternRecipientInvalid ResponseCode = "10017" // ErrItsTimeToSleep send time is 8-23 ErrItsTimeToSleep ResponseCode = "10019" // ErrDocumentsNotApproved one/all of users documents not approved ErrDocumentsNotApproved ResponseCode = "10021" // ErrInternal internal error ErrInternal ResponseCode = "10022" // ErrNumberNotFound provided number not valid ErrNumberNotFound ResponseCode = "10023" // ErrGatewayDisabled gateway disabled ErrGatewayDisabled ResponseCode = "10024" // ErrUnprocessableEntity inputs have some problems ErrUnprocessableEntity ResponseCode = "422" ErrUnauthorized ResponseCode = "1401" // ErrKeyNotValid api key is not valid ErrKeyNotValid ResponseCode = "1402" // ErrKeyRevoked api key revoked ErrKeyRevoked ResponseCode = "1403" )