forked from lokalise/go-lokalise-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
78 lines (49 loc) · 2 KB
/
doc.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
/*
Package lokalise provides functions to access the Lokalise web API.
Usage:
import "github.com/lokalise/go-lokalise-api/v2" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/lokalise/go-lokalise-api" // with go modules disabled
Initializing the client
token := os.Getenv("lokalise_token")
client, err := lokalise.New(token)
# General options
You can set global API parameters with the ClientOption functions during the initialization. The following functions are available:
* WithBaseURL
* WithRetryCount
* WithRetryTimeout
* WithConnectionTimeout
* WithDebug
* WithPageLimit
Usage:
Api, err := lokalise.New(
"token-string",
lokalise.WithDebug(true),
...
)
# Objects and models
Individual objects are represented as instances of according structs. Different objects are used for creating and updating in most cases.
Here are some object types:
* Create/Update request objects, i.e. NewKey, NewContributor etc
* Response objects: single/multiple, i.e. KeyResponse/KeysResponse and special , i.e. DeleteKeyResponse. There is no separate ErrorResponse - errors are encapsulated into concrete method's response.
* List options that are used for sending certain options and pagination, i.e. KeyListOptions.
# Request options and pagination
Some resources, such as Projects, Keys, Files, Tasks, Screenshots, Translations have optional parameters for List method (Keys also have an option for Retrieve). These parameters should be set before calling.
All request options could be set inline and separately:
// separately:
keys := client.Keys()
keys.SetListOptions(lokalise.KeyListOptions{
IncludeTranslations: 1,
IncludeComments: 1,
})
resp, err := keys.List("{PROJECT_ID}")
// inline:
client.Keys().WithListOptions(lokalise.KeyListOptions{Limit: 3}).List("{PROJECT_ID}")
There are two parameters, used for pagination: Limit and Page.
t := Api.Teams()
t.SetPageOptions(lokalise.PageOptions{
Page: 2,
Limit: 10,
})
resp, err := t.List()
*/
package lokalise