Class: SimplyWompi::Transactions::Domain::Entities::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/simply_wompi/transactions/domain/entities/transaction.rb

Overview

Transaction Entity

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, created_at:, amount_in_cents:, status:, reference:, customer_email:, currency:, payment_method_type:, payment_method:, redirect_url:, payment_link_id:) ⇒ Transaction

Returns a new instance of Transaction.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 21

def initialize(
  id:,
  created_at:,
  amount_in_cents:,
  status:,
  reference:,
  customer_email:,
  currency:,
  payment_method_type:,
  payment_method:,
  redirect_url:,
  payment_link_id:
)
  unless id.is_a?(String)
    raise ArgumentError("ArgumentError id: #{id.class}, is not instance of #{String}")
  end

  unless created_at.is_a?(Date)
    raise ArgumentError("ArgumentError created_at: #{created_at.class}, is not instance of #{Date}")
  end

  unless amount_in_cents.is_a?(Integer)
    raise ArgumentError("ArgumentError amount_in_cents: #{amount_in_cents.class}, is not instance of #{Integer}")
  end

  unless status.is_a?(String)
    raise ArgumentError("ArgumentError status: #{status.class}, is not instance of #{String}")
  end

  unless reference.is_a?(String)
    raise ArgumentError("ArgumentError reference: #{reference.class}, is not instance of #{String}")
  end

  unless customer_email.is_a?(String)
    raise ArgumentError("ArgumentError customer_email: #{customer_email.class}, is not instance of #{String}")
  end

  unless currency.is_a?(String)
    raise ArgumentError("ArgumentError currency: #{currency.class}, is not instance of #{String}")
  end

  unless payment_method_type.is_a?(String)
    raise ArgumentError("ArgumentError payment_method_type: #{payment_method_type.class}, is not instance of #{String}")
  end

  unless payment_method.is_a?(Dtos::CreatePaymentPaymentMethodDto)
    raise ArgumentError("ArgumentError payment_method: #{payment_method.class}, is not instance of #{CreatePaymentPaymentMethodDto}")
  end

  unless redirect_url.is_a?(String)
    raise ArgumentError("ArgumentError redirect_url: #{redirect_url.class}, is not instance of #{String}")
  end

  unless payment_link_id.is_a?(String)
    raise ArgumentError("ArgumentError payment_link_id: #{payment_link_id.class}, is not instance of #{String}")
  end

  self.id = id
  self.created_at = created_at
  self.amount_in_cents = amount_in_cents
  self.status = status
  self.reference = reference
  self.customer_email = customer_email
  self.currency = currency
  self.payment_method_type = payment_method_type
  self.payment_method = payment_method
  self.redirect_url = redirect_url
  self.payment_link_id = payment_link_id
end

Instance Attribute Details

#amount_in_centsObject

Returns the value of attribute amount_in_cents.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def amount_in_cents
  @amount_in_cents
end

#created_atObject

Returns the value of attribute created_at.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def currency
  @currency
end

#customer_emailObject

Returns the value of attribute customer_email.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def customer_email
  @customer_email
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def id
  @id
end

Returns the value of attribute payment_link_id.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def payment_link_id
  @payment_link_id
end

#payment_methodObject

Returns the value of attribute payment_method.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def payment_method
  @payment_method
end

#payment_method_typeObject

Returns the value of attribute payment_method_type.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def payment_method_type
  @payment_method_type
end

#redirect_urlObject

Returns the value of attribute redirect_url.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def redirect_url
  @redirect_url
end

#referenceObject

Returns the value of attribute reference.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def reference
  @reference
end

#statusObject

Returns the value of attribute status.



9
10
11
# File 'lib/simply_wompi/transactions/domain/entities/transaction.rb', line 9

def status
  @status
end