author | Mikael Berthe <mikael@lilotux.net> |
Tue, 23 Aug 2022 22:27:55 +0200 | |
changeset 257 | 0b6a4fdf32f8 |
parent 238 | 1c0042e76902 |
child 259 | f807b8fb46c6 |
permissions | -rw-r--r-- |
130 | 1 |
/* |
207 | 2 |
Copyright 2017-2018 Mikael Berthe |
130 | 3 |
Copyright 2017 Ollivier Robert |
4 |
||
5 |
Licensed under the MIT license. Please see the LICENSE file is this directory. |
|
6 |
*/ |
|
7 |
||
138
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
131
diff
changeset
|
8 |
package madon |
7 | 9 |
|
21
555716349f64
Move App stuff into app.go.
Ollivier Robert <roberto@keltia.net>
parents:
13
diff
changeset
|
10 |
import ( |
162
68df3a01e1a7
Use github.com/pkg/errors
Mikael Berthe <mikael@lilotux.net>
parents:
159
diff
changeset
|
11 |
"github.com/pkg/errors" |
21
555716349f64
Move App stuff into app.go.
Ollivier Robert <roberto@keltia.net>
parents:
13
diff
changeset
|
12 |
) |
7 | 13 |
|
149
5f922977d7c7
Add support for limits and paging ({since,max}_id) API parameters
Mikael Berthe <mikael@lilotux.net>
parents:
145
diff
changeset
|
14 |
// LimitParams contains common limit/paging options for the Mastodon REST API |
5f922977d7c7
Add support for limits and paging ({since,max}_id) API parameters
Mikael Berthe <mikael@lilotux.net>
parents:
145
diff
changeset
|
15 |
type LimitParams struct { |
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
158
diff
changeset
|
16 |
Limit int // Number of items per query |
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
158
diff
changeset
|
17 |
SinceID, MaxID int64 // Boundaries |
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
158
diff
changeset
|
18 |
All bool // Get as many items as possible |
149
5f922977d7c7
Add support for limits and paging ({since,max}_id) API parameters
Mikael Berthe <mikael@lilotux.net>
parents:
145
diff
changeset
|
19 |
} |
5f922977d7c7
Add support for limits and paging ({since,max}_id) API parameters
Mikael Berthe <mikael@lilotux.net>
parents:
145
diff
changeset
|
20 |
|
120 | 21 |
// apiCallParams is a map with the parameters for an API call |
22 |
type apiCallParams map[string]string |
|
23 |
||
7 | 24 |
const ( |
138
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
131
diff
changeset
|
25 |
// MadonVersion contains the version of the Madon library |
237 | 26 |
MadonVersion = "2.4.0-dev" |
12
4f58e9f1e2bc
Add APIEndpoint. Fill in Gondole variable.
Ollivier Robert <roberto@keltia.net>
parents:
7
diff
changeset
|
27 |
|
238
1c0042e76902
Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents:
237
diff
changeset
|
28 |
currentAPIPath = "/api" |
77
603dd20de7e1
Use site part of the endpoint but fix "/api/v1". Use FallBack if necessary.
Ollivier Robert <roberto@keltia.net>
parents:
67
diff
changeset
|
29 |
|
83
adc39ae774c0
Make it work with non-defaut instances
Mikael Berthe <mikael@lilotux.net>
parents:
77
diff
changeset
|
30 |
// NoRedirect is the URI for no redirection in the App registration |
21
555716349f64
Move App stuff into app.go.
Ollivier Robert <roberto@keltia.net>
parents:
13
diff
changeset
|
31 |
NoRedirect = "urn:ietf:wg:oauth:2.0:oob" |
7 | 32 |
) |
33 |
||
99
6ec2a44a1bd1
Return error rather than empty entities
Mikael Berthe <mikael@lilotux.net>
parents:
89
diff
changeset
|
34 |
// Error codes |
33
bce8b17415ae
Add new error ErrAlreadyRegistered.
Ollivier Robert <roberto@keltia.net>
parents:
26
diff
changeset
|
35 |
var ( |
138
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
131
diff
changeset
|
36 |
ErrUninitializedClient = errors.New("use of uninitialized madon client") |
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
131
diff
changeset
|
37 |
ErrAlreadyRegistered = errors.New("app already registered") |
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
131
diff
changeset
|
38 |
ErrEntityNotFound = errors.New("entity not found") |
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
131
diff
changeset
|
39 |
ErrInvalidParameter = errors.New("incorrect parameter") |
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
131
diff
changeset
|
40 |
ErrInvalidID = errors.New("incorrect entity ID") |
33
bce8b17415ae
Add new error ErrAlreadyRegistered.
Ollivier Robert <roberto@keltia.net>
parents:
26
diff
changeset
|
41 |
) |