class Reggora::Loan

Public Class Methods

new(client) click to toggle source
# File lib/reggora/Entity/Lender/loan.rb, line 3
def initialize(client)
  @model = 'loan'
  @client = client
end

Public Instance Methods

all(offset = 0, limit = 0, ordering = '-created', loan_officer = []) click to toggle source

retrieves all loans, and can take a number of query parameters

# File lib/reggora/Entity/Lender/loan.rb, line 8
def all(offset = 0, limit = 0, ordering = '-created', loan_officer = [])
  @client.get("/#{@model}s", {offset: offset, limit: limit, ordering: ordering, loan_officer: loan_officer})
end
create(loan_params) click to toggle source

creates a loan and returns the ID of the created loan

# File lib/reggora/Entity/Lender/loan.rb, line 18
def create(loan_params)
  @client.post("/#{@model}", loan_params)
end
delete(id) click to toggle source

deletes a specific loan

# File lib/reggora/Entity/Lender/loan.rb, line 27
def delete(id)
  @client.delete("/#{@model}/#{id}")
end
edit(id, loan_params) click to toggle source

edits a loan and returns the ID of the edited loan. Only the provided fields will be updated

# File lib/reggora/Entity/Lender/loan.rb, line 23
def edit(id, loan_params)
  @client.put("/#{@model}/#{id}", loan_params)
end
find(id) click to toggle source

retrieves a specific loan by id

# File lib/reggora/Entity/Lender/loan.rb, line 13
def find(id)
  @client.get("/#{@model}/#{id}")
end
sample_data() click to toggle source
# File lib/reggora/Entity/Lender/loan.rb, line 31
def sample_data
  n = rand(10...100)
  s = (0...50).map { ('a'..'z').to_a[rand(26)] }.join
  {
    "loan_number": "#{3 * n}#{s[1...5]}#{n}",
    "loan_officer": "5d4c4afdcfd7ff000a515085",
    "appraisal_type": "Refinance",
    "due_date": (Time.now + 60*60*24*30).strftime("%Y-%m-%dT%H:%M:%SZ"),
    "subject_property_address": "100 Mass Ave",
    "subject_property_city": "Boston",
    "subject_property_state": "MA",
    "subject_property_zip": "02192",
    "case_number": "10029MA",
    "loan_type": "FHA"
  }
end