Class: XporterOnDemand::Endpoint
- Inherits:
-
Object
- Object
- XporterOnDemand::Endpoint
- Includes:
- Utils
- Defined in:
- lib/xporter_on_demand/endpoint.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#id ⇒ Object
Returns the value of attribute id.
-
#options ⇒ Object
Returns the value of attribute options.
-
#pagination ⇒ Object
Returns the value of attribute pagination.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#uri ⇒ Object
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #build_query ⇒ Object
-
#initialize(args = {}) ⇒ Endpoint
constructor
A new instance of Endpoint.
Methods included from Utils
#assign_attributes, #configure_request, #create_result, #dont_raise_exception, #handle_exceptions, #parameterize, #unwrap
Constructor Details
#initialize(args = {}) ⇒ Endpoint
Returns a new instance of Endpoint.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/xporter_on_demand/endpoint.rb', line 22 def initialize(args = {}) = args.fetch(:options, []) @parameters = args.fetch(:parameters, {}) @parameters[:page] ||= 1 @parameters[:page_size] ||= 25 @id = args[:id] # Check that all the options are valid? # Check that the parameters are valid? # Check the pagination params are valid? end |
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
7 8 9 |
# File 'lib/xporter_on_demand/endpoint.rb', line 7 def endpoint @endpoint end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/xporter_on_demand/endpoint.rb', line 7 def id @id end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/xporter_on_demand/endpoint.rb', line 7 def end |
#pagination ⇒ Object
Returns the value of attribute pagination.
7 8 9 |
# File 'lib/xporter_on_demand/endpoint.rb', line 7 def pagination @pagination end |
#parameters ⇒ Object
Returns the value of attribute parameters.
7 8 9 |
# File 'lib/xporter_on_demand/endpoint.rb', line 7 def parameters @parameters end |
#uri ⇒ Object
Returns the value of attribute uri.
7 8 9 |
# File 'lib/xporter_on_demand/endpoint.rb', line 7 def uri @uri end |
Class Method Details
.create(endpoint, args = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/xporter_on_demand/endpoint.rb', line 9 def self.create(endpoint, args = {}) endpoint_name = endpoint.to_s.classify unless const_defined?(endpoint_name, false) class_name = Class.new(self) endpoint_class = const_set(endpoint_name, class_name) end const_get(endpoint_name).new(args).tap do |s| s.instance_variable_set(:@endpoint, endpoint) end end |
Instance Method Details
#build_query ⇒ Object
36 37 38 |
# File 'lib/xporter_on_demand/endpoint.rb', line 36 def build_query URI.escape(resource + "?" + build_parameters) end |