Class: ZipMoney::Capture
- Inherits:
-
Object
- Object
- ZipMoney::Capture
- Includes:
- Request
- Defined in:
- lib/zipMoney/api/capture.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Attributes included from Request
Instance Method Summary collapse
-
#do ⇒ Object
Performs the Capture api call on zipMoney endpoint.
-
#initialize ⇒ Capture
constructor
Initializes a ZipMoney::Capture object.
-
#validate ⇒ Object
Performs the parameters validation.
Methods included from Request
Constructor Details
#initialize ⇒ Capture
Initializes a ZipMoney::Capture object
Returns ZipMoney::Capture object
12 13 14 15 16 17 18 |
# File 'lib/zipMoney/api/capture.rb', line 12 def initialize @params = Struct::CaptureParams.new @params.order = Struct::Order.new @params. = Struct::Metadata.new @params.version = Struct::Version.new @params.order.detail = Array.new end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
5 6 7 |
# File 'lib/zipMoney/api/capture.rb', line 5 def params @params end |
Instance Method Details
#do ⇒ Object
Performs the Capture api call on zipMoney endpoint
Returns ZipMoney::Cancel object
23 24 25 26 |
# File 'lib/zipMoney/api/capture.rb', line 23 def do validate ZipMoney.api.capture(@params) end |
#validate ⇒ Object
Performs the parameters validation
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/zipMoney/api/capture.rb', line 29 def validate raise ArgumentError, "Params emtpy" if @params.nil? @errors = [] @errors << 'txn_id must be provided' if @params.txn_id.nil? @errors << 'order.id must be provided' if @params.order.id.nil? @errors << 'order.total must be provided' if @params.order.total.nil? @errors << 'order.shipping_value must be provided' if @params.order.shipping_value.nil? @errors << 'order.tax must be provided' if @params.order.tax.nil? @errors << 'order detail must be provided' if @params.order.detail.nil? validate_item_details @params.order.detail raise ZipMoney::RequestError.new("Following error(s) occurred while making request, please resolve them to make the request: #{@errors}") if @errors.any? end |