forked from blockfrost/blockfrost-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
88 lines (75 loc) · 2.47 KB
/
types.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
package blockfrost
import "fmt"
const (
CardanoMainNet = "https://cardano-mainnet.blockfrost.io/api/v0"
CardanoTestNet = "https://cardano-testnet.blockfrost.io/api/v0"
CardanoPreProd = "https://cardano-preprod.blockfrost.io/api/v0"
CardanoPreview = "https://cardano-preview.blockfrost.io/api/v0"
IPFSNet = "https://ipfs.blockfrost.io/api/v0"
)
// resource paths
const (
resourceHealth = "health"
resourceHealthClock = "health/clock"
resourceMetrics = "metrics"
resourceMetricsEndpoint = "metrics/endpoints"
resourceBlock = "blocks"
resourceBlocksLatest = "blocks/latest"
resourceBlocksLatestTransactions = "blocks/latest/txs"
resourceBlocksSlot = "blocks/slot"
resourceBlocksEpoch = "blocks/epoch"
)
// APIError is used to describe errors from the API.
// See https://docs.blockfrost.io/#section/Errors
type APIError struct {
Response interface{}
}
func (e *APIError) Error() string {
return fmt.Sprintf("API Error, %+v", e.Response)
}
// Autobanned defines model for HTTP `418` (Auto Banned).
type AutoBanned struct {
Error string `json:"error"`
Message string `json:"message"`
StatusCode int `json:"status_code"`
}
// BadRequest defines model for HTTP `400` (Bad Request)
type BadRequest struct {
Error string `json:"error"`
Message string `json:"message"`
StatusCode int `json:"status_code"`
}
// InternalServerError defines model for HTTP `500` (Internal Server Error)
type InternalServerError struct {
Error string `json:"error"`
Message string `json:"message"`
StatusCode int `json:"status_code"`
}
// NotFound defines model for HTTP `404` (Resource Not Found).
type NotFound struct {
Error string `json:"error"`
Message string `json:"message"`
StatusCode int `json:"status_code"`
}
// OverusageLimit defines model for HTTP `429` (Over Usage).
type OverusageLimit struct {
Error string `json:"error"`
Message string `json:"message"`
StatusCode int `json:"status_code"`
}
// UnauthorizedEror defines model for HTTP `403` (Unauthorized).
type UnauthorizedError struct {
Error string `json:"error"`
Message string `json:"message"`
StatusCode int `json:"status_code"`
}
type Transaction string
// APIQueryParams contains query parameters. Marshalled to
// "count", "page", "order", "from", "to".
type APIQueryParams struct {
Count int
Page int
Order string
From string
To string
}