Sha256: 5be9867ac7efcd66bf84f7bb62735b194d3e6ac349c9157119026d8a68041efd
Contents?: true
Size: 995 Bytes
Versions: 86
Compression:
Stored size: 995 Bytes
Contents
require 'httparty' module ForestLiana class ForestApiRequester def self.get(route, query: nil, headers: {}) begin HTTParty.get("#{forest_api_url}#{route}", { headers: base_headers.merge(headers), query: query, }).response rescue raise 'Cannot reach Forest API, it seems to be down right now.' end end def self.post(route, body: nil, query: nil, headers: {}) begin HTTParty.post("#{forest_api_url}#{route}", { headers: base_headers.merge(headers), query: query, body: body.to_json, }).response rescue raise 'Cannot reach Forest API, it seems to be down right now.' end end private def self.base_headers { 'Content-Type' => 'application/json', 'forest-secret-key' => ForestLiana.env_secret, } end def self.forest_api_url ENV['FOREST_URL'] || 'https://api.forestadmin.com' end end end
Version data entries
86 entries across 86 versions & 1 rubygems