lib/pdfmonkey/adapter.rb in pdfmonkey-0.4.0 vs lib/pdfmonkey/adapter.rb in pdfmonkey-0.5.0

- old
+ new

@@ -9,19 +9,23 @@ end def call(method, resource) response = send_request(method, resource) - if response.is_a?(Net::HTTPSuccess) - extract_attributes(response, resource) - else - extract_errors(response) + case response + when Net::HTTPNoContent then true + when Net::HTTPSuccess then extract_attributes(response, resource) + else extract_errors(response) end rescue StandardError => e { errors: [e.message], status: 'error' } end + private def build_delete_request(uri, _resource) + Net::HTTP::Delete.new(uri, headers) + end + private def build_get_request(uri, _resource) Net::HTTP::Get.new(uri, headers) end private def build_post_request(uri, resource) @@ -43,10 +47,11 @@ end private def headers { 'Authorization' => "Bearer #{config.private_key}", - 'Content-Type' => 'application/json' + 'Content-Type' => 'application/json', + 'User-Agent' => 'Ruby' } end private def send_request(method, resource) uri = URI(url_for(resource))