Sha256: 9d0ac097121a2d887246712b8441ca352be3b7b9526dadc57013afc9944d9d37
Contents?: true
Size: 667 Bytes
Versions: 4
Compression:
Stored size: 667 Bytes
Contents
require 'json' module MobilizeAmericaClient module Request API_DOMAIN = 'api.mobilize.us'.freeze API_BASE_PATH = '/v1'.freeze def get(path:, params: {}) request(method: :get, path: path, params: params) end private def esc(untrusted) CGI.escape(untrusted.to_s) end def request(method:, path:, params: {}, body: {}) response = connection.send(method) do |req| req.path = "#{API_BASE_PATH}#{path}" req.params = params req.headers['Content-Type'] = 'application/json' req.body = ::JSON.generate(body) unless body.empty? end JSON.parse(response.body) end end end
Version data entries
4 entries across 4 versions & 1 rubygems