class ActionKitRest::Base
Public Instance Methods
create(params)
click to toggle source
# File lib/action_kit_rest/base.rb, line 13 def create(params) resp = client.post_json_request(normalized_base_path, params) id = extract_id_from_response(resp) get(id) end
get(id)
click to toggle source
# File lib/action_kit_rest/base.rb, line 9 def get(id) client.get_request("#{normalized_base_path}#{url_escape(id)}/") end
list(filters = {})
click to toggle source
# File lib/action_kit_rest/base.rb, line 5 def list(filters = {}) client.get_request(normalized_base_path, filters) end
normalized_base_path()
click to toggle source
# File lib/action_kit_rest/base.rb, line 24 def normalized_base_path "#{base_path}/" end
update(id, params)
click to toggle source
# File lib/action_kit_rest/base.rb, line 19 def update(id, params) client.put_json_request("#{normalized_base_path}#{url_escape(id)}/", params) get(id) end
Private Instance Methods
extract_id_from_location(location)
click to toggle source
# File lib/action_kit_rest/base.rb, line 38 def extract_id_from_location(location) location.scan(%r{/(\d+)/$}).first.first end
extract_id_from_response(resp)
click to toggle source
# File lib/action_kit_rest/base.rb, line 34 def extract_id_from_response(resp) extract_id_from_location(resp.response.headers['location']) end
url_escape(string)
click to toggle source
# File lib/action_kit_rest/base.rb, line 30 def url_escape(string) CGI.escape(string.to_s) end