json_api_client 1.3.0 → 1.4.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
  SHA1:
3
- metadata.gz: 26657a3496cb5b8c5d6ae5ed91657a709e3fe2eb
4
- data.tar.gz: 07c8e931b94e2ce4c5ad99aded81c3261be6e586
3
+ metadata.gz: e0d020be7e9bf6e1b22999ffc3a0acde1ecc5625
4
+ data.tar.gz: 5125ad8d9ea03cf4cf58c77e4031d678de6778f8
5
5
  SHA512:
6
- metadata.gz: 43083388e55b1c38eade789c4bf2de4d71f9a1aa60490b82e2b57b1c03cf24384178fbbfa2caa48ef125537254b5baed608a6b9d42ab5dcef706b994cc65d901
7
- data.tar.gz: 8fd7501b9abc8b4fd3b9de79a3c31d69cfd9ba6ae1a14181cc38b2ce12f04b435380dd556417b7a1d259c05cd22155fdedfd4a4f1afa8b0d83750df11ec2d837
6
+ metadata.gz: 625e1b33f72351b242e9d3ed4920b43be7ab14c150c71eeb3d7f5f077a644d5bc8dfee01c58855735e3095d5f084e32ecd86ce0f3075f70bd869b1765e72b3c9
7
+ data.tar.gz: 7f8675ae9030f8b1d4d1342d77075c73f117715a0b3b8540144ca7074701e38fbed1f0e3b4c793fbddcdb588d627ae166beda7c2908d79fe7cd3f0ab66677205
data/README.md CHANGED
@@ -188,7 +188,7 @@ user.verify(foo: 'bar')
188
188
 
189
189
  [See specification](http://jsonapi.org/format/#fetching-includes)
190
190
 
191
- If the response returns a [compound document](http://jsonapi.org/format/#document-structure-compound-documents), then we should be able to get the related resources.
191
+ If the response returns a [compound document](http://jsonapi.org/format/#document-compound-documents), then we should be able to get the related resources.
192
192
 
193
193
  ```ruby
194
194
  # makes request to /articles/1?include=author,comments.author
@@ -338,6 +338,15 @@ end
338
338
  MyApi::SomeResource.all
339
339
  ```
340
340
 
341
+ ### Custom headers
342
+
343
+ You can inject custom headers on resource request by wrapping your code into block:
344
+ ```ruby
345
+ MyApi::SomeResource.with_headers(x_access_token: 'secure_token_here') do
346
+ MyApi::SomeResource.find(1)
347
+ end
348
+ ```
349
+
341
350
  ### Connections
342
351
 
343
352
  You can configure your API client to use a custom connection that implementes the `run` instance method. It should return data that your parser can handle. The default connection class wraps Faraday and lets you add middleware.
@@ -69,6 +69,10 @@ module JsonApiClient
69
69
  paginate(page: 1, per_page: 1).to_a.first
70
70
  end
71
71
 
72
+ def last
73
+ paginate(page: 1, per_page: 1).pages.last.to_a.last
74
+ end
75
+
72
76
  def build
73
77
  klass.new(params)
74
78
  end
@@ -56,7 +56,7 @@ module JsonApiClient
56
56
 
57
57
  class << self
58
58
  extend Forwardable
59
- def_delegators :_new_scope, :where, :order, :includes, :select, :all, :paginate, :page, :with_params, :first, :find
59
+ def_delegators :_new_scope, :where, :order, :includes, :select, :all, :paginate, :page, :with_params, :first, :find, :last
60
60
 
61
61
  # The table name for this resource. i.e. Article -> articles, Person -> people
62
62
  #
@@ -1,3 +1,4 @@
1
+ require 'bigdecimal'
1
2
  module JsonApiClient
2
3
  class Schema
3
4
  Property = Struct.new(:name, :type, :default) do
@@ -14,6 +15,8 @@ module JsonApiClient
14
15
  value.to_f
15
16
  when :time
16
17
  value.is_a?(Time) || nil ? value : Time.parse(value)
18
+ when :decimal
19
+ value.nil? ? nil : BigDecimal.new(value)
17
20
  when :boolean
18
21
  case value
19
22
  when "false", "0", 0, false
@@ -1,3 +1,3 @@
1
1
  module JsonApiClient
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.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.3.0
4
+ version: 1.4.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: 2016-09-13 00:00:00.000000000 Z
11
+ date: 2017-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.4.5
179
+ rubygems_version: 2.5.2
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Build client libraries compliant with specification defined by jsonapi.org