Class: Bondora::API

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/bondora/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(auth_code, *sandbox) ⇒ Object

Create new API client

Parameters:

  • auth_code (String)

    authorization code

  • sandbox (Bool)

    mode switch



10
11
12
13
14
15
16
17
18
# File 'lib/bondora/api.rb', line 10

def initialize(auth_code, *sandbox)
  self.class.headers 'Authorization' => "Bearer #{auth_code}"

  if sandbox
    self.class.base_uri 'https://api-sandbox.bondora.com/api/v1'
  else
    self.class.base_uri 'https://api.bondora.com/api/v1'
  end
end

Instance Method Details

#auction(auction_id) ⇒ String

Get auction for specified auction

Parameters:

  • auction_id (String)

    auction id

Returns:

  • (String)

    specified auction as JSON string.



32
33
34
# File 'lib/bondora/api.rb', line 32

def auction(auction_id)
  self.class.get("/auction/#{auction_id}").to_json
end

#auctionsString

Get all auctions

Returns:

  • (String)

    all auctions as JSON string.



24
25
26
# File 'lib/bondora/api.rb', line 24

def auctions
  self.class.get('/auctions').to_json
end

#balanceString

Get account balance details

Returns:

  • (String)

    account balance details as JSON string.



62
63
64
# File 'lib/bondora/api.rb', line 62

def balance
  self.class.get('/account/balance').to_json
end

#bid(bid_id) ⇒ String

Get bid details

Parameters:

  • bid_id (String)

    bid id

Returns:

  • (String)

    bid details as JSON string.



102
103
104
# File 'lib/bondora/api.rb', line 102

def bid(bid_id)
  self.class.get("/bid/#{bid_id}").to_json
end

#bidsString

Get bids

Returns:

  • (String)

    bids as JSON string.



94
95
96
# File 'lib/bondora/api.rb', line 94

def bids
  self.class.get('/bids').to_json
end

#investmentsString

Get account investments

Returns:

  • (String)

    investments as JSON string.



69
70
71
# File 'lib/bondora/api.rb', line 69

def investments
  self.class.get('/account/investments').to_json
end

#loandatasetString

Get loandatasets

Returns:

  • (String)

    loandatasets as JSON string.



109
110
111
# File 'lib/bondora/api.rb', line 109

def loandataset
  self.class.get('/loandataset').to_json
end

#loanpart(loanpart_id) ⇒ String

Get loanpart details

Parameters:

  • loanpart_id (String)

    loanpart id

Returns:

  • (String)

    loanpart details as JSON string.



55
56
57
# File 'lib/bondora/api.rb', line 55

def loanpart(loanpart_id)
  self.class.get("/loanpart/#{loanpart_id}").to_json
end

#report(report_id) ⇒ String

Get report details

Parameters:

  • report_id (String)

    report id

Returns:

  • (String)

    report details as JSON string.



124
125
126
# File 'lib/bondora/api.rb', line 124

def report(report_id)
  self.class.get("/report/#{report_id}").to_json
end

#reportsString

Get reports

Returns:

  • (String)

    reports as JSON string.



116
117
118
# File 'lib/bondora/api.rb', line 116

def reports
  self.class.get('/reports').to_json
end

#secondarymarketString

Get all secondary market offers

Returns:

  • (String)

    all secondary market offers as JSON string.



39
40
41
# File 'lib/bondora/api.rb', line 39

def secondarymarket
  self.class.get('/secondarymarket').to_json
end

#secondarymarket_item(item_id) ⇒ String

Get secondary market item details

Parameters:

  • item_id (String)

    secondary market item id

Returns:

  • (String)

    secondary market item details as JSON string.



47
48
49
# File 'lib/bondora/api.rb', line 47

def secondarymarket_item(item_id)
  self.class.get("/secondarymarket/#{item_id}").to_json
end