Module: GreenhouseIo::API
Instance Method Summary collapse
- #get_response(url, options) ⇒ Object
- #parse_json(response) ⇒ Object
- #post_response(url, payload, headers) ⇒ Object
Instance Method Details
#get_response(url, options) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/greenhouse_io/api.rb', line 6 def get_response(url, ) headers = {} if self.api_token credential = Base64.strict_encode64(self.api_token + ':') headers = { "Authorization" => "Basic " + credential } end headers.merge!({ params: }) unless .empty? RestClient.get(url, headers) end |
#parse_json(response) ⇒ Object
22 23 24 |
# File 'lib/greenhouse_io/api.rb', line 22 def parse_json(response) JSON.parse(response.body, symbolize_names: GreenhouseIo.configuration.symbolize_keys) end |
#post_response(url, payload, headers) ⇒ Object
16 17 18 19 20 |
# File 'lib/greenhouse_io/api.rb', line 16 def post_response(url, payload, headers) credential = Base64.strict_encode64(self.api_token + ':') headers.merge!({ "Authorization" => "Basic " + credential }) RestClient.post(url, payload[:body], headers) end |