Module: Moonclerk::APIOperations::List
- Included in:
- Customer, Form, ListObject, Payment
- Defined in:
- lib/moonclerk/api_operations/list.rb
Instance Method Summary collapse
- #list(params = {}) ⇒ Object (also: #all)
- #where(options = {}) ⇒ Object
Instance Method Details
#list(params = {}) ⇒ Object Also known as: all
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/moonclerk/api_operations/list.rb', line 4 def list(params = {}) response = request(:get, url, params) klass = self.is_a?(Moonclerk::ListObject) ? self[:object] : self.class_name.underscore.downcase obj = ListObject.construct_from({ data: response, object: klass }) # Set a count and offset so that we can fetch the same number when accessing the # next and previous pages obj.count = params[:count] obj.offset = params[:offset] obj end |
#where(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/moonclerk/api_operations/list.rb', line 23 def where( = {}) = Util.symbolize_names() params = {} (@permitted_attributes + default_param_keys).each do |key| if [key] if key.to_s.split("_").last =~ /from|to/ params[key] = CGI.escape([key].strftime("%Y-%m-%d")) else params[key] = CGI.escape([key].to_s) end end end list(params) end |