Sha256: 9282ad32db494f43d9d8253fec38602ec384b45f4992130b3b8bee6b89f8c92a
Contents?: true
Size: 920 Bytes
Versions: 6
Compression:
Stored size: 920 Bytes
Contents
# frozen_string_literal: true 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(%r{/(\d+)/$}).first.first end end end
Version data entries
6 entries across 6 versions & 1 rubygems