transparency_data 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -24,6 +24,8 @@ Within a Rails app, create a `config/initializers/transparency_data.rb` and stic
24
24
  config.api_key = 'YOUR_KEY_HERE'
25
25
  end
26
26
 
27
+ Optionally, you can set `TransparencyData.api_domain` if you don't want to hit the production API at `transparencydata.com`.
28
+
27
29
  ## Usage
28
30
 
29
31
  See the official [API docs](http://transparencydata.com/api/) for all parameters you can send in, and the [schema docs](http://transparencydata.com/docs/) for what you get back:
@@ -8,28 +8,13 @@ Hash.send :include, Hashie::HashExtensions
8
8
 
9
9
  module TransparencyData
10
10
 
11
- VERSION = "0.0.3".freeze
12
-
13
- # config/initializers/transparency_data.rb (for instance)
14
- #
15
- # TransparencyData.configure do |config|
16
- # config.api_key = 'api_key'
17
- # end
18
- #
11
+ VERSION = "0.0.4".freeze
12
+
19
13
  def self.configure
20
14
  yield self
21
15
  true
22
16
  end
23
17
 
24
- def self.api_url(endpoint, version = self.api_version)
25
- "http://transparencydata.com/api/#{version}#{endpoint}.json"
26
- end
27
-
28
- # class << self
29
- # attr_accessor :api_key
30
- # attr_accessor :api_version
31
- # end
32
-
33
18
  def self.api_version
34
19
  @api_version || "1.0"
35
20
  end
@@ -45,7 +30,18 @@ module TransparencyData
45
30
  def self.api_key=(value)
46
31
  @api_key = value
47
32
  end
48
-
33
+
34
+ def self.api_domain
35
+ @api_domain || "transparencydata.com"
36
+ end
37
+
38
+ def self.api_domain=(value)
39
+ @api_domain = value
40
+ end
41
+
42
+ def self.api_url(endpoint, version = self.api_version)
43
+ "http://#{self.api_domain}/api/#{version}#{endpoint}.json"
44
+ end
49
45
 
50
46
  end
51
47
 
@@ -140,6 +140,14 @@ module TransparencyData
140
140
  end
141
141
  end
142
142
 
143
+ get(:recipient_contributor_summary) do |recipient_id, contributor_id, api_params|
144
+ uri TransparencyData.api_url("/aggregates/recipient/#{recipient_id}/contributor/#{contributor_id}/amount")
145
+ params TransparencyData::Client.prepare_params(api_params) if api_params
146
+ handler do |response|
147
+ Hashie::Mash.new(JSON.parse(response.body))
148
+ end
149
+ end
150
+
143
151
  def self.prepare_params(params)
144
152
  params.each do |key, value|
145
153
  if value.is_a?(Hash)
@@ -155,6 +163,9 @@ module TransparencyData
155
163
 
156
164
  elsif value.is_a?(Array)
157
165
  params[key] = value.join("|")
166
+
167
+ elsif value.is_a?(String)
168
+ params[key] = value.sub(/[\*\?!=&%]/,'')
158
169
  end
159
170
  end
160
171
  params
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Wynn Netherland
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-06-21 00:00:00 -04:00
19
+ date: 2010-06-24 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency