class Payrix::Http::RequestParams
Public Class Methods
new(sort = '', expand = [], page = 1, totals = {})
click to toggle source
# File lib/payrix/http/request_params.rb, line 4 def initialize(sort = '', expand = [], page = 1, totals = {}) self.sort = sort self.expand = expand self.page = page self.totals = totals end
Public Instance Methods
expand()
click to toggle source
# File lib/payrix/http/request_params.rb, line 23 def expand @expand.map do |s| fields = s.split(',').map { |field| "[#{field.strip}]" } "expand#{fields.join}[]" end.join('&') end
expand=(expand)
click to toggle source
# File lib/payrix/http/request_params.rb, line 30 def expand=(expand) if expand.is_a?(Array) @expand = expand end end
go_next_page()
click to toggle source
# File lib/payrix/http/request_params.rb, line 62 def go_next_page @page = @page.nil? || @page == 0 ? 1 : @page + 1 end
page()
click to toggle source
# File lib/payrix/http/request_params.rb, line 54 def page @page.nil? || @page == 0 ? "" : "page[number]=#{@page}" end
page=(page)
click to toggle source
# File lib/payrix/http/request_params.rb, line 58 def page=(page) @page = page end
sort()
click to toggle source
# File lib/payrix/http/request_params.rb, line 11 def sort @sort end
sort=(sort)
click to toggle source
# File lib/payrix/http/request_params.rb, line 15 def sort=(sort) if sort.is_a?(Array) && sort.size == 2 @sort = "#{sort[0]}[sort]=#{sort[1]}" else @sort = sort end end
totals()
click to toggle source
Retrieve the totals header string
# File lib/payrix/http/request_params.rb, line 37 def totals @totals.map do |action, values| if values.is_a?(Array) && !values.empty? values.map do |value| "#{action}[]=#{value}" end end end.join('&') end
totals=(totals)
click to toggle source
Set the totals hash
# File lib/payrix/http/request_params.rb, line 48 def totals=(totals) if totals.is_a?(Hash) @totals = totals end end