json_api_client 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/json_api_client/connection.rb +2 -1
- data/lib/json_api_client/resource.rb +3 -2
- data/lib/json_api_client/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: 97343e5f4ab100e19f26bc047874835f90d8e76a
|
4
|
+
data.tar.gz: 6009f0ddb1f43af631e3b10a6e0bd9bd5cf7c9c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f35608521648cf8337507f466831598a4bb77e5254f60c18a0bbeeac854c8832eeb5b7d8faf63b356e953d1bb4f11958339c98e9d453e69dab21d50c3b0e211d
|
7
|
+
data.tar.gz: e3a07f87d572b36eab928742f87688d38dc02bbb2f65e62ee8e30f71fc125a6c1c5715f32e17e62a6d0a5bc63ab7f4386d76ccbecdfb9ed6719ae5b670accc72
|
data/README.md
CHANGED
@@ -381,6 +381,23 @@ module MyApi
|
|
381
381
|
end
|
382
382
|
```
|
383
383
|
|
384
|
+
##### Specifying an HTTP Proxy
|
385
|
+
|
386
|
+
All resources have a class method ```connection_options``` used to pass options to the JsonApiClient::Connection initializer.
|
387
|
+
|
388
|
+
```ruby
|
389
|
+
MyApi::Base.connection_options[:proxy] = 'http://proxy.example.com'
|
390
|
+
MyApi::Base.connection do |connection|
|
391
|
+
# ...
|
392
|
+
end
|
393
|
+
|
394
|
+
module MyApi
|
395
|
+
class User < Base
|
396
|
+
# will use the customized connection with proxy
|
397
|
+
end
|
398
|
+
end
|
399
|
+
```
|
400
|
+
|
384
401
|
### Custom Parser
|
385
402
|
|
386
403
|
You can configure your API client to use a custom parser that implements the `parse` class method. It should return a `JsonApiClient::ResultSet` instance. You can use it by setting the parser attribute on your model:
|
@@ -5,8 +5,9 @@ module JsonApiClient
|
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
site = options.fetch(:site)
|
8
|
+
connection_options = options.slice(:proxy, :ssl, :request, :headers, :params)
|
8
9
|
adapter_options = Array(options.fetch(:adapter, Faraday.default_adapter))
|
9
|
-
@faraday = Faraday.new(site) do |builder|
|
10
|
+
@faraday = Faraday.new(site, connection_options) do |builder|
|
10
11
|
builder.request :json
|
11
12
|
builder.use Middleware::JsonRequest
|
12
13
|
builder.use Middleware::Status
|
@@ -410,8 +410,9 @@ module JsonApiClient
|
|
410
410
|
return nil unless relationship_definitions = relationships[method]
|
411
411
|
|
412
412
|
# look in included data
|
413
|
-
|
414
|
-
|
413
|
+
if relationship_definitions.key?("data")
|
414
|
+
return last_result_set.included.data_for(method, relationship_definitions)
|
415
|
+
end
|
415
416
|
|
416
417
|
if association = association_for(method)
|
417
418
|
# look for a defined relationship url
|
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.1.
|
4
|
+
version: 1.1.1
|
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-02-
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|