json_api_client 1.18.0 → 1.19.0

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
  SHA256:
3
- metadata.gz: 3b057aa807765f05d20cfb89d4eadfe4b88737b246242a33632107fb8d6199c2
4
- data.tar.gz: 21872ac5864207638b55504eea5fd7e8b7ecbae4e1a35c2fc5e3b89e2245323b
3
+ metadata.gz: 0e8f9fadfa22191ced6400cea007f0f62a05e8e6fbebc2af2fb5ac4180de5fe6
4
+ data.tar.gz: 02eda05ecb80f46b09ce66773c997e00dbb1fa3bb72d340f596b9eb84cee22ff
5
5
  SHA512:
6
- metadata.gz: 076ca94be2e0c032aeaf40b282deb7786bf151e493f7bd639523fb5bc6f7b97940c0549e57853f5bb550b903ec84dac2e1c2eb37e676d81055565f3223bfba45
7
- data.tar.gz: bd0cace4b70cfa5879d06dbb793fcfac842ab589498ec41d4f49542f0519c833f7612d153d64338bc18eb1b778799869feb3bdb5f1d02641038646fd1cf7ffc6
6
+ metadata.gz: 98abc203b52e5718f1d8b7ef1427536fd06d6ff257c4c01969a60a87d27eff2a471b46dabcd17917e877233fb810810758e6bcaa277b31708487cdacd322b358
7
+ data.tar.gz: 1526cad7c4c92ebe245d74d7fdf09c803e078f4454be7f351ef5c5644fbc8d78e9a1aa356eecbcbbd0f0d1a310f0e502c0f9cd9100da838271a4fcbf9191d272
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # JsonApiClient [![Build Status](https://travis-ci.org/JsonApiClient/json_api_client.png)](https://travis-ci.org/JsonApiClient/json_api_client) [![Code Climate](https://codeclimate.com/github/JsonApiClient/json_api_client.png)](https://codeclimate.com/github/JsonApiClient/json_api_client) [![Code Coverage](https://codeclimate.com/github/JsonApiClient/json_api_client/coverage.png)](https://codeclimate.com/github/JsonApiClient/json_api_client)
1
+ # JsonApiClient [![Build Status](https://travis-ci.org/JsonApiClient/json_api_client.png?branch=master)](https://travis-ci.org/JsonApiClient/json_api_client) [![Code Climate](https://codeclimate.com/github/JsonApiClient/json_api_client.png)](https://codeclimate.com/github/JsonApiClient/json_api_client) [![Code Coverage](https://codeclimate.com/github/JsonApiClient/json_api_client/coverage.png)](https://codeclimate.com/github/JsonApiClient/json_api_client)
2
2
 
3
3
  This gem is meant to help you build an API client for interacting with REST APIs as laid out by [http://jsonapi.org](http://jsonapi.org). It attempts to give you a query building framework that is easy to understand (it is similar to ActiveRecord scopes).
4
4
 
@@ -44,6 +44,28 @@ module JsonApiClient
44
44
  class NotAuthorized < ClientError
45
45
  end
46
46
 
47
+ class NotFound < ClientError
48
+ attr_reader :uri
49
+ def initialize(uri)
50
+ @uri = uri
51
+
52
+ msg = "Resource not found: #{uri.to_s}"
53
+ super nil, msg
54
+ end
55
+ end
56
+
57
+ class RequestTimeout < ClientError
58
+ end
59
+
60
+ class Conflict < ClientError
61
+ def initialize(env, msg = 'Resource already exists')
62
+ super env, msg
63
+ end
64
+ end
65
+
66
+ class TooManyRequests < ClientError
67
+ end
68
+
47
69
  class ConnectionError < ApiError
48
70
  end
49
71
 
@@ -59,23 +81,16 @@ module JsonApiClient
59
81
  end
60
82
  end
61
83
 
62
- class Conflict < ServerError
63
- def initialize(env, msg = 'Resource already exists')
64
- super env, msg
65
- end
84
+ class InternalServerError < ServerError
66
85
  end
67
86
 
68
- class NotFound < ServerError
69
- attr_reader :uri
70
- def initialize(uri)
71
- @uri = uri
87
+ class BadGateway < ServerError
88
+ end
72
89
 
73
- msg = "Couldn't find resource at: #{uri.to_s}"
74
- super nil, msg
75
- end
90
+ class ServiceUnavailable < ServerError
76
91
  end
77
92
 
78
- class InternalServerError < ServerError
93
+ class GatewayTimeout < ServerError
79
94
  end
80
95
 
81
96
  class UnexpectedStatus < ServerError
@@ -38,14 +38,24 @@ module JsonApiClient
38
38
  raise Errors::AccessDenied, env
39
39
  when 404
40
40
  raise Errors::NotFound, env[:url]
41
+ when 408
42
+ raise Errors::RequestTimeout, env
41
43
  when 409
42
44
  raise Errors::Conflict, env
43
45
  when 422
44
46
  # Allow to proceed as resource errors will be populated
47
+ when 429
48
+ raise Errors::TooManyRequests, env
45
49
  when 400..499
46
50
  raise Errors::ClientError, env
47
51
  when 500
48
52
  raise Errors::InternalServerError, env
53
+ when 502
54
+ raise Errors::BadGateway, env
55
+ when 503
56
+ raise Errors::ServiceUnavailable, env
57
+ when 504
58
+ raise Errors::GatewayTimeout, env
49
59
  when 501..599
50
60
  raise Errors::ServerError, env
51
61
  else
@@ -67,11 +67,11 @@ module JsonApiClient
67
67
  end
68
68
 
69
69
  def build(attrs = {})
70
- klass.new @path_params.merge(attrs.symbolize_keys)
70
+ klass.new @path_params.merge(attrs.with_indifferent_access)
71
71
  end
72
72
 
73
73
  def create(attrs = {})
74
- klass.create @path_params.merge(attrs.symbolize_keys)
74
+ klass.create @path_params.merge(attrs.with_indifferent_access)
75
75
  end
76
76
 
77
77
  def params
@@ -348,7 +348,7 @@ module JsonApiClient
348
348
  #
349
349
  # @param params [Hash] Attributes, links, and relationships
350
350
  def initialize(params = {})
351
- params = params.symbolize_keys
351
+ params = params.with_indifferent_access
352
352
  @persisted = nil
353
353
  @destroyed = nil
354
354
  self.links = self.class.linker.new(params.delete(:links) || {})
@@ -538,7 +538,7 @@ module JsonApiClient
538
538
  end
539
539
 
540
540
  def path_attributes
541
- _belongs_to_params.merge attributes.slice( self.class.primary_key ).symbolize_keys
541
+ _belongs_to_params.merge attributes.slice( self.class.primary_key ).with_indifferent_access
542
542
  end
543
543
 
544
544
  protected
@@ -1,3 +1,3 @@
1
1
  module JsonApiClient
2
- VERSION = "1.18.0"
2
+ VERSION = "1.19.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Ching
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-02 00:00:00.000000000 Z
11
+ date: 2021-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport