Skip to content

Commit

Permalink
2.58.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Feb 23, 2016
1 parent 3720a05 commit c359173
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rdoc
@@ -1,3 +1,6 @@
== 2.58.0
* Add AccountUpdaterDailyReport webhook parsing

== 2.57.0
* Add Verification#create
* Add options to `submit_for_settlement` transaction flows
Expand Down
1 change: 1 addition & 0 deletions lib/braintree.rb
Expand Up @@ -20,6 +20,7 @@
require "braintree/base_module"
require "braintree/modification"

require "braintree/account_updater_daily_report"
require "braintree/add_on"
require "braintree/add_on_gateway"
require "braintree/address"
Expand Down
20 changes: 20 additions & 0 deletions lib/braintree/account_updater_daily_report.rb
@@ -0,0 +1,20 @@
module Braintree
class AccountUpdaterDailyReport # :nodoc:
include BaseModule

attr_reader :report_url
attr_reader :report_date

class << self
protected :new
def _new(*args) # :nodoc:
self.new *args
end
end

def initialize(attributes) # :nodoc:
set_instance_variables_from_hash(attributes)
@report_date = Date.parse(report_date)
end
end
end
2 changes: 1 addition & 1 deletion lib/braintree/version.rb
@@ -1,7 +1,7 @@
module Braintree
module Version
Major = 2
Minor = 57
Minor = 58
Tiny = 0

String = "#{Major}.#{Minor}.#{Tiny}"
Expand Down
5 changes: 4 additions & 1 deletion lib/braintree/webhook_notification.rb
Expand Up @@ -28,9 +28,11 @@ module Kind
PartnerMerchantConnected = "partner_merchant_connected"
PartnerMerchantDisconnected = "partner_merchant_disconnected"
PartnerMerchantDeclined = "partner_merchant_declined"

AccountUpdaterDailyReport = "account_updater_daily_report"
end

attr_reader :subscription, :kind, :timestamp, :transaction, :partner_merchant, :disbursement, :dispute
attr_reader :subscription, :kind, :timestamp, :transaction, :partner_merchant, :disbursement, :dispute, :account_updater_daily_report

def self.parse(signature, payload)
Configuration.gateway.webhook_notification.parse(signature, payload)
Expand All @@ -50,6 +52,7 @@ def initialize(gateway, attributes) # :nodoc:
@transaction = Transaction._new(gateway, @subject[:transaction]) if @subject.has_key?(:transaction)
@disbursement = Disbursement._new(gateway, @subject[:disbursement]) if @subject.has_key?(:disbursement)
@dispute = Dispute._new(@subject[:dispute]) if @subject.has_key?(:dispute)
@account_updater_daily_report = AccountUpdaterDailyReport._new(@subject[:account_updater_daily_report]) if @subject.has_key?(:account_updater_daily_report)
end

def merchant_account
Expand Down
12 changes: 12 additions & 0 deletions lib/braintree/webhook_testing_gateway.rb
Expand Up @@ -53,6 +53,8 @@ def _subject_sample_xml(kind, id)
_disbursement_sample_xml(id)
when Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfully
_subscription_charged_successfully(id)
when Braintree::WebhookNotification::Kind::AccountUpdaterDailyReport
_account_updater_daily_report_sample_xml(id)
else
_subscription_sample_xml(id)
end
Expand Down Expand Up @@ -299,5 +301,15 @@ def _disbursement_sample_xml(id)
</disbursement>
XML
end

def _account_updater_daily_report_sample_xml(id)

<<-XML
<account-updater-daily-report>
<report-date type="date">2016-01-14</report-date>
<report-url>link-to-csv-report</report-url>
</account-updater-daily-report>
XML
end
end
end
15 changes: 15 additions & 0 deletions spec/unit/braintree/webhook_notification_spec.rb
Expand Up @@ -228,6 +228,21 @@
end
end

context "account_updater_daily_report" do
it "builds a sample notification for an account_updater_daily_report webhook" do
sample_notification = Braintree::WebhookTesting.sample_notification(
Braintree::WebhookNotification::Kind::AccountUpdaterDailyReport,
"my_id"
)

notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])

notification.kind.should == Braintree::WebhookNotification::Kind::AccountUpdaterDailyReport
notification.account_updater_daily_report.report_url.should == "link-to-csv-report"
notification.account_updater_daily_report.report_date.should == Date.parse("2016-01-14")
end
end

describe "parse" do
it "raises InvalidSignature error when the signature is completely invalid" do
sample_notification = Braintree::WebhookTesting.sample_notification(
Expand Down

0 comments on commit c359173

Please sign in to comment.