classic

package
v0.0.0-...-377ecce Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoContent is returned when an HTTP resposne has a 2XX response code but a 0 ContentLength
	ErrNoContent = errors.New("HTTP response has no content length")
)

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	UserID     string        `json:"userId" xml:"userId"`
	AttID      string        `json:"attId" xml:"attId"`
	AttTypeID  AttributeType `json:"attTypeId" xml:"attTypeId"`
	AttName    string        `json:"attName" xml:"attName"`
	AttData    string        `json:"attData" xml:"attData"`
	LastModify time.Time     `json:"lastModifiy" xml:"lastModify"`
}

func (Attribute) String

func (a Attribute) String() string

type AttributeType

type AttributeType int

func (AttributeType) String

func (a AttributeType) String() string

type AuthResponse

type AuthResponse struct {
	UserID        string `json:"userId"`
	GroupID       string `json:"groupId"`
	OrgID         string `json:"orgId"`
	ContactName   string `json:"contactName"`
	UserName      string `json:"userName"`
	Active        bool   `json:"active,string"`
	Validated     bool   `json:"validated,string"`
	Deleted       bool   `json:"deleted,string"`
	FormStatus    string `json:"formStats"`
	LastModify    string `json:"lastModify"`
	NoMassEmail   bool   `json:"noMassEmail,string"`
	PrefBBContact string `json:"prefBBContact"`
	PrefBBImage   string `json:"prefBBImage"`
	Token         string `json:"token"`
	Password      string `json:"password"`
}

AuthResponse is a MemberClicks classic auth response

type Client

type Client struct {
	OrganizationID string

	HttpClient *http.Client

	sync.Mutex
	// contains filtered or unexported fields
}

Classic handles sending/receiving data to/from the MemberClicks Classic

func New

func New(ctx context.Context, orgID, apiKey, username, password string) (*Client, error)

New returns a new Classic instance with the given authToken

func (*Client) Auth

func (c *Client) Auth(ctx context.Context) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, uri string, respData interface{}) (*http.Response, error)

Get sends a HTTP GET request to the given uri and returns the XML encoded respone in respData

func (*Client) NewRequest

func (c *Client) NewRequest(method string, urlStr string, body io.Reader) (*http.Request, error)

NewRequest matches the http.NewRequest signature but sets required headers.

func (*Client) Post

func (c *Client) Post(ctx context.Context, uri string, form url.Values, respData interface{}) (*http.Response, error)

Post sends a HTTP Post request to the given url and returns the result decoded into respDatc.

func (*Client) PostJSON

func (c *Client) PostJSON(ctx context.Context, urlStr string, data interface{}, respData interface{}) (*http.Response, error)

PostJSON sends a JSON POST request to the urlStr with a body of data and decodes result into respData

func (*Client) PostXML

func (c *Client) PostXML(ctx context.Context, urlStr string, data interface{}, respData interface{}) (*http.Response, error)

PostXML sends a XML POST request to the urlStr with a body of data and decodes result into respData

func (*Client) User

func (c *Client) User(ctx context.Context, userID string) (*Profile, error)

func (*Client) Users

func (c *Client) Users(ctx context.Context, params url.Values) (*UserList, error)

type ErrorResponse

type ErrorResponse struct {
	Timestamp      int64             `json:"timestamp"`
	Status         int               `json:"status"`
	Error          string            `json:"error"`
	Message        string            `json:"message"`
	MessageDetails []string          `json:"messageDetails"` // not sure what format this is
	Path           string            `json:"path"`
	Parameters     map[string]string // not sure what format this is, probably string
}

ErrorResponse is a MemberClicks classic error response

func (*ErrorResponse) Time

func (e *ErrorResponse) Time() time.Time

Time returns the time of the error response

type Profile

type Profile struct {
	UserID      string      `json:"userId" xml:"userId"`
	GroupID     string      `json:"groupId" xml:"groupId"`
	ContactName string      `json:"contactName" xml:"contactName"`
	Active      bool        `json:"active,string" xml:"active"`
	Validated   bool        `json:"validated,string" xml:"validated"`
	Deleted     bool        `json:"deleted,string" xml:"deleted"`
	Attributes  []Attribute `json:"attribute" xml:"attribute"`
}

func (*Profile) Get

func (p *Profile) Get(attName string) (attData string)

type UserList

type UserList struct {
	Users []Profile `json:"user" xml:"user"`
}

Jump to

Keyboard shortcuts

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