Class: Remit::GetPipeline::Pipeline
- Inherits:
-
Object
- Object
- Remit::GetPipeline::Pipeline
- Defined in:
- lib/remit/get_pipeline.rb
Direct Known Subclasses
MultiUsePipeline, PostpaidPipeline, RecipientPipeline, RecurringUsePipeline, SingleUsePipeline
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Class Method Summary collapse
- .convert_key(key) ⇒ Object
-
.inherited(subclass) ⇒ Object
Create the parameters hash for the subclass.
- .parameter(name) ⇒ Object
-
.parameters ⇒ Object
Returns a hash of all of the parameters for this request, including those that are inherited.
Instance Method Summary collapse
-
#initialize(api, options) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #url ⇒ Object
Constructor Details
#initialize(api, options) ⇒ Pipeline
Returns a new instance of Pipeline.
48 49 50 51 52 53 54 |
# File 'lib/remit/get_pipeline.rb', line 48 def initialize(api, ) @api = api .each do |k,v| self.send("#{k}=", v) end end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
33 34 35 |
# File 'lib/remit/get_pipeline.rb', line 33 def api @api end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
9 10 11 |
# File 'lib/remit/get_pipeline.rb', line 9 def parameters @parameters end |
Class Method Details
.convert_key(key) ⇒ Object
22 23 24 |
# File 'lib/remit/get_pipeline.rb', line 22 def convert_key(key) key.to_s.gsub(/_(.)/) { $1.upcase }.to_sym end |
.inherited(subclass) ⇒ Object
Create the parameters hash for the subclass.
13 14 15 |
# File 'lib/remit/get_pipeline.rb', line 13 def inherited(subclass) #:nodoc: subclass.instance_variable_set('@parameters', []) end |
.parameter(name) ⇒ Object
17 18 19 20 |
# File 'lib/remit/get_pipeline.rb', line 17 def parameter(name) attr_accessor name @parameters << name end |
.parameters ⇒ Object
Returns a hash of all of the parameters for this request, including those that are inherited.
28 29 30 |
# File 'lib/remit/get_pipeline.rb', line 28 def parameters #:nodoc: (superclass.respond_to?(:parameters) ? superclass.parameters : []) + @parameters end |
Instance Method Details
#url ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/remit/get_pipeline.rb', line 56 def url uri = URI.parse(@api.pipeline_url) query = {} self.class.parameters.each do |p| val = self.send(p) # Convert Time values to seconds from Epoch val = val.to_i if val.is_a?(Time) query[self.class.convert_key(p.to_s)] = val end # Remove any unused optional parameters query.reject! { |key, value| value.nil? || (value.is_a?(String) && value.empty?) } uri.query = SignedQuery.new(@api.pipeline_url, @api.secret_key, query).to_s uri.to_s end |