transparencia_brasil 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,10 @@ module TransparenciaBrasil
|
|
9
9
|
Addressable::URI.parse(TransparenciaBrasil.configuration.endpoint)
|
10
10
|
end
|
11
11
|
|
12
|
+
def token
|
13
|
+
TransparenciaBrasil.configuration.token
|
14
|
+
end
|
15
|
+
|
12
16
|
def get_entity(klass, path, params = {})
|
13
17
|
objects_from_response(klass, request(:get, path, params))
|
14
18
|
end
|
@@ -42,7 +46,11 @@ module TransparenciaBrasil
|
|
42
46
|
end
|
43
47
|
|
44
48
|
def connection_builder(method, url, params)
|
45
|
-
request_setup = Proc.new { |config|
|
49
|
+
request_setup = Proc.new { |config|
|
50
|
+
config.verbose = ENV['DEBUG']
|
51
|
+
config.headers['App-Token'] = token
|
52
|
+
config.ssl_verify_peer = false
|
53
|
+
}
|
46
54
|
|
47
55
|
connection = case method
|
48
56
|
when :get
|
data/spec/spec_helper.rb
CHANGED
@@ -23,13 +23,17 @@ RSpec.configure do |config|
|
|
23
23
|
config.order = 'random'
|
24
24
|
end
|
25
25
|
|
26
|
+
TransparenciaBrasil.configure do |c|
|
27
|
+
c.token = "aaa"
|
28
|
+
end
|
29
|
+
|
26
30
|
[:get, :post, :delete, :put].each do |operation|
|
27
31
|
Kernel.send(:define_method, "a_#{operation}") do |path|
|
28
32
|
a_request(operation, TransparenciaBrasil.configuration.endpoint + path)
|
29
33
|
end
|
30
34
|
|
31
35
|
Kernel.send(:define_method, "stub_#{operation}") do |path|
|
32
|
-
stub_request(operation, TransparenciaBrasil.configuration.endpoint + path)
|
36
|
+
stub_request(operation, TransparenciaBrasil.configuration.endpoint + path).with(headers: {"App-Token" => TransparenciaBrasil.configuration.token})
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|