Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements Trustpilot API.
func NewClient ¶
func NewClient(opts ...ClientOption) (*Client, error)
NewClient sets up a new Trustpilot client.
Example ¶
authConfig := &trustpilot.PasswordGrantConfig{ ClientID: "1a9SsZ2XJKraw1Prl8m+gvq", ClientSecret: "AxLoJhlAcbWiVA8cHW2fINep", Username: "apiuser@example.com", Password: "6X2hQa1lPHu9dVjikUr0FbRt", } client, err := trustpilot.NewClient( trustpilot.AuthConfig(authConfig), trustpilot.Debug(true), ) if err != nil { // TODO handle the error. } _ = client
Output:
func (*Client) CreateInvitation ¶
func (c *Client) CreateInvitation(ctx context.Context, r *CreateInvitationRequest) (*CreateInvitationResponse, error)
func (*Client) ListTemplates ¶
func (c *Client) ListTemplates(ctx context.Context, r *ListTemplatesRequest) (*ListTemplatesResponse, error)
type ClientOption ¶
ClientOption is a functional option for configuring the API client.
func APIBaseURL ¶
func APIBaseURL(u *url.URL) ClientOption
APIBaseURL allows to change the default API base url.
func AuthConfig ¶
func AuthConfig(conf *PasswordGrantConfig) ClientOption
AuthConfig is a functional option for configuring oauth 2.0 password grant credentials.
func Debug ¶
func Debug(b bool) ClientOption
Debug is a functional option for configuring client debug.
func HTTPClient ¶
func HTTPClient(h *http.Client) ClientOption
HTTPClient is a functional option for configuring http client.
func InvitationAPIBaseURL ¶
func InvitationAPIBaseURL(u *url.URL) ClientOption
InvitationAPIBaseURL allows to change the default Invitation API base url.
func TokenURL ¶
func TokenURL(u *url.URL) ClientOption
TokenURL allows to change the default API oauth 2.0 token url.
type CreateInvitationRequest ¶
type CreateInvitationRequest struct { BusinessUnitID string // Required. ConsumerEmail string `json:"consumerEmail"` // Required. ReplyTo string `json:"replyTo,omitempty"` ReferenceNumber string `json:"referenceNumber,omitempty"` // The customer’s internal reference number. ConsumerName string `json:"consumerName,omitempty"` Locale string `json:"locale,omitempty"` LocationID string `json:"locationId,omitempty"` SenderEmail string `json:"senderEmail,omitempty"` SenderName string `json:"senderName,omitempty"` ServiceReviewInvitation *ServiceReviewInvitation `json:"serviceReviewInvitation,omitempty"` }
type CreateInvitationResponse ¶
type CreateInvitationResponse struct { }
type ErrorResponse ¶
type ErrorResponse struct { Message string `json:"message,omitempty"` ErrorCode int `json:"errorCode,omitempty"` Details string `json:"details,omitempty"` CorrelationID string `json:"correlationId,omitempty"` }
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type ListTemplatesRequest ¶
type ListTemplatesRequest struct {
BusinessUnitID string // Required.
}
type ListTemplatesResponse ¶
type ListTemplatesResponse struct {
Templates []Template `json:"templates"`
}
type PasswordGrantConfig ¶
type PasswordGrantConfig struct { ClientID string ClientSecret string Username string Password string }
PasswordGrantConfig configuration for the oauth2 password grant type. Use TokenURL client option to set oauth2 token url.
type ServiceReviewInvitation ¶
type Trustpilot ¶
type Trustpilot interface { CreateInvitation(ctx context.Context, r *CreateInvitationRequest) (*CreateInvitationResponse, error) ListTemplates(ctx context.Context, r *ListTemplatesRequest) (*ListTemplatesResponse, error) }
Trustpilot defines the Trustpilot API client interface.