Sha256: 0b42477e5843b7d757ea8c8277ceccd3f8cf9e05a895d0f14802372a35dd659f

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

module Mollie
  class Customer
    class Subscription < Base
      STATUS_ACTIVE    = "active"
      STATUS_PENDING   = "pending" # Waiting for a valid mandate.
      STATUS_CANCELED  = "canceled"
      STATUS_SUSPENDED = "suspended" # Active, but mandate became invalid.
      STATUS_COMPLETED = "completed"

      attr_accessor :id,
                    :customer_id,
                    :mode,
                    :created_at,
                    :status,
                    :amount,
                    :times,
                    :interval,
                    :description,
                    :method,
                    :canceled_at,
                    :webhook_url

      def active?
        status == STATUS_ACTIVE
      end

      def pending?
        status == STATUS_PENDING
      end

      def suspended?
        status == STATUS_SUSPENDED
      end

      def canceled?
        status == STATUS_CANCELED
      end

      def completed?
        status == STATUS_COMPLETED
      end

      def created_at=(created_at)
        @created_at = Time.parse(created_at.to_s) rescue nil
      end

      def canceled_at=(canceled_at)
        @canceled_at = Time.parse(canceled_at.to_s) rescue nil
      end

      def amount=(amount)
        @amount = Mollie::Amount.new(amount)
      end

      def times=(times)
        @times = times.to_i
      end

      def customer(options = {})
        Customer.get(customer_id, options)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mollie-api-ruby-4.0.0.pre.alpha.2 lib/mollie/customer/subscription.rb
mollie-api-ruby-4.0.0 lib/mollie/customer/subscription.rb
mollie-api-ruby-4.0.0.pre.alpha.1 lib/mollie/customer/subscription.rb