Skip to content

Commit

Permalink
Handle api response of null for data when a list contains no entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
goodwink committed Feb 5, 2013
1 parent 33b5c64 commit 9760469
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/pipedrive/deal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ class Deal < Base
def self.all
res = get "/deals"
if res.ok?
res['data'].map{|deal| Deal.new(deal)}
if !res['data'].nil?
res['data'].map{|deal| Deal.new(deal)}
else
[]
end
else
bad_response(res)
end
Expand Down
6 changes: 5 additions & 1 deletion lib/pipedrive/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ class Organization < Base
def self.all
res = get "/organizations"
if res.ok?
res['data'].map{|org| Organization.new(org)}
if !res['data'].nil?
res['data'].map{|org| Organization.new(org)}
else
[]
end
else
bad_response(res)
end
Expand Down

0 comments on commit 9760469

Please sign in to comment.