class DuffelAPI::Services::RefundsService
Public Instance Methods
create(options = {})
click to toggle source
Creates a refund
@option [required, Hash] :params the payload for creating the refund @return [Resources::Refund] @raise [Errors::Error] when the Duffel API returns an error
# File lib/duffel_api/services/refunds_service.rb, line 11 def create(options = {}) path = "/payments/refunds" params = options.delete(:params) || {} options[:params] = {} options[:params]["data"] = params begin response = make_request(:post, path, options) # Response doesn't raise any errors until #body is called response.tap(&:raw_body) end return if response.raw_body.nil? Resources::Refund.new(unenvelope_body(response.parsed_body), response) end
get(id, options = {})
click to toggle source
Retrieves a single refund by ID
@param id [String] @return [Resources::Refund] @raise [Errors::Error] when the Duffel API returns an error
# File lib/duffel_api/services/refunds_service.rb, line 35 def get(id, options = {}) path = substitute_url_pattern("/payments/refunds/:id", "id" => id) response = make_request(:get, path, options) return if response.raw_body.nil? Resources::Refund.new(unenvelope_body(response.parsed_body), response) end