forked from aliforever/gista
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush.go
43 lines (39 loc) · 962 Bytes
/
push.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package gista
import (
"github.com/aliforever/gista/constants"
"github.com/aliforever/gista/errs"
"github.com/aliforever/gista/responses"
)
type push struct {
ig *Instagram
}
func newPush(i *Instagram) *push {
return &push{ig: i}
}
func (p *push) Register(pushChannel, token string) (res *responses.PushRegister, err error) {
if pushChannel != "mqtt" && pushChannel != "gcm" {
err = errs.BadPushChannel(pushChannel)
return
}
res = &responses.PushRegister{}
dt := "android_gcm"
if pushChannel == "mqtt" {
dt = "android_mqtt"
}
mainPushChannel := "false"
if pushChannel == "mqtt" {
mainPushChannel = "true"
}
err = p.ig.client.Request(constants.PushRegister).
SetSignedPost(false).
AddPost("device_type", dt).
AddPost("is_main_push_channel", mainPushChannel).
AddPhoneIdPost().
AddPost("device_token", token).
AddCSRFPost().
AddGuIdPost().
AddUuIdPost().
AddPost("users", *p.ig.AccountId).
GetResponse(res)
return
}