-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4dca0d7
commit f521dd0
Showing
16 changed files
with
269 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Braintree | ||
class EnrichedCustomerData | ||
include BaseModule | ||
|
||
attr_reader :fields_updated | ||
attr_reader :profile_data | ||
|
||
def initialize(attributes) # :nodoc: | ||
set_instance_variables_from_hash(attributes) | ||
@profile_data = VenmoProfileData._new(attributes[:profile_data]) | ||
end | ||
|
||
class << self | ||
protected :new | ||
end | ||
|
||
def self._new(*args) # :nodoc: | ||
self.new(*args) | ||
end | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
lib/braintree/payment_method_customer_data_updated_metadata.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Braintree | ||
class PaymentMethodCustomerDataUpdatedMetadata | ||
include BaseModule | ||
|
||
attr_reader :token | ||
attr_reader :payment_method | ||
attr_reader :datetime_updated | ||
attr_reader :enriched_customer_data | ||
|
||
def initialize(gateway, attributes) # :nodoc: | ||
set_instance_variables_from_hash(attributes) | ||
@payment_method = PaymentMethodParser.parse_payment_method(gateway, attributes[:payment_method]) | ||
@enriched_customer_data = EnrichedCustomerData._new(enriched_customer_data) if enriched_customer_data | ||
end | ||
|
||
class << self | ||
protected :new | ||
end | ||
|
||
def self._new(*args) # :nodoc: | ||
self.new(*args) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Braintree | ||
class VenmoProfileData | ||
include BaseModule | ||
|
||
attr_reader :username | ||
attr_reader :first_name | ||
attr_reader :last_name | ||
attr_reader :phone_number | ||
attr_reader :email | ||
|
||
def initialize(attributes) # :nodoc: | ||
set_instance_variables_from_hash(attributes) | ||
end | ||
|
||
class << self | ||
protected :new | ||
end | ||
|
||
def self._new(*args) # :nodoc: | ||
self.new(*args) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Braintree | ||
module Version | ||
Major = 4 | ||
Minor = 5 | ||
Minor = 6 | ||
Tiny = 0 | ||
|
||
String = "#{Major}.#{Minor}.#{Tiny}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") | ||
|
||
describe Braintree::EnrichedCustomerData do | ||
describe "self.new" do | ||
it "is protected" do | ||
expect do | ||
Braintree::EnrichedCustomerData.new | ||
end.to raise_error(NoMethodError, /protected method .new/) | ||
end | ||
end | ||
|
||
describe "self._new" do | ||
it "initializes the object with the appropriate attributes set" do | ||
|
||
params = { | ||
fields_updated: ["username"], | ||
profile_data: { | ||
username: "a-username", | ||
first_name: "a-first-name", | ||
last_name: "a-last-name", | ||
phone_number: "a-phone-number", | ||
email: "a-email", | ||
}, | ||
} | ||
|
||
payment_method_customer_data_updated = Braintree::EnrichedCustomerData._new(params) | ||
|
||
payment_method_customer_data_updated.profile_data.should be_a(Braintree::VenmoProfileData) | ||
payment_method_customer_data_updated.fields_updated.should eq(["username"]) | ||
end | ||
end | ||
end |
45 changes: 45 additions & 0 deletions
45
spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") | ||
|
||
describe Braintree::PaymentMethodCustomerDataUpdatedMetadata do | ||
describe "self.new" do | ||
it "is protected" do | ||
expect do | ||
Braintree::PaymentMethodCustomerDataUpdatedMetadata.new | ||
end.to raise_error(NoMethodError, /protected method .new/) | ||
end | ||
end | ||
|
||
describe "self._new" do | ||
it "initializes the object with the appropriate attributes set" do | ||
|
||
params = { | ||
token: "a-token", | ||
payment_method: { | ||
venmo_account: { | ||
venmo_user_id: "venmo-user-id", | ||
}, | ||
}, | ||
datetime_updated: "2022-01-01T21:28:37Z", | ||
enriched_customer_data: { | ||
fields_updated: ["username"], | ||
profile_data: { | ||
username: "a-username", | ||
first_name: "a-first-name", | ||
last_name: "a-last-name", | ||
phone_number: "a-phone-number", | ||
email: "a-email", | ||
}, | ||
}, | ||
} | ||
|
||
payment_method_customer_data_updated = Braintree::PaymentMethodCustomerDataUpdatedMetadata._new(:gateway, params) | ||
|
||
payment_method_customer_data_updated.token.should eq("a-token") | ||
payment_method_customer_data_updated.datetime_updated.should eq("2022-01-01T21:28:37Z") | ||
payment_method_customer_data_updated.payment_method.should be_a(Braintree::VenmoAccount) | ||
payment_method_customer_data_updated.enriched_customer_data.profile_data.first_name.should eq("a-first-name") | ||
payment_method_customer_data_updated.enriched_customer_data.profile_data.last_name.should eq("a-last-name") | ||
payment_method_customer_data_updated.enriched_customer_data.fields_updated.should eq(["username"]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") | ||
|
||
describe Braintree::VenmoProfileData do | ||
describe "self.new" do | ||
it "is protected" do | ||
expect do | ||
Braintree::VenmoProfileData.new | ||
end.to raise_error(NoMethodError, /protected method .new/) | ||
end | ||
end | ||
|
||
describe "self._new" do | ||
it "initializes the object with the appropriate attributes set" do | ||
|
||
params = { | ||
username: "a-username", | ||
first_name: "a-first-name", | ||
last_name: "a-last-name", | ||
phone_number: "12312312343", | ||
email: "a-email", | ||
} | ||
|
||
payment_method_customer_data_updated = Braintree::VenmoProfileData._new(params) | ||
|
||
payment_method_customer_data_updated.username.should eq("a-username") | ||
payment_method_customer_data_updated.first_name.should eq("a-first-name") | ||
payment_method_customer_data_updated.last_name.should eq("a-last-name") | ||
payment_method_customer_data_updated.phone_number.should eq("12312312343") | ||
payment_method_customer_data_updated.email.should eq("a-email") | ||
end | ||
end | ||
end |
Oops, something went wrong.