gaurun-client: github.com/osamingo/gaurun-client Index | Files

package gaurun

import "github.com/osamingo/gaurun-client"

Index

Package Files

client.go error.go struct.go

func NewError Uses

func NewError(resp *http.Response) error

NewError generates *gaurun.Error from *http.Response.

type AndroidSetting Uses

type AndroidSetting struct {
    CollapseKey    string `json:"collapse_key,omitempty"`
    DelayWhileIdle bool   `json:"delay_while_idle,omitempty"`
    TimeToLive     int    `json:"time_to_live,omitempty"`
}

An AndroidSetting has setting fields for FCM/GCM.

type Client Uses

type Client struct {
    Endpoint   *url.URL
    HTTPClient *http.Client
}

A Client for gaurun server.

func NewClient Uses

func NewClient(endpoint string, cli *http.Client) (*Client, error)

NewClient generates a client for gaurun server.

func (*Client) Push Uses

func (cli *Client) Push(c context.Context, p *Payload) error

Push sends a payload to gaurun server.

func (*Client) PushMulti Uses

func (cli *Client) PushMulti(c context.Context, ps ...*Payload) error

PushMulti sends payloads to gaurun server.

type Error Uses

type Error struct {
    StatusCode int
    Response   gaurun.ResponseGaurun
}

An Error is error response from gaurun server.

func (*Error) Error Uses

func (err *Error) Error() string

Error implements error interface.

type Extend Uses

type Extend gaurun.ExtendJSON

An Extend is alias gaurun.ExtendJSON.

type IOSSetting Uses

type IOSSetting struct {
    Badge            int       `json:"badge,omitempty"`
    Sound            string    `json:"sound,omitempty"`
    ContentAvailable bool      `json:"content_available,omitempty"`
    MutableContent   bool      `json:"mutable_content,omitempty"`
    Expiry           int       `json:"expiry,omitempty"`
    Retry            int       `json:"retry,omitempty"`
    Extend           []*Extend `json:"extend,omitempty"`
}

An IOSSetting has setting fields for APNs.

type Notification Uses

type Notification struct {
    Tokens   []string `json:"token"`
    Platform Platform `json:"platform"`
    Message  string   `json:"message"`
    // Metadata
    ID  uint64 `json:"seq_id,omitempty"`
    AndroidSetting
    IOSSetting
}

A Notification has gaurun notification data.

type Payload Uses

type Payload struct {
    Notifications []*Notification `json:"notifications"`
}

A Payload has notifications.

type Platform Uses

type Platform int

A Platform is alias gaurun platform enum.

const (
    // PlatformAndroid is enum for FCM/GCM.
    PlatformAndroid Platform = gaurun.PlatFormAndroid
    // PlatformIOS is enum for APNs.
    PlatformIOS Platform = gaurun.PlatFormIos
)

Package gaurun imports 11 packages (graph). Updated 2018-08-19. Refresh now. Tools for package owners.