Sha256: 9ae0e5bdf9e6f2bfb39c0904c4d96823afb0fc7e2b758ba1ede8b4814e3c62bd

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

module PayPal
  module ExpressCheckout
    module Response
      class Profile < PayPal::ExpressCheckout::Response::Base
        has_fields :recurring, :amount, :ship_to, :credit_card, :payer, :address

        OUTSTANDING = {
          "AddToNextBilling"    => :next_billing,
          "NoAutoBill"          => :no_auto_bill
        }

        STATUS = {
          "Cancelled"           => :cancelled,
          "Active"              => :active,
          "Suspended"           => :suspended
        }

        PERIOD = {
          "Month"               => :monthly,
          "Weekly"              => :weekly,
          "Year"                => :yearly,
          "Day"                 => :daily
        }

        def active?
          status == :active
        end

        def build_auto_bill_outstanding(value)
          OUTSTANDING.fetch(value, value)
        end

        def build_status(value)
          STATUS.fetch(value, value)
        end

        def build_date(string)
          Time.parse(string)
        end

        def build_start_at(string)
          Time.parse(string)
        end

        def build_last_payment_date(string)
          Time.parse(string)
        end

        def build_period(value)
          PERIOD.fetch(value, value)
        end

        alias_method :build_start_at, :build_date
        alias_method :build_last_payment_date, :build_date
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paypal-payment-0.1.2 lib/paypal/express_checkout/response/profile.rb