author | Mikael Berthe <mikael@lilotux.net> |
Mon, 17 Apr 2017 15:22:45 +0200 | |
changeset 133 | 0085bcfc1131 |
parent 131 | 68ef6504637e |
child 136 | 1af0a6199a93 |
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 |
||
7 | 8 |
package gondole |
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 |
|
83
adc39ae774c0
Make it work with non-defaut instances
Mikael Berthe <mikael@lilotux.net>
parents:
74
diff
changeset
|
14 |
// Client contains data for a gondole 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 |
/* |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
26 |
Entities: |
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 |
Everything manipulated/returned by the API |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
29 |
*/ |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
30 |
|
70 | 31 |
// Account represents a Mastodon account entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
32 |
type Account struct { |
70 | 33 |
ID int `json:"id"` |
34 |
Username string `json:"username"` |
|
35 |
Acct string `json:"acct"` |
|
36 |
DisplayName string `json:"display_name"` |
|
37 |
Note string `json:"note"` |
|
38 |
URL string `json:"url"` |
|
39 |
Avatar string `json:"avatar"` |
|
40 |
Header string `json:"header"` |
|
41 |
Locked bool `json:"locked"` |
|
42 |
CreatedAt string `json:"created_at"` |
|
43 |
FollowersCount int `json:"followers_count"` |
|
44 |
FollowingCount int `json:"following_count"` |
|
45 |
StatusesCount int `json:"statuses_count"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
46 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
47 |
|
70 | 48 |
// Application represents a Mastodon application entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
49 |
type Application struct { |
70 | 50 |
Name string `json:"name"` |
51 |
Website string `json:"website"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
52 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
53 |
|
70 | 54 |
// Attachment represents a Mastodon attachement entity |
55 |
type Attachment struct { |
|
56 |
ID int `json:"iD"` |
|
57 |
Type string `json:"type"` |
|
58 |
URL string `json:"url"` |
|
59 |
RemoteURL string `json:"remote_url"` |
|
60 |
PreviewURL string `json:"preview_url"` |
|
61 |
TextURL string `json:"text_url"` |
|
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 { |
100 | 66 |
URL string `json:"url"` |
67 |
Title string `json:"title"` |
|
68 |
Description string `json:"description"` |
|
69 |
Image string `json:"image"` |
|
70 | 70 |
} |
71 |
||
72 |
// Context represents a Mastodon context entity |
|
73 |
type Context struct { |
|
74 |
Ancestors []Status `json:"ancestors"` |
|
75 |
Descendents []Status `json:"descendents"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
76 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
77 |
|
70 | 78 |
// Error represents a Mastodon error entity |
79 |
type Error struct { |
|
80 |
Text string `json:"error"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
81 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
82 |
|
70 | 83 |
// Instance represents a Mastodon instance entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
84 |
type Instance struct { |
70 | 85 |
URI string `json:"uri"` |
86 |
Title string `json:"title"` |
|
87 |
Description string `json:"description"` |
|
88 |
Email string `json:"email"` |
|
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 { |
70 | 93 |
ID int `json:"id"` |
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 { |
70 | 101 |
ID int `json:"id"` |
102 |
Type string `json:"type"` |
|
103 |
CreatedAt string `json:"created_at"` |
|
104 |
Account *Account `json:"account"` |
|
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 { |
133
0085bcfc1131
Add ID to the Relationship structure
Mikael Berthe <mikael@lilotux.net>
parents:
131
diff
changeset
|
110 |
ID int `json:"id"` |
70 | 111 |
Following bool `json:"following"` |
112 |
FollowedBy bool `json:"followed_by"` |
|
113 |
Blocking bool `json:"blocking"` |
|
114 |
Muting bool `json:"muting"` |
|
115 |
Requested bool `json:"requested"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
116 |
} |
70 | 117 |
|
118 |
// Report represents a Mastodon report entity |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
119 |
type Report struct { |
70 | 120 |
ID int `json:"iD"` |
121 |
ActionTaken string `json:"action_taken"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
122 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
123 |
|
70 | 124 |
// Results represents a Mastodon results entity |
125 |
type Results struct { |
|
126 |
Accounts []Account `json:"accounts"` |
|
127 |
Statuses []Status `json:"statuses"` |
|
128 |
Hashtags []string `json:"hashtags"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
129 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
130 |
|
70 | 131 |
// Status represents a Mastodon status entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
132 |
type Status struct { |
70 | 133 |
ID int `json:"id"` |
134 |
URI string `json:"uri"` |
|
135 |
URL string `json:"url"` |
|
136 |
Account *Account `json:"account"` |
|
137 |
InReplyToID int `json:"in_reply_to_id"` |
|
138 |
InReplyToAccountID int `json:"in_reply_to_account_id"` |
|
139 |
Reblog *Status `json:"reblog"` |
|
140 |
Content string `json:"content"` |
|
141 |
CreatedAt time.Time `json:"created_at"` |
|
142 |
ReblogsCount int `json:"reblogs_count"` |
|
143 |
FavouritesCount int `json:"favourites_count"` |
|
144 |
Reblogged bool `json:"reblogged"` |
|
145 |
Favourited bool `json:"favourited"` |
|
146 |
Sensitive bool `json:"sensitive"` |
|
147 |
SpoilerText string `json:"spoiler_text"` |
|
148 |
Visibility string `json:"visibility"` |
|
149 |
MediaAttachments []Attachment `json:"media_attachments"` |
|
150 |
Mentions []Mention `json:"mentions"` |
|
151 |
Tags []Tag `json:"tags"` |
|
152 |
Application Application `json:"application"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
153 |
} |
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
154 |
|
70 | 155 |
// Tag represents a Mastodon tag entity |
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
156 |
type Tag struct { |
70 | 157 |
Name string `json:"name"` |
158 |
URL string `json:"url"` |
|
17
9f17ef336aad
Add all types documented.
Ollivier Robert <roberto@keltia.net>
parents:
16
diff
changeset
|
159 |
} |