KivaApi
Get Loan data from Kiva's API
Installation
Add this line to your application's Gemfile:
gem 'kiva_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kiva_api
Usage
Initializing the object
When initializing the KivaApi::Loan object, you can optionally add the loan ID to the initialization.
require 'kiva_api'
loan_api = KivaApi::Loan.new(92464)
# => #<KivaApi::Loan:0x007ff09b9daa88 @host="https://api.kivaws.org/v2", @loan_number=92464>
loan_api.get_data # this will hit the @host on Kiva for the loan number that you specify
loan_response = loan_api.response
loan_response.parsed_body
# => {"class"=>["Loan_Partner", "Loan"], "properties"=>{"id"=>92464...
loan_response.state
# => :ended
loan_response.loan_amount
# => "825.00"
loan_response.funded_amount
# => "825.00"
loan_response.basket_amount
# => "0.00"
loan_response.paid_amount
# => "825.00"
terms = loan_api.terms_response
terms.expected_payments
# => [{:amount=>"35.87", :effective_date=>"2009-04-08T07:00:00Z", :due_to_kiva_date=>"2009-06-01T07:00:00Z"}, ...]
Bad Responses
loan_api = KivaApi::Loan.new(1)
loan_api.get_data
# => #<HTTParty::Response:0x7fa2ab088658 parsed_response={"class"=>["error", "SirenE....
Contributing
- Fork it ( https://github.com/stevepm/kiva_api/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request