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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: accd7a899ecb47c6c3422e33a0b73616ce4e136b
4
- data.tar.gz: 3391e4cfdcf7954653114bb48504fe8af5160f2d
3
+ metadata.gz: 2dadc91d9ffe9a3f067aac7611c8cd9cf83b35d0
4
+ data.tar.gz: 46dde8e05c454858b8abcbd5a5bf2442b16fe381
5
5
  SHA512:
6
- metadata.gz: 80cd9c0868459f585815ea381d163d1df3f9fca050db242acbbab50982463f38a2b6be9770de59f7ad4b1adf9a393195c4665cbee657b26a9a863e942eb9f0da
7
- data.tar.gz: 57085547060814204777c1153be45118b250a0cf3e26479046ba2d172fa291dec3a39d6027d4c56ba843ed0a968cc1e3282eebf7098590effb9217d0f7a45cea
6
+ metadata.gz: 083213560d825076bfbab0ac737c8770e1cc19162aa881a73d201024220fc86aa828edeb2d26c15a2e21e3e3ad3e9cb81b66ad035437d9eb2f84db2139914a1a
7
+ data.tar.gz: eb2f84556f1be7ae941a156f89a29ef6e3a4b81bc0bf2e3c171ceafbe04d4170f566cadfe6a23eb251c5d02e4104df329f82e7b3243c522ba25e5f62685949c1
@@ -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, media_ids: media_ids }, Mastodon::Status)
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
@@ -11,7 +11,7 @@ module Mastodon
11
11
  end
12
12
 
13
13
  def patch
14
- 0
14
+ 1
15
15
  end
16
16
 
17
17
  def pre
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.0
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-21 00:00:00.000000000 Z
11
+ date: 2016-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http