Permalink
Browse files

Updating Bio.find to optionally return office information as well

  • Loading branch information...
ajb committed Jun 23, 2012
1 parent 7279f1e commit 6d91de3f733cf8cd87b457b7f2b4aa5ff50c7f03
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/gov_kit/vote_smart.rb
@@ -21,12 +21,21 @@ def self.find(candidate_id)
class Bio < VoteSmartResource
def self.find(candidate_id)
+ def self.find(candidate_id, include_office = false)
response = get("/CandidateBio.getBio", :query => {"candidateId" => candidate_id})
# Sometimes VoteSmart returns nil if no one is found!
raise(ResourceNotFound, 'Could not find bio for candidate') if response.blank? || response['error']
parse(response['bio']['candidate'])
+
+ # Previous versions ommitted "office" data from response.
+ # include_office is optional so to not break backwards compatibility.
+ if include_office
+ parse(response['bio'])
+ else
+ parse(response['bio']['candidate'])
+ end
end
end

0 comments on commit 6d91de3

Please sign in to comment.