Sha256: c2c6800d829f88fe2e4ec448c3bbebee0e8299c0b141170e92f2547aea2fc01a

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

module Paid
  class Order < APIResource
    attr_reader :id
    attr_reader :object
    attr_reader :amount
    attr_accessor :charge_now
    attr_accessor :customer
    attr_accessor :metadata
    attr_accessor :subscription


    def self.all(params={}, headers={})
      method = APIMethod.new(:get, "/orders", params, headers, self)
      APIList.new(self, method.execute, method)
    end

    def self.retrieve(id, params={}, headers={})
      params = ParamsBuilder.merge(params, {
        :id => id
      })
      method = APIMethod.new(:get, "/orders/:id", params, headers, self)
      self.new(method.execute, method)
    end

    def self.create(params={}, headers={})
      method = APIMethod.new(:post, "/orders", params, headers, self)
      self.new(method.execute, method)
    end

    def refresh(params={}, headers={})
      method = APIMethod.new(:get, "/orders/:id", params, headers, self)
      self.refresh_from(method.execute, method)
    end

    def save(params={}, headers={})
      params = ParamsBuilder.merge(params, changed_api_attributes)
      method = APIMethod.new(:put, "/orders/:id", params, headers, self)
      self.refresh_from(method.execute, method)
    end


    APIResource.register_api_subclass(self, "order")
    @api_attributes = {
      :id => { :readonly => true },
      :object => { :readonly => true },
      :amount => { :readonly => true },
      :charge_now => nil,
      :customer => nil,
      :metadata => nil,
      :subscription => nil
    }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paid-1.2.1 lib/paid/order.rb
paid-1.2.0 lib/paid/order.rb
paid-1.1.4 lib/paid/order.rb
paid-1.1.3 lib/paid/order.rb