-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclass.go
More file actions
55 lines (46 loc) · 1.39 KB
/
Copy pathclass.go
File metadata and controls
55 lines (46 loc) · 1.39 KB
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
package leancloud
import "net/url"
const classBaseURL = "classes"
func (cloud *Client) makeClassURL(parts ...string) string {
return cloud.makeURLPrefix(classBaseURL, parts...)
}
func (cloud *Client) createObject(className, jsonData string) (*result, error) {
return cloud.httpPost(cloud.makeClassURL(className), jsonData)
}
func (cloud *Client) getObject(className, objectId, include string) (*result, error) {
p := url.Values{}
p.Add("include", include)
url := cloud.makeClassURL(className, objectId)
return cloud.httpGet(url, p)
}
func (cloud *Client) getObjectDirectly(location string) (*result, error) {
return cloud.httpGet(location, nil)
}
func (cloud *Client) updateObject(className, objectId, jsonData string) (*result, error) {
url := cloud.makeClassURL(className, objectId)
return cloud.httpPut(url, jsonData)
}
func (cloud *Client) deleteObject(className, objectId string) (*result, error) {
url := cloud.makeClassURL(className, objectId)
return cloud.httpDelete(url)
}
func (cloud *Client) queryObject(className, whereJson, limit, skip, order, keys string) (*result, error) {
p := url.Values{}
if whereJson != "" {
p.Add("where", whereJson)
}
if limit != "" {
p.Add("limit", limit)
}
if skip != "" {
p.Add("skip", skip)
}
if order != "" {
p.Add("order", order)
}
if keys != "" {
p.Add("keys", keys)
}
url := cloud.makeClassURL(className)
return cloud.httpGet(url, p)
}