spearly-sdk-ruby 0.3.2 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff4e69930eb91c2c598d261ecf89ba3054ae06781adcd1b5a65220df547aed41
4
- data.tar.gz: 3d7aa5463bb510214093c434ef2360de11af132cdfb2f9fbc092037b23463711
3
+ metadata.gz: c6ca2e7efcf2a6ef0c4c933c9edd49115fc2c82c5d601c34a84c76ca87bd1602
4
+ data.tar.gz: 2e924b9bf892c8504034bf654acdda7f28d6bdc36cc01b1bc915f6333b4c5648
5
5
  SHA512:
6
- metadata.gz: d668c71f640036c5e34a0a7fef4f2420c5ddfa0503e07930c0e9e114cafb342d4923fd499d58e4354895210dc46f10cdaf8950c140efa2cae2a471b64e5b783e
7
- data.tar.gz: f3d0eba2bd731c73771d0cae35e0ecc0ace751336f28ea023cc001f1a4ff7ce87254c5fabc3497954aa02b5fd7619df67c9f39448a31c12e143b11eea31809d3
6
+ metadata.gz: c73bf97ee424325e8032d2719e25dc38cdfd369fac1f3775af89324f152c513c1a147a3082fefe83dab2b39d03e7f303a75c4a38a54a4e7fbdc5d1fd1c564fb9
7
+ data.tar.gz: aa26cc8cb81db6f9587439fc297915deaf88c5bc61e83266390f25a9e6f37da2571de3eb17f040c12dfb8ad10d5800f8d7385ee4fb48fa813d9dc2b9527fb9fd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.4.0] - 2021-09-13
2
+
3
+ - Error handling improvements
4
+
1
5
  ## [0.3.2] - 2021-09-13
2
6
 
3
7
  - Use the new `Spearly API v2`
@@ -5,7 +5,7 @@ module Spearly
5
5
  module Rails
6
6
  module Helpers
7
7
  def spearly_authorize!
8
- spearly_token
8
+ raise Spearly::Auth::AuthorizationError unless spearly_token
9
9
  end
10
10
 
11
11
  private
@@ -13,18 +13,16 @@ module Spearly
13
13
  def spearly_token
14
14
  @spearly_token ||= begin
15
15
  token = Spearly::Auth::Token.new(request.authorization)
16
- token.info
17
16
 
18
- token
17
+ token.info ? token : nil
19
18
  end
20
19
  end
21
20
 
22
21
  def spearly_user
23
22
  @spearly_user ||= begin
24
23
  user = Spearly::Auth::User.new(request.authorization)
25
- user.find
26
24
 
27
- user
25
+ user.find ? user : nil
28
26
  end
29
27
  end
30
28
  end
@@ -26,12 +26,7 @@ module Spearly
26
26
  'Accept' => 'application/vnd.spearly.v2+json',
27
27
  'Authorization' => @token)
28
28
 
29
- case res.status
30
- when 401
31
- raise Spearly::Auth::AuthorizationError
32
- when 500
33
- raise Spearly::Auth::ServerError
34
- end
29
+ return unless res.status == 200
35
30
 
36
31
  @data = JSON.parse(res.body)
37
32
  end
@@ -26,12 +26,7 @@ module Spearly
26
26
  'Accept' => 'application/vnd.spearly.v2+json',
27
27
  'Authorization' => @token)
28
28
 
29
- case res.status
30
- when 401
31
- raise Spearly::Auth::AuthorizationError
32
- when 500
33
- raise Spearly::Auth::ServerError
34
- end
29
+ return unless res.status == 200
35
30
 
36
31
  @data = JSON.parse(res.body)['data']
37
32
  end
@@ -46,12 +41,7 @@ module Spearly
46
41
  'Accept' => 'application/vnd.spearly.v2+json',
47
42
  'Authorization' => @token)
48
43
 
49
- case res.status
50
- when 401
51
- raise Spearly::Auth::AuthorizationError
52
- when 500
53
- raise Spearly::Auth::ServerError
54
- end
44
+ return [] unless res.status == 200
55
45
 
56
46
  team_hashes = JSON.parse(res.body)['data']
57
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spearly
4
- VERSION = '0.3.2'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spearly-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spearly
@@ -166,7 +166,7 @@ licenses: []
166
166
  metadata:
167
167
  homepage_uri: https://github.com/unimal-jp/spearly-sdk-ruby
168
168
  source_code_uri: https://github.com/unimal-jp/spearly-sdk-ruby
169
- changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.3.2/CHANGELOG.md
169
+ changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.4.0/CHANGELOG.md
170
170
  post_install_message:
171
171
  rdoc_options: []
172
172
  require_paths: