class Signable::Query::Client

Public Class Methods

new() click to toggle source
# File lib/signable/query/client.rb, line 6
def initialize
  self.class.base_uri "https://#{Signable.configuration.base_url}/v1"
  self.class.basic_auth Signable.configuration.api_key, ''
  self.class.default_options[:verify] = false
end

Public Instance Methods

all(entry_point, offset, limit) click to toggle source
# File lib/signable/query/client.rb, line 12
def all(entry_point, offset, limit)
  response = self.class.get "/#{entry_point}", query: { offset: offset, limit: limit }
  Response.new response
end
create(entry_point, object) click to toggle source
# File lib/signable/query/client.rb, line 27
def create(entry_point, object)
  response = self.class.post "/#{entry_point}", body: jsonify(object.form_data)
  Response.new response
end
delete(entry_poind, id) click to toggle source
# File lib/signable/query/client.rb, line 32
def delete(entry_poind, id)
  response = self.class.delete "/#{entry_point}/#{id}"
  Response.new response
end
find(entry_point, id) click to toggle source
# File lib/signable/query/client.rb, line 17
def find(entry_point, id)
  response = self.class.get "/#{entry_point}/#{id}"
  Response.new response
end
update(entry_point, id, object) click to toggle source
# File lib/signable/query/client.rb, line 22
def update(entry_point, id, object)
  response = self.class.put "/#{entry_point}/#{id}", body: jsonify(object.form_data)
  Response.new response
end

Private Instance Methods

jsonify(hash) click to toggle source
# File lib/signable/query/client.rb, line 39
def jsonify(hash)
  hash.each do |key, value|
    if value.is_a? Array
      hash[key] = value.to_json
    end
  end

  hash
end