class Tikkie::Api::Resources::Refund
Resource for a Refund
.
Constants
- STATUS_PAID
- STATUS_PENDING
Attributes
payment_request_token[R]
payment_token[R]
Public Class Methods
new(config, options = {})
click to toggle source
Calls superclass method
Tikkie::Api::Resources::Base::new
# File lib/tikkie/api/resources/refund.rb, line 15 def initialize(config, options = {}) @payment_request_token = options.delete(:payment_request_token) @payment_token = options.delete(:payment_token) @refund_token = options.delete(:refund_token) super(config, options) end
Public Instance Methods
amount()
click to toggle source
# File lib/tikkie/api/resources/refund.rb, line 26 def amount Tikkie::Api::Amount.from_cents(body[:amountInCents]).to_d end
created_at()
click to toggle source
# File lib/tikkie/api/resources/refund.rb, line 38 def created_at Time.parse(body[:createdDateTime]) if body[:createdDateTime] end
description()
click to toggle source
# File lib/tikkie/api/resources/refund.rb, line 30 def description body[:description] end
paid?()
click to toggle source
# File lib/tikkie/api/resources/refund.rb, line 50 def paid? status == STATUS_PAID end
pending?()
click to toggle source
# File lib/tikkie/api/resources/refund.rb, line 46 def pending? status == STATUS_PENDING end
reference_id()
click to toggle source
# File lib/tikkie/api/resources/refund.rb, line 34 def reference_id body[:referenceId] end
refund_token()
click to toggle source
# File lib/tikkie/api/resources/refund.rb, line 22 def refund_token @refund_token || body[:refundToken] end
status()
click to toggle source
# File lib/tikkie/api/resources/refund.rb, line 42 def status body[:status] end
Private Instance Methods
create_resource(attributes)
click to toggle source
# File lib/tikkie/api/resources/refund.rb, line 60 def create_resource(attributes) params = { description: attributes.fetch(:description) } amount = Tikkie::Api::Amount.new(attributes.fetch(:amount)) params[:amountInCents] = amount.to_cents params[:referenceId] = attributes[:reference_id] if attributes.key?(:reference_id) request.post("paymentrequests/#{payment_request_token}/payments/#{payment_token}/refunds", options, params) end
load_resource()
click to toggle source
# File lib/tikkie/api/resources/refund.rb, line 56 def load_resource request.get("paymentrequests/#{payment_request_token}/payments/#{payment_token}/refunds/#{refund_token}", options) end