class EasyPing::Refund
Public Class Methods
create(*args)
click to toggle source
# File lib/easy_ping/action.rb, line 62 def self.create(*args) new(EasyPing::Base.config).refund(*args) end
new(config)
click to toggle source
Calls superclass method
EasyPing::Action::new
# File lib/easy_ping/action.rb, line 66 def initialize(config) super(config) @settings = config.to_options end
Public Instance Methods
all(*args)
click to toggle source
# File lib/easy_ping/action.rb, line 100 def all(*args) params = indifferent_params(args, 'charge_id') # map keys to API request format params = compile params # set up charge id for refund action @charge_id = params.delete 'charge_id' raw_response = client.run :get, api_endpoint, params EasyPing::Model::Wrapper.parse! raw_response, config end
find(*args)
click to toggle source
# File lib/easy_ping/action.rb, line 91 def find(*args) params = indifferent_params(args, 'charge_id', 'refund_id') @charge_id, @refund_id = params.values_at('charge_id', 'refund_id') # run request and parse return result raw_response = client.run :get, "#{api_endpoint}/#{@refund_id}" EasyPing::Model::Wrapper.parse! raw_response, config end
refund(*args)
click to toggle source
# File lib/easy_ping/action.rb, line 71 def refund(*args) amount = args.first if Integer === amount params = indifferent_params(args, 'amount', 'description', 'charge_id') else params = indifferent_params(args, 'description', 'charge_id') end # map keys to API request format and verify options params = compile params verify! params, refund_requires # set up charge id for refund action @charge_id = params.delete 'charge_id' # run request and parse return result raw_response = client.run(:post, api_endpoint, params) EasyPing::Model::Wrapper.parse! raw_response, config end
Private Instance Methods
api_endpoint()
click to toggle source
# File lib/easy_ping/action.rb, line 114 def api_endpoint "/v1/charges/#{@charge_id}/refunds" end
mappings()
click to toggle source
# File lib/easy_ping/action.rb, line 122 def mappings { 'from' => 'charge_id', 'offset' => 'starting_after' } end
refund_requires()
click to toggle source
# File lib/easy_ping/action.rb, line 118 def refund_requires ['charge_id', 'description'] end