Sha256: 76fea946ee290700a80e766fdd282b2f27843f8013431af6f39ebcc3fc816838

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require "omise/object"
require "omise/list"
require "omise/customer"
require "omise/dispute"
require "omise/refund_list"
require "omise/transaction"

module Omise
  class Charge < OmiseObject
    self.endpoint = "/charges"

    def self.retrieve(id, attributes = {})
      new resource(location(id), attributes).get(attributes)
    end

    def self.list(attributes = {})
      List.new resource(location, attributes).get(attributes)
    end

    def self.create(attributes = {})
      new resource(location, attributes).post(attributes)
    end

    def reload(attributes = {})
      assign_attributes resource(attributes).get(attributes)
    end

    def update(attributes = {})
      assign_attributes resource(attributes).patch(attributes)
    end

    def capture(options = {})
      assign_attributes nested_resource("capture", options).post
    end

    def reverse(options = {})
      assign_attributes nested_resource("reverse", options).post
    end

    def customer(options = {})
      expand_attribute Customer, "customer", options
    end

    def dispute(options = {})
      expand_attribute Dispute, "dispute", options
    end

    def transaction(options = {})
      expand_attribute Transaction, "transaction", options
    end

    def refunds
      list_attribute RefundList, "refunds"
    end

    def captured
      lookup_attribute_value :captured, :paid
    end

    def paid
      lookup_attribute_value :paid, :captured
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omise-0.4.0 lib/omise/charge.rb