Class: Reggora::Vendor

Inherits:
Object
  • Object
show all
Defined in:
lib/reggora/Entity/Lender/vendor.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Vendor

Returns a new instance of Vendor.



3
4
5
6
# File 'lib/reggora/Entity/Lender/vendor.rb', line 3

def initialize(client)
  @model = 'vendor'
  @client = client
end

Instance Method Details

#all(offset = 0, limit = 0) ⇒ Object

returns all the vendors associated with the requesting lender.



9
10
11
# File 'lib/reggora/Entity/Lender/vendor.rb', line 9

def all(offset = 0, limit = 0)
  @client.get("/#{@model}s", {offset: offset, limit: limit})
end

#delete(vendor_id) ⇒ Object

removes a vendor from your lender panel.



40
41
42
# File 'lib/reggora/Entity/Lender/vendor.rb', line 40

def delete(vendor_id)
  @client.delete("/#{@model}/#{vendor_id}")
end

#edit(vendor_id, edit_vendor_params) ⇒ Object

edits a vendor. Only the fields that are in the request body will be updated.



35
36
37
# File 'lib/reggora/Entity/Lender/vendor.rb', line 35

def edit(vendor_id, edit_vendor_params)
  @client.put("/#{@model}/#{vendor_id}", edit_vendor_params)
end

#find(vendor_id) ⇒ Object

takes a vendor ID as a URL parameter and returns the corresponding vendor.



14
15
16
# File 'lib/reggora/Entity/Lender/vendor.rb', line 14

def find(vendor_id)
  @client.get("/#{@model}/#{vendor_id}")
end

#find_by_branch(branch_id) ⇒ Object

returns the vendors associated with the requesting lender filtered by branch.



24
25
26
# File 'lib/reggora/Entity/Lender/vendor.rb', line 24

def find_by_branch(branch_id)
  @client.get("/#{@model}s/branch", {branch_id: branch_id})
end

#find_by_zone(zones, offset = 0, limit = 0) ⇒ Object

returns the vendors associated with the requesting lender filtered by zip code.



19
20
21
# File 'lib/reggora/Entity/Lender/vendor.rb', line 19

def find_by_zone(zones, offset = 0, limit = 0)
  @client.post("/#{@model}s/by_zone", {zones: zones}, {offset: offset, limit: limit})
end

#invite(firm_name, firstname, lastname, email, phone) ⇒ Object

adds a vendor to your lender.



29
30
31
32
# File 'lib/reggora/Entity/Lender/vendor.rb', line 29

def invite(firm_name, firstname, lastname, email, phone)
  invite_params = vendor_params(firm_name, firstname, lastname, email, phone)
  @client.post("/#{@model}", {}, invite_params)
end

#vendor_params(firm_name = "", firstname = "", lastname = "", phone = "") ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/reggora/Entity/Lender/vendor.rb', line 44

def vendor_params(firm_name = "", firstname = "", lastname = "", phone = "")
  {
      firm_name: firm_name,
      firstname: firstname,
      lastname: lastname,
      phone: phone
  }
end