Sha256: 21d19225e5544715543bf17a0231960b0a878edca33b4a3cfbb5a39de79e6ae4
Contents?: true
Size: 889 Bytes
Versions: 11
Compression:
Stored size: 889 Bytes
Contents
module ActionKitRest class Base < Vertebrae::Model def list(filters = {}) client.get_request(normalized_base_path, filters) end def get(id) client.get_request("#{normalized_base_path}#{url_escape(id)}/") end def create(params) resp = client.post_json_request(normalized_base_path, params) id = extract_id_from_response(resp) get(id) end def update(id, params) client.put_json_request("#{normalized_base_path}#{url_escape(id)}/", params) get(id) end def normalized_base_path "#{base_path}/" end private def url_escape(string) CGI.escape(string.to_s) end def extract_id_from_response(resp) extract_id_from_location(resp.response.headers["location"]) end def extract_id_from_location(location) location.scan(/\/(\d+)\/$/).first.first end end end
Version data entries
11 entries across 11 versions & 1 rubygems