mastodon-api 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mastodon/error.rb +17 -1
- data/lib/mastodon/rest/request.rb +1 -1
- data/lib/mastodon/rest/statuses.rb +1 -1
- data/lib/mastodon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dadc91d9ffe9a3f067aac7611c8cd9cf83b35d0
|
4
|
+
data.tar.gz: 46dde8e05c454858b8abcbd5a5bf2442b16fe381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 083213560d825076bfbab0ac737c8770e1cc19162aa881a73d201024220fc86aa828edeb2d26c15a2e21e3e3ad3e9cb81b66ad035437d9eb2f84db2139914a1a
|
7
|
+
data.tar.gz: eb2f84556f1be7ae941a156f89a29ef6e3a4b81bc0bf2e3c171ceafbe04d4170f566cadfe6a23eb251c5d02e4104df329f82e7b3243c522ba25e5f62685949c1
|
data/lib/mastodon/error.rb
CHANGED
@@ -7,12 +7,28 @@ module Mastodon
|
|
7
7
|
UnprocessableEntity = Class.new(ClientError)
|
8
8
|
TooManyRequests = Class.new(ClientError)
|
9
9
|
|
10
|
+
ServerError = Class.new(self)
|
11
|
+
InternalServerError = Class.new(ServerError)
|
12
|
+
BadGateway = Class.new(ServerError)
|
13
|
+
ServiceUnavailable = Class.new(ServerError)
|
14
|
+
GatewayTimeout = Class.new(ServerError)
|
15
|
+
|
10
16
|
ERRORS = {
|
11
17
|
400 => Mastodon::Error::BadRequest,
|
12
18
|
401 => Mastodon::Error::Unauthorized,
|
13
19
|
403 => Mastodon::Error::Forbidden,
|
14
20
|
422 => Mastodon::Error::UnprocessableEntity,
|
15
|
-
429 => Mastodon::Error::TooManyRequests
|
21
|
+
429 => Mastodon::Error::TooManyRequests,
|
22
|
+
500 => Mastodon::Error::InternalServerError,
|
23
|
+
502 => Mastodon::Error::BadGateway,
|
24
|
+
503 => Mastodon::Error::ServiceUnavailable,
|
25
|
+
504 => Mastodon::Error::GatewayTimeout
|
16
26
|
}.freeze
|
27
|
+
|
28
|
+
class << self
|
29
|
+
def from_response(body)
|
30
|
+
new(body['error'])
|
31
|
+
end
|
32
|
+
end
|
17
33
|
end
|
18
34
|
end
|
@@ -25,7 +25,7 @@ module Mastodon
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def fail_or_return(code, body)
|
28
|
-
raise Mastodon::Error::ERRORS[code] if Mastodon::Error::ERRORS.include?(code)
|
28
|
+
raise Mastodon::Error::ERRORS[code].from_response(body) if Mastodon::Error::ERRORS.include?(code)
|
29
29
|
body
|
30
30
|
end
|
31
31
|
|
@@ -12,7 +12,7 @@ module Mastodon
|
|
12
12
|
# @param media_ids [Array<Integer>]
|
13
13
|
# @return [Mastodon::Status]
|
14
14
|
def create_status(text, in_reply_to_id = nil, media_ids = [])
|
15
|
-
perform_request_with_object(:post, "/api/v1/statuses", { status: text, in_reply_to_id: in_reply_to_id
|
15
|
+
perform_request_with_object(:post, "/api/v1/statuses", array_param(:media_ids, media_ids).merge({ status: text, in_reply_to_id: in_reply_to_id }), Mastodon::Status)
|
16
16
|
end
|
17
17
|
|
18
18
|
# Retrieve status
|
data/lib/mastodon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mastodon-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugen Rochko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|