author | Mikael Berthe <mikael@lilotux.net> |
Sat, 27 May 2017 13:18:48 +0200 | |
changeset 186 | eb9e257ba50c |
parent 185 | faa72b9877c5 |
child 187 | e1b1f4a168b7 |
permissions | -rw-r--r-- |
130 | 1 |
/* |
2 |
Copyright 2017 Ollivier Robert |
|
3 |
Copyright 2017 Mikael Berthe |
|
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:
136
diff
changeset
|
8 |
package madon |
7 | 9 |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
10 |
import ( |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
11 |
"time" |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
12 |
) |
16
9d64e00d3ea6
Begin to fill in types.
Ollivier Robert <roberto@keltia.net>
parents:
10
diff
changeset
|
13 |
|
138
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
136
diff
changeset
|
14 |
// Client contains data for a madon client application |
74
ba06092b91a6
Rename "Gondole" as "Client" to avoid "gondole.Gondole".
Ollivier Robert <roberto@keltia.net>
parents:
70
diff
changeset
|
15 |
type Client struct { |
131
68ef6504637e
Introduce RestoreApp(), bump library version
Mikael Berthe <mikael@lilotux.net>
parents:
130
diff
changeset
|
16 |
Name string // Name of the client |
68ef6504637e
Introduce RestoreApp(), bump library version
Mikael Berthe <mikael@lilotux.net>
parents:
130
diff
changeset
|
17 |
ID string // Application ID |
68ef6504637e
Introduce RestoreApp(), bump library version
Mikael Berthe <mikael@lilotux.net>
parents:
130
diff
changeset
|
18 |
Secret string // Application secret |
68ef6504637e
Introduce RestoreApp(), bump library version
Mikael Berthe <mikael@lilotux.net>
parents:
130
diff
changeset
|
19 |
APIBase string // API prefix URL |
68ef6504637e
Introduce RestoreApp(), bump library version
Mikael Berthe <mikael@lilotux.net>
parents:
130
diff
changeset
|
20 |
InstanceURL string // Instance base URL |
85 | 21 |
|
131
68ef6504637e
Introduce RestoreApp(), bump library version
Mikael Berthe <mikael@lilotux.net>
parents:
130
diff
changeset
|
22 |
UserToken *UserToken // User token |
10 | 23 |
} |
24 |
||
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
25 |
/* |
138
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
136
diff
changeset
|
26 |
Entities - Everything manipulated/returned by the API |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
27 |
*/ |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
28 |
|
70 | 29 |
// Account represents a Mastodon account entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
30 |
type Account struct { |
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
31 |
ID int64 `json:"id"` |
136
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
32 |
Username string `json:"username"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
33 |
Acct string `json:"acct"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
34 |
DisplayName string `json:"display_name"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
35 |
Note string `json:"note"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
36 |
URL string `json:"url"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
37 |
Avatar string `json:"avatar"` |
182 | 38 |
AvatarStatic string `json:"avatar_static"` |
39 |
HeaderStatic string `json:"header_static"` |
|
136
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
40 |
Locked bool `json:"locked"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
41 |
CreatedAt time.Time `json:"created_at"` |
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
42 |
FollowersCount int64 `json:"followers_count"` |
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
43 |
FollowingCount int64 `json:"following_count"` |
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
44 |
StatusesCount int64 `json:"statuses_count"` |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
45 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
46 |
|
70 | 47 |
// Application represents a Mastodon application entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
48 |
type Application struct { |
70 | 49 |
Name string `json:"name"` |
50 |
Website string `json:"website"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
51 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
52 |
|
70 | 53 |
// Attachment represents a Mastodon attachement entity |
54 |
type Attachment struct { |
|
186
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
55 |
ID int64 `json:"id"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
56 |
Type string `json:"type"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
57 |
URL string `json:"url"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
58 |
RemoteURL *string `json:"remote_url"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
59 |
PreviewURL string `json:"preview_url"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
60 |
TextURL *string `json:"text_url"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
61 |
Meta *interface{} `json:"meta"` |
10 | 62 |
} |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
63 |
|
70 | 64 |
// Card represents a Mastodon card entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
65 |
type Card struct { |
186
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
66 |
URL string `json:"url"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
67 |
Title string `json:"title"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
68 |
Description string `json:"description"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
69 |
Image string `json:"image"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
70 |
Type *string `json:"type"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
71 |
AuthorName *string `json:"author_name"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
72 |
AuthorURL *string `json:"author_url"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
73 |
ProviderName *string `json:"provider_name"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
74 |
ProviderURL *string `json:"provider_url"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
75 |
HTML *string `json:"html"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
76 |
Width *int `json:"width"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
77 |
Height *int `json:"height"` |
70 | 78 |
} |
79 |
||
80 |
// Context represents a Mastodon context entity |
|
81 |
type Context struct { |
|
82 |
Ancestors []Status `json:"ancestors"` |
|
175
2541f5050df3
Fix Descendants spelling
Mikael Berthe <mikael@lilotux.net>
parents:
172
diff
changeset
|
83 |
Descendants []Status `json:"descendants"` |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
84 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
85 |
|
70 | 86 |
// Error represents a Mastodon error entity |
87 |
type Error struct { |
|
88 |
Text string `json:"error"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
89 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
90 |
|
70 | 91 |
// Instance represents a Mastodon instance entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
92 |
type Instance struct { |
70 | 93 |
URI string `json:"uri"` |
94 |
Title string `json:"title"` |
|
95 |
Description string `json:"description"` |
|
96 |
Email string `json:"email"` |
|
147
b682706e2f31
Add version filed (Mastodon 1.3+) to the Instance type
Mikael Berthe <mikael@lilotux.net>
parents:
138
diff
changeset
|
97 |
Version string `json:"version"` |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
98 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
99 |
|
70 | 100 |
// Mention represents a Mastodon mention entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
101 |
type Mention struct { |
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
102 |
ID int64 `json:"id"` |
70 | 103 |
URL string `json:"url"` |
104 |
Username string `json:"username"` |
|
105 |
Acct string `json:"acct"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
106 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
107 |
|
70 | 108 |
// Notification represents a Mastodon notification entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
109 |
type Notification struct { |
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
110 |
ID int64 `json:"id"` |
136
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
111 |
Type string `json:"type"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
112 |
CreatedAt time.Time `json:"created_at"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
113 |
Account *Account `json:"account"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
114 |
Status *Status `json:"status"` |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
115 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
116 |
|
70 | 117 |
// Relationship represents a Mastodon relationship entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
118 |
type Relationship struct { |
186
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
119 |
ID int64 `json:"id"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
120 |
Following bool `json:"following"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
121 |
FollowedBy bool `json:"followed_by"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
122 |
Blocking bool `json:"blocking"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
123 |
Muting bool `json:"muting"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
124 |
Requested bool `json:"requested"` |
eb9e257ba50c
Sync types with current Mastodon documentation
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
125 |
DomainBlocking bool `jsin:"domain_blocking"` |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
126 |
} |
70 | 127 |
|
128 |
// Report represents a Mastodon report entity |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
129 |
type Report struct { |
172
1f8ea3aa20e7
Fix case mistakes in JSON tags
Mikael Berthe <mikael@lilotux.net>
parents:
159
diff
changeset
|
130 |
ID int64 `json:"id"` |
70 | 131 |
ActionTaken string `json:"action_taken"` |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
132 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
133 |
|
70 | 134 |
// Results represents a Mastodon results entity |
135 |
type Results struct { |
|
136 |
Accounts []Account `json:"accounts"` |
|
137 |
Statuses []Status `json:"statuses"` |
|
138 |
Hashtags []string `json:"hashtags"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
139 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
140 |
|
70 | 141 |
// Status represents a Mastodon status entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
142 |
type Status struct { |
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
143 |
ID int64 `json:"id"` |
70 | 144 |
URI string `json:"uri"` |
145 |
URL string `json:"url"` |
|
146 |
Account *Account `json:"account"` |
|
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
147 |
InReplyToID int64 `json:"in_reply_to_id"` |
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
148 |
InReplyToAccountID int64 `json:"in_reply_to_account_id"` |
70 | 149 |
Reblog *Status `json:"reblog"` |
150 |
Content string `json:"content"` |
|
151 |
CreatedAt time.Time `json:"created_at"` |
|
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
152 |
ReblogsCount int64 `json:"reblogs_count"` |
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
153 |
FavouritesCount int64 `json:"favourites_count"` |
70 | 154 |
Reblogged bool `json:"reblogged"` |
155 |
Favourited bool `json:"favourited"` |
|
185
faa72b9877c5
Update types (add Muted to Status entity)
Mikael Berthe <mikael@lilotux.net>
parents:
182
diff
changeset
|
156 |
Muted bool `json:"muted"` |
70 | 157 |
Sensitive bool `json:"sensitive"` |
158 |
SpoilerText string `json:"spoiler_text"` |
|
159 |
Visibility string `json:"visibility"` |
|
160 |
MediaAttachments []Attachment `json:"media_attachments"` |
|
161 |
Mentions []Mention `json:"mentions"` |
|
162 |
Tags []Tag `json:"tags"` |
|
163 |
Application Application `json:"application"` |
|
181
1217aa2a132b
Add status language field
Mikael Berthe <mikael@lilotux.net>
parents:
175
diff
changeset
|
164 |
Language string `json:"language"` |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
165 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
166 |
|
70 | 167 |
// Tag represents a Mastodon tag entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
168 |
type Tag struct { |
70 | 169 |
Name string `json:"name"` |
170 |
URL string `json:"url"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
171 |
} |