todon-api 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/mastodon/access_token.rb +21 -0
- data/lib/mastodon/account.rb +73 -0
- data/lib/mastodon/app.rb +17 -0
- data/lib/mastodon/base.rb +50 -0
- data/lib/mastodon/card.rb +41 -0
- data/lib/mastodon/client.rb +28 -0
- data/lib/mastodon/collection.rb +27 -0
- 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 +28 -0
- data/lib/mastodon/entities/mention.rb +14 -0
- data/lib/mastodon/error.rb +34 -0
- data/lib/mastodon/field.rb +18 -0
- data/lib/mastodon/filter.rb +29 -0
- data/lib/mastodon/hashtag.rb +19 -0
- data/lib/mastodon/headers.rb +17 -0
- data/lib/mastodon/instance.rb +33 -0
- data/lib/mastodon/list.rb +15 -0
- data/lib/mastodon/media.rb +34 -0
- data/lib/mastodon/notification.rb +30 -0
- data/lib/mastodon/relationship.rb +41 -0
- data/lib/mastodon/rest/accounts.rb +87 -0
- data/lib/mastodon/rest/api.rb +45 -0
- data/lib/mastodon/rest/apps.rb +27 -0
- data/lib/mastodon/rest/client.rb +10 -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 +31 -0
- data/lib/mastodon/rest/notifications.rb +34 -0
- data/lib/mastodon/rest/relationships.rb +126 -0
- data/lib/mastodon/rest/reports.rb +20 -0
- data/lib/mastodon/rest/request.rb +41 -0
- data/lib/mastodon/rest/scheduled_statuses.rb +43 -0
- data/lib/mastodon/rest/search.rb +20 -0
- data/lib/mastodon/rest/statuses.rb +124 -0
- data/lib/mastodon/rest/suggestions.rb +27 -0
- data/lib/mastodon/rest/timelines.rb +60 -0
- data/lib/mastodon/rest/utils.rb +40 -0
- data/lib/mastodon/results.rb +18 -0
- data/lib/mastodon/scheduled_status.rb +25 -0
- data/lib/mastodon/status.rb +96 -0
- data/lib/mastodon/streaming/client.rb +97 -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 +43 -0
- data/lib/mastodon/version.rb +29 -0
- data/lib/mastodon.rb +6 -0
- data/mastodon.gemspec +23 -0
- metadata +175 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/account'
|
3
|
+
require 'mastodon/access_token'
|
4
|
+
|
5
|
+
module Mastodon
|
6
|
+
module REST
|
7
|
+
module Accounts
|
8
|
+
include Mastodon::REST::Utils
|
9
|
+
|
10
|
+
# Retrieve account of authenticated user
|
11
|
+
# @return [Mastodon::Account]
|
12
|
+
def verify_credentials
|
13
|
+
perform_request_with_object(:get, '/api/v1/accounts/verify_credentials', {}, Mastodon::Account)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Update authenticated account attributes
|
17
|
+
# @param params [Hash]
|
18
|
+
# @option params :display_name [String] The name to display in the user's profile
|
19
|
+
# @option params :note [String] A new biography for the user
|
20
|
+
# @option params :avatar [File, StringIO, HTTP::FormData::File]
|
21
|
+
# @option params :header [File, StringIO, HTTP::FormData::File]
|
22
|
+
# @return [Mastodon::Account]
|
23
|
+
def update_credentials(params = {})
|
24
|
+
%i(avatar header).each do |key|
|
25
|
+
next unless params.key?(key)
|
26
|
+
params[key] = params[key].is_a?(HTTP::FormData::File) ? params[key] : HTTP::FormData::File.new(params[key])
|
27
|
+
end
|
28
|
+
|
29
|
+
perform_request_with_object(:patch, '/api/v1/accounts/update_credentials', params, Mastodon::Account)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Retrieve account
|
33
|
+
# @param id [Integer]
|
34
|
+
# @return [Mastodon::Account]
|
35
|
+
def account(id)
|
36
|
+
perform_request_with_object(:get, "/api/v1/accounts/#{id}", {}, Mastodon::Account)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Get a list of followers
|
40
|
+
# @param id [Integer]
|
41
|
+
# @param options [Hash]
|
42
|
+
# @option options :max_id [Integer]
|
43
|
+
# @option options :since_id [Integer]
|
44
|
+
# @option options :min_id [Integer]
|
45
|
+
# @option options :limit [Integer]
|
46
|
+
# @return [Mastodon::Collection<Mastodon::Account>]
|
47
|
+
def followers(id, options = {})
|
48
|
+
perform_request_with_collection(:get, "/api/v1/accounts/#{id}/followers", options, Mastodon::Account)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Get a list of followed accounts
|
52
|
+
# @param id [Integer]
|
53
|
+
# @param options [Hash]
|
54
|
+
# @option options :max_id [Integer]
|
55
|
+
# @option options :since_id [Integer]
|
56
|
+
# @option options :min_id [Integer]
|
57
|
+
# @option options :limit [Integer]
|
58
|
+
# @return [Mastodon::Collection<Mastodon::Account>]
|
59
|
+
def following(id, options = {})
|
60
|
+
perform_request_with_collection(:get, "/api/v1/accounts/#{id}/following", options, Mastodon::Account)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Sign up (requires authentication with client credentials)
|
64
|
+
# @param params [Hash]
|
65
|
+
# @option params :username [String]
|
66
|
+
# @option params :email [String]
|
67
|
+
# @option params :password [String]
|
68
|
+
# @option params :agreement [Boolean]
|
69
|
+
# @option params :locale [String]
|
70
|
+
# @return [Mastodon::AccessToken]
|
71
|
+
def create_account(params = {})
|
72
|
+
perform_request_with_object(:post, '/api/v1/accounts', params, Mastodon::AccessToken)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Search accounts
|
76
|
+
# @param query [String]
|
77
|
+
# @param params [Hash]
|
78
|
+
# @option params :limit [Integer]
|
79
|
+
# @option params :resolve [Boolean] Whether to attempt resolving unknown remote accounts
|
80
|
+
# @option params :following [Boolean] Only return matches the authenticated user follows
|
81
|
+
# @return [Mastodon::Collection<Mastodon::Account>]
|
82
|
+
def search_accounts(query, params = {})
|
83
|
+
perform_request_with_collection(:get, '/api/v1/accounts/search', { q: query }.merge(params), Mastodon::Account)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'mastodon/rest/statuses'
|
2
|
+
require 'mastodon/rest/accounts'
|
3
|
+
require 'mastodon/rest/timelines'
|
4
|
+
require 'mastodon/rest/notifications'
|
5
|
+
require 'mastodon/rest/search'
|
6
|
+
require 'mastodon/rest/relationships'
|
7
|
+
require 'mastodon/rest/media'
|
8
|
+
require 'mastodon/rest/suggestions'
|
9
|
+
require 'mastodon/rest/apps'
|
10
|
+
require 'mastodon/rest/instances'
|
11
|
+
require 'mastodon/rest/custom_emojis'
|
12
|
+
require 'mastodon/rest/domain_blocks'
|
13
|
+
require 'mastodon/rest/filters'
|
14
|
+
require 'mastodon/rest/endorsements'
|
15
|
+
require 'mastodon/rest/suggestions'
|
16
|
+
require 'mastodon/rest/reports'
|
17
|
+
require 'mastodon/rest/lists'
|
18
|
+
require 'mastodon/rest/scheduled_statuses'
|
19
|
+
require 'mastodon/rest/conversations'
|
20
|
+
|
21
|
+
module Mastodon
|
22
|
+
module REST
|
23
|
+
module API
|
24
|
+
include Mastodon::REST::Statuses
|
25
|
+
include Mastodon::REST::Accounts
|
26
|
+
include Mastodon::REST::Timelines
|
27
|
+
include Mastodon::REST::Notifications
|
28
|
+
include Mastodon::REST::Search
|
29
|
+
include Mastodon::REST::Relationships
|
30
|
+
include Mastodon::REST::Media
|
31
|
+
include Mastodon::REST::Suggestions
|
32
|
+
include Mastodon::REST::Apps
|
33
|
+
include Mastodon::REST::Instances
|
34
|
+
include Mastodon::REST::CustomEmojis
|
35
|
+
include Mastodon::REST::DomainBlocks
|
36
|
+
include Mastodon::REST::Filters
|
37
|
+
include Mastodon::REST::Endorsements
|
38
|
+
include Mastodon::REST::Suggestions
|
39
|
+
include Mastodon::REST::Reports
|
40
|
+
include Mastodon::REST::Lists
|
41
|
+
include Mastodon::REST::ScheduledStatuses
|
42
|
+
include Mastodon::REST::Conversations
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/app'
|
3
|
+
require 'mastodon/entities/app'
|
4
|
+
|
5
|
+
module Mastodon
|
6
|
+
module REST
|
7
|
+
module Apps
|
8
|
+
include Mastodon::REST::Utils
|
9
|
+
|
10
|
+
# Register a new OAuth client app on the target instance
|
11
|
+
# @param name [String]
|
12
|
+
# @param redirect_uri [String]
|
13
|
+
# @param scopes [String]
|
14
|
+
# @param website [String]
|
15
|
+
# @return [Mastodon::App]
|
16
|
+
def create_app(name, redirect_uri, scopes = 'read', website = nil)
|
17
|
+
perform_request_with_object(:post, '/api/v1/apps', { client_name: name, redirect_uris: redirect_uri, scopes: scopes, website: website }, Mastodon::App)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Return currently used app and confirm that client credentials are valid
|
21
|
+
# @return [Mastodon::Entities::App]
|
22
|
+
def verify_app_credentials
|
23
|
+
perform_request_with_object(:get, '/api/v1/apps/verify_credentials', {}, Mastodon::Entities::App)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/conversation'
|
3
|
+
|
4
|
+
module Mastodon
|
5
|
+
module REST
|
6
|
+
module Conversations
|
7
|
+
include Mastodon::REST::Utils
|
8
|
+
|
9
|
+
# Get a list of conversations
|
10
|
+
# @param options [Hash]
|
11
|
+
# @option options :max_id [Integer]
|
12
|
+
# @option options :since_id [Integer]
|
13
|
+
# @option options :min_id [Integer]
|
14
|
+
# @option options :limit [Integer]
|
15
|
+
# @return [Mastodon::Collection<Mastodon::Conversation>]
|
16
|
+
def conversations(options = {})
|
17
|
+
perform_request_with_collection(:get, '/api/v1/conversations', options, Mastodon::Conversation)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Mark a conversation as read
|
21
|
+
# @param id [Integer]
|
22
|
+
# @return [Mastodon::Conversation]
|
23
|
+
def mark_conversation_as_read(id)
|
24
|
+
perform_request_with_object(:post, "/api/v1/conversations/#{id}/read", {}, Mastodon::Conversation)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Delete a conversation. Does not delete statuses in the conversation
|
28
|
+
# @param id [Integer]
|
29
|
+
def delete_conversation(id)
|
30
|
+
perform_request(:delete, "/api/v1/conversations/#{id}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/emoji'
|
3
|
+
|
4
|
+
module Mastodon
|
5
|
+
module REST
|
6
|
+
module CustomEmojis
|
7
|
+
include Mastodon::REST::Utils
|
8
|
+
|
9
|
+
# Get a list of custom emojis on the server
|
10
|
+
# @return [Mastodon::Collection<Mastodon::Emoji>]
|
11
|
+
def custom_emojis
|
12
|
+
perform_request_with_collection('/api/v1/custom_emojis', {}, Mastodon::Emoji)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
|
3
|
+
module Mastodon
|
4
|
+
module REST
|
5
|
+
module DomainBlocks
|
6
|
+
include Mastodon::REST::Utils
|
7
|
+
|
8
|
+
# Get a list of blocked domains
|
9
|
+
# @param options [Hash]
|
10
|
+
# @option options :max_id [Integer]
|
11
|
+
# @option options :since_id [Integer]
|
12
|
+
# @option options :min_id [Integer]
|
13
|
+
# @option options :limit [Integer]
|
14
|
+
# @return [Mastodon::Collection<String>]
|
15
|
+
def domain_blocks(options = {})
|
16
|
+
perform_request_with_collection('/api/v1/domain_blocks', options, String)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Block a domain
|
20
|
+
# @param domain [String]
|
21
|
+
def block_domain(domain)
|
22
|
+
perform_request(:post, '/api/v1/domain_blocks', domain: domain)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Unblock a domain
|
26
|
+
# @param domain [String]
|
27
|
+
def unblock_domain(domain)
|
28
|
+
perform_request(:delete, '/api/v1/domain_blocks', domain: domain)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/account'
|
3
|
+
require 'mastodon/relationship'
|
4
|
+
|
5
|
+
module Mastodon
|
6
|
+
module REST
|
7
|
+
module Endorsements
|
8
|
+
include Mastodon::REST::Utils
|
9
|
+
|
10
|
+
# Get a list of endorsed accounts
|
11
|
+
# @param options [Hash]
|
12
|
+
# @option options :max_id [Integer]
|
13
|
+
# @option options :since_id [Integer]
|
14
|
+
# @option options :min_id [Integer]
|
15
|
+
# @option options :limit [Integer]
|
16
|
+
# @return [Mastodon::Collection<Mastodon::Account>]
|
17
|
+
def endorsements(options = {})
|
18
|
+
perform_request_with_collection('/api/v1/endorsements', options, Mastodon::Account)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Endorse an account (feature on own profile)
|
22
|
+
# @param account_id [Integer]
|
23
|
+
# @return [Mastodon::Relationship]
|
24
|
+
def endorse(account_id)
|
25
|
+
perform_request_with_object(:post, "/api/v1/accounts/#{account_id}/pin", {}, Mastodon::Relationship)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Unendorse an account (no longer feature it on own profile)
|
29
|
+
# @param account_id [Integer]
|
30
|
+
# @return [Mastodon::Relationship]
|
31
|
+
def unendorse(account_id)
|
32
|
+
perform_request_with_object(:post, "/api/v1/accounts/#{account_id}/unpin", {}, Mastodon::Relationship)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/filter'
|
3
|
+
|
4
|
+
module Mastodon
|
5
|
+
module REST
|
6
|
+
module Filters
|
7
|
+
include Mastodon::REST::Utils
|
8
|
+
|
9
|
+
# Get a list of filters
|
10
|
+
# @param options [Hash]
|
11
|
+
# @option options :max_id [Integer]
|
12
|
+
# @option options :since_id [Integer]
|
13
|
+
# @option options :min_id [Integer]
|
14
|
+
# @option options :limit [Integer]
|
15
|
+
# @return [Mastodon::Collection<Mastodon::Filter>]
|
16
|
+
def filters(options = {})
|
17
|
+
perform_request_with_collection('/api/v1/filters', options, Mastodon::Filter)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Retrieve a filter
|
21
|
+
# @param id [Integer]
|
22
|
+
# @return [Mastodon::Filter]
|
23
|
+
def filter(id)
|
24
|
+
perform_request_with_object(:put, "/api/v1/filters/#{id}", {}, Mastodon::Filter)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Create a filter
|
28
|
+
# @param params [Hash]
|
29
|
+
# @option params :phrase [String]
|
30
|
+
# @option params :context [Array<String>]
|
31
|
+
# @option params :irreversible [Boolean]
|
32
|
+
# @option params :whole_word [Boolean]
|
33
|
+
# @option params :expires_in [Integer]
|
34
|
+
# @return [Mastodon::Filter]
|
35
|
+
def create_filter(params = {})
|
36
|
+
params[:'context[]'] = params.delete(:context) if params.key?(:context)
|
37
|
+
perform_request_with_object(:post, '/api/v1/filters', params, Mastodon::Filter)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Update a filter
|
41
|
+
# @param id [Integer]
|
42
|
+
# @param params [Hash]
|
43
|
+
# @option params :phrase [String]
|
44
|
+
# @option params :context [Array<String>]
|
45
|
+
# @option params :irreversible [Boolean]
|
46
|
+
# @option params :whole_word [Boolean]
|
47
|
+
# @option params :expires_in [Integer]
|
48
|
+
# @return [Mastodon::Filter]
|
49
|
+
def update_filter(id, params = {})
|
50
|
+
params[:'context[]'] = params.delete(:context) if params.key?(:context)
|
51
|
+
perform_request_with_object(:put, "/api/v1/filters/#{id}", params, Mastodon::Filter)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Delete a filter
|
55
|
+
# @param id [Integer]
|
56
|
+
def delete_filter(id)
|
57
|
+
perform_request(:delete, "/api/v1/filters/#{id}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/instance'
|
3
|
+
|
4
|
+
module Mastodon
|
5
|
+
module REST
|
6
|
+
module Instances
|
7
|
+
include Mastodon::REST::Utils
|
8
|
+
|
9
|
+
# Retrieve the current instance. Does not require authentication
|
10
|
+
# @return [Mastodon::Instance]
|
11
|
+
def instance
|
12
|
+
perform_request_with_object(:get, '/api/v1/instance', {}, Mastodon::Instance)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Retrieve activity statistics for the current instance. Does not require authentication
|
16
|
+
# @return [Mastodon::Collection<Hash>]
|
17
|
+
def activity
|
18
|
+
perform_request_with_collection(:get, '/api/v1/instance/activity', {}, Hash)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Retrieve domains of instances known to the current instance. Does not require authentication
|
22
|
+
# @return [Mastodon::Collection<String>]
|
23
|
+
def peers
|
24
|
+
perform_request_with_collection(:get, '/api/v1/instance/peers', {}, String)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/list'
|
3
|
+
require 'mastodon/account'
|
4
|
+
|
5
|
+
module Mastodon
|
6
|
+
module REST
|
7
|
+
module Lists
|
8
|
+
include Mastodon::REST::Utils
|
9
|
+
|
10
|
+
# Get a list of your lists
|
11
|
+
# @param options [Hash]
|
12
|
+
# @option options :max_id [Integer]
|
13
|
+
# @option options :since_id [Integer]
|
14
|
+
# @option options :limit [Integer]
|
15
|
+
# @return [Mastodon::Collection<Mastodon::List>]
|
16
|
+
def lists(options = {})
|
17
|
+
perform_request_with_collection(:get, '/api/v1/lists', options, Mastodon::List)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Retrieve a list
|
21
|
+
# @param id [Integer]
|
22
|
+
# @return [Mastodon::List]
|
23
|
+
def list(id)
|
24
|
+
perform_request_with_object(:get, "/api/v1/lists/#{id}", {}, Mastodon::List)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Create a list
|
28
|
+
# @param params [Hash]
|
29
|
+
# @option params :title
|
30
|
+
# @return [Mastodon::List]
|
31
|
+
def create_list(params = {})
|
32
|
+
perform_request_with_object(:post, '/api/v1/lists/', params, Mastodon::List)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Update a list
|
36
|
+
# @param id [Integer]
|
37
|
+
# @param params [Hash]
|
38
|
+
# @option params :title
|
39
|
+
# @return [Mastodon::List]
|
40
|
+
def update_list(id, params = {})
|
41
|
+
perform_request_with_object(:put, "/api/v1/lists/#{id}", params, Mastodon::List)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Delete a list
|
45
|
+
# @param id [Integer]
|
46
|
+
def delete_list(id)
|
47
|
+
perform_request(:delete, "/api/v1/lists/#{id}")
|
48
|
+
end
|
49
|
+
|
50
|
+
# Get a list of accounts on the list
|
51
|
+
# @param id [Integer]
|
52
|
+
# @param options [Hash]
|
53
|
+
# @option options :max_id [Integer]
|
54
|
+
# @option options :since_id [Integer]
|
55
|
+
# @option options :min_id [Integer]
|
56
|
+
# @option options :limit [Integer]
|
57
|
+
# @return [Mastodon::Collection<Mastodon::Account>]
|
58
|
+
def list_accounts(id, options = {})
|
59
|
+
perform_request_with_collection(:get, "/api/v1/lists/#{id}/accounts", options, Mastodon::Account)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Add accounts to a list
|
63
|
+
# @param id [Integer]
|
64
|
+
# @param account_ids [Array<Integer>]
|
65
|
+
def add_accounts_to_list(id, account_ids = [])
|
66
|
+
perform_request(:post, "/api/v1/lists/#{id}/accounts", { 'account_ids[]': account_ids })
|
67
|
+
end
|
68
|
+
|
69
|
+
# Remove accounts from list
|
70
|
+
# @param id [Integer]
|
71
|
+
# @param account_ids [Array<Integer>]
|
72
|
+
def remove_accounts_from_list(id, account_ids = [])
|
73
|
+
perform_request(:delete, "/api/v1/lists/#{id}/accounts", { 'account_ids[]': account_ids })
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/media'
|
3
|
+
|
4
|
+
module Mastodon
|
5
|
+
module REST
|
6
|
+
module Media
|
7
|
+
include Mastodon::REST::Utils
|
8
|
+
|
9
|
+
# Upload a media file
|
10
|
+
# @param file [File, StringIO, HTTP::FormData::File]
|
11
|
+
# @param params [Hash]
|
12
|
+
# @option params :description [String] Alternative text
|
13
|
+
# @option params :focus [String] Two floating points, comma-delimited
|
14
|
+
# @return [Mastodon::Media]
|
15
|
+
def upload_media(file, params = {})
|
16
|
+
file = file.is_a?(HTTP::FormData::File) ? file : HTTP::FormData::File.new(file)
|
17
|
+
perform_request_with_object(:post, '/api/v1/media', { file: file }.merge(params), Mastodon::Media)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Update a media description, can only be updated while it's not associated to a status
|
21
|
+
# @param id [Integer]
|
22
|
+
# @param params [Hash]
|
23
|
+
# @option params :description [String] Alternative text
|
24
|
+
# @option params :focus [String] Two floating points, comma-delimited
|
25
|
+
# @return [Mastodon::Media]
|
26
|
+
def update_media(id, params)
|
27
|
+
perform_request_with_object(:put, "/api/v1/media/#{id}", params, Mastodon::Media)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/notification'
|
3
|
+
|
4
|
+
module Mastodon
|
5
|
+
module REST
|
6
|
+
module Notifications
|
7
|
+
include Mastodon::REST::Utils
|
8
|
+
|
9
|
+
# Get a list of notifications for the authenticated user
|
10
|
+
# @param options [Hash]
|
11
|
+
# @option options :max_id [Integer]
|
12
|
+
# @option options :since_id [Integer]
|
13
|
+
# @option options :min_id [Integer]
|
14
|
+
# @option options :limit [Integer]
|
15
|
+
# @option options :exclude_types [Array<String>]
|
16
|
+
# @return [Mastodon::Collection<Mastodon::Notification>]
|
17
|
+
def notifications(options = {})
|
18
|
+
options[:'exclude_types[]'] = options.delete(:exclude_types) if options.key?(:exclude_types)
|
19
|
+
perform_request_with_collection(:get, '/api/v1/notifications', options, Mastodon::Notification)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Dismiss a notification
|
23
|
+
# @param id [Integer]
|
24
|
+
def dismiss_notification(id)
|
25
|
+
perform_request(:post, "/api/v1/notifications/#{id}/dismiss")
|
26
|
+
end
|
27
|
+
|
28
|
+
# Clear all notifications
|
29
|
+
def clear_notifications
|
30
|
+
perform_request(:post, '/api/v1/notifications/clear')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
require 'mastodon/relationship'
|
3
|
+
require 'mastodon/status'
|
4
|
+
|
5
|
+
module Mastodon
|
6
|
+
module REST
|
7
|
+
module Relationships
|
8
|
+
include Mastodon::REST::Utils
|
9
|
+
|
10
|
+
# Get the relationships of authenticated user towards given other users
|
11
|
+
# @param ids [Integer]
|
12
|
+
# @return [Mastodon::Collection<Mastodon::Relationship>]
|
13
|
+
def relationships(*ids)
|
14
|
+
perform_request_with_collection(:get, '/api/v1/accounts/relationships', { 'id[]': ids }, Mastodon::Relationship)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get a list of pending follow requests
|
18
|
+
# @param options [Hash]
|
19
|
+
# @option options :max_id [Integer]
|
20
|
+
# @option options :since_id [Integer]
|
21
|
+
# @option options :min_id [Integer]
|
22
|
+
# @option options :limit [Integer]
|
23
|
+
# @return [Mastodon::Collection<Mastodon::Account>]
|
24
|
+
def follow_requests(options = {})
|
25
|
+
perform_request_with_collection(:get, '/api/v1/follow_requests', options, Mastodon::Account)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Authorize a follow request
|
29
|
+
# @param id [Integer]
|
30
|
+
def authorize_follow_request(id)
|
31
|
+
perform_request(:post, "/api/v1/follow_requests/#{id}/authorize")
|
32
|
+
end
|
33
|
+
|
34
|
+
# Reject a follow request
|
35
|
+
# @param id [Integer]
|
36
|
+
def reject_follow_request(id)
|
37
|
+
perform_request(:post, "/api/v1/follow_requests/#{id}/reject")
|
38
|
+
end
|
39
|
+
|
40
|
+
# Follow a user
|
41
|
+
# @param id [Integer]
|
42
|
+
# @return [Mastodon::Relationship]
|
43
|
+
def follow(id)
|
44
|
+
perform_request_with_object(:post, "/api/v1/accounts/#{id}/follow", {}, Mastodon::Relationship)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Follow a remote user
|
48
|
+
# @param uri [String] username@domain of the person you want to follow
|
49
|
+
# @return [Mastodon::Account]
|
50
|
+
def remote_follow(uri)
|
51
|
+
perform_request_with_object(:post, '/api/v1/follows', { uri: uri }, Mastodon::Account)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Unfollow a user
|
55
|
+
# @param id [Integer]
|
56
|
+
# @return [Mastodon::Relationship]
|
57
|
+
def unfollow(id)
|
58
|
+
perform_request_with_object(:post, "/api/v1/accounts/#{id}/unfollow", {}, Mastodon::Relationship)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Get a list of blocked accounts
|
62
|
+
# @param options [Hash]
|
63
|
+
# @option options :max_id [Integer]
|
64
|
+
# @option options :since_id [Integer]
|
65
|
+
# @option options :min_id [Integer]
|
66
|
+
# @option options :limit [Integer]
|
67
|
+
# @return [Mastodon::Collection<Mastodon::Account>]
|
68
|
+
def blocks(options = {})
|
69
|
+
perform_request_with_collection(:get, '/api/v1/blocks', options, Mastodon::Account)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Block a user
|
73
|
+
# @param id [Integer]
|
74
|
+
# @return [Mastodon::Relationship]
|
75
|
+
def block(id)
|
76
|
+
perform_request_with_object(:post, "/api/v1/accounts/#{id}/block", {}, Mastodon::Relationship)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Unblock a user
|
80
|
+
# @param id [Integer]
|
81
|
+
# @return [Mastodon::Relationship]
|
82
|
+
def unblock(id)
|
83
|
+
perform_request_with_object(:post, "/api/v1/accounts/#{id}/unblock", {}, Mastodon::Relationship)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Get a list of muted accounts
|
87
|
+
# @param options [Hash]
|
88
|
+
# @option options :max_id [Integer]
|
89
|
+
# @option options :since_id [Integer]
|
90
|
+
# @option options :min_id [Integer]
|
91
|
+
# @option options :limit [Integer]
|
92
|
+
# @return [Mastodon::Collection<Mastodon::Account>]
|
93
|
+
def mutes(options = {})
|
94
|
+
perform_request_with_collection(:get, '/api/v1/mutes', options, Mastodon::Account)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Mute a user
|
98
|
+
# @param id [Integer]
|
99
|
+
# @return [Mastodon::Relationship]
|
100
|
+
def mute(id)
|
101
|
+
perform_request_with_object(:post, "/api/v1/accounts/#{id}/mute", {}, Mastodon::Relationship)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Unmute a user
|
105
|
+
# @param id [Integer]
|
106
|
+
# @return [Mastodon::Relationship]
|
107
|
+
def unmute(id)
|
108
|
+
perform_request_with_object(:post, "/api/v1/accounts/#{id}/unmute", {}, Mastodon::Relationship)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Mute notifications for a status
|
112
|
+
# @param id [Integer]
|
113
|
+
# @return [Mastodon::Status]
|
114
|
+
def mute_status(id)
|
115
|
+
perform_request_with_object(:post, "/api/v1/statuses/#{id}/mute", {}, Mastodon::Status)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Unmute notifications for a status
|
119
|
+
# @param id [Integer]
|
120
|
+
# @return [Mastodon::Status]
|
121
|
+
def unmute_status(id)
|
122
|
+
perform_request_with_object(:post, "/api/v1/statuses/#{id}/unmute", {}, Mastodon::Status)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mastodon/rest/utils'
|
2
|
+
|
3
|
+
module Mastodon
|
4
|
+
module REST
|
5
|
+
module Reports
|
6
|
+
include Mastodon::REST::Utils
|
7
|
+
|
8
|
+
# Create a report
|
9
|
+
# @param account_id [Integer]
|
10
|
+
# @param params [Hash]
|
11
|
+
# @option params :status_ids [Array<Integer>] Statuses to be included in the report
|
12
|
+
# @option params :comment [String] Description of the report
|
13
|
+
# @option params :forward [Boolean] Whether to forward a copy of the report to the origin of the account
|
14
|
+
def create_report(account_id, params = {})
|
15
|
+
params[:'status_ids[]'] = params.delete(:status_ids) if params.key?(:status_ids)
|
16
|
+
perform_request(:post, '/api/v1/reports', { account_id: account_id }.merge(params))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|