usabilla

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 10 Imported by: 0

README

Usabilla

This is a Go client for Usabilla API.

CircleCI GoDoc

Getting Started

After installing Go and setting up your GOPATH, create a main.go file

package main

import (
    "os"
    "fmt"

    "github.com/usabilla/api-go"
)

func main() {
    key := os.Getenv("USABILLA_API_KEY")
    secret := os.Getenv("USABILLA_API_SECRET")

    // Pass the key and secret which should be defined as ENV vars
    usabilla := usabilla.New(key, secret, nil)

    resource := usabilla.Buttons()

    // Get the first ten buttons
    params := map[string]string{"limit": "10"}
    buttons, _ := resource.Get(params)

    // Print all feedback items for each button
    for _, button := range buttons.Items {
        feedback, _ := resource.Feedback().Get(button.ID, nil)
        fmt.Printf("Feedback for button: %s\n%v\n", button.ID, feedback.Items)
    }
}

Then install usabilla package

go get github.com/usabilla/api-go

Run the file

go run main.go

And you will get all feedback items for each button.

The project includes a more detailed example, which you can run from the root directory of the project

go run example/main.go

Documentation

Overview

Package usabilla provides a wrapper around Usabilla Public API.

https://usabilla.com/api

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID     string    `json:"id"`
	Date   time.Time `json:"date"`
	Name   string    `json:"name"`
	Status string    `json:"status"`
}

App represents an app item.

type AppCampaignResponse

type AppCampaignResponse struct {
	Items []AppCampaignStruct `json:"items"`
	// contains filtered or unexported fields
}

AppCampaignResponse is a response that contains App campaign data.

type AppCampaignResultStruct

type AppCampaignResultStruct struct {
	ID         string                 `json:"id"`
	Date       time.Time              `json:"date"`
	CampaignID string                 `json:"campaignId"`
	AppID      string                 `json:"appId"`
	Data       map[string]interface{} `json:"data"`
	Context    map[string]interface{} `json:"context"`
	Metadata   map[string]interface{} `json:"metadata"`
	Complete   bool                   `json:"complete"`
}

AppCampaignResultStruct represents a campaign result item.

type AppCampaignResults

type AppCampaignResults struct {
	// contains filtered or unexported fields
}

AppCampaignResults represents a App Campaign Results resource.

func (*AppCampaignResults) Get

func (acr *AppCampaignResults) Get(campaignID string, params map[string]string) (*AppCampaignResultsResponse, error)

Get function of AppCampaignResults resource returns all the campaign results

func (*AppCampaignResults) Iterate

func (acr *AppCampaignResults) Iterate(campaignID string, params map[string]string) chan AppCampaignResultStruct

Iterate uses a channel which transparently uses the HasMore field to fire a new API request. Once all results have consumed on the channel it closes the chanel.

type AppCampaignResultsResponse

type AppCampaignResultsResponse struct {
	Items []AppCampaignResultStruct `json:"items"`
	// contains filtered or unexported fields
}

AppCampaignResultsResponse is a response that contains App campaign results data.

type AppCampaignStruct

type AppCampaignStruct struct {
	ID             string    `json:"id"`
	CreatedAt      time.Time `json:"createdAt"`
	LastModifiedAt time.Time `json:"lastModifiedAt"`
	Status         string    `json:"status"`
	Name           string    `json:"name"`
	AppIds         []string  `json:"appIds"`
}

AppCampaignStruct represents a campaign item.

type AppCampaigns

type AppCampaigns struct {
	// contains filtered or unexported fields
}

AppCampaigns represents a App Campaign resource.

func (*AppCampaigns) Get

func (ac *AppCampaigns) Get(params map[string]string) (*AppCampaignResponse, error)

Get function of AppCampaigns resource returns all the campaigns

func (*AppCampaigns) Results

func (ac *AppCampaigns) Results() *AppCampaignResults

Results encapsulates the App Campaign Results resource

type AppFeedbackItem

type AppFeedbackItem struct {
	ID           string                 `json:"id"`
	Date         time.Time              `json:"date"`
	Timestamp    string                 `json:"timestamp"`
	DeviceName   string                 `json:"deviceName"`
	Data         map[string]interface{} `json:"data"`
	Custom       map[string]string      `json:"custom"`
	AppID        string                 `json:"appId"`
	AppName      string                 `json:"appName"`
	AppVersion   string                 `json:"appVersion"`
	OsName       string                 `json:"osName"`
	OsVersion    string                 `json:"osVersion"`
	Location     string                 `json:"location"`
	GeoLocation  map[string]interface{} `json:"geolocation"`
	FreeMemory   int                    `json:"freeMemory"`
	TotalMemory  int                    `json:"totalMemory"`
	FreeStorage  int                    `json:"freeStorage"`
	TotalStorage int                    `json:"totalStorage"`
	Screenshot   string                 `json:"screenshot"`
	Screensize   string                 `json:"screensize"`
	Connection   string                 `json:"connection"`
	IPAddress    string                 `json:"ipAddress"`
	Language     string                 `json:"language"`
	Orientation  string                 `json:"orientation"`
	BatteryLevel float32                `json:"batteryLevel"`
}

AppFeedbackItem represents an app feedback item.

type AppFeedbackItems

type AppFeedbackItems struct {
	// contains filtered or unexported fields
}

AppFeedbackItems represents the apps feedback item subresource of Usabilla API.

func (*AppFeedbackItems) Get

func (af *AppFeedbackItems) Get(appID string, params map[string]string) (*AppFeedbackResponse, error)

Get function of AppFeedbackItem resource returns all the feedback items for a specific app, taking into account the provided query parameters.

Valid query parameters are:

limit int
since string (Time stamp)

func (*AppFeedbackItems) Iterate

func (af *AppFeedbackItems) Iterate(appID string, params map[string]string) chan AppFeedbackItem

Iterate uses an AppFeedbackItem channel which transparently uses the HasMore field to fire a new api request once all items have been consumed on the channel.

type AppFeedbackResponse

type AppFeedbackResponse struct {
	Items []AppFeedbackItem `json:"items"`
	// contains filtered or unexported fields
}

AppFeedbackResponse is a response that contains app feedback item data.

type AppResponse

type AppResponse struct {
	Items []App `json:"items"`
	// contains filtered or unexported fields
}

AppResponse is a response that contains app data.

type Apps

type Apps struct {
	// contains filtered or unexported fields
}

Apps represents the app resource of Usabilla API.

func (*Apps) Feedback

func (a *Apps) Feedback() *AppFeedbackItems

Feedback encapsulates the app feedback item resource.

func (*Apps) Get

func (a *Apps) Get(params map[string]string) (*AppResponse, error)

Get function of Apps resource returns all apps taking into account the specified query parameters.

Valid query parameters are:

limit int
since string (Time stamp)

type Button

type Button struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Button represents a button item.

type ButtonResponse

type ButtonResponse struct {
	Items []Button `json:"items"`
	// contains filtered or unexported fields
}

ButtonResponse is a response that contains button data.

func NewButtonResponse

func NewButtonResponse(data []byte) (*ButtonResponse, error)

NewButtonResponse creates a button response and unmarshals json API button response to Go struct.

type Buttons

type Buttons struct {
	// contains filtered or unexported fields
}

Buttons represents the button resource of Usabilla API.

func (*Buttons) Feedback

func (b *Buttons) Feedback() *FeedbackItems

Feedback encapsulates the feedback item resource.

func (*Buttons) Get

func (b *Buttons) Get(params map[string]string) (*ButtonResponse, error)

Get function of Buttons resource returns all the buttons taking into account the specified query parameters.

Valid query parameters are:

limit int
since string (Time stamp)

type CampaignResponse

type CampaignResponse struct {
	Items []CampaignStruct `json:"items"`
	// contains filtered or unexported fields
}

CampaignResponse is a response that contains campaign data.

func NewCampaignResponse

func NewCampaignResponse(data []byte) (*CampaignResponse, error)

NewCampaignResponse creates a campaign response and unmarshals json API campaign response to Go struct.

type CampaignResultResponse

type CampaignResultResponse struct {
	Items []CampaignResultStruct `json:"items"`
	// contains filtered or unexported fields
}

CampaignResultResponse is a response that contains campaign result data.

func NewCampaignResultResponse

func NewCampaignResultResponse(data []byte) (*CampaignResultResponse, error)

NewCampaignResultResponse creates a new campaign result response and unmarshals json API campaign results response to Go struct.

type CampaignResultStruct

type CampaignResultStruct struct {
	ID         string                 `json:"id"`
	UserAgent  string                 `json:"userAgent"`
	Location   string                 `json:"location"`
	Date       time.Time              `json:"date"`
	CampaignID string                 `json:"campaignId"`
	CustomData map[string]string      `json:"customData"`
	Data       map[string]interface{} `json:"data"`
	URL        string                 `json:"url"`
	Time       float64                `json:"time"`
}

CampaignResultStruct represents a campaign result item.

type CampaignResults

type CampaignResults struct {
	// contains filtered or unexported fields
}

CampaignResults represents the campaign result resource of Usabilla API.

func (*CampaignResults) Get

func (r *CampaignResults) Get(campaignID string, params map[string]string) (*CampaignResultResponse, error)

Get function of CampaignResults resource returns all the campaign result items for a specific campaign, taking into account the provided query parameters.

Valid query params are:

limit int
since string (Time stamp)

func (*CampaignResults) Iterate

func (r *CampaignResults) Iterate(campaignID string, params map[string]string) chan CampaignResultStruct

Iterate uses a CampaignResult channel which transparently uses the HasMore field to fire a new api request once all results have been consumed on the channel

type CampaignStatStruct

type CampaignStatStruct struct {
	ID         string `json:"id"`
	Completed  int    `json:"completed"`
	Conversion int    `json:"conversion"`
	Views      int    `json:"views"`
}

CampaignStatStruct represents a campaign statistics item.

type CampaignStats

type CampaignStats struct {
	// contains filtered or unexported fields
}

CampaignStats represents the campaign statistics resource of Usabilla API.

func (*CampaignStats) Get

func (cs *CampaignStats) Get(campaignID string, params map[string]string) (*CampaignStatsResponse, error)

Get function of CampaignStats resource returns the campaign statistics for a specific campaign, taking into account the provided query parameters.

Valid query parameters are:

limit int
since string (Time stamp)

func (*CampaignStats) Iterate

func (cs *CampaignStats) Iterate(campaignID string, params map[string]string) chan CampaignStatStruct

Iterate uses a CampaignStat channel which transparently uses the HasMore field to fire a new api request once all stats items have been consumed on the channel.

type CampaignStatsResponse

type CampaignStatsResponse struct {
	Items []CampaignStatStruct `json:"items"`
	// contains filtered or unexported fields
}

CampaignStatsResponse is a response that contains campaign statistics data.

func NewCampaignStatsResponse

func NewCampaignStatsResponse(data []byte) (*CampaignStatsResponse, error)

NewCampaignStatsResponse creates a new campaign statistics response and unmarshals json API campaign statistics response to Go struct.

type CampaignStruct

type CampaignStruct struct {
	ID          string    `json:"id"`
	Date        time.Time `json:"date"`
	ButtonID    string    `json:"buttonId"`
	AnalyticsID string    `json:"analyticsId"`
	Status      string    `json:"status"`
	Name        string    `json:"name"`
	Type        string    `json:"type"`
}

CampaignStruct represents a campaign item.

type Campaigns

type Campaigns struct {
	// contains filtered or unexported fields
}

Campaigns represents the campaign resource of Usabilla API.

func (*Campaigns) Get

func (c *Campaigns) Get(params map[string]string) (*CampaignResponse, error)

Get function of Campaigns resource returns all the campaigns taking into account the provided query parameters.

Valid query parameters are:

limit int
since string (Time stamp)

func (*Campaigns) Results

func (c *Campaigns) Results() *CampaignResults

Results encapsulates the campaign results resource.

func (*Campaigns) Stats

func (c *Campaigns) Stats() *CampaignStats

Stats encapsulates the campaign statistics resource.

type EmailButton

type EmailButton struct {
	ID        string                   `json:"id"`
	Date      string                   `json:"date"`
	Name      string                   `json:"name"`
	IntroText string                   `json:"introText"`
	Locale    string                   `json:"locale"`
	Groups    []map[string]interface{} `json:"groups"`
}

EmailButton represents an email button item.

type EmailButtonResponse

type EmailButtonResponse struct {
	Items []EmailButton `json:"items"`
	// contains filtered or unexported fields
}

EmailButtonResponse is a response that contains email button data.

func NewEmailButtonResponse

func NewEmailButtonResponse(data []byte) (*EmailButtonResponse, error)

NewEmailButtonResponse creates an email button response and unmarshals json API email button response to Go struct.

type EmailButtons

type EmailButtons struct {
	// contains filtered or unexported fields
}

EmailButtons represents the email button resource of Usabilla API.

func (*EmailButtons) Feedback

func (eb *EmailButtons) Feedback() *FeedbackItems

Feedback encapsulates the email feedback item resource.

We use the FeedbackItems subresource of websites button feedback, as the email feedback items have the same structure for websites . The only difference being that image is contained in the website feedback item response, but it is omitted for the email one.

In this way, feedback items response for email use the same Get and Iterate functions.

func (*EmailButtons) Get

func (eb *EmailButtons) Get(params map[string]string) (*EmailButtonResponse, error)

Get function of EmailButtons resource returns all the email buttons taking into account the specified query parameters.

Valid query parameters are:

limit int
since string (Time stamp)

type FeedbackItem

type FeedbackItem struct {
	ID        string            `json:"id"`
	UserAgent string            `json:"userAgent"`
	Comment   string            `json:"comment"`
	Location  string            `json:"location"`
	Date      time.Time         `json:"date"`
	Custom    map[string]string `json:"custom"`
	Email     string            `json:"email"`
	Image     string            `json:"image,omitempty"`
	Labels    []string          `json:"labels"`
	NPS       int               `json:"nps"`
	PublicURL string            `json:"publicUrl"`
	Rating    int               `json:"rating"`
	ButtonID  string            `json:"buttonId"`
	Tags      []string          `json:"tags"`
	URL       string            `json:"url"`
}

FeedbackItem represents a feedback item.

type FeedbackItems

type FeedbackItems struct {
	// contains filtered or unexported fields
}

FeedbackItems represents the feedback item subresource of Usabilla API.

func (*FeedbackItems) Get

func (f *FeedbackItems) Get(buttonID string, params map[string]string) (*FeedbackResponse, error)

Get function of FeedbackItem resource returns all the feedback items for a specific button, taking into account the provided query parameters.

Valid query parameters are:

limit int
since string (Time stamp)

func (*FeedbackItems) Iterate

func (f *FeedbackItems) Iterate(buttonID string, params map[string]string) chan FeedbackItem

Iterate uses a FeedbackItem channel which transparently uses the HasMore field to fire a new api request once all items have been consumed on the channel.

type FeedbackResponse

type FeedbackResponse struct {
	Items []FeedbackItem `json:"items"`
	// contains filtered or unexported fields
}

FeedbackResponse is a response that contains feedback item data.

func NewFeedbackResponse

func NewFeedbackResponse(data []byte) (*FeedbackResponse, error)

NewFeedbackResponse creates a feedback response and unmarshals json API feedback items response to Go struct.

type GeoLoc

type GeoLoc struct {
	Country string `json:"country"`
	Region  string `json:"region"`
	City    string `json:"city"`
}

type InpageWidgetFeedbackItems

type InpageWidgetFeedbackItems struct {
	// contains filtered or unexported fields
}

InpageWidgetFeedbackItems represents the inpage feedbacks resource of Usabilla API.

func (*InpageWidgetFeedbackItems) Get

Get function of CampaignResults resource returns all the campaign result items for a specific campaign, taking into account the provided query parameters.

Valid query params are:

limit int
since string (Time stamp)

func (*InpageWidgetFeedbackItems) Iterate

func (r *InpageWidgetFeedbackItems) Iterate(inpageID string, params map[string]string) chan InpageWidgetFeedbackStruct

Iterate uses a InpageWidgetFeedbackItems channel which transparently uses the HasMore field to fire a new api request once all results have been consumed on the channel

type InpageWidgetFeedbackResponse

type InpageWidgetFeedbackResponse struct {
	Items []InpageWidgetFeedbackStruct `json:"items"`
	// contains filtered or unexported fields
}

InpageWidgetFeedbackResponse is the response with in-page feedback data.

func NewInpageWidgetFeedbackResponse

func NewInpageWidgetFeedbackResponse(data []byte) (*InpageWidgetFeedbackResponse, error)

NewInpageWidgetFeedbackResponse creates a new inpage feedback response and unmarshals json API inpage feedback response to Go struct.

type InpageWidgetFeedbackStruct

type InpageWidgetFeedbackStruct struct {
	ID         string                 `json:"id"`
	Date       time.Time              `json:"date"`
	Data       map[string]interface{} `json:"data"`
	CustomData map[string]interface{} `json:"customData"`
	Widget_ID  string                 `json:"widgetId"`
	Rating     float64                `json:"rating"`
	Mood       int                    `json:"mood"`
	Nps        int                    `json:"nps,omitempty"`
	Comment    string                 `json:"comment"`
	UserAgent  string                 `json:"userAgent"`
	Geo        GeoLoc                 `json:"geo"`
	Url        string                 `json:"url"`
}

type InpageWidgetResponse

type InpageWidgetResponse struct {
	Items []InpageWidgetStruct `json:"items"`
	// contains filtered or unexported fields
}

InpageWidgetResponse is a response that lists inpage widgets.

func NewInpageWidgetResponse

func NewInpageWidgetResponse(data []byte) (*InpageWidgetResponse, error)

NewInpageWidgetResponse creates a inpage response and unmarshals json API inpage response to Go struct.

type InpageWidgetStruct

type InpageWidgetStruct struct {
	ID   string    `json:"id"`
	Date time.Time `json:"date"`
	Name string    `json:"name"`
}

type InpageWidgets

type InpageWidgets struct {
	// contains filtered or unexported fields
}

InpageWidgets represents the inpage widgets resource of Usabilla API.

func (*InpageWidgets) Feedback

Results encapsulates the inpage feedback resource.

func (*InpageWidgets) Get

func (c *InpageWidgets) Get(params map[string]string) (*InpageWidgetResponse, error)

//////////// Inpage ////////////// Get function of Inpage resource returns all the Inpage Widgets taking into account the provided query parameters.

Valid query parameters are:

limit int
since string (Time stamp)

type Usabilla

type Usabilla struct {
	Client *http.Client
	// contains filtered or unexported fields
}

Usabilla is the client that exposes all the resources of the Usabilla API. You can provide a custom http client to change the way the client works.

func New

func New(key, secret string, customClient *http.Client) *Usabilla

New creates a new Usabilla instance and sets the auth with key and secret. Client is the default http client. To change the way the client works provide a custom http client. Passing nil will use the http.DefaultClient

func (*Usabilla) AppCampaigns

func (usabilla *Usabilla) AppCampaigns() *AppCampaigns

AppsCampaigns encapsulates the AppCampaigns resource

func (*Usabilla) Apps

func (usabilla *Usabilla) Apps() *Apps

Apps encapsulates the app resource.

func (*Usabilla) Buttons

func (usabilla *Usabilla) Buttons() *Buttons

Buttons encapsulates the button resource.

func (*Usabilla) Campaigns

func (usabilla *Usabilla) Campaigns() *Campaigns

Campaigns encapsulates the campaign resource.

func (*Usabilla) EmailButtons

func (usabilla *Usabilla) EmailButtons() *EmailButtons

EmailButtons encapsulates the email button resource.

func (*Usabilla) InpageWidgets

func (usabilla *Usabilla) InpageWidgets() *InpageWidgets

Inpage encapsulates the app resource.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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