Sha256: 1d66d5b3006218b86b8264aa66100620457f87d846289fba10976c945e9aad94

Contents?: true

Size: 1.97 KB

Versions: 3

Compression:

Stored size: 1.97 KB

Contents

module PayPal
  module Recurring
    module Response
      class Profile < Base
        mapping(
          :profile_id          => :PROFILEID,
          :status              => :STATUS,
          :description         => :DESC,
          :outstanding         => :AUTOBILLOUTAMT,
          :failed              => :MAXFAILEDPAYMENTS,
          :payer_name          => :SUBSCRIBERNAME,
          :start_at            => :PROFILESTARTDATE,
          :reference           => :PROFILEREFERENCE,
          :completed           => :NUMCYCLESCOMPLETED,
          :remaining           => :NUMCYCLESREMAINING,
          :outstanding_balance => :OUTSTANDINGBALANCE,
          :failed_count        => :FAILEDPAYMENTCOUNT,
          :last_payment_date   => :LASTPAYMENTDATE,
          :last_payment_amount => :LASTPAYMENTAMT,
          :period              => :BILLINGPERIOD,
          :frequency           => :BILLINGFREQUENCY,
          :currency            => :CURRENCYCODE,
          :amount              => :AMT,
          :initial_amount      => :AGGREGATEOPTIONALAMT
        )

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

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

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

        def active?
          status == :active
        end

        private
        def build_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_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

3 entries across 3 versions & 2 rubygems

Version Path
didil-paypal-recurring-1.1.1 lib/paypal/recurring/response/profile.rb
paypal-recurring-1.1.0 lib/paypal/recurring/response/profile.rb
paypal-recurring-1.0.0 lib/paypal/recurring/response/profile.rb