Skip to content
Browse files

Add support for SUBJECT parameter.

API Credentials can have optional SUBJECT parameter to specify
the email address of the third-party merchant.
  • Loading branch information...
1 parent 8ae734d commit 66dd33ae99f67d63006f2c84547ab8b368e42951 @soulim soulim committed Sep 6, 2012
Showing with 31 additions and 0 deletions.
  1. +2 −0 lib/paypal/nvp/request.rb
  2. +29 −0 spec/paypal/nvp/request_spec.rb
View
2 lib/paypal/nvp/request.rb
@@ -2,6 +2,7 @@ module Paypal
module NVP
class Request < Base
attr_required :username, :password, :signature
+ attr_optional :subject
attr_accessor :version
ENDPOINT = {
@@ -27,6 +28,7 @@ def common_params
:USER => self.username,
:PWD => self.password,
:SIGNATURE => self.signature,
+ :SUBJECT => self.subject,
:VERSION => self.version
}
end
View
29 spec/paypal/nvp/request_spec.rb
@@ -47,6 +47,35 @@
end
end
end
+
+ context 'when optional parameters are given' do
+ let(:optional_attributes) do
+ { :subject => 'user@example.com' }
+ end
+
+ it 'should setup subject' do
+ client = Paypal::NVP::Request.new attributes.merge(optional_attributes)
+ client.subject.should == 'user@example.com'
+ end
+ end
+ end
+
+ describe '#common_params' do
+ {
+ :username => :USER,
+ :password => :PWD,
+ :signature => :SIGNATURE,
+ :subject => :SUBJECT,
+ :version => :VERSION
+ }.each do |option_key, param_key|
+ it "should include :#{param_key}" do
+ instance.common_params.should include(param_key)
+ end
+
+ it "should set :#{param_key} as #{option_key}" do
+ instance.common_params[param_key].should == instance.send(option_key)
+ end
+ end
end
describe '#request' do

0 comments on commit 66dd33a

Please sign in to comment.
Something went wrong with that request. Please try again.