Sha256: 807a4b2ac36c6852c2228fb70b8e2fb2ad153eb49dcb735fe2b7828a8483b41c
Contents?: true
Size: 1.1 KB
Versions: 9
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true require "rest-client" require "json" require_relative "../response/api_error" require_relative "../error/api_error" module ONEAccess module API class ApiBase class << self def send_get(method, params = {}) Http::HttpClient.get(api_url(method), params) end def send_post(method, body) Http::HttpClient.post(api_url(method), body, content_type: :json) end def resource_api_path const_get("RESOURCE_API_PATH") rescue StandardError nil end def api_url(method = nil) url = "#{base_url}#{resource_api_path}" return url if method.nil? "#{url}/#{method}" end protected def api_path(path) raise "API path has already been set" if resource_api_path self.resource_api_path = path end private def base_url raise "base_url must be implemented" end def resource_api_path=(path) const_set("RESOURCE_API_PATH", path) end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems