This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
definitions.go
94 lines (83 loc) · 2.52 KB
/
definitions.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
89
90
91
92
93
94
package moneybutton
// RefreshTokenResponse is used to get a refresh token for getting
// user information from the moneybutton API
//
// Specs: https://docs.moneybutton.com/docs/api-oauth-endpoints.html
type RefreshTokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"` // "Bearer"
ExpiresIn uint32 `json:"expires_in"` // 3600 (default is 1 hour)
RefreshToken string `json:"refresh_token"`
Scope string `json:"scope"`
}
// UserIdentity is the user identity
//
// Specs: https://docs.moneybutton.com/docs/api-rest-user-identity.html
type UserIdentity struct {
Data *userIdentityData `json:"data"`
JSONAPI *jsonAPIVersion `json:"jsonapi"`
}
// userIdentityAttributes is used in identity data
type userIdentityAttributes struct {
ID string `json:"id"`
Name string `json:"name"`
}
// userIdentityData is the identity data
type userIdentityData struct {
Attributes *userIdentityAttributes `json:"attributes"`
ID string `json:"id"`
Type string `json:"type"`
}
// UserProfile is the user fields returned for the user profile
//
// Specs: https://docs.moneybutton.com/docs/api-rest-user-profile.html
type UserProfile struct {
Data *userProfileData `json:"data"`
}
// userProfileAttributes
type userProfileAttributes struct {
AvatarURL string `json:"avatar-url"`
Bio string `json:"bio"`
CreatedAt string `json:"created-at"`
DefaultCurrency string `json:"default-currency"`
DefaultLanguage string `json:"default-language"`
Name string `json:"name"`
PrimaryPaymail string `json:"primary-paymail"`
}
// userProfileData
type userProfileData struct {
Attributes *userProfileAttributes `json:"attributes"`
ID string `json:"id"`
Type string `json:"type"`
}
/*
{
"errors": [
{
"id": "ffb71830-409b-11eb-9032-37efc953c879",
"status": 400,
"title": "Bad Request",
"detail": "Invalid grant: authorization code has expired"
}
],
"jsonapi": {
"version": "1.0"
}
}
*/
// errorResponse is the error response from the MoneyButton API
type errorResponse struct {
Errors []*apiError `json:"errors"`
JSONAPI *jsonAPIVersion `json:"jsonapi"`
}
// apiError is the individual error
type apiError struct {
Detail string `json:"detail"`
ID string `json:"id"`
Status int `json:"status"`
Title string `json:"title"`
}
// jsonAPIVersion is the API version
type jsonAPIVersion struct {
Version string `json:"version"`
}