pixela

package module
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 11 Imported by: 1

README

English | 日本語

pixela4go

CI MIT License GoDoc Go Report Card Version

Pixela API client for Go.

Cloning count

Documentation

https://godoc.org/github.com/ebc-2in2crc/pixela4go

Installation

$ go get -u github.com/ebc-2in2crc/pixela4go

Usage

package main

import (
	"context"
	"log"

	pixela "github.com/ebc-2in2crc/pixela4go"
)

func main() {
	// Specify the number of retries if you want to retry when the API call is rejected.
	// If you do not want to retry, you do not need to specify it.
	pixela.RetryCount = 10
	
	client := pixela.New("YOUR_NAME", "YOUR_TOKEN")

	// Create new user
	uci := &pixela.UserCreateInput{
		AgreeTermsOfService: pixela.Bool(true),
		NotMinor:            pixela.Bool(true),
		ThanksCode:          pixela.String("thanks-code"),
	}
	result, err := client.User().CreateWithContext(context.Background(), uci)
	if err != nil {
		log.Fatal(err)
	}
	if result.IsSuccess == false {
		log.Fatal(result.Message)
	}

	// Updates the profile information for the user
	upi := &pixela.UserProfileUpdateInput{
		DisplayName:       pixela.String("display-name"),
		GravatarIconEmail: pixela.String("gravatar-icon-email"),
		Title:             pixela.String("title"),
		Timezone:          pixela.String("Asia/Tokyo"),
		AboutURL:          pixela.String("https://github.com/ebc-2in2crc"),
		ContributeURLs:    []string{},
		PinnedGraphID:     pixela.String("pinned-graph-id"),
	}
	result, err = client.UserProfile().UpdateWithContext(context.Background(), upi)
	if err != nil {
		log.Fatal(err)
	}
	if result.IsSuccess == false {
		log.Fatal(result.Message)
	}

	// Create new graph
	gci := &pixela.GraphCreateInput{
		ID:                  pixela.String("graph-id"),
		Name:                pixela.String("graph-name"),
		Unit:                pixela.String("commit"),
		Type:                pixela.String(pixela.GraphTypeInt),
		Color:               pixela.String(pixela.GraphColorShibafu),
		TimeZone:            pixela.String("Asia/Tokyo"),
		SelfSufficient:      pixela.String(pixela.GraphSelfSufficientIncrement),
		IsSecret:            pixela.Bool(true),
		PublishOptionalData: pixela.Bool(true),
	}
	result, err = client.Graph().CreateWithContext(context.Background(), gci)
	if err != nil {
		log.Fatal(err)
	}
	if result.IsSuccess == false {
		log.Fatal(result.Message)
	}

	// Register value
	pci := &pixela.PixelCreateInput{
		Date:     pixela.String("20180915"),
		Quantity: pixela.String("5"),
		GraphID:  pixela.String("graph-id"),
	}
	result, err = client.Pixel().CreateWithContext(context.Background(), pci)
	if err != nil {
		log.Fatal(err)
	}
	if result.IsSuccess == false {
		log.Fatal(result.Message)
	}

	// Create new webhook
	wci := &pixela.WebhookCreateInput{
		GraphID: pixela.String("graph-id"),
		Type:    pixela.String(pixela.WebhookTypeIncrement),
	}
	webhook, err := client.Webhook().CreateWithContext(context.Background(), wci)
	if err != nil {
		log.Fatal(err)
	}
	if webhook.IsSuccess == false {
		log.Fatal(webhook.Message)
	}

	// Invoke webhook
	wii := &pixela.WebhookInvokeInput{WebhookHash: pixela.String("webhook-hash")}
	result, err = client.Webhook().InvokeWithContext(context.Background(), wii)
	if err != nil {
		log.Fatal(err)
	}
	if result.IsSuccess == false {
		log.Fatal(result.Message)
	}
}

Contribution

  1. Fork this repository
  2. Create your issue branch (git checkout -b issue/:id)
  3. Change codes
  4. Run test suite with the make test command and confirm that it passes
  5. Run make fmt
  6. Commit your changes (git commit -am 'Add some feature')
  7. Create new Pull Request

License

MIT

Author

ebc-2in2crc

Documentation

Index

Constants

View Source
const (
	GraphTypeInt   = "int"
	GraphTypeFloat = "float"
)

It is the type of quantity to be handled in the graph. Only int or float are supported.

View Source
const (
	GraphColorShibafu = "shibafu"
	GraphColorMomiji  = "momiji"
	GraphColorSora    = "sora"
	GraphColorIchou   = "ichou"
	GraphColorAjisai  = "ajisai"
	GraphColorKuro    = "kuro"
)

Defines the display color of the pixel in the pixelation graph. shibafu (green), momiji (red), sora (blue), ichou (yellow), ajisai (purple) and kuro (black) are supported as color kind.

View Source
const (
	GraphSelfSufficientIncrement = "increment"
	GraphSelfSufficientDecrement = "decrement"
	GraphSelfSufficientNone      = "none"
)

If SVG graph with this field increment or decrement is referenced, Pixel of this graph itself will be incremented or decremented. It is suitable when you want to record the PVs on a web page or site simultaneously. The specification of increment or decrement is the same as Increment a Pixel and Decrement a Pixel with webhook. If not specified, it is treated as none .

View Source
const (
	GraphModeShort = "short"
	GraphModeBadge = "badge"
	GraphModeLine  = "line"
)

Specify the graph display mode. Supported modes are short (for displaying only about 90 days), badge (Badge format pasted on GitHub README. Information for the last 49 days is expressed in 7 pixels.), and line .

View Source
const (
	GraphModeSimple      = "simple"
	GraphModeSimpleShort = "simple-short"
)

Specify the graph display mode in html format.

View Source
const (
	WebhookTypeAdd       = "add"
	WebhookTypeIncrement = "increment"
	WebhookTypeDecrement = "decrement"
	WebhookTypeStopwatch = "stopwatch"
	WebhookTypeSubtract  = "subtract"
)

Specify the behavior when this Webhook is invoked.

View Source
const APIBaseURL = "https://pixe.la"

APIBaseURL is Base URL for API requests.

View Source
const APIBaseURLForV1 = APIBaseURL + "/v1"

APIBaseURLForV1 is Base URL for API version 1 requests.

View Source
const (
	GraphAppearanceDark = "dark"
)

Dark theme

Variables

View Source
var ErrAPICallRejected = errors.New("api call rejected")

ErrAPICallRejected API call rejected. See: https://help.pixe.la/en/blog/release-request-rejecting

View Source
var RetryCount = 0

RetryCount number of retries when an API call is rejected (max: 20)

Functions

func Bool

func Bool(v bool) *bool

Bool returns a pointer to the bool value passed in.

func BoolValue

func BoolValue(v *bool) bool

BoolValue returns the value of the bool pointer passed in or false if the pointer is nil.

func String

func String(v string) *string

String returns a pointer to the string value passed in.

func StringValue

func StringValue(v *string) string

StringValue returns the value of the string pointer passed in or "" if the pointer is nil.

Types

type Client

type Client struct {
	UserName string
	Token    string
}

A Client manages communication with the Pixela User API.

func New

func New(userName, token string) *Client

New return a new Client instance.

func (*Client) Graph

func (c *Client) Graph() *Graph

Graph returns a new Pixela graph API client.

func (*Client) Pixel

func (c *Client) Pixel() *Pixel

Pixel returns a new Pixela pixel API client.

func (*Client) User

func (c *Client) User() *User

User returns a new Pixela user API client.

func (*Client) UserProfile added in v1.2.0

func (c *Client) UserProfile() *UserProfile

UserProfile returns a new Pixela user profile API client.

func (*Client) Webhook

func (c *Client) Webhook() *Webhook

Webhook returns a new Pixela webhook API client.

type Graph

type Graph struct {
	UserName string
	Token    string
}

A Graph manages communication with the Pixela graph API.

func (*Graph) Add added in v1.7.0

func (g *Graph) Add(input *GraphAddInput) (*Result, error)

Add quantity to the "Pixel" of the day.

func (*Graph) AddWithContext added in v1.7.0

func (g *Graph) AddWithContext(ctx context.Context, input *GraphAddInput) (*Result, error)

AddWithContext quantity to the "Pixel" of the day.

func (*Graph) Create

func (g *Graph) Create(input *GraphCreateInput) (*Result, error)

Create creates a new pixelation graph definition.

func (*Graph) CreateWithContext added in v1.4.0

func (g *Graph) CreateWithContext(ctx context.Context, input *GraphCreateInput) (*Result, error)

CreateWithContext creates a new pixelation graph definition.

func (*Graph) Delete

func (g *Graph) Delete(input *GraphDeleteInput) (*Result, error)

Delete deletes the predefined pixelation graph definition.

func (*Graph) DeleteWithContext added in v1.4.0

func (g *Graph) DeleteWithContext(ctx context.Context, input *GraphDeleteInput) (*Result, error)

DeleteWithContext deletes the predefined pixelation graph definition.

func (*Graph) Get added in v1.3.0

func (g *Graph) Get(input *GraphGetInput) (*GraphDefinition, error)

Get gets predefined pixelation graph definitions.

func (*Graph) GetAll

func (g *Graph) GetAll() (*GraphDefinitions, error)

GetAll gets all predefined pixelation graph definitions.

func (*Graph) GetAllWithContext added in v1.4.0

func (g *Graph) GetAllWithContext(ctx context.Context) (*GraphDefinitions, error)

GetAllWithContext gets all predefined pixelation graph definitions.

func (*Graph) GetPixelDates

func (g *Graph) GetPixelDates(input *GraphGetPixelDatesInput) (*Pixels, error)

GetPixelDates gets a Date list of Pixel registered in the graph specified by graphID. You can specify a period with from and to parameters.

If you do not specify both from and to; You will get a list of 365 days ago from today.

If you specify from only; You will get a list of 365 days from from date.

If you specify to only; You will get a list of 365 days ago from to date.

If you specify both from andto; You will get a list you specify. You can not specify a period greater than 365 days.

func (*Graph) GetPixelDatesWithContext added in v1.4.0

func (g *Graph) GetPixelDatesWithContext(ctx context.Context, input *GraphGetPixelDatesInput) (*Pixels, error)

GetPixelDatesWithContext gets a Date list of Pixel registered in the graph specified by graphID. You can specify a period with from and to parameters.

If you do not specify both from and to; You will get a list of 365 days ago from today.

If you specify from only; You will get a list of 365 days from from date.

If you specify to only; You will get a list of 365 days ago from to date.

If you specify both from andto; You will get a list you specify. You can not specify a period greater than 365 days.

func (*Graph) GetSVG

func (g *Graph) GetSVG(input *GraphGetSVGInput) (string, error)

GetSVG get a graph expressed in SVG format diagram that based on the registered information.

func (*Graph) GetSVGWithContext added in v1.4.0

func (g *Graph) GetSVGWithContext(ctx context.Context, input *GraphGetSVGInput) (string, error)

GetSVGWithContext get a graph expressed in SVG format diagram that based on the registered information.

func (*Graph) GetWithContext added in v1.4.0

func (g *Graph) GetWithContext(ctx context.Context, input *GraphGetInput) (*GraphDefinition, error)

GetWithContext gets predefined pixelation graph definitions.

func (*Graph) Stats

func (g *Graph) Stats(input *GraphStatsInput) (*Stats, error)

Stats gets various statistics based on the registered information.

func (*Graph) StatsWithContext added in v1.4.0

func (g *Graph) StatsWithContext(ctx context.Context, input *GraphStatsInput) (*Stats, error)

StatsWithContext gets various statistics based on the registered information.

func (*Graph) Stopwatch

func (g *Graph) Stopwatch(input *GraphStopwatchInput) (*Result, error)

Stopwatch start and end the measurement of the time.

func (*Graph) StopwatchWithContext added in v1.4.0

func (g *Graph) StopwatchWithContext(ctx context.Context, input *GraphStopwatchInput) (*Result, error)

StopwatchWithContext start and end the measurement of the time.

func (*Graph) Subtract added in v1.7.0

func (g *Graph) Subtract(input *GraphSubtractInput) (*Result, error)

Subtract quantity from the "Pixel" of the day.

func (*Graph) SubtractWithContext added in v1.7.0

func (g *Graph) SubtractWithContext(ctx context.Context, input *GraphSubtractInput) (*Result, error)

SubtractWithContext quantity from the "Pixel" of the day.

func (*Graph) URL

func (g *Graph) URL(input *GraphURLInput) string

URL displays the details of the graph in html format.

func (*Graph) Update

func (g *Graph) Update(input *GraphUpdateInput) (*Result, error)

Update updates predefined pixelation graph definitions. The items that can be updated are limited as compared with the pixelation graph definition creation.

func (*Graph) UpdatePixels added in v1.9.0

func (g *Graph) UpdatePixels(input *GraphUpdatePixelsInput) (*Result, error)

UpdatePixels is used to register multiple Pixels (quantities for a specific day) at a time.

func (*Graph) UpdatePixelsWithContext added in v1.9.0

func (g *Graph) UpdatePixelsWithContext(ctx context.Context, input *GraphUpdatePixelsInput) (*Result, error)

UpdatePixelsWithContext is used to register multiple Pixels (quantities for a specific day) at a time.

func (*Graph) UpdateWithContext added in v1.4.0

func (g *Graph) UpdateWithContext(ctx context.Context, input *GraphUpdateInput) (*Result, error)

UpdateWithContext updates predefined pixelation graph definitions. The items that can be updated are limited as compared with the pixelation graph definition creation.

type GraphAddInput added in v1.7.0

type GraphAddInput struct {
	// ID is a required field
	ID *string `json:"-"`
	// Quantity is a required field
	Quantity *string `json:"quantity"`
}

GraphAddInput is input of Graph.Add().

type GraphCreateInput

type GraphCreateInput struct {
	// ID is a required field
	ID *string `json:"id"`
	// Name is a required field
	Name *string `json:"name"`
	// Unit is a required field
	Unit *string `json:"unit"`
	// Type is a required field
	Type *string `json:"type"`
	// Color is a required field
	Color               *string `json:"color"`
	TimeZone            *string `json:"timezone,omitempty"`
	SelfSufficient      *string `json:"selfSufficient,omitempty"`
	IsSecret            *bool   `json:"isSecret,omitempty"`
	PublishOptionalData *bool   `json:"publishOptionalData,omitempty"`
}

GraphCreateInput is input of Graph.Create().

type GraphDefinition

type GraphDefinition struct {
	ID                  string   `json:"id"`
	Name                string   `json:"name"`
	Unit                string   `json:"unit"`
	Type                string   `json:"type"`
	Color               string   `json:"color"`
	TimeZone            string   `json:"timezone"`
	PurgeCacheURLs      []string `json:"purgeCacheURLs"`
	SelfSufficient      string   `json:"selfSufficient"`
	IsSecret            bool     `json:"isSecret"`
	PublishOptionalData bool     `json:"publishOptionalData"`
	Result
}

GraphDefinition is graph definition.

type GraphDefinitions

type GraphDefinitions struct {
	Graphs []GraphDefinition `json:"graphs"`
	Result
}

GraphDefinitions is graph definition list.

type GraphDeleteInput

type GraphDeleteInput struct {
	// ID is a required field
	ID *string `json:"-"`
}

GraphDeleteInput is input of Graph.Delete().

type GraphGetInput added in v1.3.0

type GraphGetInput struct {
	// ID is a required field
	ID *string `json:"-"`
}

GraphGetInput is input of Graph.Get().

type GraphGetPixelDatesInput

type GraphGetPixelDatesInput struct {
	// ID is a required field
	ID       *string
	From     *string
	To       *string
	WithBody *bool
}

GraphGetPixelDatesInput is input of Graph.GetPixelDates().

type GraphGetSVGInput

type GraphGetSVGInput struct {
	// ID is a required field
	ID         *string `json:"-"`
	Date       *string `json:"date,omitempty"`
	Mode       *string `json:"mode,omitempty"`
	Appearance *string `json:"appearance,omitempty"`
}

GraphGetSVGInput is input of Graph.GetSVG().

type GraphStatsInput

type GraphStatsInput struct {
	// ID is a required field
	ID *string
}

GraphStatsInput is input of Graph.Stats().

type GraphStopwatchInput

type GraphStopwatchInput struct {
	// ID is a required field
	ID *string
}

GraphStopwatchInput is input of Graph.Stopwatch().

type GraphSubtractInput added in v1.7.0

type GraphSubtractInput struct {
	// ID is a required field
	ID *string `json:"-"`
	// Quantity is a required field
	Quantity *string `json:"quantity"`
}

GraphSubtractInput is input of Graph.Subtract().

type GraphURLInput

type GraphURLInput struct {
	// ID is a required field
	ID   *string `json:"-"`
	Mode *string
}

GraphURLInput is input of Graph.GetURL().

type GraphUpdateInput

type GraphUpdateInput struct {
	// ID is a required field
	ID                  *string  `json:"-"`
	Name                *string  `json:"name,omitempty"`
	Unit                *string  `json:"unit,omitempty"`
	Color               *string  `json:"color,omitempty"`
	TimeZone            *string  `json:"timezone,omitempty"`
	PurgeCacheURLs      []string `json:"purgeCacheURLs,omitempty"`
	SelfSufficient      *string  `json:"selfSufficient,omitempty"`
	IsSecret            *bool    `json:"isSecret,omitempty"`
	PublishOptionalData *bool    `json:"publishOptionalData,omitempty"`
}

GraphUpdateInput is input of Graph.Update().

type GraphUpdatePixelsInput added in v1.9.0

type GraphUpdatePixelsInput struct {
	// ID is a required field
	ID     *string      `json:"-"`
	Pixels []PixelInput `json:"-"`
}

GraphUpdatePixelsInput is input of Graph.UpdatePixels().

type Pixel

type Pixel struct {
	UserName string
	Token    string
}

A Pixel manages communication with the Pixela pixel API.

func (*Pixel) Create

func (p *Pixel) Create(input *PixelCreateInput) (*Result, error)

Create records the quantity of the specified date as a "Pixel".

func (*Pixel) CreateWithContext added in v1.4.0

func (p *Pixel) CreateWithContext(ctx context.Context, input *PixelCreateInput) (*Result, error)

CreateWithContext records the quantity of the specified date as a "Pixel".

func (*Pixel) Decrement

func (p *Pixel) Decrement(input *PixelDecrementInput) (*Result, error)

Decrement decrements quantity "Pixel" of the day (it is used "timezone" setting if Graph's "timezone" is specified, if not specified, calculates it in "UTC"). If the graph type is int then -1 added, and for float then -0.01 added.

func (*Pixel) DecrementWithContext added in v1.4.0

func (p *Pixel) DecrementWithContext(ctx context.Context, input *PixelDecrementInput) (*Result, error)

DecrementWithContext decrements quantity "Pixel" of the day (it is used "timezone" setting if Graph's "timezone" is specified, if not specified, calculates it in "UTC"). If the graph type is int then -1 added, and for float then -0.01 added.

func (*Pixel) Delete

func (p *Pixel) Delete(input *PixelDeleteInput) (*Result, error)

Delete deletes the registered "Pixel".

func (*Pixel) DeleteWithContext added in v1.4.0

func (p *Pixel) DeleteWithContext(ctx context.Context, input *PixelDeleteInput) (*Result, error)

DeleteWithContext deletes the registered "Pixel".

func (*Pixel) Get

func (p *Pixel) Get(input *PixelGetInput) (*Quantity, error)

Get gets registered quantity as "Pixel".

func (*Pixel) GetWithContext added in v1.4.0

func (p *Pixel) GetWithContext(ctx context.Context, input *PixelGetInput) (*Quantity, error)

GetWithContext gets registered quantity as "Pixel".

func (*Pixel) Increment

func (p *Pixel) Increment(input *PixelIncrementInput) (*Result, error)

Increment increments quantity "Pixel" of the day (it is used "timezone" setting if Graph's "timezone" is specified, if not specified, calculates it in "UTC"). If the graph type is int then 1 added, and for float then 0.01 added.

func (*Pixel) IncrementWithContext added in v1.4.0

func (p *Pixel) IncrementWithContext(ctx context.Context, input *PixelIncrementInput) (*Result, error)

IncrementWithContext increments quantity "Pixel" of the day (it is used "timezone" setting if Graph's "timezone" is specified, if not specified, calculates it in "UTC"). If the graph type is int then 1 added, and for float then 0.01 added.

func (*Pixel) Update

func (p *Pixel) Update(input *PixelUpdateInput) (*Result, error)

Update updates the quantity already registered as a "Pixel".

func (*Pixel) UpdateWithContext added in v1.4.0

func (p *Pixel) UpdateWithContext(ctx context.Context, input *PixelUpdateInput) (*Result, error)

UpdateWithContext updates the quantity already registered as a "Pixel".

type PixelCreateInput

type PixelCreateInput struct {
	// GraphID is a required field
	GraphID *string `json:"-"`
	// Date is a required field
	Date *string `json:"date"`
	// Quantity is a required field
	Quantity     *string `json:"quantity"`
	OptionalData *string `json:"optionalData,omitempty"`
}

PixelCreateInput is input of Pixel.Create().

type PixelDecrementInput

type PixelDecrementInput struct {
	// GraphID is a required field
	GraphID *string
}

PixelDecrementInput is input of Pixel.Decrement().

type PixelDeleteInput

type PixelDeleteInput struct {
	// GraphID is a required field
	GraphID *string
	// Date is a required field
	Date *string
}

PixelDeleteInput is input of Pixel.Delete().

type PixelGetInput

type PixelGetInput struct {
	// GraphID is a required field
	GraphID *string
	// Date is required field.
	Date *string
}

PixelGetInput is input of Pixel.Get().

type PixelIncrementInput

type PixelIncrementInput struct {
	// GraphID is a required field
	GraphID *string
}

PixelIncrementInput is input of Pixel.Increment().

type PixelInput added in v1.9.0

type PixelInput struct {
	// Date is a required field
	Date *string `json:"date"`
	// Quantity is a required field
	Quantity     *string `json:"quantity"`
	OptionalData *string `json:"optionalData,omitempty"`
}

PixelInput is input of Graph.UpdatePixels().

type PixelUpdateInput

type PixelUpdateInput struct {
	// GraphID is a required field
	GraphID *string `json:"-"`
	// Date is required field.
	Date         *string `json:"-"`
	Quantity     *string `json:"quantity,omitempty"`
	OptionalData *string `json:"optionalData,omitempty"`
}

PixelUpdateInput is input of Pixel.Update().

type PixelWithBody added in v1.3.0

type PixelWithBody struct {
	Date         string `json:"date"`
	Quantity     string `json:"quantity"`
	OptionalData string `json:"optionalData"`
}

PixelWithBody is Date of Pixel registered in the graph.

type Pixels

type Pixels struct {
	// Pixels as []PixelWithBody when `withBody` is true.
	// Pixels as []string when `withBody` is false.
	Pixels interface{}
	Result
}

Pixels is Date list of Pixel registered in the graph.

type Quantity

type Quantity struct {
	Quantity     string `json:"quantity"`
	OptionalData string `json:"optionalData"`
	Result
}

Quantity ... registered quantity.

type Result

type Result struct {
	Message    string `json:"message"`
	IsSuccess  bool   `json:"isSuccess"`
	IsRejected bool   `json:"isRejected"`
	StatusCode int    `json:"statusCode"`
}

Result is Pixela API Result struct.

type Stats

type Stats struct {
	TotalPixelsCount  int     `json:"totalPixelsCount"`
	MaxQuantity       int     `json:"maxQuantity"`
	MaxDate           string  `json:"maxDate"`
	MinQuantity       int     `json:"minQuantity"`
	MinDate           string  `json:"minDate"`
	TotalQuantity     int     `json:"totalQuantity"`
	AvgQuantity       float64 `json:"avgQuantity"`
	TodaysQuantity    int     `json:"todaysQuantity"`
	YesterdayQuantity int     `json:"yesterdayQuantity"`
	Result
}

Stats is various statistics based on the registered information.

type User

type User struct {
	UserName string
	Token    string
}

A User manages communication with the Pixela user API.

func (*User) Create

func (u *User) Create(input *UserCreateInput) (*Result, error)

Create creates a new Pixela user.

func (*User) CreateWithContext added in v1.4.0

func (u *User) CreateWithContext(ctx context.Context, input *UserCreateInput) (*Result, error)

CreateWithContext creates a new Pixela user.

func (*User) Delete

func (u *User) Delete() (*Result, error)

Delete deletes the specified registered user.

func (*User) DeleteWithContext added in v1.4.0

func (u *User) DeleteWithContext(ctx context.Context) (*Result, error)

DeleteWithContext deletes the specified registered user.

func (*User) Update

func (u *User) Update(input *UserUpdateInput) (*Result, error)

Update updates the authentication token for the specified user.

func (*User) UpdateWithContext added in v1.4.0

func (u *User) UpdateWithContext(ctx context.Context, input *UserUpdateInput) (*Result, error)

UpdateWithContext updates the authentication token for the specified user.

type UserCreateInput

type UserCreateInput struct {
	// AgreeTermsOfService is a required field
	AgreeTermsOfService *bool
	// NotMinor is a required field
	NotMinor   *bool
	ThanksCode *string
}

UserCreateInput is input of User.Create().

type UserProfile added in v1.2.0

type UserProfile struct {
	UserName string
	Token    string
}

A UserProfile manages communication with the Pixela user profile API.

func (*UserProfile) URL added in v1.2.0

func (u *UserProfile) URL() string

URL outputs the profile of the user specified by username in html format.

func (*UserProfile) Update added in v1.2.0

func (u *UserProfile) Update(input *UserProfileUpdateInput) (*Result, error)

Update updates the profile information for the user corresponding to username.

func (*UserProfile) UpdateWithContext added in v1.4.0

func (u *UserProfile) UpdateWithContext(ctx context.Context, input *UserProfileUpdateInput) (*Result, error)

UpdateWithContext updates the profile information for the user corresponding to username.

type UserProfileUpdateInput added in v1.2.0

type UserProfileUpdateInput struct {
	DisplayName       *string  `json:"displayName,omitempty"`
	GravatarIconEmail *string  `json:"gravatarIconEmail,omitempty"`
	Title             *string  `json:"title,omitempty"`
	Timezone          *string  `json:"timezone,omitempty"`
	AboutURL          *string  `json:"aboutURL,omitempty"`
	ContributeURLs    []string `json:"contributeURLs,omitempty"`
	PinnedGraphID     *string  `json:"pinnedGraphID,omitempty"`
}

UserProfileUpdateInput is input of UserProfile.Update().

type UserUpdateInput

type UserUpdateInput struct {
	// NewToken is a required field
	NewToken   *string
	ThanksCode *string
}

UserUpdateInput is input of User.Update().

type Webhook

type Webhook struct {
	UserName string
	Token    string
}

A Webhook manages communication with the Pixela webhook API.

func (*Webhook) Create

func (w *Webhook) Create(input *WebhookCreateInput) (*WebhookCreateResult, error)

Create create a new Webhook.

func (*Webhook) CreateWithContext added in v1.4.0

func (w *Webhook) CreateWithContext(ctx context.Context, input *WebhookCreateInput) (*WebhookCreateResult, error)

CreateWithContext create a new Webhook.

func (*Webhook) Delete

func (w *Webhook) Delete(input *WebhookDeleteInput) (*Result, error)

Delete delete the registered Webhook.

func (*Webhook) DeleteWithContext added in v1.4.0

func (w *Webhook) DeleteWithContext(ctx context.Context, input *WebhookDeleteInput) (*Result, error)

DeleteWithContext delete the registered Webhook.

func (*Webhook) GetAll

func (w *Webhook) GetAll() (*WebhookDefinitions, error)

GetAll get all predefined webhooks definitions.

func (*Webhook) GetAllWithContext added in v1.4.0

func (w *Webhook) GetAllWithContext(ctx context.Context) (*WebhookDefinitions, error)

GetAllWithContext get all predefined webhooks definitions.

func (*Webhook) Invoke

func (w *Webhook) Invoke(input *WebhookInvokeInput) (*Result, error)

Invoke invoke the webhook registered in advance. It is used "timezone" setting as post date if Graph's "timezone" is specified, if not specified, calculates it in "UTC".

func (*Webhook) InvokeWithContext added in v1.4.0

func (w *Webhook) InvokeWithContext(ctx context.Context, input *WebhookInvokeInput) (*Result, error)

InvokeWithContext invoke the webhook registered in advance. It is used "timezone" setting as post date if Graph's "timezone" is specified, if not specified, calculates it in "UTC".

type WebhookCreateInput

type WebhookCreateInput struct {
	// GraphID is a required filed
	GraphID *string `json:"graphID"`
	// Type is a required filed
	Type *string `json:"type"`
}

WebhookCreateInput is input of Webhook.Create().

type WebhookCreateResult

type WebhookCreateResult struct {
	WebhookHash string `json:"webhookHash"`
	Result
}

WebhookCreateResult is Create() Result struct.

type WebhookDefinition

type WebhookDefinition struct {
	WebhookHash string `json:"webhookHash"`
	GraphID     string `json:"graphId"`
	Type        string `json:"type"`
}

WebhookDefinition is webhook definition.

type WebhookDefinitions

type WebhookDefinitions struct {
	Webhooks []WebhookDefinition `json:"webhooks"`
	Result
}

WebhookDefinitions is webhook definition list.

type WebhookDeleteInput

type WebhookDeleteInput struct {
	// WebhookHash is a required filed
	WebhookHash *string
}

WebhookDeleteInput is input of Webhook.Delete().

type WebhookInvokeInput

type WebhookInvokeInput WebhookDeleteInput

WebhookInvokeInput is input of Webhook.Invoke().

Jump to

Keyboard shortcuts

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