class ForteRuby::API::Objects
Public Instance Methods
all()
click to toggle source
# File lib/forte_ruby/api/objects.rb, line 4 def all send_request(url, :get) do |response| parse_response(response) end end
build_from(params)
click to toggle source
# File lib/forte_ruby/api/objects.rb, line 10 def build_from(params) single_class.new(params.merge(request_data: request_data, new: true)) end
filter(params)
click to toggle source
# File lib/forte_ruby/api/objects.rb, line 20 def filter(params) filter_value = params.map{ |key, value| "#{key}+eq+#{value}"}.join("+and+") send_request(url + "?filter=#{filter_value}", :get) do |response| parse_response(response) end end
find_by_id(id)
click to toggle source
# File lib/forte_ruby/api/objects.rb, line 14 def find_by_id(id) send_request(url + "/#{id}", :get) do |response| parse_response(response) end end
Protected Instance Methods
single_class()
click to toggle source
# File lib/forte_ruby/api/objects.rb, line 29 def single_class raise 'Impelement it' end
url()
click to toggle source
# File lib/forte_ruby/api/objects.rb, line 33 def url raise 'Impelement it' end
Private Instance Methods
parse_response(response)
click to toggle source
# File lib/forte_ruby/api/objects.rb, line 39 def parse_response(response) parsed_response = JSON.parse(response) if parsed_response['results'] self.result = parsed_response['results'].map do |object_params| single_class.new(object_params.merge(request_data: request_data)) end else self.result = single_class.new(parsed_response) end end