Class: DPay::PayoutDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/dpay/payout/payout_details.rb,
sig/dpay/payout/payout_details.rbs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ PayoutDetails

Returns a new instance of PayoutDetails.

Parameters:

  • data (Hash[String, untyped])


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dpay/payout/payout_details.rb', line 12

def initialize(data)
  @raw = data
  @id = Internal::Coerce.integer(data["id"])
  @state = Internal::Coerce.optional_integer(data["state"])
  @net = Internal::Coerce.money(data["net"])
  @fee = Internal::Coerce.money(data["fee"])
  @gross = Internal::Coerce.money(data["gross"])
  @creation_date = data["creation_date"].is_a?(String) ? data["creation_date"] : nil
  @direct_settlement = Internal::Coerce.integer(data["direct_settlement"]) == 1
  @nrb = data["nrb"].is_a?(String) ? data["nrb"] : nil
  @declined = Internal::Coerce.integer(data["declined"]) == 1
  @decline_reason = data["decline_reason"].is_a?(String) ? data["decline_reason"] : nil
  @decline_status = data["decline_status"].is_a?(String) ? data["decline_status"] : nil
  @receiver = data["receiver"].is_a?(Hash) ? PayoutReceiver.from_api(data["receiver"]) : nil
  freeze
end

Instance Attribute Details

#creation_dateString? (readonly)

Returns the value of attribute creation_date.

Returns:

  • (String, nil)


5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def creation_date
  @creation_date
end

#decline_reasonString? (readonly)

Returns the value of attribute decline_reason.

Returns:

  • (String, nil)


5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def decline_reason
  @decline_reason
end

#decline_statusString? (readonly)

Returns the value of attribute decline_status.

Returns:

  • (String, nil)


5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def decline_status
  @decline_status
end

#feeMoney (readonly)

Returns the value of attribute fee.

Returns:



5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def fee
  @fee
end

#grossMoney (readonly)

Returns the value of attribute gross.

Returns:



5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def gross
  @gross
end

#idInteger (readonly)

Returns the value of attribute id.

Returns:

  • (Integer)


5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def id
  @id
end

#netMoney (readonly)

Returns the value of attribute net.

Returns:



5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def net
  @net
end

#nrbString? (readonly)

Returns the value of attribute nrb.

Returns:

  • (String, nil)


5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def nrb
  @nrb
end

#rawHash[String, untyped] (readonly)

Returns the value of attribute raw.

Returns:

  • (Hash[String, untyped])


5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def raw
  @raw
end

#receiverPayoutReceiver? (readonly)

Returns the value of attribute receiver.

Returns:



5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def receiver
  @receiver
end

#stateInteger? (readonly)

Returns the value of attribute state.

Returns:

  • (Integer, nil)


5
6
7
# File 'lib/dpay/payout/payout_details.rb', line 5

def state
  @state
end

Class Method Details

.from_api(data) ⇒ PayoutDetails

Parameters:

  • data (Hash[String, untyped])

Returns:



8
9
10
# File 'lib/dpay/payout/payout_details.rb', line 8

def self.from_api(data)
  new(data)
end

Instance Method Details

#declined?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/dpay/payout/payout_details.rb', line 46

def declined?
  @declined
end

#direct_settlement?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/dpay/payout/payout_details.rb', line 42

def direct_settlement?
  @direct_settlement
end

#failed?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/dpay/payout/payout_details.rb', line 38

def failed?
  @state == -1
end

#processed?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/dpay/payout/payout_details.rb', line 34

def processed?
  @state == 1
end

#waiting?Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/dpay/payout/payout_details.rb', line 29

def waiting?
  state = @state
  !state.nil? && state.zero?
end