Sha256: 08e67c151a2b7b452b32d49047ae8e2fd47a24afd49f8afc07e4d0aee3e60c72

Contents?: true

Size: 999 Bytes

Versions: 3

Compression:

Stored size: 999 Bytes

Contents

require "omise/object"
require "omise/list"
require "omise/charge_list"
require "omise/search_scope"

module Omise
  class Link < OmiseObject
    self.endpoint = "/links"

    def self.search
      SearchScope.new(:link)
    end

    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 destroy(attributes = {})
      assign_attributes resource(attributes).delete
    end

    def charges(options = {})
      if options.empty?
        list_attribute ChargeList, "charges"
      else
        response = collection.resource(location("charges")).get(options)
        ChargeList.new(self, response)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
omise-0.11.0 lib/omise/link.rb
omise-0.10.1 lib/omise/link.rb
omise-0.10.0 lib/omise/link.rb