class HackerRank::Base

Constants

BASE_URI

Public Class Methods

all(params = {}) click to toggle source
# File lib/hackerrank/base.rb, line 11
def self.all(params = {})
  request :get, "", params
end
collection_path(collection_path) click to toggle source
# File lib/hackerrank/base.rb, line 7
def self.collection_path(collection_path)
  @collection_path = collection_path
end
create(params) click to toggle source
# File lib/hackerrank/base.rb, line 19
def self.create(params)
  request :post, "", params
end
delete(id, params = {}) click to toggle source
# File lib/hackerrank/base.rb, line 27
def self.delete(id, params = {})
  request :delete, "/#{id}", params
end
find(id, params = {}) click to toggle source
# File lib/hackerrank/base.rb, line 15
def self.find(id, params = {})
  request :get, "/#{id}", params
end
update(id, params) click to toggle source
# File lib/hackerrank/base.rb, line 23
def self.update(id, params)
  request :put, "/#{id}", params
end

Private Class Methods

auth() click to toggle source
# File lib/hackerrank/base.rb, line 37
def self.auth
  { access_token: HackerRank.access_token }
end
request(method, path, body_params, query_params = {}) click to toggle source
# File lib/hackerrank/base.rb, line 33
def self.request(method, path, body_params, query_params = {})
  HTTParty.send(method, "#{BASE_URI}#{@collection_path.call(body_params)}#{path}", { query: auth.merge(query_params), body: body_params })[response_key]
end