Class: UpsPickup::Shipper
- Inherits:
-
Object
- Object
- UpsPickup::Shipper
- Defined in:
- lib/ups_pickup/shipper.rb
Instance Attribute Summary collapse
-
#account_country_code ⇒ Object
Returns the value of attribute account_country_code.
-
#account_number ⇒ Object
Returns the value of attribute account_number.
-
#card_address ⇒ Object
Returns the value of attribute card_address.
-
#card_hoder_name ⇒ Object
Returns the value of attribute card_hoder_name.
-
#card_number ⇒ Object
Returns the value of attribute card_number.
-
#card_type ⇒ Object
Returns the value of attribute card_type.
-
#expiration_date ⇒ Object
Returns the value of attribute expiration_date.
-
#payment_method ⇒ Object
Returns the value of attribute payment_method.
-
#security_code ⇒ Object
Returns the value of attribute security_code.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Shipper
constructor
options=>:card_address=>{:state=>,:city=>,…} Valid Card Type values are : 01 = American Express 03 = Discover 04 = Mastercard 06 = VISA.
- #to_ups_hash ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Shipper
options=>:card_address=>{:state=>,:city=>,…} Valid Card Type values are : 01 = American Express 03 = Discover 04 = Mastercard 06 = VISA
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ups_pickup/shipper.rb', line 11 def initialize(={}) @account_number = [:account_number] @account_country_code = [:account_country_code] || "US" @card_hoder_name = [:card_hoder_name] # TODO Validate card type 01 = American Express 03 = Discover 04 = Mastercard 06 = VISA # if country code is US and payment method is 3 @card_type = [:card_type] @card_number = [:card_number] @expiration_date = [:expiration_date] @security_code = [:security_code] @card_address = UpsPickup::Address.new([:card_address]) #TODO raise an exception for payment method @payment_method = [:payment_method] if ![:payment_method].nil? && [0,1,2,3,4,5].include?([:payment_method].to_i) @payment_method ||="00" end |
Instance Attribute Details
#account_country_code ⇒ Object
Returns the value of attribute account_country_code.
3 4 5 |
# File 'lib/ups_pickup/shipper.rb', line 3 def account_country_code @account_country_code end |
#account_number ⇒ Object
Returns the value of attribute account_number.
3 4 5 |
# File 'lib/ups_pickup/shipper.rb', line 3 def account_number @account_number end |
#card_address ⇒ Object
Returns the value of attribute card_address.
4 5 6 |
# File 'lib/ups_pickup/shipper.rb', line 4 def card_address @card_address end |
#card_hoder_name ⇒ Object
Returns the value of attribute card_hoder_name.
3 4 5 |
# File 'lib/ups_pickup/shipper.rb', line 3 def card_hoder_name @card_hoder_name end |
#card_number ⇒ Object
Returns the value of attribute card_number.
3 4 5 |
# File 'lib/ups_pickup/shipper.rb', line 3 def card_number @card_number end |
#card_type ⇒ Object
Returns the value of attribute card_type.
3 4 5 |
# File 'lib/ups_pickup/shipper.rb', line 3 def card_type @card_type end |
#expiration_date ⇒ Object
Returns the value of attribute expiration_date.
4 5 6 |
# File 'lib/ups_pickup/shipper.rb', line 4 def expiration_date @expiration_date end |
#payment_method ⇒ Object
Returns the value of attribute payment_method.
4 5 6 |
# File 'lib/ups_pickup/shipper.rb', line 4 def payment_method @payment_method end |
#security_code ⇒ Object
Returns the value of attribute security_code.
4 5 6 |
# File 'lib/ups_pickup/shipper.rb', line 4 def security_code @security_code end |
Instance Method Details
#to_ups_hash ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ups_pickup/shipper.rb', line 27 def to_ups_hash if @payment_method.to_i == 3 { "ns2:Account"=>{ "AccountNumber"=>@account_number, "AccountCountryCode"=>@account_country_code }, "ns2:ChargeCard"=>{ "ns2:CardType"=>@card_type, "ns2:CardNumber"=>@card_number, "ns2:ExpirationDate"=>@expiration_date, "ns2:SecurityCode"=>@security_code, "ns2:CardAddress"=>{ "ns2:AddressLine"=>@card_address.to_ups_hash } } } else { "ns2:Account"=>{ "ns2:AccountNumber"=>@account_number, "ns2:AccountCountryCode"=>@account_country_code } } end end |