Documentation
¶
Index ¶
- Constants
- Variables
- type API
- func (a *API) Auth(ctx context.Context) error
- func (a *API) AuthCodeRedirect(w http.ResponseWriter, r *http.Request, scope, state, redirectURL string)
- func (a *API) CheckPassword(ctx context.Context, username, password string) (err error)
- func (a *API) ClientCredentials(ctx context.Context, scope string) (*Token, error)
- func (a *API) Countries(ctx context.Context) (Countries, error)
- func (a *API) CreateProfileSearch(ctx context.Context, params interface{}) (*ProfileSearchResp, error)
- func (a *API) Do(ctx context.Context, req *http.Request, result interface{}) error
- func (a *API) Events(ctx context.Context) (Events, error)
- func (a *API) Get(ctx context.Context, urlStr string, result interface{}) error
- func (a *API) GetAuthCodeURL(scope, state, redirectURL string) string
- func (a *API) GetAuthRequestURL(scope, state, redirectURL string) string
- func (a *API) GetProfileSearch(ctx context.Context, search *ProfileSearchResp) (*ProfileResp, error)
- func (a *API) GetToken(ctx context.Context, authCode, scope, state, redirectURL string) (*Token, error)
- func (a *API) Groups(ctx context.Context) (Groups, error)
- func (a *API) LastRequest() *http.Request
- func (a *API) LastResponse() *http.Response
- func (a *API) Me(ctx context.Context, accessToken string) (*Profile, error)
- func (a *API) MemberStatuses(ctx context.Context) (MemberStatuses, error)
- func (a *API) MemberTypes(ctx context.Context) (MemberTypes, error)
- func (a *API) OwnerPassword(ctx context.Context, username, password string) (*Token, error)
- func (a *API) Post(ctx context.Context, urlStr string, form url.Values, result interface{}) error
- func (a *API) PostJSON(ctx context.Context, urlStr string, data, result interface{}) error
- func (a *API) Profile(ctx context.Context, id string) (*Profile, error)
- func (a *API) ProfilePageCt(ctx context.Context, pageSize int) (int, error)
- func (a *API) ProfileSearch(ctx context.Context, searchID string, pageNum int) (*ProfileResp, error)
- func (a *API) Profiles(ctx context.Context, pageNum, pageSize int) (*ProfileResp, error)
- func (a *API) RefreshToken(ctx context.Context, scope string, refreshToken string) (*Token, error)
- func (a *API) ResourceOwnerCredentials(ctx context.Context, username, password string) (*Token, error)
- func (a *API) SetAccessToken(accessToken string) *API
- type Countries
- type Country
- type Event
- type Events
- type Group
- type Groups
- type MemberStatus
- type MemberStatuses
- type MemberType
- type MemberTypes
- type Profile
- func (p *Profile) Attributes() map[string]interface{}
- func (p *Profile) DeleteAttr(names ...string)
- func (p *Profile) Entity() string
- func (p *Profile) Get(name string, dstVal interface{}) error
- func (p *Profile) GetID() string
- func (p *Profile) Groups() []string
- func (p *Profile) ID() int64
- func (p *Profile) Load(ps []datastore.Property) error
- func (p *Profile) MarshalJSON() ([]byte, error)
- func (p *Profile) MemberType() string
- func (p *Profile) Save() (list []datastore.Property, err error)
- func (p *Profile) Set(name string, val interface{})
- func (p *Profile) UnmarshalJSON(data []byte) error
- type ProfileResp
- type ProfileSearchResp
- type Token
Constants ¶
const (
ScopeRead = "read"
)
Scopes
Variables ¶
var ( ErrNoSuchField = errors.New("no such field") ErrEmptyMap = errors.New("map is empty") )
Error messages
var ( ErrInvalidDstVal = errors.New("invalid destination value") ErrCannotAssignValue = errors.New("cannot assign to destination value") )
Errors related to copying values between interfaces
var ( // Timeout is the duration before HTTP requests to the API servers time out Timeout = 15 * time.Second )
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { Client *http.Client Timeout time.Duration sync.RWMutex // contains filtered or unexported fields }
API is an MemberClicks API client
func (*API) Auth ¶
Auth initializes a default ClientCredentials requests and stores the resulting access token if successful
func (*API) AuthCodeRedirect ¶
func (a *API) AuthCodeRedirect(w http.ResponseWriter, r *http.Request, scope, state, redirectURL string)
AuthCodeRedirect does an http.Redirect to the authcodeurl
func (*API) CheckPassword ¶
CheckPassword is shorthand for OwnerPasswordGrant, without returning the token
func (*API) ClientCredentials ¶
ClientCredentials returns a client_credentials token
func (*API) CreateProfileSearch ¶
func (a *API) CreateProfileSearch(ctx context.Context, params interface{}) (*ProfileSearchResp, error)
CreateProfileSearch creates a profile search and returns the resulting search ID. Profile searches exipre every half an hour.
func (*API) GetAuthCodeURL ¶
GetAuthCodeURL returns a auth code URL for redirecting the client to authorize with MemberClicks
func (*API) GetAuthRequestURL ¶
func (*API) GetProfileSearch ¶
func (a *API) GetProfileSearch(ctx context.Context, search *ProfileSearchResp) (*ProfileResp, error)
ProfileSearch returns a profile search with the given ID.
func (*API) GetToken ¶
func (a *API) GetToken(ctx context.Context, authCode, scope, state, redirectURL string) (*Token, error)
GetToken trades an auth code for an access token
func (*API) LastRequest ¶
LastRequest returns a copy of the last HTTP request make to the API
func (*API) LastResponse ¶
LastResponse returns a copy of the last HTTP request make to the API
func (*API) MemberStatuses ¶
func (a *API) MemberStatuses(ctx context.Context) (MemberStatuses, error)
MemberStatuses returns the complete list of member statuses.
func (*API) MemberTypes ¶
func (a *API) MemberTypes(ctx context.Context) (MemberTypes, error)
MemberTypes returns a slice of member types for the account
func (*API) OwnerPassword ¶
OwnerPassword returns a token with the owner "password" grant type
func (*API) ProfilePageCt ¶
ProfilePageCt gets the total number of profiles
func (*API) ProfileSearch ¶
func (a *API) ProfileSearch(ctx context.Context, searchID string, pageNum int) (*ProfileResp, error)
ProfileSearch returns a profile search with the given ID. If pageNum is less than 1, all pages of the search will be returned.
func (*API) Profiles ¶
Profiles returns a page of profiles. Set the pageNum to be < 1 to get all pages at the same time.
func (*API) RefreshToken ¶
RefreshToken gets a new token from a refresh token
func (*API) ResourceOwnerCredentials ¶
func (*API) SetAccessToken ¶
SetAccessToken sets the internal access token to use on requests if no other Authorization header is set.
type MemberStatus ¶
type MemberStatus struct {
Name string `json:"name"`
}
MemberStatus is a member status
type MemberStatuses ¶
type MemberStatuses []MemberStatus
MemberStatuses is a complete list of member statuses.
type MemberType ¶
MemberType is a member type
type Profile ¶
type Profile struct {
// contains filtered or unexported fields
}
Profile is a memberclicks user profile. It stores the attributes in a private attributes map, and implmenets the interface of json.Marshaler, json.Unmarshaler, and datastore.PropertyLoadSaver to make the values accessible
func (*Profile) Attributes ¶
func (*Profile) DeleteAttr ¶
DeleteAttr deletes a given attribute
func (*Profile) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (*Profile) MemberType ¶
MemberType returns the profile member type
func (*Profile) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface
type ProfileResp ¶
type ProfileResp struct { TotalCount int `json:"totalCount"` TotalPageCount int `json:"totalPageCount"` PageNumber int `json:"pageNumber"` PageSize int `json:"pageSize"` Count int `json:"count"` FirstPageURL string `json:"firstPageUrl"` NextPageURL string `json:"nextPageUrl"` LastPageURL string `json:"lastPageUrl"` Profiles []Profile `json:"profiles"` }
type ProfileSearchResp ¶
type Token ¶
type Token struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` RefreshToken string `json:"refresh_token"` // ExpiresIn is expiration time in seconds, usually 3600 or one hour ExpiresIn int64 `json:"expires_in"` Scope string `json:"scope"` ServiceID int64 `json:"serviceId"` UserID int64 `json:"userId"` JTI string `json:"jti"` }
Token is a OAuth2 access token response from the server