Class: StripeTransfer

Inherits:
StripeModelCallbacks::ApplicationRecord show all
Defined in:
lib/stripe_model_callbacks/models/stripe_transfer.rb

Instance Attribute Summary

Attributes inherited from StripeModelCallbacks::ApplicationRecord

#stripe_object

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StripeModelCallbacks::ApplicationRecord

create_from_stripe!, create_on_stripe!, #destroy_on_stripe, #destroy_on_stripe!, #reload!, #reload_from_stripe!, #to_stripe, #update_on_stripe, #update_on_stripe!

Class Method Details

.stripe_classObject



5
6
7
# File 'lib/stripe_model_callbacks/models/stripe_transfer.rb', line 5

def self.stripe_class
  Stripe::Transfer
end

Instance Method Details

#assign_from_stripe(object) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/stripe_model_callbacks/models/stripe_transfer.rb', line 9

def assign_from_stripe(object)
  assign_attributes(
    amount: Money.new(object.amount, object.currency),
    amount_reversed: Money.new(object.amount_reversed, object.currency),
    created: Time.zone.at(object.created),
    metadata: JSON.generate(object.)
  )

  StripeModelCallbacks::AttributesAssignerService.execute!(
    model: self, stripe_model: object,
    attributes: %w[
      balance_transaction currency description destination destination_payment livemode reversed
      source_transaction source_type transfer_group status
    ]
  )
end