Sha256: a11be24017f257d93f52c4752da790c951e940ba7ba70eeb337f592a0cb77c64

Contents?: true

Size: 1.65 KB

Versions: 15

Compression:

Stored size: 1.65 KB

Contents

module Mollie
  class Refund < Base
    STATUS_QUEUED     = 'queued'.freeze
    STATUS_PENDING    = 'pending'.freeze
    STATUS_PROCESSING = 'processing'.freeze
    STATUS_REFUNDED   = 'refunded'.freeze
    STATUS_FAILED     = 'failed'.freeze

    attr_accessor :id,
                  :amount,
                  :settlement_amount,
                  :status,
                  :lines,
                  :payment_id,
                  :order_id,
                  :description,
                  :created_at,
                  :_links

    alias links _links

    def queued?
      status == STATUS_QUEUED
    end

    def pending?
      status == STATUS_PENDING
    end

    def processing?
      status == STATUS_PROCESSING
    end

    def refunded?
      status == STATUS_REFUNDED
    end

    def failed?
      status == STATUS_FAILED
    end

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

    def settlement_amount=(settlement_amount)
      @settlement_amount = Amount.new(settlement_amount)
    end

    def lines=(lines)
      @lines = lines.map { |line| Order::Line.new(line) }
    end

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

    def payment(options = {})
      Payment.get(payment_id, options)
    end

    def settlement(options = {})
      settlement_id = Util.extract_id(links, 'settlement')
      return if settlement_id.nil?
      Settlement.get(settlement_id, options)
    end

    def order(options = {})
      return if order_id.nil?
      Order.get(order_id, options)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mollie-api-ruby-4.6.2 lib/mollie/refund.rb
mollie-api-ruby-4.6.1 lib/mollie/refund.rb
mollie-api-ruby-4.6.0 lib/mollie/refund.rb
mollie-api-ruby-4.5.0 lib/mollie/refund.rb
mollie-api-ruby-4.4.1 lib/mollie/refund.rb
mollie-api-ruby-4.4.0 lib/mollie/refund.rb
mollie-api-ruby-4.3.1 lib/mollie/refund.rb
mollie-api-ruby-4.3.0 lib/mollie/refund.rb
mollie-api-ruby-4.2.0 lib/mollie/refund.rb
mollie-api-ruby-4.1.5 lib/mollie/refund.rb
mollie-api-ruby-4.1.4 lib/mollie/refund.rb
mollie-api-ruby-4.1.3 lib/mollie/refund.rb
mollie-api-ruby-4.1.2 lib/mollie/refund.rb
mollie-api-ruby-4.1.1 lib/mollie/refund.rb
mollie-api-ruby-4.1.0 lib/mollie/refund.rb