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
5 6 7 8 9 10 11 12 13 |
# File 'lib/greenhouse_io/api.rb', line 5 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
21 22 23 |
# File 'lib/greenhouse_io/api.rb', line 21 def parse_json(response) JSON.parse(response.body, symbolize_names: GreenhouseIo.configuration.symbolize_keys) end |
#post_response(url, payload, headers) ⇒ Object
15 16 17 18 19 |
# File 'lib/greenhouse_io/api.rb', line 15 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 |