Class: Kiva::Loan
- Inherits:
-
Object
- Object
- Kiva::Loan
- Includes:
- Api, DynamicInitializer
- Defined in:
- lib/ruby-kiva/loan.rb
Instance Attribute Summary collapse
-
#activity ⇒ Object
Returns the value of attribute activity.
-
#basket_amount ⇒ Object
Returns the value of attribute basket_amount.
-
#borrower_count ⇒ Object
Returns the value of attribute borrower_count.
-
#delinquent ⇒ Object
Returns the value of attribute delinquent.
-
#description ⇒ Object
Returns the value of attribute description.
-
#funded_amount ⇒ Object
Returns the value of attribute funded_amount.
-
#funded_date ⇒ Object
Returns the value of attribute funded_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#journal_totals ⇒ Object
Returns the value of attribute journal_totals.
-
#loan_amount ⇒ Object
Returns the value of attribute loan_amount.
-
#name ⇒ Object
Returns the value of attribute name.
-
#paid_amount ⇒ Object
Returns the value of attribute paid_amount.
-
#partner_id ⇒ Object
Returns the value of attribute partner_id.
-
#sector ⇒ Object
Returns the value of attribute sector.
-
#status ⇒ Object
Returns the value of attribute status.
-
#terms ⇒ Object
Returns the value of attribute terms.
-
#use ⇒ Object
Returns the value of attribute use.
Class Method Summary collapse
-
.find(params) ⇒ Object
Search for Loans.
-
.newest(options = {}) ⇒ Object
Supported options: * :page: The requested page number.
Instance Method Summary collapse
- #description_languages ⇒ Object
- #description_text(language) ⇒ Object
- #description_texts ⇒ Object
- #journal_entries(params = {}) ⇒ Object
-
#lenders(params = {}) ⇒ Object
Get the lenders for this loan Caches the lenders, reload loan if you need to refresh the lenders.
- #loan_updates ⇒ Object
- #to_s ⇒ Object
Methods included from DynamicInitializer
Methods included from Api
app_id, app_id=, friendly, friendly=, included
Instance Attribute Details
#activity ⇒ Object
Returns the value of attribute activity.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def activity @activity end |
#basket_amount ⇒ Object
Returns the value of attribute basket_amount.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def basket_amount @basket_amount end |
#borrower_count ⇒ Object
Returns the value of attribute borrower_count.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def borrower_count @borrower_count end |
#delinquent ⇒ Object
Returns the value of attribute delinquent.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def delinquent @delinquent end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def description @description end |
#funded_amount ⇒ Object
Returns the value of attribute funded_amount.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def funded_amount @funded_amount end |
#funded_date ⇒ Object
Returns the value of attribute funded_date.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def funded_date @funded_date end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def id @id end |
#journal_totals ⇒ Object
Returns the value of attribute journal_totals.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def journal_totals @journal_totals end |
#loan_amount ⇒ Object
Returns the value of attribute loan_amount.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def loan_amount @loan_amount end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def name @name end |
#paid_amount ⇒ Object
Returns the value of attribute paid_amount.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def paid_amount @paid_amount end |
#partner_id ⇒ Object
Returns the value of attribute partner_id.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def partner_id @partner_id end |
#sector ⇒ Object
Returns the value of attribute sector.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def sector @sector end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def status @status end |
#terms ⇒ Object
Returns the value of attribute terms.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def terms @terms end |
#use ⇒ Object
Returns the value of attribute use.
6 7 8 |
# File 'lib/ruby-kiva/loan.rb', line 6 def use @use end |
Class Method Details
.find(params) ⇒ Object
Search for Loans. Different searches are possible either: :id: An ID, a comma delimited String of IDs or an Array of IDs __or__ :lender_id: A single ID of a lender __or__ :team_id : a single ID of a team __or a combination of__
-
:partner_id: A (comma delimited) String of Partner IDs or an Array of partner IDs
-
:status: A String or symbol with the Loan status
-
:query: A String
If searching for a single ID, then this method can return nil (no item with this ID found). Otherwise this method will always return a PagedArray instance (which might be empty though)
When searching for multiple Loans, then the :page parameter is supported to specify the desired page.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ruby-kiva/loan.rb', line 80 def self.find(params) if params[:id] # find one or many by ID data = get("/loans/#{sanitize_id_parameter(params[:id])}.json", :query => (params)) many = sanitize_id_parameter(params[:id]).include?(',') elsif params[:lender_id] # find all loans for a lender data = get("/lenders/#{params[:lender_id]}/loans.json", :query => (params)) many = true elsif params[:team_id] # find all loans for a team data = get("/teams/#{params[:team_id]}/loans.json", :query => (params)) many = true else # search puts "Searching with #{(params).merge((params)).inspect}" data = get('/loans/search.json', :query => (params)) many = true end json_to_paged_array(data, 'loans', many) end |
.newest(options = {}) ⇒ Object
Supported options:
-
:page: The requested page number
58 59 60 61 |
# File 'lib/ruby-kiva/loan.rb', line 58 def self.newest( = {}) data = get('/loans/newest.json', :query => ()) json_to_paged_array(data, 'loans', true) end |
Instance Method Details
#description_languages ⇒ Object
28 29 30 |
# File 'lib/ruby-kiva/loan.rb', line 28 def description_languages @description_languages end |
#description_text(language) ⇒ Object
36 37 38 |
# File 'lib/ruby-kiva/loan.rb', line 36 def description_text(language) description_texts[language] end |
#description_texts ⇒ Object
32 33 34 |
# File 'lib/ruby-kiva/loan.rb', line 32 def description_texts @description_texts end |
#journal_entries(params = {}) ⇒ Object
47 48 49 |
# File 'lib/ruby-kiva/loan.rb', line 47 def journal_entries(params = {}) @journal_entries ||= JournalEntry.find(params.merge({:loan_id => self.id})) end |
#lenders(params = {}) ⇒ Object
Get the lenders for this loan Caches the lenders, reload loan if you need to refresh the lenders
42 43 44 |
# File 'lib/ruby-kiva/loan.rb', line 42 def lenders(params = {}) @lenders ||= Lender.find(params.merge({:loan_id => self.id})) end |
#loan_updates ⇒ Object
51 52 53 |
# File 'lib/ruby-kiva/loan.rb', line 51 def loan_updates @loan_updates ||= find_loan_updates() end |
#to_s ⇒ Object
98 99 100 |
# File 'lib/ruby-kiva/loan.rb', line 98 def to_s() "<Loan '%s' (%s) in %s with status %s, from %s>" % [self.name, self.id, self.location, self.id, self.borrowers] end |