mastodon-api 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mastodon.rb +2 -0
- data/lib/mastodon/access_token.rb +21 -0
- data/lib/mastodon/account.rb +44 -2
- data/lib/mastodon/app.rb +8 -1
- data/lib/mastodon/card.rb +41 -0
- data/lib/mastodon/client.rb +8 -1
- data/lib/mastodon/conversation.rb +25 -0
- data/lib/mastodon/emoji.rb +21 -0
- data/lib/mastodon/entities/app.rb +12 -0
- data/lib/mastodon/entities/hashtag.rb +12 -0
- data/lib/mastodon/entities/media.rb +13 -1
- data/lib/mastodon/entities/mention.rb +1 -1
- data/lib/mastodon/field.rb +18 -0
- data/lib/mastodon/filter.rb +29 -0
- data/lib/mastodon/hashtag.rb +19 -0
- data/lib/mastodon/instance.rb +33 -0
- data/lib/mastodon/list.rb +15 -0
- data/lib/mastodon/media.rb +16 -2
- data/lib/mastodon/notification.rb +30 -0
- data/lib/mastodon/relationship.rb +23 -2
- data/lib/mastodon/rest/accounts.rb +52 -9
- data/lib/mastodon/rest/api.rb +24 -0
- data/lib/mastodon/rest/apps.rb +7 -0
- data/lib/mastodon/rest/conversations.rb +34 -0
- data/lib/mastodon/rest/custom_emojis.rb +16 -0
- data/lib/mastodon/rest/domain_blocks.rb +32 -0
- data/lib/mastodon/rest/endorsements.rb +36 -0
- data/lib/mastodon/rest/filters.rb +61 -0
- data/lib/mastodon/rest/instances.rb +28 -0
- data/lib/mastodon/rest/lists.rb +77 -0
- data/lib/mastodon/rest/media.rb +17 -3
- data/lib/mastodon/rest/notifications.rb +34 -0
- data/lib/mastodon/rest/relationships.rb +68 -1
- data/lib/mastodon/rest/reports.rb +20 -0
- data/lib/mastodon/rest/request.rb +7 -3
- data/lib/mastodon/rest/scheduled_statuses.rb +43 -0
- data/lib/mastodon/rest/search.rb +20 -0
- data/lib/mastodon/rest/statuses.rb +57 -5
- data/lib/mastodon/rest/suggestions.rb +13 -2
- data/lib/mastodon/rest/timelines.rb +19 -0
- data/lib/mastodon/rest/utils.rb +3 -3
- data/lib/mastodon/results.rb +18 -0
- data/lib/mastodon/scheduled_status.rb +25 -0
- data/lib/mastodon/status.rb +49 -4
- data/lib/mastodon/streaming/client.rb +96 -0
- data/lib/mastodon/streaming/connection.rb +44 -0
- data/lib/mastodon/streaming/events/filters_change.rb +7 -0
- data/lib/mastodon/streaming/events/status_delete.rb +16 -0
- data/lib/mastodon/streaming/message_parser.rb +23 -0
- data/lib/mastodon/streaming/response.rb +42 -0
- data/lib/mastodon/version.rb +2 -2
- data/mastodon.gemspec +5 -3
- metadata +68 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 964fc483f0637a71cd58ef1b86f1a94dd31dd3a6
|
4
|
+
data.tar.gz: 3188dfd0d8f30b4cc65f12c8e46548340e324159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ac8a2fcad9cb903a21e699ff33397d0c4976bf4eb26304a5cfb9982dc2e493fef0d6790831d8ee0dd143d65c3681f9090711594930b9f2f905bc2415c54c9e6
|
7
|
+
data.tar.gz: a69549432a0183c1e0d5d5faac7eb8635569c149e903b268058ce78afa7e2e843aa588692ce730e8eb7c7896c0478266e4fd5e5b02582dad3aec40acf1d824f3
|
data/lib/mastodon.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Mastodon
|
2
|
+
class AccessToken < Mastodon::Base
|
3
|
+
# @!attribute [r] access_token
|
4
|
+
# @return [String]
|
5
|
+
# @!attribute [r] token_type
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute [r] scope
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute [r] created_at
|
10
|
+
# @return [String]
|
11
|
+
normal_attr_reader :access_token,
|
12
|
+
:token_type,
|
13
|
+
:scope,
|
14
|
+
:created_at
|
15
|
+
|
16
|
+
def initialize(attributes = {})
|
17
|
+
attributes.fetch('access_token')
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/mastodon/account.rb
CHANGED
@@ -1,17 +1,26 @@
|
|
1
|
+
require 'mastodon/emoji'
|
2
|
+
require 'mastodon/field'
|
3
|
+
|
1
4
|
module Mastodon
|
2
5
|
class Account < Mastodon::Base
|
3
6
|
# @!attribute [r] id
|
4
|
-
# @return [
|
7
|
+
# @return [String]
|
5
8
|
# @!attribute [r] username
|
6
9
|
# @return [String]
|
7
10
|
# @!attribute [r] acct
|
8
11
|
# @return [String]
|
12
|
+
# @!attribute [r] display_name
|
13
|
+
# @return [String]
|
9
14
|
# @!attribute [r] url
|
10
15
|
# @return [String]
|
11
16
|
# @!attribute [r] avatar
|
12
17
|
# @return [String]
|
18
|
+
# @!attribute [r] avatar_static
|
19
|
+
# @return [String]
|
13
20
|
# @!attribute [r] header
|
14
21
|
# @return [String]
|
22
|
+
# @!attribute [r] header_static
|
23
|
+
# @return [String]
|
15
24
|
# @!attribute [r] note
|
16
25
|
# @return [String]
|
17
26
|
# @!attribute [r] followers_count
|
@@ -20,8 +29,41 @@ module Mastodon
|
|
20
29
|
# @return [Integer]
|
21
30
|
# @!attribute [r] statuses_count
|
22
31
|
# @return [Integer]
|
32
|
+
# @!attribute [r] created_at
|
33
|
+
# @return [String]
|
34
|
+
# @!attribute [r] locked?
|
35
|
+
# @return [Boolean]
|
36
|
+
# @!attribute [r] bot?
|
37
|
+
# @return [Boolean]
|
38
|
+
# @!attribute [r] moved
|
39
|
+
# @return [Mastodon::Account]
|
40
|
+
# @!attribute [r] emojis
|
41
|
+
# @return [Mastodon::Collection<Mastodon::Emoji>]
|
42
|
+
# @!attribute [r] fields
|
43
|
+
# @return [Mastodon::Collection<Mastodon::Field>]
|
44
|
+
|
45
|
+
normal_attr_reader :id,
|
46
|
+
:username,
|
47
|
+
:acct,
|
48
|
+
:display_name,
|
49
|
+
:created_at,
|
50
|
+
:url,
|
51
|
+
:avatar,
|
52
|
+
:avatar_static,
|
53
|
+
:header,
|
54
|
+
:header_static,
|
55
|
+
:note,
|
56
|
+
:followers_count,
|
57
|
+
:following_count,
|
58
|
+
:statuses_count
|
59
|
+
|
60
|
+
predicate_attr_reader :locked,
|
61
|
+
:bot
|
62
|
+
|
63
|
+
object_attr_reader :moved, Mastodon::Account
|
23
64
|
|
24
|
-
|
65
|
+
collection_attr_reader :emojis, Mastodon::Emoji
|
66
|
+
collection_attr_reader :fields, Mastodon::Field
|
25
67
|
|
26
68
|
def initialize(attributes = {})
|
27
69
|
attributes.fetch('id')
|
data/lib/mastodon/app.rb
CHANGED
@@ -4,7 +4,14 @@ module Mastodon
|
|
4
4
|
# @return [String]
|
5
5
|
# @!attribute [r] client_secret
|
6
6
|
# @return [String]
|
7
|
+
# @!attribute [r] name
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute [r] website
|
10
|
+
# @return [String]
|
7
11
|
|
8
|
-
normal_attr_reader :client_id,
|
12
|
+
normal_attr_reader :client_id,
|
13
|
+
:client_secret,
|
14
|
+
:name,
|
15
|
+
:website
|
9
16
|
end
|
10
17
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Mastodon
|
2
|
+
class Card < Mastodon::Base
|
3
|
+
# @!attribute [r] url
|
4
|
+
# @return [String]
|
5
|
+
# @!attribute [r] title
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute [r] description
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute [r] image
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute [r] type
|
12
|
+
# @return [String]
|
13
|
+
# @!attribute [r] author_name
|
14
|
+
# @return [String]
|
15
|
+
# @!attribute [r] author_url
|
16
|
+
# @return [String]
|
17
|
+
# @!attribute [r] provider_name
|
18
|
+
# @return [String]
|
19
|
+
# @!attribute [r] provider_url
|
20
|
+
# @return [String]
|
21
|
+
# @!attribute [r] html
|
22
|
+
# @return [String]
|
23
|
+
# @!attribute [r] width
|
24
|
+
# @return [String]
|
25
|
+
# @!attribute [r] height
|
26
|
+
# @return [String]
|
27
|
+
|
28
|
+
normal_attr_reader :url,
|
29
|
+
:title,
|
30
|
+
:description,
|
31
|
+
:image,
|
32
|
+
:type,
|
33
|
+
:author_name,
|
34
|
+
:author_url,
|
35
|
+
:provider_name,
|
36
|
+
:provider_url,
|
37
|
+
:html,
|
38
|
+
:width,
|
39
|
+
:height
|
40
|
+
end
|
41
|
+
end
|
data/lib/mastodon/client.rb
CHANGED
@@ -2,7 +2,13 @@ require 'mastodon/version'
|
|
2
2
|
|
3
3
|
module Mastodon
|
4
4
|
class Client
|
5
|
-
|
5
|
+
DEFAULT_TIMEOUT = {
|
6
|
+
connect: 2,
|
7
|
+
read: 5,
|
8
|
+
write: 20,
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
attr_reader :base_url, :bearer_token, :timeout
|
6
12
|
|
7
13
|
# @param options [Hash]
|
8
14
|
# @option options :base_url [String] URL of the instance you want to connect to
|
@@ -10,6 +16,7 @@ module Mastodon
|
|
10
16
|
def initialize(options = {})
|
11
17
|
@base_url = options[:base_url]
|
12
18
|
@bearer_token = options[:bearer_token]
|
19
|
+
@timeout = DEFAULT_TIMEOUT.merge(options[:timeout] || {})
|
13
20
|
end
|
14
21
|
|
15
22
|
# User agent of the client
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'mastodon/account'
|
2
|
+
require 'mastodon/status'
|
3
|
+
|
4
|
+
module Mastodon
|
5
|
+
class Conversation < Mastodon::Base
|
6
|
+
# @!attribute [r] id
|
7
|
+
# @return [String]
|
8
|
+
# @!attribute [r] unread?
|
9
|
+
# @return [Boolean]
|
10
|
+
# @!attribute [r] accounts
|
11
|
+
# @return [Mastodon::Collection<Mastodon::Account>]
|
12
|
+
# @!attribute [r] last_status
|
13
|
+
# @return [Mastodon::Status]
|
14
|
+
|
15
|
+
normal_attr_reader :id
|
16
|
+
predicate_attr_reader :unread
|
17
|
+
collection_attr_reader :accounts, Mastodon::Account
|
18
|
+
object_attr_reader :last_status, Mastodon::Status
|
19
|
+
|
20
|
+
def initialize(attributes = {})
|
21
|
+
attributes.fetch('id')
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Mastodon
|
2
|
+
class Emoji < Mastodon::Base
|
3
|
+
# @!attribute [r] shortcode
|
4
|
+
# @return [String]
|
5
|
+
# @!attribute [r] static_url
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute [r] url
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute [r] visible_in_picker?
|
10
|
+
# @return [Boolean]
|
11
|
+
|
12
|
+
normal_attr_reader :shortcode, :static_url, :url
|
13
|
+
|
14
|
+
predicate_attr_reader :visible_in_picker
|
15
|
+
|
16
|
+
def initialize(attributes = {})
|
17
|
+
attributes.fetch('shortcode')
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -5,12 +5,24 @@ module Mastodon
|
|
5
5
|
# @return [Integer]
|
6
6
|
# @!attribute [r] url
|
7
7
|
# @return [String]
|
8
|
+
# @!attribute [r] remote_url
|
9
|
+
# @return [String]
|
8
10
|
# @!attribute [r] preview_url
|
9
11
|
# @return [String]
|
10
12
|
# @!attribute [r] type
|
11
13
|
# @return [String]
|
14
|
+
# @!attribute [r] meta
|
15
|
+
# @return [Hash]
|
16
|
+
# @!attribute [r] description
|
17
|
+
# @return [String]
|
12
18
|
|
13
|
-
normal_attr_reader :id,
|
19
|
+
normal_attr_reader :id,
|
20
|
+
:url,
|
21
|
+
:remote_url,
|
22
|
+
:preview_url,
|
23
|
+
:type,
|
24
|
+
:meta,
|
25
|
+
:description
|
14
26
|
end
|
15
27
|
end
|
16
28
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Mastodon
|
2
|
+
class Field < Mastodon::Base
|
3
|
+
# @!attribute [r] name
|
4
|
+
# @return [String]
|
5
|
+
# @!attribute [r] value
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute [r] verified_at
|
8
|
+
# @return [String]
|
9
|
+
|
10
|
+
normal_attr_reader :name, :value, :verified_at
|
11
|
+
|
12
|
+
# Is this field a verified link?
|
13
|
+
# @return [Boolean]
|
14
|
+
def verified?
|
15
|
+
attributes['verified_at'].present?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Mastodon
|
2
|
+
class Filter < Mastodon::Base
|
3
|
+
# @!attribute [r] id
|
4
|
+
# @return [String]
|
5
|
+
# @!attribute [r] phrase
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute [r] context
|
8
|
+
# @return [Array<String>]
|
9
|
+
# @!attribute [r] expires_at
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute [r] irreversible?
|
12
|
+
# @return [Boolean]
|
13
|
+
# @!attribute [r] whole_word?
|
14
|
+
# @return [Boolean]
|
15
|
+
|
16
|
+
normal_attr_reader :id,
|
17
|
+
:phrase,
|
18
|
+
:context,
|
19
|
+
:expires_at
|
20
|
+
|
21
|
+
predicate_attr_reader :irreversible,
|
22
|
+
:whole_word
|
23
|
+
|
24
|
+
def initialize(attributes = {})
|
25
|
+
attributes.fetch('id')
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Mastodon
|
2
|
+
class Hashtag < Mastodon::Base
|
3
|
+
# @!attribute [r] name
|
4
|
+
# @return [String]
|
5
|
+
# @!attribute [r] url
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute [r] history
|
8
|
+
# @return [Array<Hash>]
|
9
|
+
|
10
|
+
normal_attr_reader :name,
|
11
|
+
:url,
|
12
|
+
:history
|
13
|
+
|
14
|
+
def initialize(attributes = {})
|
15
|
+
attributes.fetch('name')
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Mastodon
|
2
|
+
class Instance < Mastodon::Base
|
3
|
+
# @!attribute [r] uri
|
4
|
+
# @return [String]
|
5
|
+
# @!attribute [r] title
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute [r] description
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute [r] email
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute [r] version
|
12
|
+
# @return [String]
|
13
|
+
# @!attribute [r] urls
|
14
|
+
# @return [Hash]
|
15
|
+
# @!attribute [r] stats
|
16
|
+
# @return [Hash]
|
17
|
+
# @!attribute [r] languages
|
18
|
+
# @return [Array<String>]
|
19
|
+
# @!attribute [r] contact_account
|
20
|
+
# @return [Mastodon::Account]
|
21
|
+
|
22
|
+
normal_attr_reader :uri,
|
23
|
+
:title,
|
24
|
+
:description,
|
25
|
+
:email,
|
26
|
+
:version,
|
27
|
+
:urls,
|
28
|
+
:stats,
|
29
|
+
:languages
|
30
|
+
|
31
|
+
object_attr_reader :contact_account, Mastodon::Account
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Mastodon
|
2
|
+
class List < Mastodon::Base
|
3
|
+
# @!attribute [r] id
|
4
|
+
# @return [String]
|
5
|
+
# @!attribute [r] title
|
6
|
+
# @return [String]
|
7
|
+
|
8
|
+
normal_attr_reader :id, :title
|
9
|
+
|
10
|
+
def initialize(attributes = {})
|
11
|
+
attributes.fetch('id')
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/mastodon/media.rb
CHANGED
@@ -1,20 +1,34 @@
|
|
1
1
|
module Mastodon
|
2
2
|
class Media < Mastodon::Base
|
3
3
|
# @!attribute [r] id
|
4
|
-
# @return [
|
4
|
+
# @return [String]
|
5
5
|
# @!attribute [r] type
|
6
6
|
# @return [String] Image or video
|
7
7
|
# @!attribute [r] url
|
8
8
|
# @return [String] Full file URL
|
9
|
+
# @!attribute [r] remote_url
|
10
|
+
# @return [String]
|
9
11
|
# @!attribute [r] preview_url
|
10
12
|
# @return [String] URL to preview image
|
11
13
|
# @!attribute [r] text_url
|
12
14
|
# @return [String] URL that can be put into status body and will redirect to the status/media
|
15
|
+
# @!attribute [r] meta
|
16
|
+
# @return [Hash]
|
17
|
+
# @!attribute [r] description
|
18
|
+
# @return [String]
|
13
19
|
|
14
|
-
normal_attr_reader :id,
|
20
|
+
normal_attr_reader :id,
|
21
|
+
:type,
|
22
|
+
:url,
|
23
|
+
:remote_url,
|
24
|
+
:preview_url,
|
25
|
+
:text_url,
|
26
|
+
:meta,
|
27
|
+
:description
|
15
28
|
|
16
29
|
def initialize(attributes = {})
|
17
30
|
attributes.fetch('id')
|
31
|
+
super
|
18
32
|
end
|
19
33
|
end
|
20
34
|
end
|