Permalink
Browse files

Support for recipient_contributor_summary

  • Loading branch information...
luigi committed Jun 24, 2010
1 parent ebc0473 commit 300d1926c4ec409bcd078eeedfcc83d672b7dd58
Showing with 30 additions and 0 deletions.
  1. +8 −0 lib/transparency_data/client.rb
  2. +22 −0 test/client_test.rb
@@ -140,6 +140,14 @@ class Client < MonsterMash::Base
end
end
+ get(:recipient_contributor_summary) do |recipient_id, contributor_id, api_params|
+ uri TransparencyData.api_url("/aggregates/recipient/#{recipient_id}/contributor/#{contributor_id}/amount")
+ params TransparencyData::Client.prepare_params(api_params) if api_params
+ handler do |response|
+ Hashie::Mash.new(JSON.parse(response.body))
+ end
+ end
+
def self.prepare_params(params)
params.each do |key, value|
if value.is_a?(Hash)
View
@@ -219,6 +219,28 @@ class ClientTest < Test::Unit::TestCase
end
end
+
+ context "recipient methods" do
+
+ setup do
+ boone = TransparencyData::Client.entities(:search => "t boone pickens")
+ boone.each do |entity|
+ @boone_id = entity.id if entity['type'] == "individual"
+ end
+ ted = TransparencyData::Client.entities(:search => "ted stevens")
+ ted.each do |entity|
+ @stevens_id = entity.id if entity['type'] == "politician"
+ end
+ end
+
+ should "return a contributor summary" do
+ VCR.use_cassette('recipient contributor summary') do
+ summary = TransparencyData::Client.recipient_contributor_summary(@stevens_id, @boone_id)
+ assert_equal summary.amount.class, Fixnum
+ end
+ end
+
+ end
end

0 comments on commit 300d192

Please sign in to comment.