utils

package
v0.0.0-...-877814a Latest Latest
Warning

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

Go to latest
Published: May 30, 2015 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Scope          string = "https://www.googleapis.com/auth/analytics.readonly"
	ReturnURI      string = "localhost:9000"
	LocalStoreFile string = "localStore.dat"
)

Base constants

Variables

This section is empty.

Functions

func BrowserOpen

func BrowserOpen(url string) error

BrowserOpen opens a URL is the OS' default web browser

func CheckError

func CheckError(err error)

Check for normal errors

func ProcessCSV

func ProcessCSV(filename string) (output []string, ok bool)

func ToCSV

func ToCSV(file *os.File, data [][]string) bool

func WebCallback

func WebCallback(ch chan string)

WebCallback listens on a predefined port for a oauth response sends back via channel once it receives a response and shuts down.

Types

type AccessData

type AccessData struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
}

AccessData contains the access and refresh token information received after a successful retrieval from Google or local stores

type AuthCode

type AuthCode struct {
	Code         string `json:"code"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	RedirectURI  string `json:"redirect_uri"`
	GrantType    string `json:"grant_type"`
}

AuthCode is the authorisation code POST request struct for exchanging for access and refresh tokens

func (*AuthCode) ToURLValues

func (a *AuthCode) ToURLValues() (out url.Values)

type AuthData

type AuthData struct {
	ClientID     string   `json:"client_id"`
	ClientSecret string   `json:"client_secret"`
	AuthURI      string   `json:"auth_uri"`
	TokenURI     string   `json:"token_uri"`
	RedirectURIs []string `json:"redirect_uris"`
}

AuthData is the primary struct of JSON config file

type AuthInfo

type AuthInfo struct {
	Data AuthData `json:"installed"`
}

AuthInfo is the outer structure of client_secret.json

type DataFrameData

type DataFrameData struct {
	Index *[]string
	Data  *[]*SeriesData
	Size  int
}

Set of results

func DataFrame

func DataFrame(data *map[string]*SeriesData) *DataFrameData

Create new DataFrame

type Daterange

type Daterange struct {
	Start     string
	End       string
	Precision string
	Segments  []*Daterange
	IsSplit   bool
}

Daterange object

func GenDayRanges

func GenDayRanges(start string, end string) (out []Daterange)

func GenWeekRanges

func GenWeekRanges(start int, end int, year int) (out []Daterange)

func (Daterange) GetDates

func (d Daterange) GetDates()

Get Time objects

func (Daterange) SplitDays

func (d Daterange) SplitDays() bool

Split daterange into days

func (Daterange) SplitMonths

func (d Daterange) SplitMonths() bool

Split daterange into months

func (Daterange) SplitWeeks

func (d Daterange) SplitWeeks() bool

Split daterange into weeks

type DiffMap

type DiffMap [][]int

Diffmap data structure

type GError

type GError struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

GError is the error strucure of oauth2 server response when requesting the token set

type OauthData

type OauthData struct {
	Tokens   *AccessData
	JSONfile string
	// contains filtered or unexported fields
}

Client is the working struct of the library

func (*OauthData) ImportConfig

func (d *OauthData) ImportConfig(filename string) (err error)

ImportConfig imports client secret information from the JSON obtained from Google Developer Console (API console).

func (*OauthData) InitConnection

func (d *OauthData) InitConnection() (err error)

func (*OauthData) ProcessRefreshResponse

func (d *OauthData) ProcessRefreshResponse(contents []byte) (data *RefreshData, err error)

Process token refresh

func (*OauthData) ProcessTokenResponse

func (d *OauthData) ProcessTokenResponse(contents []byte) (data *AccessData, err error)

func (*OauthData) RefreshToken

func (d *OauthData) RefreshToken() (err error)

RefreshToken refreshes access token in case of expiry

func (*OauthData) RegisterClient

func (d *OauthData) RegisterClient() (err error)

type RefreshData

type RefreshData struct {
	AccessToken string `json:"access_token"`
	Expires     int    `json:"expires_in"`
	TokenType   string `json:"token_type"`
}

RefreshData is the token refresh response data structure

type SeriesData

type SeriesData struct {
	Data    *[]interface{}
	Headers *[]string
	Size    int
}

Results Row data structure

func Series

func Series(data *map[string]interface{}) *SeriesData

Initiate Results row

func (*SeriesData) Add

func (s *SeriesData) Add(key string, val interface{}) (ok bool)

func (*SeriesData) ApplyDiff

func (s *SeriesData) ApplyDiff(diff *DiffMap)

Apply DiffMap

func (*SeriesData) Delete

func (s *SeriesData) Delete(key string) (ok bool)

func (*SeriesData) Diff

func (s *SeriesData) Diff(s2 *SeriesData) (out *DiffMap, ok bool)

Find difference between Series

func (*SeriesData) Get

func (s *SeriesData) Get(key string) (loc int, val interface{}, ok bool)

func (*SeriesData) Index

func (s *SeriesData) Index() *[]string

Get column index

func (*SeriesData) SetIndex

func (s *SeriesData) SetIndex(newIndex *[]string) (ok bool)

Set or replace column index

func (*SeriesData) Sum

func (s *SeriesData) Sum() (total float64, ok bool)

If row is made up of numeric numbers, get total

func (*SeriesData) Swap

func (s *SeriesData) Swap(i int, j int)

Swap items

Jump to

Keyboard shortcuts

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