Documentation
¶
Index ¶
- func CheckResponse(r *http.Response) error
- type Account
- type AccountInterface
- type AccountService
- type AnswerOptions
- type AuthenticationError
- type BasicCredentialProvider
- type Client
- func (c *Client) AddAutheticationToken(req *http.Request) error
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)
- func (c *Client) IsAuthenticationRequired(method, urlStr string) bool
- func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
- func (c *Client) SetToken(token *Token)
- type CredentialProvider
- type Dataset
- type DatasetsInterface
- type DatasetsService
- func (s *DatasetsService) Add(ctx context.Context, dataset *Dataset) (*Dataset, *Response, error)
- func (s *DatasetsService) Delete(ctx context.Context, datasetID int, dryRun bool) (*DeleteResponse, *Response, error)
- func (s *DatasetsService) Get(ctx context.Context, datasetID int) (*Dataset, *Response, error)
- func (s *DatasetsService) Update(ctx context.Context, dataset *Dataset) (*Dataset, *Response, error)
- type DeleteResponse
- type Deployment
- type Deployments
- type DeploymentsInterface
- type DeploymentsService
- func (s *DeploymentsService) Add(ctx context.Context, deployment *Deployment) (*Deployments, *Response, error)
- func (s *DeploymentsService) Delete(ctx context.Context, deploymentKey string, dryRun bool) (*DeleteResponse, *Response, error)
- func (s *DeploymentsService) Get(ctx context.Context) (*Deployments, *Response, error)
- type ErrorCode
- type ErrorResponse
- type Feedback
- type FeedbackData
- type FeedbackField
- type FeedbackInterface
- type FeedbackService
- type FieldData
- type Fields
- type FieldsInterface
- type FieldsService
- type Filter
- type FilterCollection
- type FilterKey
- type FilterModifier
- type Meta
- type PaginationOptions
- type Report
- type ReportsInterface
- type ReportsService
- func (s *ReportsService) Add(ctx context.Context, report *Report) (*Report, *Response, error)
- func (s *ReportsService) Delete(ctx context.Context, reportID int, dryRun bool) (*DeleteResponse, *Response, error)
- func (s *ReportsService) Get(ctx context.Context, reportID int) (*Report, *Response, error)
- func (s *ReportsService) Update(ctx context.Context, report *Report) (*Report, *Response, error)
- type Response
- type ServerError
- type Token
- type TokenInterface
- type TokenService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the response if the response is either an error or not.
Types ¶
type Account ¶
type Account struct {
Meta Meta `json:"_meta,omitempty"`
Name string
Package string
EndDate string
NumberUsers int `json:"number_users"`
NumberCharts int `json:"number_charts"`
NumberForms int `json:"number_forms"`
NumberReports int `json:"number_reports"`
Reports []Report
}
Account is a struct which reflects to mopinion Account resource.
type AccountInterface ¶
AccountInterface holds only one method for retrieving the account.
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
AccountService implements AccountInterface.
type AnswerOptions ¶
AnswerOptions is a struct which reflects to mopinion AnswerOptions resource.
type AuthenticationError ¶
type AuthenticationError ErrorResponse
AuthenticationError occurs when an invalid token is provided.
func (*AuthenticationError) Error ¶
func (r *AuthenticationError) Error() string
type BasicCredentialProvider ¶
type BasicCredentialProvider struct {
// contains filtered or unexported fields
}
BasicCredentialProvider implements CredentialProvider.
type Client ¶
type Client struct {
// BaseURL holds the url for the mopinion api.
BaseURL *url.URL
// UserAgent holds the agent name while communicating with mopinion api.
UserAgent string
// Services used for talking to different parts of the Mopinion API.
Token TokenInterface
Account AccountInterface
Deployments DeploymentsInterface
Datasets DatasetsInterface
Fields FieldsInterface
Feedback FeedbackInterface
Reports ReportsInterface
// contains filtered or unexported fields
}
Client represents the Mopinion client.
func NewClient ¶
func NewClient(httpClient *http.Client, credentialProvider CredentialProvider) (*Client, error)
NewClient returns a new Mopinion API client.
func (*Client) AddAutheticationToken ¶
AddAutheticationToken adds an x-auth-token.
func (*Client) IsAuthenticationRequired ¶
IsAuthenticationRequired checks if an auth token needs to be passed along with the given relative URL.
func (*Client) NewRequest ¶
NewRequest creates an API request.
type CredentialProvider ¶
type CredentialProvider interface {
// Keys returns public and private keys respectively.
Keys() (string, string, error)
}
CredentialProvider is an interface to be used to retrieve keys to access the Mopinion API.
func NewBasicCredentialProvider ¶
func NewBasicCredentialProvider(publicKey, privateKey string) CredentialProvider
NewBasicCredentialProvider returns a BasicCredentialProvider.
type Dataset ¶
type Dataset struct {
Meta *Meta `json:"_meta,omitempty"`
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
ReportID int `json:"report_id,omitempty"`
Description string `json:"description,omitempty"`
DataSource string `json:"data_source,omitempty"`
}
Dataset is a struct which reflects to mopinion Dataset resource.
type DatasetsInterface ¶
type DatasetsInterface interface {
Get(ctx context.Context, datasetID int) (*Dataset, *Response, error)
Add(ctx context.Context, dataset *Dataset) (*Dataset, *Response, error)
Update(ctx context.Context, dataset *Dataset) (*Dataset, *Response, error)
Delete(ctx context.Context, datasetID int, dryRun bool) (*DeleteResponse, *Response, error)
}
DatasetsInterface contains CRUD methods around Dataset model.
type DatasetsService ¶
type DatasetsService struct {
// contains filtered or unexported fields
}
DatasetsService implemets DatasetsInterface, holds a reference of service back to mopinion client.
func (*DatasetsService) Add ¶
Add creates a new dataset if validation passes. Dataset report id or name cannot be empty.
func (*DatasetsService) Delete ¶
func (s *DatasetsService) Delete(ctx context.Context, datasetID int, dryRun bool) (*DeleteResponse, *Response, error)
Delete removes the record with given id. If dry-run is true, It rehearses the operation.
type DeleteResponse ¶
type DeleteResponse struct {
Executed bool
ResourcesAffected map[string]interface{} `json:"resources_affected"`
}
DeleteResponse is a struct which reflects to mopinion DeleteResponse resource.
type Deployment ¶
Deployment is a struct which reflects to mopinion Deployment resource.
type Deployments ¶
type Deployments struct {
Meta Meta `json:"_meta"`
Deployments []Deployment
}
Deployments is a struct which reflects to mopinion Deployments resource.
func (*Deployments) UnmarshalJSON ¶
func (d *Deployments) UnmarshalJSON(buf []byte) (err error)
UnmarshalJSON implements Unmarshaler interface.
type DeploymentsInterface ¶
type DeploymentsInterface interface {
Get(ctx context.Context) (*Deployments, *Response, error)
Add(ctx context.Context, deployment *Deployment) (*Deployments, *Response, error)
Delete(ctx context.Context, deploymentKey string, dryRun bool) (*DeleteResponse, *Response, error)
}
DeploymentsInterface contains CRUD methods for Deployments model.
type DeploymentsService ¶
type DeploymentsService struct {
// contains filtered or unexported fields
}
DeploymentsService implements DeploymentsInterface.
func (*DeploymentsService) Add ¶
func (s *DeploymentsService) Add(ctx context.Context, deployment *Deployment) (*Deployments, *Response, error)
Add creates a new Deployment, if the given deployment is valid.
func (*DeploymentsService) Delete ¶
func (s *DeploymentsService) Delete(ctx context.Context, deploymentKey string, dryRun bool) (*DeleteResponse, *Response, error)
Delete removes the deployment for given given ID.
func (*DeploymentsService) Get ¶
func (s *DeploymentsService) Get(ctx context.Context) (*Deployments, *Response, error)
Get returns Deployments
type ErrorResponse ¶
type ErrorResponse struct {
Response *http.Response
Status int `json:"status"`
ErrorCode int `json:"error_code"`
Title string `json:"title"`
Type string `json:"type"`
}
ErrorResponse represent the returning error struct. Implements the error interface.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
Error returns an explainatory message.
type Feedback ¶
type Feedback struct {
Meta Meta `json:"_meta"`
Data []FeedbackData
}
Feedback is a struct which reflects to mopinion Feedback resource.
type FeedbackData ¶
type FeedbackData struct {
Created string
DatasetID int `json:"dataset_id"`
ID int
ReportID int `json:"report_id"`
Tags []string
Fields []FeedbackField
}
FeedbackData is a struct which reflects to mopinion FeedbackData resource.
type FeedbackField ¶
FeedbackField is a struct which reflects to mopinion FeedbackField resource.
type FeedbackInterface ¶
type FeedbackInterface interface {
GetByDataset(ctx context.Context, datasetID int, options *PaginationOptions, filters *FilterCollection) (*Feedback, *Response, error)
GetByReport(ctx context.Context, reportID int, options *PaginationOptions, filters *FilterCollection) (*Feedback, *Response, error)
}
FeedbackInterface holds two methods that return feedback by a given dataset or report. FeedbackInterface accepts pagination options and filters.
type FeedbackService ¶
type FeedbackService struct {
// contains filtered or unexported fields
}
FeedbackService implements FeedbackInterface.
func (*FeedbackService) GetByDataset ¶
func (s *FeedbackService) GetByDataset(ctx context.Context, datasetID int, options *PaginationOptions, filters *FilterCollection) (*Feedback, *Response, error)
GetByDataset returns feedback by given dataset id, pagination options and filters.
func (*FeedbackService) GetByReport ¶
func (s *FeedbackService) GetByReport(ctx context.Context, reportID int, options *PaginationOptions, filters *FilterCollection) (*Feedback, *Response, error)
GetByReport returns feedback by given report id, pagination options and filters.
type FieldData ¶
type FieldData struct {
AnswerOptions *AnswerOptions `json:"answer_options"`
AnswerValues []string `json:"answer_values"`
DatasetID int
Key string
Label string
ReportID int `json:"report_id"`
ShortLabel string `json:"short_label"`
Type string
}
FieldData is a struct which reflects to mopinion FieldData resource.
type FieldsInterface ¶
type FieldsInterface interface {
GetByDataset(ctx context.Context, datasetID int) (*Fields, *Response, error)
GetByReport(ctx context.Context, reportID int) (*Fields, *Response, error)
}
FieldsInterface has two methods returning fields for a specific dataset or report.
type FieldsService ¶
type FieldsService struct {
// contains filtered or unexported fields
}
FieldsService implements FieldsInterface
func (*FieldsService) GetByDataset ¶
func (s *FieldsService) GetByDataset(ctx context.Context, datasetID int) (*Fields, *Response, error)
GetByDataset returns the fields of given dataset id
func (*FieldsService) GetByReport ¶
GetByReport returns the fields of given report id
type Filter ¶
type Filter struct {
Key FilterKey
Modifier FilterModifier
Value string
}
Filter is a struct composed of key, modifier and its value. For more information, look at the link below. https://developer.mopinion.com/api/#section/Requests-and-Responses/Filters
type FilterCollection ¶
type FilterCollection struct {
Filters []Filter
}
FilterCollection holds the filters to be applied on feedback data.
type FilterKey ¶
type FilterKey string
FilterKey type represents the possible filters
const ( // Date refers to the time when a record is created. Date FilterKey = "date" // Rating is a geenral numeric rating, its value should be numeric. Rating FilterKey = "rating" // Nps is Net Promotor Score, its value should be between 0 and 10. Nps FilterKey = "nps" // Ces is Customer Effort Score, its value should be between 1 and 5. Ces FilterKey = "ces" // CesInverse is Customer Effort Score CesInverse FilterKey = "ces_inverse" // Gcr is Goal Completion Rate. Option are no, partly, yes. Gcr FilterKey = "gcr" // Tags can be assigned to the feedback items. Tags FilterKey = "tags" )
type FilterModifier ¶
type FilterModifier string
FilterModifier type represents the possible modifiers
const ( // Not is used for logical not Not FilterModifier = "!" // Lt means less than Lt FilterModifier = "<" // Lte means less than or equal Lte FilterModifier = "<<" // Gt means greater than Gt FilterModifier = ">" // Gte means greater than or equal Gte FilterModifier = ">>" )
type Meta ¶
type Meta struct {
Code int
Count int
HasMore bool `json:"has_more"`
Message string
Next interface{} // boolean false, or a string with a url
Previous interface{}
Total int
}
Meta is a struct that takes place in responses from Mopinion API, with the json tag `_meta`. It holds basic information about the resources.
type PaginationOptions ¶
type PaginationOptions struct {
Page int `url:"page,omitempty"`
Limit int `url:"limit,omitempty"`
Sort string `url:"sort,omitempty"`
Order string `url:"order,omitempty"`
}
PaginationOptions holds info for pagination.
type Report ¶
type Report struct {
Meta *Meta `json:"_meta,omitempty"`
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Language string `json:"language,omitempty"`
Created string `json:"created,omitempty"`
Datasets []Dataset
}
Report is a struct which reflects to mopinion Report resource.
type ReportsInterface ¶
type ReportsInterface interface {
Get(ctx context.Context, reportID int) (*Report, *Response, error)
Add(ctx context.Context, report *Report) (*Report, *Response, error)
Update(ctx context.Context, report *Report) (*Report, *Response, error)
Delete(ctx context.Context, reportID int, dryRun bool) (*DeleteResponse, *Response, error)
}
ReportsInterface contains CRUD methods for Report model.
type ReportsService ¶
type ReportsService struct {
// contains filtered or unexported fields
}
ReportsService implements ReportsInterface.
func (*ReportsService) Delete ¶
func (s *ReportsService) Delete(ctx context.Context, reportID int, dryRun bool) (*DeleteResponse, *Response, error)
Delete removes the report for given given ID.
type ServerError ¶
type ServerError ErrorResponse
ServerError is unexpected server side error, coming through Mopinion API.
func (*ServerError) Error ¶
func (r *ServerError) Error() string
type Token ¶
type Token struct {
Token string
}
Token contains a string which is retrieved by Token service. It is used to generate a hmac signature.
type TokenInterface ¶
TokenInterface has only one method that returns a token by given public and private keys.
type TokenService ¶
type TokenService struct {
// contains filtered or unexported fields
}
TokenService implements TokenInterface.