class DataValidation::API
Constants
- BASE_URI
Attributes
key[R]
Public Class Methods
new(key)
click to toggle source
# File lib/data_validation/api.rb, line 10 def initialize(key) @key = key end
Public Instance Methods
get(uri, h = {})
click to toggle source
# File lib/data_validation/api.rb, line 14 def get(uri, h = {}) HTTParty.get("#{BASE_URI}/#{uri}", headers: headers.merge(h)) end
post(uri, body = nil, h = {})
click to toggle source
# File lib/data_validation/api.rb, line 18 def post(uri, body = nil, h = {}) q = {} q[:body] = body unless body.nil? q[:headers] = headers.merge(h) HTTParty.post("#{BASE_URI}/#{uri}", q) end
valid_response?(response)
click to toggle source
# File lib/data_validation/api.rb, line 25 def valid_response?(response) code = response.code code >= 200 && code <= 299 end
Private Instance Methods
headers()
click to toggle source
# File lib/data_validation/api.rb, line 31 def headers { 'Authorization' => "bearer #{@key}" } end