Sha256: f16fca3fd2b1c630eee46cfd811958869fa0ba79f7f04687ea327244a5a2a534

Contents?: true

Size: 516 Bytes

Versions: 3

Compression:

Stored size: 516 Bytes

Contents

class ShippingEasy::Resources::Base

  def self.command(name, command_options, &block)
    define_singleton_method name do |options = {}|
      options[:relative_path] = command_options.fetch(:relative_path, block.call(options))
      options[:http_method] = command_options.fetch(:http_method, :get)
      execute_request!(options)
    end
  end

  def self.execute_request!(options = {})
    response = ShippingEasy::Http::Request.connect!(options)
    ShippingEasy::Http::ResponseHandler.run(response)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shipping_easy-0.2.2 lib/shipping_easy/resources/base.rb
shipping_easy-0.2.1 lib/shipping_easy/resources/base.rb
shipping_easy-0.2.0 lib/shipping_easy/resources/base.rb