agrid-client 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/agrid_client.gemspec +0 -3
- data/lib/agrid_client/api_client.rb +0 -1
- data/lib/agrid_client/configuration.rb +2 -2
- data/lib/agrid_client/models/city_with_full_state.rb +11 -4
- data/lib/agrid_client/models/company.rb +9 -3
- data/lib/agrid_client/version.rb +1 -1
- data/spec/spec_helper.rb +0 -41
- metadata +2 -56
- data/fixtures/vcr_cassettes/cities.yml +0 -1183
- data/fixtures/vcr_cassettes/cities_with_query.yml +0 -150
- data/spec/api/cities_api_spec.rb +0 -31
- data/spec/api/services_api_spec.rb +0 -5
- data/spec/api_client_spec.rb +0 -59
- data/spec/fixtures/cities.json +0 -1
- data/spec/fixtures/services.json +0 -0
@@ -1,150 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: http://api-staging.agrid.com.br/v1/cities?state=pr
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
User-Agent:
|
11
|
-
- agrid_client/0.0.3/ruby
|
12
|
-
Content-Type:
|
13
|
-
- application/json
|
14
|
-
AGRID-APP-ID:
|
15
|
-
- 938e3405
|
16
|
-
AGRID-APP-KEY:
|
17
|
-
- 67e19c9772662859347365530aaf77be
|
18
|
-
Accept:
|
19
|
-
- application/json
|
20
|
-
response:
|
21
|
-
status:
|
22
|
-
code: 200
|
23
|
-
message: OK
|
24
|
-
headers:
|
25
|
-
Server:
|
26
|
-
- Cowboy
|
27
|
-
Date:
|
28
|
-
- Fri, 29 Apr 2016 17:03:09 GMT
|
29
|
-
Connection:
|
30
|
-
- keep-alive
|
31
|
-
X-Frame-Options:
|
32
|
-
- SAMEORIGIN
|
33
|
-
X-Xss-Protection:
|
34
|
-
- 1; mode=block
|
35
|
-
X-Content-Type-Options:
|
36
|
-
- nosniff
|
37
|
-
Content-Type:
|
38
|
-
- application/json; charset=utf-8
|
39
|
-
Etag:
|
40
|
-
- W/"8bf54cf160ceff4f738de904b7a48ca0"
|
41
|
-
Cache-Control:
|
42
|
-
- max-age=0, private, must-revalidate
|
43
|
-
X-Request-Id:
|
44
|
-
- 3a36d116-4067-4c27-82e5-6b6d41e8942d
|
45
|
-
X-Runtime:
|
46
|
-
- '0.215425'
|
47
|
-
Transfer-Encoding:
|
48
|
-
- chunked
|
49
|
-
Via:
|
50
|
-
- 1.1 vegur
|
51
|
-
body:
|
52
|
-
encoding: ASCII-8BIT
|
53
|
-
string: !binary |-
|
54
|
-
W3siaWQiOiJhcHVjYXJhbmEiLCJ0aXRsZSI6IkFwdWNhcmFuYSIsInN0YXRl
|
55
|
-
Ijp7ImFjcm9ueW0iOiJQUiIsInRpdGxlIjoiUGFyYW7DoSJ9fSx7ImlkIjoi
|
56
|
-
c2FvLWpvc2UtZG9zLXBpbmhhaXMiLCJ0aXRsZSI6IlPDo28gSm9zw6kgZG9z
|
57
|
-
IFBpbmhhaXMiLCJzdGF0ZSI6eyJhY3JvbnltIjoiUFIiLCJ0aXRsZSI6IlBh
|
58
|
-
cmFuw6EifX0seyJpZCI6ImFndWRvcy1kby1zdWwiLCJ0aXRsZSI6IkFndWRv
|
59
|
-
cyBkbyBTdWwiLCJzdGF0ZSI6eyJhY3JvbnltIjoiUFIiLCJ0aXRsZSI6IlBh
|
60
|
-
cmFuw6EifX0seyJpZCI6InBhdG8tYnJhbmNvIiwidGl0bGUiOiJQYXRvIEJy
|
61
|
-
YW5jbyIsInN0YXRlIjp7ImFjcm9ueW0iOiJQUiIsInRpdGxlIjoiUGFyYW7D
|
62
|
-
oSJ9fSx7ImlkIjoicGlyYXF1YXJhIiwidGl0bGUiOiJQaXJhcXVhcmEiLCJz
|
63
|
-
dGF0ZSI6eyJhY3JvbnltIjoiUFIiLCJ0aXRsZSI6IlBhcmFuw6EifX0seyJp
|
64
|
-
ZCI6ImFudG9uaW5hIiwidG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IlBhcmFuYWd1w6EiLCJzdGF0
|
141
|
-
ZSI6eyJhY3JvbnltIjoiUFIiLCJ0aXRsZSI6IlBhcmFuw6EifX0seyJpZCI6
|
142
|
-
ImlyYXRpIiwidGl0bGUiOiJJcmF0aSIsInN0YXRlIjp7ImFjcm9ueW0iOiJQ
|
143
|
-
UiIsInRpdGxlIjoiUGFyYW7DoSJ9fSx7ImlkIjoicXVpdGFuZGluaGEiLCJ0
|
144
|
-
aXRsZSI6IlF1aXRhbmRpbmhhIiwic3RhdGUiOnsiYWNyb255bSI6IlBSIiwi
|
145
|
-
dGl0bGUiOiJQYXJhbsOhIn19XQ==
|
146
|
-
http_version: '1.1'
|
147
|
-
adapter_metadata:
|
148
|
-
effective_url: http://api-staging.agrid.com.br/v1/cities?state=pr
|
149
|
-
recorded_at: Fri, 29 Apr 2016 17:03:10 GMT
|
150
|
-
recorded_with: VCR 3.0.1
|
data/spec/api/cities_api_spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe 'CitiesApi' do
|
4
|
-
let(:subject) { AgridClient::CitiesApi.new(api_client) }
|
5
|
-
|
6
|
-
describe "#cities_get" do
|
7
|
-
context "without parameters" do
|
8
|
-
it "return all cities" do
|
9
|
-
response = []
|
10
|
-
VCR.use_cassette('cities', record: :new_episodes) do
|
11
|
-
response = subject.cities_get
|
12
|
-
end
|
13
|
-
type_array = response.map(&:class).uniq
|
14
|
-
|
15
|
-
expect(response).to be_an(Array)
|
16
|
-
expect(type_array).to eq([AgridClient::CityWithFullState])
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "with state param" do
|
21
|
-
it "return " do
|
22
|
-
response = []
|
23
|
-
VCR.use_cassette('cities_with_query') do
|
24
|
-
response = subject.cities_get(state: 'pr')
|
25
|
-
end
|
26
|
-
states = response.map { |r| r.state.acronym }.uniq
|
27
|
-
expect(states).to eq(['PR'])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/spec/api_client_spec.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe 'ApiClient' do
|
4
|
-
let(:subject) { AgridClient::ApiClient.new }
|
5
|
-
|
6
|
-
describe "#new" do
|
7
|
-
context "without arguments" do
|
8
|
-
it "initialize with default configuration" do
|
9
|
-
version = AgridClient::VERSION
|
10
|
-
expect(subject.default_headers).to eq({
|
11
|
-
'Content-Type' => 'application/json',
|
12
|
-
'User-Agent' => "agrid_client/#{version}/ruby"
|
13
|
-
})
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "with configuration argument" do
|
18
|
-
let(:configuration) { AgridClient::Configuration.new { |c| c.host = 'http://test.com' } }
|
19
|
-
let(:subject) { AgridClient::ApiClient.new(configuration) }
|
20
|
-
it "initialize with configuration received" do
|
21
|
-
expect(subject.config.host).to eq('test.com')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#call_api" do
|
27
|
-
it 'make a call to API' do
|
28
|
-
VCR.use_cassette('services') do
|
29
|
-
response = subject.call_api('GET','services')
|
30
|
-
expect(response).to be_an(Array)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "with options" do
|
35
|
-
it "make a call to API with options" do
|
36
|
-
subject.call_api('GET','services',
|
37
|
-
header_params: {'A-HEADER': 'olar'},
|
38
|
-
query_params: {key: 'value'})
|
39
|
-
expect(a_get('services').with(
|
40
|
-
headers: {'A-HEADER': 'olar'},
|
41
|
-
query: {key: 'value'})).to have_been_made
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "with return type" do
|
46
|
-
context "valid primitive type" do
|
47
|
-
before(:each) do
|
48
|
-
stub_get('services').to_return(body: '[1,2,3]',
|
49
|
-
headers: {'Content-Type': 'application/json'})
|
50
|
-
end
|
51
|
-
|
52
|
-
it "return deserialized response" do
|
53
|
-
expect(subject.call_api('GET', 'services',
|
54
|
-
{return_type: 'Array<Integer>'})[0]).to eq([1,2,3])
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/spec/fixtures/cities.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
[{"id":"belem-pa","title":"Belém","state":{"acronym":"PA","title":"Pará"}},{"id":"sapucaia","title":"Sapucaia","state":{"acronym":"PA","title":"Pará"}},{"id":"abaetetuba","title":"Abaetetuba","state":{"acronym":"PA","title":"Pará"}}]
|
data/spec/fixtures/services.json
DELETED
File without changes
|