Class: LendingClub::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/lending_club/client/note.rb

Constant Summary collapse

ATTRIBUTES =
[
  :loan_status,
  :loan_id,
  :portfolio_name,
  :note_id,
  :grade,
  :loan_amount,
  :accrued_interest,
  :note_amount,
  :purpose,
  :interest_rate,
  :portfolio_id,
  :order_id,
  :loan_length,
  :issue_date,
  :order_date,
  :loan_status_date,
  :credit_trend,
  :current_payment_status,
  :can_be_traded,
  :payments_received,
  :next_payment_date,
  :principal_pending,
  :interest_pending,
  :interest_received,
  :principal_received
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_hash) ⇒ Note

Returns a new instance of Note.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/lending_club/client/note.rb', line 85

def initialize(data_hash)
  @loan_status = data_hash['loanStatus'].to_s
  @loan_id = Integer(data_hash['loanId'])
  if data_hash['portfolioName']
    @portfolio_name = data_hash['portfolioName'].to_s
  end
  @note_id = Integer(data_hash['noteId'])
  @grade = data_hash['grade'].to_s
  @loan_amount = BigDecimal.new(data_hash['loanAmount'])
  @accrued_interest = BigDecimal.new(data_hash['accruedInterest'])
  @note_amount = BigDecimal.new(data_hash['noteAmount'])
  @purpose = data_hash['purpose'].to_s
  @interest_rate = Float(data_hash['interestRate'])
  if data_hash['portfolioId']
    @portfolio_id = Integer(data_hash['portfolioId'])
  end
  @order_id = Integer(data_hash['orderId'])
  @loan_length = Integer(data_hash['loanLength'])
  if data_hash['issueDate']
    @issue_date = data_hash['issueDate'].to_s
  end
  @order_date = data_hash['orderDate'].to_s
  @loan_status_date = data_hash['loanStatusDate'].to_s
  @credit_trend = data_hash['creditTrend'].to_s
  if data_hash['currentPaymentStatus']
    @current_payment_status = data_hash['currentPaymentStatus'].to_s
  end
  @can_be_traded = boolean(data_hash['canBeTraded'])
  @payments_received = BigDecimal.new(data_hash['paymentsReceived'])
  if data_hash['nextPaymentDate']
    @next_payment_date = data_hash['nextPaymentDate'].to_s
  end
  @principal_pending = BigDecimal.new(data_hash['principalPending'])
  @interest_pending = BigDecimal.new(data_hash['interestPending'])
  @interest_received = BigDecimal.new(data_hash['interestReceived'])
  @principal_received = BigDecimal.new(data_hash['principalReceived'])
end

Instance Attribute Details

#accrued_interestBigDecimal (readonly)

Returns Accrued Interest.

Returns:

  • (BigDecimal)

    Accrued Interest



47
48
49
# File 'lib/lending_club/client/note.rb', line 47

def accrued_interest
  @accrued_interest
end

#can_be_tradedBoolean (readonly)

Returns Can be traded.

Returns:

  • (Boolean)

    Can be traded



71
72
73
# File 'lib/lending_club/client/note.rb', line 71

def can_be_traded
  @can_be_traded
end

#credit_trendString (readonly)

Returns Credit trend.

Returns:

  • (String)

    Credit trend



67
68
69
# File 'lib/lending_club/client/note.rb', line 67

def credit_trend
  @credit_trend
end

#current_payment_statusString? (readonly)

Returns Current payment status.

Returns:

  • (String, nil)

    Current payment status



69
70
71
# File 'lib/lending_club/client/note.rb', line 69

def current_payment_status
  @current_payment_status
end

#gradeString (readonly)

Returns Grade.

Returns:

  • (String)

    Grade



43
44
45
# File 'lib/lending_club/client/note.rb', line 43

def grade
  @grade
end

#interest_pendingBigDecimal (readonly)

Returns Interest pending.

Returns:

  • (BigDecimal)

    Interest pending



79
80
81
# File 'lib/lending_club/client/note.rb', line 79

def interest_pending
  @interest_pending
end

#interest_rateNumber (readonly)

Returns Interest rate.

Returns:

  • (Number)

    Interest rate



53
54
55
# File 'lib/lending_club/client/note.rb', line 53

def interest_rate
  @interest_rate
end

#interest_receivedBigDecimal (readonly)

Returns Interest received.

Returns:

  • (BigDecimal)

    Interest received



81
82
83
# File 'lib/lending_club/client/note.rb', line 81

def interest_received
  @interest_received
end

#issue_dateString? (readonly)

Returns Issue date.

Returns:

  • (String, nil)

    Issue date



61
62
63
# File 'lib/lending_club/client/note.rb', line 61

def issue_date
  @issue_date
end

#loan_amountBigDecimal (readonly)

Returns Loan amount.

Returns:

  • (BigDecimal)

    Loan amount



45
46
47
# File 'lib/lending_club/client/note.rb', line 45

def loan_amount
  @loan_amount
end

#loan_idInteger (readonly)

Returns Loan Id.

Returns:

  • (Integer)

    Loan Id



37
38
39
# File 'lib/lending_club/client/note.rb', line 37

def loan_id
  @loan_id
end

#loan_lengthInteger (readonly)

Returns Loan length.

Returns:

  • (Integer)

    Loan length



59
60
61
# File 'lib/lending_club/client/note.rb', line 59

def loan_length
  @loan_length
end

#loan_statusString (readonly)

Returns Loan status.

Returns:

  • (String)

    Loan status



35
36
37
# File 'lib/lending_club/client/note.rb', line 35

def loan_status
  @loan_status
end

#loan_status_dateString (readonly)

Returns Loan status date.

Returns:

  • (String)

    Loan status date



65
66
67
# File 'lib/lending_club/client/note.rb', line 65

def loan_status_date
  @loan_status_date
end

#next_payment_dateString? (readonly)

Returns Next payment date.

Returns:

  • (String, nil)

    Next payment date



75
76
77
# File 'lib/lending_club/client/note.rb', line 75

def next_payment_date
  @next_payment_date
end

#note_amountBigDecimal (readonly)

Returns Note amount.

Returns:

  • (BigDecimal)

    Note amount



49
50
51
# File 'lib/lending_club/client/note.rb', line 49

def note_amount
  @note_amount
end

#note_idInteger (readonly)

Returns Note Id.

Returns:

  • (Integer)

    Note Id



41
42
43
# File 'lib/lending_club/client/note.rb', line 41

def note_id
  @note_id
end

#order_dateString (readonly)

Returns Order date.

Returns:

  • (String)

    Order date



63
64
65
# File 'lib/lending_club/client/note.rb', line 63

def order_date
  @order_date
end

#order_idInteger (readonly)

Returns Order Id.

Returns:

  • (Integer)

    Order Id



57
58
59
# File 'lib/lending_club/client/note.rb', line 57

def order_id
  @order_id
end

#payments_receivedBigDecimal (readonly)

Returns Payments received.

Returns:

  • (BigDecimal)

    Payments received



73
74
75
# File 'lib/lending_club/client/note.rb', line 73

def payments_received
  @payments_received
end

#portfolio_idInteger? (readonly)

Returns Portfolio Id.

Returns:

  • (Integer, nil)

    Portfolio Id



55
56
57
# File 'lib/lending_club/client/note.rb', line 55

def portfolio_id
  @portfolio_id
end

#portfolio_nameString? (readonly)

Returns Portfolio name.

Returns:

  • (String, nil)

    Portfolio name



39
40
41
# File 'lib/lending_club/client/note.rb', line 39

def portfolio_name
  @portfolio_name
end

#principal_pendingBigDecimal (readonly)

Returns Principal pending.

Returns:

  • (BigDecimal)

    Principal pending



77
78
79
# File 'lib/lending_club/client/note.rb', line 77

def principal_pending
  @principal_pending
end

#principal_receivedBigDecimal (readonly)

Returns Principal received.

Returns:

  • (BigDecimal)

    Principal received



83
84
85
# File 'lib/lending_club/client/note.rb', line 83

def principal_received
  @principal_received
end

#purposeString (readonly)

Returns Purpose.

Returns:

  • (String)

    Purpose



51
52
53
# File 'lib/lending_club/client/note.rb', line 51

def purpose
  @purpose
end

Class Method Details

.collection(data_hash) ⇒ Object



123
124
125
126
127
128
# File 'lib/lending_club/client/note.rb', line 123

def self.collection(data_hash)
  return [] unless data_hash['loans']
  data_hash['loans'].map do |loan|
    new(loan.tap {|h| h['asOfDate'] = data_hash['asOfDate']})
  end
end

Instance Method Details

#to_hObject



130
131
132
133
134
135
# File 'lib/lending_club/client/note.rb', line 130

def to_h
  ATTRIBUTES.reduce({}) do |h, attribute|
    h[attribute.to_s] = send(attribute)
    h
  end
end