flexirest 1.3.12 → 1.3.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +9 -1
- data/lib/flexirest/version.rb +1 -1
- data/spec/lib/request_spec.rb +7 -0
- 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: bc2dd846c4d1cab6b3bc1fc2a1d162bfbb5419e9
|
4
|
+
data.tar.gz: fb4672356cf5e7fec571ebe73ff381d89a47f1ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 293a96596ed43f163a15614597913ddcf6682432176fd6d8fa32a31ca5db1adad77543e3384ab0f231ca97da7b62b5d392a03bca7b0d9f6073bc5863fc064919
|
7
|
+
data.tar.gz: a851723f3928d483b287b63744146aa28865a5148cbc74e0ad889d3bf4d1dec31f2bbe941b87bcc603c3dcdf7bdbfe5391e5aa4cf98bac16a2f1cd91b3f27197
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -625,7 +625,7 @@ When url-encoding get parameters, Rudy adds brackets([]) by default to any param
|
|
625
625
|
Person.all(param: [1, 2, 3])
|
626
626
|
```
|
627
627
|
|
628
|
-
Ruby would encode the url as
|
628
|
+
Ruby would encode the url as
|
629
629
|
|
630
630
|
```
|
631
631
|
?param[]=1¶m[]=2¶m[]=3
|
@@ -688,6 +688,14 @@ Person._plain_request('http://api.example.com/v1/people', :post, {id:1234,name:"
|
|
688
688
|
|
689
689
|
The parameters are the same as for `_request`, but it does no parsing on the response
|
690
690
|
|
691
|
+
You can also bypass the response parsing using a mapped method like this:
|
692
|
+
|
693
|
+
```ruby
|
694
|
+
class Person < Flexirest::Base
|
695
|
+
get :all, "/v1/people", plain: true
|
696
|
+
end
|
697
|
+
```
|
698
|
+
|
691
699
|
### Proxying APIs
|
692
700
|
|
693
701
|
Sometimes you may be working with an old API that returns JSON in a less than ideal format or the URL or parameters required have changed. In this case you can define a descendent of `Flexirest::ProxyBase`, pass it to your model as the proxy and have it rework URLs/parameters on the way out and the response on the way back in (already converted to a Ruby hash/array). By default any non-proxied URLs are just passed through to the underlying connection layer. For example:
|
data/lib/flexirest/version.rb
CHANGED
data/spec/lib/request_spec.rb
CHANGED
@@ -31,6 +31,7 @@ describe Flexirest::Request do
|
|
31
31
|
put :headers_json, "/headers_json", request_body_type: :json
|
32
32
|
get :find, "/:id"
|
33
33
|
get :change, "/change"
|
34
|
+
get :plain, "/plain/:id", plain: true
|
34
35
|
post :create, "/create"
|
35
36
|
post :test_encoding, "/encoding", request_body_type: :json
|
36
37
|
put :update, "/put/:id"
|
@@ -260,6 +261,12 @@ describe Flexirest::Request do
|
|
260
261
|
expect(object.result).to eq(1234)
|
261
262
|
end
|
262
263
|
|
264
|
+
it "should not parse JSON from a plain request" do
|
265
|
+
response_body = "This is another non-JSON string"
|
266
|
+
expect_any_instance_of(Flexirest::Connection).to receive(:get).with(any_args).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, response_headers:{}, body:response_body)))
|
267
|
+
expect(ExampleClient.plain(id:1234)).to eq(response_body)
|
268
|
+
end
|
269
|
+
|
263
270
|
it "should return a lazy loader object if lazy loading is enabled" do
|
264
271
|
object = LazyLoadedExampleClient.fake id:1234, debug:true
|
265
272
|
expect(object).to be_an_instance_of(Flexirest::LazyLoader)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexirest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jeffries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|