-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_raw.go
44 lines (39 loc) · 1.23 KB
/
api_raw.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
package polysdk
import (
"github.com/quanxiang-cloud/go-polysdk/internal/apipath"
)
// doc type
const (
DocRaw = "raw"
DocSwag = "swag"
DocCurl = "curl"
DocJavascript = "javascript"
DocPython = "python"
)
// RawAPIRequest request raw api from polyapi
// apiPath is the full namespace of raw api. eg: /system/raw/sample_raw_api
func (c *PolyClient) RawAPIRequest(fullNamespace string, method string, header Header, data interface{}) (*HTTPResponse, error) {
uri := apipath.Join(apipath.APIRequest, fullNamespace)
return c.DoRequestAPI(uri, method, header, data)
}
type apiDocReq struct {
BodyBase
DocType string `json:"docType"`
TitleFirst bool `json:"titleFirst"`
}
// RawAPIDoc request raw api from polyapi
// fullNamespace is the full namespace of raw api. eg: /system/raw/sample_raw_api
func (c *PolyClient) RawAPIDoc(fullNamespace string, docType string, titleFirst bool) (*HTTPResponse, error) {
d := apiDocReq{
BodyBase: BodyBase{
// Signature: c.bodySign.genBodySignature(),
},
DocType: docType,
TitleFirst: titleFirst,
}
header := Header{
HeaderContentType: []string{MIMEJSON},
}
uri := apipath.Join(apipath.APIDoc, fullNamespace)
return c.DoRequestAPI(uri, MethodPost, header, d)
}