class ZipMoney::Query
Attributes
params[RW]
Public Class Methods
new()
click to toggle source
Initializes a ZipMoney::Query
object
Returns ZipMoney::Query
object
# File lib/zipMoney/api/query.rb, line 13 def initialize @params = Struct::QueryParams.new @params.orders = Array.new @params.metadata = Struct::Metadata.new @params.version = Struct::Version.new end
Public Instance Methods
do()
click to toggle source
Performs the Query
api call on zipMoney endpoint
Returns ZipMoney::Query
object
# File lib/zipMoney/api/query.rb, line 23 def do validate ZipMoney.api.query(@params) end
validate()
click to toggle source
Performs the parameters validation
# File lib/zipMoney/api/query.rb, line 29 def validate raise ArgumentError, "Params emtpy" if @params.nil? @errors = [] @errors << 'at least one order must be provided' unless @params.orders.length > 0 @params.orders.each_with_index do |item,index| @errors << "order.detail[#{index}].id must be provided" if item.id.nil? end raise ZipMoney::RequestError.new("Following error(s) occurred while making request, please resolve them to make the request: #{@errors}") if @errors.any? end