Documentation
¶
Index ¶
- Constants
- func SendPostBytes(url string, content []byte, authCode string) (string, error)
- func SendPostBytes2(url string, data []byte, authCode string) (string, error)
- func SendPostString(url, content, authCode string) (string, error)
- func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(net, addr string) (c net.Conn, err error)
- func UnmarshalResponse(rsp string) (map[string]interface{}, error)
- type AndroidNotice
- type Audience
- type HttpRequest
- func (b *HttpRequest) Body(data interface{}) *HttpRequest
- func (b *HttpRequest) Bytes() ([]byte, error)
- func (b *HttpRequest) Header(key, value string) *HttpRequest
- func (b *HttpRequest) Param(key, value string) *HttpRequest
- func (b *HttpRequest) Response() (*http.Response, error)
- func (b *HttpRequest) SetBasicAuth(userName, password string) *HttpRequest
- func (b *HttpRequest) SetCookie(cookie *http.Cookie) *HttpRequest
- func (b *HttpRequest) SetProtocolVersion(vers string) *HttpRequest
- func (b *HttpRequest) SetProxy(proxy func(*http.Request) (*url.URL, error)) *HttpRequest
- func (b *HttpRequest) SetTLSClientConfig(config *tls.Config) *HttpRequest
- func (b *HttpRequest) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *HttpRequest
- func (b *HttpRequest) SetTransport(transport http.RoundTripper) *HttpRequest
- func (b *HttpRequest) String() (string, error)
- func (b *HttpRequest) ToFile(filename string) error
- func (b *HttpRequest) ToJson(v interface{}) error
- func (b *HttpRequest) ToXML(v interface{}) error
- type IOSNotice
- type Message
- type Notice
- type Option
- type PayLoad
- func (p *PayLoad) Set3rdNotice(notice *ThirdPartyNotice)
- func (p *PayLoad) SetAudience(ad *Audience)
- func (p *PayLoad) SetMessage(m *Message)
- func (p *PayLoad) SetNotice(notice *Notice)
- func (p *PayLoad) SetOptions(o *Option)
- func (p *PayLoad) SetPlatform(pf *Platform)
- func (p *PayLoad) ToBytes() ([]byte, error)
- type Platform
- type PushClient
- func (this *PushClient) CreateSchedule(data []byte) (string, error)
- func (this *PushClient) DeleteSchedule(id string) (string, error)
- func (this *PushClient) GetReport(msg_ids string) (string, error)
- func (this *PushClient) GetSchedule(id string) (string, error)
- func (this *PushClient) Send(data []byte) (string, error)
- func (this *PushClient) SendDeleteScheduleRequest(schedule_id string, url string) (string, error)
- func (this *PushClient) SendGetReportRequest(msg_ids string, url string) (string, error)
- func (this *PushClient) SendGetScheduleRequest(schedule_id string, url string) (string, error)
- func (this *PushClient) SendPushBytes(content []byte) (string, error)
- func (this *PushClient) SendPushString(content string) (string, error)
- func (this *PushClient) SendScheduleBytes(content []byte, url string) (string, error)
- type Schedule
- type ThirdPartyNotice
- type WinPhoneNotice
Constants ¶
const ( TAG = "tag" TAG_AND = "tag_and" TAG_NOT = "tag_not" ALIAS = "alias" ID = "registration_id" )
const ( CHARSET = "UTF-8" CONTENT_TYPE_JSON = "application/json" DEFAULT_CONNECTION_TIMEOUT = 20 //seconds DEFAULT_SOCKET_TIMEOUT = 30 // seconds )
const ( IOS = "ios" ANDROID = "android" WINPHONE = "winphone" )
const ( SUCCESS_FLAG = "msg_id" HOST_NAME_SSL = "https://api.jpush.cn/v3/push" HOST_SCHEDULE = "https://api.jpush.cn/v3/schedules" HOST_REPORT = "https://report.jpush.cn/v3/received" BASE64_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" )
Variables ¶
This section is empty.
Functions ¶
func SendPostBytes ¶
func SendPostString ¶
func TimeoutDialer ¶
func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(net, addr string) (c net.Conn, err error)
TimeoutDialer returns functions of connection dialer with timeout settings for http.Transport Dial field.
func UnmarshalResponse ¶
Types ¶
type AndroidNotice ¶
type AndroidNotice struct { Alert string `json:"alert"` Title string `json:"title,omitempty"` UriActivity string `json:"uri_activity,omitempty"` UriAction string `json:"uri_action,omitempty"` BuilderId int `json:"builder_id,omitempty"` Style int `json:"style,omitempty"` Inbox map[string]interface{} `json:"inbox,omitempty"` Extras map[string]interface{} `json:"extras,omitempty"` }
type Audience ¶
type Audience struct { Object interface{} // contains filtered or unexported fields }
type HttpRequest ¶
type HttpRequest struct {
// contains filtered or unexported fields
}
HttpRequest provides more useful methods for requesting one url than http.Request.
func Delete ¶
func Delete(url string) *HttpRequest
func (*HttpRequest) Body ¶
func (b *HttpRequest) Body(data interface{}) *HttpRequest
Body adds request raw body. it supports string and []byte.
func (*HttpRequest) Bytes ¶
func (b *HttpRequest) Bytes() ([]byte, error)
Bytes returns the body []byte in response. it calls Response inner.
func (*HttpRequest) Header ¶
func (b *HttpRequest) Header(key, value string) *HttpRequest
Header add header item string in request.
func (*HttpRequest) Param ¶
func (b *HttpRequest) Param(key, value string) *HttpRequest
Param adds query param in to request. params build query string as ?key1=value1&key2=value2...
func (*HttpRequest) Response ¶
func (b *HttpRequest) Response() (*http.Response, error)
Response executes request client gets response mannually.
func (*HttpRequest) SetBasicAuth ¶
func (b *HttpRequest) SetBasicAuth(userName, password string) *HttpRequest
func (*HttpRequest) SetCookie ¶
func (b *HttpRequest) SetCookie(cookie *http.Cookie) *HttpRequest
SetCookie add cookie into request.
func (*HttpRequest) SetProtocolVersion ¶
func (b *HttpRequest) SetProtocolVersion(vers string) *HttpRequest
Set the protocol version for incoming requests. Client requests always use HTTP/1.1.
func (*HttpRequest) SetProxy ¶
func (b *HttpRequest) SetProxy(proxy func(*http.Request) (*url.URL, error)) *HttpRequest
Set http proxy example:
func(req *http.Request) (*url.URL, error) { u, _ := url.ParseRequestURI("http://127.0.0.1:8118") return u, nil }
func (*HttpRequest) SetTLSClientConfig ¶
func (b *HttpRequest) SetTLSClientConfig(config *tls.Config) *HttpRequest
SetTLSClientConfig sets tls connection configurations if visiting https url.
func (*HttpRequest) SetTimeout ¶
func (b *HttpRequest) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *HttpRequest
SetTimeout sets connect time out and read-write time out for Request.
func (*HttpRequest) SetTransport ¶
func (b *HttpRequest) SetTransport(transport http.RoundTripper) *HttpRequest
Set transport to
func (*HttpRequest) String ¶
func (b *HttpRequest) String() (string, error)
String returns the body string in response. it calls Response inner.
func (*HttpRequest) ToFile ¶
func (b *HttpRequest) ToFile(filename string) error
ToFile saves the body data in response to one file. it calls Response inner.
func (*HttpRequest) ToJson ¶
func (b *HttpRequest) ToJson(v interface{}) error
ToJson returns the map that marshals from the body bytes as json in response . it calls Response inner.
func (*HttpRequest) ToXML ¶
func (b *HttpRequest) ToXML(v interface{}) error
ToXml returns the map that marshals from the body bytes as xml in response . it calls Response inner.
type IOSNotice ¶
type IOSNotice struct { Alert interface{} `json:"alert"` Sound string `json:"sound,omitempty"` Badge string `json:"badge,omitempty"` ContentAvailable bool `json:"content-available,omitempty"` MutableContent bool `json:"mutable-content,omitempty"` Category string `json:"category,omitempty"` Extras map[string]interface{} `json:"extras,omitempty"` }
type Message ¶
type Message struct { Content string `json:"msg_content"` Title string `json:"title,omitempty"` ContentType string `json:"content_type,omitempty"` Extras map[string]interface{} `json:"extras,omitempty"` }
func (*Message) SetContent ¶
func (*Message) SetContentType ¶
type Notice ¶
type Notice struct { Alert string `json:"alert,omitempty"` Android *AndroidNotice `json:"android,omitempty"` IOS *IOSNotice `json:"ios,omitempty"` WINPhone *WinPhoneNotice `json:"winphone,omitempty"` }
func (*Notice) SetAndroidNotice ¶
func (p *Notice) SetAndroidNotice(n *AndroidNotice)
func (*Notice) SetIOSNotice ¶
func (*Notice) SetWinPhoneNotice ¶
func (p *Notice) SetWinPhoneNotice(n *WinPhoneNotice)
type Option ¶
type Option struct { SendNo int `json:"sendno,omitempty"` TimeLive int `json:"time_to_live,omitempty"` ApnsProduction bool `json:"apns_production"` OverrideMsgId int64 `json:"override_msg_id,omitempty"` BigPushDuration int `json:"big_push_duration,omitempty"` ThirdPartyChannel interface{} `json:"third_party_channel,omitempty"` }
func (*Option) SetBigPushDuration ¶
func (*Option) SetOverrideMsgId ¶
func (*Option) SetTimelive ¶
type PayLoad ¶
type PayLoad struct { Platform interface{} `json:"platform"` Audience interface{} `json:"audience"` Notification interface{} `json:"notification,omitempty"` Notification3rd interface{} `json:"notification_3rd,omitempty"` Message interface{} `json:"message,omitempty"` Options *Option `json:"options,omitempty"` }
func NewPushPayLoad ¶
func NewPushPayLoad() *PayLoad
func (*PayLoad) Set3rdNotice ¶
func (p *PayLoad) Set3rdNotice(notice *ThirdPartyNotice)
func (*PayLoad) SetAudience ¶
func (*PayLoad) SetMessage ¶
func (*PayLoad) SetOptions ¶
func (*PayLoad) SetPlatform ¶
type Platform ¶
type Platform struct { Os interface{} // contains filtered or unexported fields }
func (*Platform) AddWinphone ¶
func (this *Platform) AddWinphone()
type PushClient ¶
func NewPushClient ¶
func NewPushClient(secret, appKey string) *PushClient
func (*PushClient) CreateSchedule ¶
func (this *PushClient) CreateSchedule(data []byte) (string, error)
func (*PushClient) DeleteSchedule ¶
func (this *PushClient) DeleteSchedule(id string) (string, error)
func (*PushClient) GetSchedule ¶
func (this *PushClient) GetSchedule(id string) (string, error)
func (*PushClient) SendDeleteScheduleRequest ¶
func (this *PushClient) SendDeleteScheduleRequest(schedule_id string, url string) (string, error)
func (*PushClient) SendGetReportRequest ¶
func (this *PushClient) SendGetReportRequest(msg_ids string, url string) (string, error)
func (*PushClient) SendGetScheduleRequest ¶
func (this *PushClient) SendGetScheduleRequest(schedule_id string, url string) (string, error)
func (*PushClient) SendPushBytes ¶
func (this *PushClient) SendPushBytes(content []byte) (string, error)
func (*PushClient) SendPushString ¶
func (this *PushClient) SendPushString(content string) (string, error)
func (*PushClient) SendScheduleBytes ¶
func (this *PushClient) SendScheduleBytes(content []byte, url string) (string, error)
type Schedule ¶
type Schedule struct { Cid string `json:"cid"` Name string `json:"name"` Enabled bool `json:"enabled"` Trigger map[string]interface{} `json:"trigger"` Push *PayLoad `json:"push"` }
func (*Schedule) PeriodicalTrigger ¶
func (*Schedule) SingleTrigger ¶
type ThirdPartyNotice ¶
type ThirdPartyNotice struct { Title string `json:"title,omitempty"` Content string `json:"content"` UriActivity string `json:"uri_activity,omitempty"` UriAction string `json:"uri_action,omitempty"` Style int `json:"style,omitempty"` Inbox map[string]interface{} `json:"inbox,omitempty"` Extras map[string]interface{} `json:"extras,omitempty"` }