class ActBlueReporter::ContributionReport
Attributes
payload[R]
This class takes a report from the Campaign
class and formats it for convenience. In particular the structure of the response from ActBlue is different in the case of one or > 1 contributions.
Public Class Methods
new(payload:)
click to toggle source
# File lib/act_blue_reporter/contribution_report.rb, line 10 def initialize(payload:) @payload = payload end
Public Instance Methods
count()
click to toggle source
# File lib/act_blue_reporter/contribution_report.rb, line 26 def count @payload["count"] || 0 end
report()
click to toggle source
# File lib/act_blue_reporter/contribution_report.rb, line 14 def report # The hash from ActBlue is structured differently in the case of # 1 or 1+ responses. This code returns a predictable structure if count == 0 [] elsif count == 1 [] << @payload["contribution"] else @payload["contribution"] end end