-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructures.go
108 lines (90 loc) · 2.27 KB
/
structures.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package firebase
import (
"context"
"cloud.google.com/go/firestore"
"firebase.google.com/go/auth"
"firebase.google.com/go/messaging"
)
//Client - The client interface with all implemented requests and subs ~WIP
type Client interface {
//Connect - init all the requires clients
Connect(
ctx context.Context,
jsonAdminPath string,
) error
//GetFirestoreClient - return the firestore client
GetFirestoreClient() *firestore.Client
//GetAuthClient - return the auth client
GetAuthClient() *auth.Client
//GetMessagingClient - return the messaging client
GetMessagingClient() *messaging.Client
//FirestoreDocExists checks if the doc exists
FirestoreDocExists(
ctx context.Context,
collection string,
docID string,
) (bool, error)
//FirestoreGet - get a document from collection and ID
FirestoreGet(
ctx context.Context,
collection string,
docID string,
) (map[string]interface{}, error)
//FirestoreGetType - get a document from collection and ID into a typed param
FirestoreGetType(
ctx context.Context,
collection string,
docID string,
dataTo interface{},
) error
//FirestoreSet - Set a document given collection and ID
FirestoreSet(
ctx context.Context,
collection,
docID string,
data map[string]interface{},
merge bool,
) error
//FirestoreSet - Set a document given collection and ID
FirestoreSetType(
ctx context.Context,
collection,
docID string,
dataTo interface{},
merge bool,
) error
//SendMessageTopic - Send message on topic
SendMessageTopic(
ctx context.Context,
topic string,
data map[string]string,
) error
//VerifyToken - verify auth token
VerifyToken(
ctx context.Context,
token string,
) (string, error)
//ListenQueryAsync - listen for query updates
ListenQueryAsync(
ctx context.Context,
collection string,
path string,
operation string,
value interface{},
Listener QueryListener,
) error
}
type firebaseClient struct {
firestore bool
auth bool
messaging bool
authClient *auth.Client
firestoreClient *firestore.Client
messagingClient *messaging.Client
}
//QueryListener - listen for query updates rends a response or an error
type QueryListener func(update *QueryUpdate, err error)
//QueryUpdate -
type QueryUpdate struct {
Update *firestore.QuerySnapshot
}