Sha256: 5b9b451154e80b7a2efac5dc3c1d469f3b426acec8c7f8d5586d0c96600cad5b

Contents?: true

Size: 999 Bytes

Versions: 3

Compression:

Stored size: 999 Bytes

Contents

module Mollie
  class Customer
    class Mandate < Base
      STATUS_VALID   = "valid"
      STATUS_INVALID = "invalid"
      STATUS_PENDING = "pending"

      attr_accessor :id,
                    :status,
                    :method,
                    :details,
                    :mandate_reference,
                    :signature_date,
                    :created_at,
                    :_links

      alias_method :links, :_links

      def details=(details)
        @details = OpenStruct.new(details) if details.is_a?(Hash)
      end

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

      def valid?
        status == STATUS_VALID
      end

      def pending?
        status == STATUS_PENDING
      end

      def invalid?
        status == STATUS_INVALID
      end

      def customer(options = {})
        customer_id = Util.extract_id(links, "customer")
        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/mandate.rb
mollie-api-ruby-4.0.0 lib/mollie/customer/mandate.rb
mollie-api-ruby-4.0.0.pre.alpha.1 lib/mollie/customer/mandate.rb