author | Mikael Berthe <mikael@lilotux.net> |
Fri, 26 May 2017 11:20:29 +0200 | |
changeset 182 | d360e5a41070 |
parent 181 | 1217aa2a132b |
child 185 | faa72b9877c5 |
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 { |
|
172
1f8ea3aa20e7
Fix case mistakes in JSON tags
Mikael Berthe <mikael@lilotux.net>
parents:
159
diff
changeset
|
55 |
ID int64 `json:"id"` |
70 | 56 |
Type string `json:"type"` |
57 |
URL string `json:"url"` |
|
58 |
RemoteURL string `json:"remote_url"` |
|
59 |
PreviewURL string `json:"preview_url"` |
|
60 |
TextURL string `json:"text_url"` |
|
10 | 61 |
} |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
62 |
|
70 | 63 |
// Card represents a Mastodon card entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
64 |
type Card struct { |
100 | 65 |
URL string `json:"url"` |
66 |
Title string `json:"title"` |
|
67 |
Description string `json:"description"` |
|
68 |
Image string `json:"image"` |
|
70 | 69 |
} |
70 |
||
71 |
// Context represents a Mastodon context entity |
|
72 |
type Context struct { |
|
73 |
Ancestors []Status `json:"ancestors"` |
|
175
2541f5050df3
Fix Descendants spelling
Mikael Berthe <mikael@lilotux.net>
parents:
172
diff
changeset
|
74 |
Descendants []Status `json:"descendants"` |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
75 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
76 |
|
70 | 77 |
// Error represents a Mastodon error entity |
78 |
type Error struct { |
|
79 |
Text string `json:"error"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
80 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
81 |
|
70 | 82 |
// Instance represents a Mastodon instance entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
83 |
type Instance struct { |
70 | 84 |
URI string `json:"uri"` |
85 |
Title string `json:"title"` |
|
86 |
Description string `json:"description"` |
|
87 |
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
|
88 |
Version string `json:"version"` |
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 |
// Mention represents a Mastodon mention entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
92 |
type Mention struct { |
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
93 |
ID int64 `json:"id"` |
70 | 94 |
URL string `json:"url"` |
95 |
Username string `json:"username"` |
|
96 |
Acct string `json:"acct"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
97 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
98 |
|
70 | 99 |
// Notification represents a Mastodon notification entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
100 |
type Notification struct { |
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
101 |
ID int64 `json:"id"` |
136
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
102 |
Type string `json:"type"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
103 |
CreatedAt time.Time `json:"created_at"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
104 |
Account *Account `json:"account"` |
1af0a6199a93
Change CreatedAt fields to time.Time
Mikael Berthe <mikael@lilotux.net>
parents:
133
diff
changeset
|
105 |
Status *Status `json:"status"` |
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 |
// Relationship represents a Mastodon relationship entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
109 |
type Relationship struct { |
182 | 110 |
ID int64 `json:"id"` |
111 |
Following bool `json:"following"` |
|
112 |
FollowedBy bool `json:"followed_by"` |
|
113 |
Blocking bool `json:"blocking"` |
|
114 |
Muting bool `json:"muting"` |
|
115 |
MutingBoosts bool `json:"muting_boosts"` |
|
116 |
Requested bool `json:"requested"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
117 |
} |
70 | 118 |
|
119 |
// Report represents a Mastodon report entity |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
120 |
type Report struct { |
172
1f8ea3aa20e7
Fix case mistakes in JSON tags
Mikael Berthe <mikael@lilotux.net>
parents:
159
diff
changeset
|
121 |
ID int64 `json:"id"` |
70 | 122 |
ActionTaken string `json:"action_taken"` |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
123 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
124 |
|
70 | 125 |
// Results represents a Mastodon results entity |
126 |
type Results struct { |
|
127 |
Accounts []Account `json:"accounts"` |
|
128 |
Statuses []Status `json:"statuses"` |
|
129 |
Hashtags []string `json:"hashtags"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
130 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
131 |
|
70 | 132 |
// Status represents a Mastodon status entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
133 |
type Status struct { |
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
134 |
ID int64 `json:"id"` |
70 | 135 |
URI string `json:"uri"` |
136 |
URL string `json:"url"` |
|
137 |
Account *Account `json:"account"` |
|
159
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
138 |
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
|
139 |
InReplyToAccountID int64 `json:"in_reply_to_account_id"` |
70 | 140 |
Reblog *Status `json:"reblog"` |
141 |
Content string `json:"content"` |
|
142 |
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
|
143 |
ReblogsCount int64 `json:"reblogs_count"` |
408aa794d9bb
s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents:
147
diff
changeset
|
144 |
FavouritesCount int64 `json:"favourites_count"` |
70 | 145 |
Reblogged bool `json:"reblogged"` |
146 |
Favourited bool `json:"favourited"` |
|
147 |
Sensitive bool `json:"sensitive"` |
|
148 |
SpoilerText string `json:"spoiler_text"` |
|
149 |
Visibility string `json:"visibility"` |
|
150 |
MediaAttachments []Attachment `json:"media_attachments"` |
|
151 |
Mentions []Mention `json:"mentions"` |
|
152 |
Tags []Tag `json:"tags"` |
|
153 |
Application Application `json:"application"` |
|
181
1217aa2a132b
Add status language field
Mikael Berthe <mikael@lilotux.net>
parents:
175
diff
changeset
|
154 |
Language string `json:"language"` |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
155 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
156 |
|
70 | 157 |
// Tag represents a Mastodon tag entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
158 |
type Tag struct { |
70 | 159 |
Name string `json:"name"` |
160 |
URL string `json:"url"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
161 |
} |