cention-sdk-go: github.com/cention-sany/cention-sdk-go/cention Index | Files | Directories

package cention

import "github.com/cention-sany/cention-sdk-go/cention"

cention provides the func to communicate with Cention Application through JSONAPI.

Index

Package Files

cs.go

Constants

const (
    ANSWER_ERRAND event = 1
)

Variables

var (
    DEBUG               bool
    ErrUnmatchEventType = errors.New("cention: event type not match")
    ErrSecretFail       = errors.New("cention: secret check failed")
    ErrNoMoreAttachment = errors.New("cention: no more attachment")
)

type Answer Uses

type Answer struct {
    Message
    UserType string `json:"user_type"`
    UserID   string `json:"user_id"`
}

type AnswerErrand Uses

type AnswerErrand struct {
    ID     int `mapstructure:"c3_id"`
    Answer struct {
        ID       int `mapstructure:"c3_id"`
        Response struct {
            ID       int    `mapstructure:"c3_id"`
            Body     string `mapstructure:"body"`
            HtmlBody string `mapstructure:"html_body"`
            Subject  string `mapstructure:"subject"`
            To       []struct {
                ID      int    `mapstructure:"c3_id"`
                Address string `mapstructure:"email_address"`
                Name    string `mapstructure:"name"`
            }   `mapstructure:"to"`
        }   `mapstructure:"response"`
    }   `mapstructure:"answer"`
    // contains filtered or unexported fields
}

func (*AnswerErrand) GetNextAttachment Uses

func (a *AnswerErrand) GetNextAttachment(ctx context.Context, ep,
    tk string) (*Attachment, error)

GetNextAttachment will retrieve attachment data from Cention server by providing its endpoint ep and JWT token tk. Only successfully call will advance attachment index.

func (*AnswerErrand) MoreAttachment Uses

func (a *AnswerErrand) MoreAttachment() (bool, error)

type Attachment Uses

type Attachment struct {
    Id         int    `json:"c3_id,omitempty" mapstructure:"c3_id"`
    Ct         string `json:"content_type" mapstructure:"content_type"`
    Name       string `json:"name" mapstructure:"name"`
    B64Content string `json:"content" mapstructure:"content"`
    CID        string `json:"content_id,omitempty" mapstructure:"content_id"`
}

func CreateAttachment Uses

func CreateAttachment(name, ct string, r io.Reader) (*Attachment, error)

CreateAttachment is a helper function to create Attachment object. User can directly mutate the Attachment field. name is attachment's filename. ct is attachment content type and r is the content of attachment.

func (*Attachment) Content Uses

func (a *Attachment) Content() (io.Reader, error)

type Attr Uses

type Attr struct {
    Msg *Message `json:"msg"`
    Ans *Answer  `json:"answer,omitempty"`
}

type CE Uses

type CE struct {
    Data struct {
        Type string `json:"type"`
        Attr `json:"attributes"`
    } `json:"data"`
}

type Callback Uses

type Callback struct {
    *jsonapi.OnePayload
    Meta *struct {
        Secret string `json:"api_secret"`
    }   `json:"meta"`
}

func Parse Uses

func Parse(r *http.Request) (*Callback, error)

func ParseWithSecret Uses

func ParseWithSecret(r *http.Request, s string) (*Callback, error)

func (*Callback) AnswerErrand Uses

func (c *Callback) AnswerErrand() (*AnswerErrand, error)

type CreatedResponse Uses

type CreatedResponse struct {
    Data struct {
        Type string `json:"type"`
        ID   string `json:"id"`
    } `json:"data"`
}

func CreateErrand Uses

func CreateErrand(ctx context.Context, ep, tk string,
    m *Message, ans *Answer) (*CreatedResponse, error)

type Message Uses

type Message struct {
    Message_id string        `json:"message_id"`
    Name       string        `json:"name"`
    From       string        `json:"from"`
    Subject    string        `json:"subject"`
    Body       string        `json:"body"`
    HtmlBody   string        `json:"html_body"`
    As         []*Attachment `json:"attachments,omitempty"`
}

Directories

PathSynopsis
cmd/cce
cmd/cserve

Package cention imports 13 packages (graph) and is imported by 2 packages. Updated 2017-05-14. Refresh now. Tools for package owners.