Documentation ¶
Index ¶
- Constants
- Variables
- func CheckResponse(r *http.Response) error
- type Account
- type AccountsServices
- type BalanceDebitted
- type Client
- type DebitRewardOptions
- type ErrorResponse
- type FraudSignal
- type FraudSignals
- type ListReferralsOptions
- type ListReferralsResult
- type ListRewardOptions
- type MobileWidget
- func (mw MobileWidget) BuildUrl() (string, error)
- func (mw *MobileWidget) WithAccount(aid string) *MobileWidget
- func (mw *MobileWidget) WithEmail(email string) *MobileWidget
- func (mw *MobileWidget) WithFirstName(name string) *MobileWidget
- func (mw *MobileWidget) WithLastName(name string) *MobileWidget
- func (mw *MobileWidget) WithLocale(locale string) *MobileWidget
- func (mw *MobileWidget) WithPayment(pid string) *MobileWidget
- type Referral
- type ReferralCode
- type ReferralCodeService
- type ReferralObject
- type ReferralService
- type ReferredReward
- type ReferredUser
- type Reward
- type RewardBalances
- type RewardBalancesServices
- type Subscription
- type Tenant
- type User
- type UsersServices
Constants ¶
const (
HOST = "http://app.referralsaasquatch.com"
)
Variables ¶
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type Account ¶
type Account struct { Id string `json:"id"` Currency string `json:"currency"` Subscription *Subscription `json:"subscription,omitempty"` Referral *Referral `json:"referral,omitempty"` }
type AccountsServices ¶
type AccountsServices struct {
// contains filtered or unexported fields
}
func (*AccountsServices) CreateOrUpdateAccount ¶
func (s *AccountsServices) CreateOrUpdateAccount(payload Account) (*Account, error)
func (*AccountsServices) LookupAccount ¶
func (s *AccountsServices) LookupAccount(accountId string) (*Account, error)
type BalanceDebitted ¶
type Client ¶
type Client struct { BaseURL *url.URL Referral *ReferralService ReferralCode *ReferralCodeService Accounts *AccountsServices Users *UsersServices RewardBalances *RewardBalancesServices // contains filtered or unexported fields }
A Client manages communication with the SaaSquatch API.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type DebitRewardOptions ¶
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error StatusCode int `json:"statusCode"` Message string `json:"message"` ApiErrorCode string `json:"apiErrorCode"` }
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type FraudSignal ¶
type FraudSignals ¶
type FraudSignals struct { Name FraudSignal `json:"name"` Ip FraudSignal `json:"ip"` Email FraudSignal `json:"email"` Rate FraudSignal `json:"rate"` }
type ListReferralsOptions ¶
type ListReferralsOptions struct { ReferringAccountId string `url:"referringAccountId,omitempty"` ReferringUserId string `url:"referringUserId,omitempty"` DateReferralPaid string `url:"dateReferralPaid,omitempty"` DateReferralEnded string `url:"dateReferralEnded,omitempty"` ReferredModerationStatus string `url:"referredModerationStatus,omitempty"` ReferrerModerationStatus string `url:"referrerModerationStatus,omitempty"` Limit int `url:"limit,omitempty"` Offset int `url:"offset,omitempty"` }
type ListReferralsResult ¶
type ListReferralsResult struct { Count int `json:"count"` TotalCount int `json:"totalCount"` Referrals []ReferralObject `json:"referrals"` }
type ListRewardOptions ¶
type MobileWidget ¶
type MobileWidget struct {
// contains filtered or unexported fields
}
func NewMobileWidget ¶
func NewMobileWidget(tn *Tenant, uid, email, firstName string) *MobileWidget
func (MobileWidget) BuildUrl ¶
func (mw MobileWidget) BuildUrl() (string, error)
func (*MobileWidget) WithAccount ¶
func (mw *MobileWidget) WithAccount(aid string) *MobileWidget
func (*MobileWidget) WithEmail ¶
func (mw *MobileWidget) WithEmail(email string) *MobileWidget
func (*MobileWidget) WithFirstName ¶
func (mw *MobileWidget) WithFirstName(name string) *MobileWidget
func (*MobileWidget) WithLastName ¶
func (mw *MobileWidget) WithLastName(name string) *MobileWidget
func (*MobileWidget) WithLocale ¶
func (mw *MobileWidget) WithLocale(locale string) *MobileWidget
func (*MobileWidget) WithPayment ¶
func (mw *MobileWidget) WithPayment(pid string) *MobileWidget
type ReferralCode ¶
type ReferralCodeService ¶
type ReferralCodeService struct {
// contains filtered or unexported fields
}
func (*ReferralCodeService) LookupReferralCode ¶
func (s *ReferralCodeService) LookupReferralCode(cd string) (*ReferralCode, error)
type ReferralObject ¶
type ReferralObject struct { Id string `json:"id"` ReferredUser *ReferredUser `json:"referredUser"` ReferrerUser *ReferredUser `json:"referrerUser"` ReferredReward *ReferredReward `json:"referredReward"` ReferrerReward *ReferredReward `json:"referrerReward"` ModerationStatus string `json:"moderationStatus"` ReferredModerationStatus string `json:"referredModerationStatus"` ReferrerModerationStatus string `json:"referrerModerationStatus"` FraudSignals *FraudSignals `json:"fraudSignals,omitempty"` DateReferralStarted int `json:"dateReferralStarted"` DateReferralPaid int `json:"dateReferralPaid"` DateReferralEnded int `json:"dateReferralEnded"` DateModerated int `json:"dateModerated"` }
type ReferralService ¶
type ReferralService struct {
// contains filtered or unexported fields
}
func (*ReferralService) ListReferrals ¶
func (s *ReferralService) ListReferrals(opt ListReferralsOptions) (*ListReferralsResult, error)
type ReferredReward ¶
type ReferredReward struct { Id string `json:"id"` Type string `json:"type"` DateGiven int `json:"dateGiven"` DateExpires int `json:"dateExpires"` DateCancelled int `json:"dateCancelled"` Cancellable bool `json:"cancellable"` RewardSource string `json:"rewardSource"` Unit string `json:"unit"` DiscountPercent int `json:"discountPercent"` FeatureType string `json:"featureType"` Name string `json:"name"` Description string `json:"description"` Quantity int `json:"quantity"` AssignedCredit int `json:"assignedCredit"` RedeemedCredit int `json:"redeemedCredit"` Currency string `json:"currency"` }
type ReferredUser ¶
type ReferredUser struct { Id string `json:"id"` AccountId string `json:"accountId"` ReferralCode string `json:"referralCode"` Email string `json:"email"` ImageUrl string `json:"imageUrl"` FirstName string `json:"firstName"` LastName string `json:"lastName"` FirstSeenIP string `json:"firstSeenIP"` LastSeenIP string `json:"lastSeenIP"` DateCreated int `json:"dateCreated"` EmailHash string `json:"emailHash"` ReferralSource string `json:"referralSource"` Locale string `json:"locale"` }
type Reward ¶
type Reward struct { Type string `json:"type"` Unit string `json:"unit"` Credit int `json:"credit"` DiscountPercent int `json:"discountPercent"` MonthsDiscountIsValid int `json:"monthsDiscountIsValid"` //Only works with types FEATURE FeatureType string `json:"featureType,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Quantity int `json:"quantity,omitempty"` }
type RewardBalances ¶
type RewardBalances struct { Type string `json:"type"` Unit string `json:"unit,omitempty"` Count int `json:"count,omitempty"` FeatureType string `json:"featureType,omitempty"` TotalAssignedCredit int `json:"totalAssignedCredit,omitempty"` TotalRedeemedCredit int `json:"totalRedeemedCredit,omitempty"` TotalDiscountPercent int `json:"totalDiscountPercent,omitempty"` ReferredDiscountPercent int `json:"referredDiscountPercent,omitempty"` ReferrerDiscountPercent int `json:"referrerDiscountPercent,omitempty"` }
type RewardBalancesServices ¶
type RewardBalancesServices struct {
// contains filtered or unexported fields
}
func (*RewardBalancesServices) DebitRewardBalance ¶
func (s *RewardBalancesServices) DebitRewardBalance(opt DebitRewardOptions) (*BalanceDebitted, error)
func (*RewardBalancesServices) ListRewardBalances ¶
func (s *RewardBalancesServices) ListRewardBalances(opt ListRewardOptions) ([]RewardBalances, error)
type Subscription ¶
type Tenant ¶
func (*Tenant) DisableSecureMode ¶
func (Tenant) NewMobileWidget ¶
func (tn Tenant) NewMobileWidget(uid, email, firstName string) *MobileWidget
type UsersServices ¶
type UsersServices struct {
// contains filtered or unexported fields
}
func (*UsersServices) CreateOrUpdateUser ¶
func (s *UsersServices) CreateOrUpdateUser(payload User) (*User, error)
func (*UsersServices) LookupUser ¶
func (s *UsersServices) LookupUser(accountId, userId string) (*User, error)