Class: LendingClub::Note
- Inherits:
-
Object
- Object
- LendingClub::Note
- 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
-
#accrued_interest ⇒ BigDecimal
readonly
Accrued Interest.
-
#can_be_traded ⇒ Boolean
readonly
Can be traded.
-
#credit_trend ⇒ String
readonly
Credit trend.
-
#current_payment_status ⇒ String?
readonly
Current payment status.
-
#grade ⇒ String
readonly
Grade.
-
#interest_pending ⇒ BigDecimal
readonly
Interest pending.
-
#interest_rate ⇒ Number
readonly
Interest rate.
-
#interest_received ⇒ BigDecimal
readonly
Interest received.
-
#issue_date ⇒ String?
readonly
Issue date.
-
#loan_amount ⇒ BigDecimal
readonly
Loan amount.
-
#loan_id ⇒ Integer
readonly
Loan Id.
-
#loan_length ⇒ Integer
readonly
Loan length.
-
#loan_status ⇒ String
readonly
Loan status.
-
#loan_status_date ⇒ String
readonly
Loan status date.
-
#next_payment_date ⇒ String?
readonly
Next payment date.
-
#note_amount ⇒ BigDecimal
readonly
Note amount.
-
#note_id ⇒ Integer
readonly
Note Id.
-
#order_date ⇒ String
readonly
Order date.
-
#order_id ⇒ Integer
readonly
Order Id.
-
#payments_received ⇒ BigDecimal
readonly
Payments received.
-
#portfolio_id ⇒ Integer?
readonly
Portfolio Id.
-
#portfolio_name ⇒ String?
readonly
Portfolio name.
-
#principal_pending ⇒ BigDecimal
readonly
Principal pending.
-
#principal_received ⇒ BigDecimal
readonly
Principal received.
-
#purpose ⇒ String
readonly
Purpose.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data_hash) ⇒ Note
constructor
A new instance of Note.
- #to_h ⇒ Object
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_interest ⇒ BigDecimal (readonly)
Returns Accrued Interest.
47 48 49 |
# File 'lib/lending_club/client/note.rb', line 47 def accrued_interest @accrued_interest end |
#can_be_traded ⇒ Boolean (readonly)
Returns Can be traded.
71 72 73 |
# File 'lib/lending_club/client/note.rb', line 71 def can_be_traded @can_be_traded end |
#credit_trend ⇒ String (readonly)
Returns Credit trend.
67 68 69 |
# File 'lib/lending_club/client/note.rb', line 67 def credit_trend @credit_trend end |
#current_payment_status ⇒ String? (readonly)
Returns Current payment status.
69 70 71 |
# File 'lib/lending_club/client/note.rb', line 69 def current_payment_status @current_payment_status end |
#grade ⇒ String (readonly)
Returns Grade.
43 44 45 |
# File 'lib/lending_club/client/note.rb', line 43 def grade @grade end |
#interest_pending ⇒ BigDecimal (readonly)
Returns Interest pending.
79 80 81 |
# File 'lib/lending_club/client/note.rb', line 79 def interest_pending @interest_pending end |
#interest_rate ⇒ Number (readonly)
Returns Interest rate.
53 54 55 |
# File 'lib/lending_club/client/note.rb', line 53 def interest_rate @interest_rate end |
#interest_received ⇒ BigDecimal (readonly)
Returns Interest received.
81 82 83 |
# File 'lib/lending_club/client/note.rb', line 81 def interest_received @interest_received end |
#issue_date ⇒ String? (readonly)
Returns Issue date.
61 62 63 |
# File 'lib/lending_club/client/note.rb', line 61 def issue_date @issue_date end |
#loan_amount ⇒ BigDecimal (readonly)
Returns Loan amount.
45 46 47 |
# File 'lib/lending_club/client/note.rb', line 45 def loan_amount @loan_amount end |
#loan_id ⇒ Integer (readonly)
Returns Loan Id.
37 38 39 |
# File 'lib/lending_club/client/note.rb', line 37 def loan_id @loan_id end |
#loan_length ⇒ Integer (readonly)
Returns Loan length.
59 60 61 |
# File 'lib/lending_club/client/note.rb', line 59 def loan_length @loan_length end |
#loan_status ⇒ String (readonly)
Returns Loan status.
35 36 37 |
# File 'lib/lending_club/client/note.rb', line 35 def loan_status @loan_status end |
#loan_status_date ⇒ String (readonly)
Returns 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_date ⇒ String? (readonly)
Returns Next payment date.
75 76 77 |
# File 'lib/lending_club/client/note.rb', line 75 def next_payment_date @next_payment_date end |
#note_amount ⇒ BigDecimal (readonly)
Returns Note amount.
49 50 51 |
# File 'lib/lending_club/client/note.rb', line 49 def note_amount @note_amount end |
#note_id ⇒ Integer (readonly)
Returns Note Id.
41 42 43 |
# File 'lib/lending_club/client/note.rb', line 41 def note_id @note_id end |
#order_date ⇒ String (readonly)
Returns Order date.
63 64 65 |
# File 'lib/lending_club/client/note.rb', line 63 def order_date @order_date end |
#order_id ⇒ Integer (readonly)
Returns Order Id.
57 58 59 |
# File 'lib/lending_club/client/note.rb', line 57 def order_id @order_id end |
#payments_received ⇒ BigDecimal (readonly)
Returns Payments received.
73 74 75 |
# File 'lib/lending_club/client/note.rb', line 73 def payments_received @payments_received end |
#portfolio_id ⇒ Integer? (readonly)
Returns Portfolio Id.
55 56 57 |
# File 'lib/lending_club/client/note.rb', line 55 def portfolio_id @portfolio_id end |
#portfolio_name ⇒ String? (readonly)
Returns Portfolio name.
39 40 41 |
# File 'lib/lending_club/client/note.rb', line 39 def portfolio_name @portfolio_name end |
#principal_pending ⇒ BigDecimal (readonly)
Returns Principal pending.
77 78 79 |
# File 'lib/lending_club/client/note.rb', line 77 def principal_pending @principal_pending end |
#principal_received ⇒ BigDecimal (readonly)
Returns Principal received.
83 84 85 |
# File 'lib/lending_club/client/note.rb', line 83 def principal_received @principal_received end |
#purpose ⇒ String (readonly)
Returns 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_h ⇒ Object
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 |