Class: ShippingEasy::Resources::Base
- Inherits:
-
Object
- Object
- ShippingEasy::Resources::Base
show all
- Defined in:
- lib/shipping_easy/resources/base.rb
Class Method Summary
collapse
Class Method Details
.command(name, command_options = {}, &block) ⇒ Object
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/shipping_easy/resources/base.rb', line 3
def self.command(name, command_options = {}, &block)
define_singleton_method name do |options = {}|
request_options = {}
request_options[:relative_path] = command_options.fetch(:relative_path, block.call(options))
request_options[:http_method] = command_options.fetch(:http_method, :get)
request_options[:payload] = options.delete(:payload) if options.has_key?(:payload)
request_options[:params] = options unless options.nil? || options.empty?
execute_request!(request_options, command_options.fetch(:request_type, :public))
end
end
|
.execute_request!(options = {}, request_type) ⇒ Object