Class: LendingClub::OrderCollection
- Inherits:
-
Object
- Object
- LendingClub::OrderCollection
- Defined in:
- lib/lending_club/client/order_collection.rb
Instance Attribute Summary collapse
-
#aid ⇒ Integer
readonly
The member id of the account under management.
-
#orders ⇒ Array<Order>
readonly
Array of Orders.
Instance Method Summary collapse
- #add(order) ⇒ Object
-
#initialize(orders, aid) ⇒ OrderCollection
constructor
A new instance of OrderCollection.
- #to_h ⇒ Object
- #update_orders(response) ⇒ Object
Constructor Details
#initialize(orders, aid) ⇒ OrderCollection
Returns a new instance of OrderCollection.
9 10 11 12 13 |
# File 'lib/lending_club/client/order_collection.rb', line 9 def initialize(orders, aid) @orders = [] orders.each { |o| add(o) } @aid = Integer(aid) end |
Instance Attribute Details
#aid ⇒ Integer (readonly)
Returns The member id of the account under management.
7 8 9 |
# File 'lib/lending_club/client/order_collection.rb', line 7 def aid @aid end |
#orders ⇒ Array<Order> (readonly)
Returns array of Orders.
5 6 7 |
# File 'lib/lending_club/client/order_collection.rb', line 5 def orders @orders end |
Instance Method Details
#add(order) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/lending_club/client/order_collection.rb', line 38 def add(order) is_valid, = validate(order) raise Error.new() unless is_valid @orders << order self end |
#to_h ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lending_club/client/order_collection.rb', line 15 def to_h { 'aid' => @aid, 'orders' => @orders.map do |order| { 'loanId' => order.loan_id, 'requestedAmount' => order.requested_amount, 'portfolioId' => order.portfolio_id } end } end |
#update_orders(response) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/lending_club/client/order_collection.rb', line 28 def update_orders(response) response['orderConfirmations'].each do |confirmation| order = lookup(confirmation['loanId']) order.order_instruct_id = Integer(confirmation['orderInstructId']) order.invested_amount = Integer(confirmation['investedAmount']) order.execution_status = confirmation['executionStatus'] end self end |