Class: Reggora::Order

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Order

Returns a new instance of Order.



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

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

Instance Method Details

#all(offset = 0, limit = 0, ordering = '-created', search = '', due_in = nil, loan_officer = [], filter = '') ⇒ Object

retrieves all orders (limit 10 at a time). Can be filtered with query parameters



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

def all(offset = 0, limit = 0, ordering = '-created', search = '', due_in = nil, loan_officer = [], filter = '')
  @client.get("/#{@model}s", {offset: offset, limit: limit, ordering: ordering, search: search, due_in: due_in, loan_officer: loan_officer, filter: filter})
end

#cancel(id) ⇒ Object

cancels a specific order



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

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

#create(loan_params) ⇒ Object

creates an order and returns the ID of the created Order



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

def create(loan_params)
  @client.post("/#{@model}", loan_params)
end

#edit(id, loan_params) ⇒ Object

edits a order and returns the ID of the edited order



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

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

#find(id) ⇒ Object

retrieves a specific order by id



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

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

#place_on_hold(order_id, reason = '') ⇒ Object

place an active order on hold, which will disable editing and other functionality while on hold.



34
35
36
# File 'lib/reggora/Entity/Lender/order.rb', line 34

def place_on_hold(order_id, reason = '')
  @client.put("/order/#{order_id}/hold", {reason: reason})
end

#remove_from_hold(order_id) ⇒ Object



38
39
40
# File 'lib/reggora/Entity/Lender/order.rb', line 38

def remove_from_hold(order_id)
  @client.put("/order/#{order_id}/unhold")
end

#sample_data(loan_id, product_id, vendors) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/reggora/Entity/Lender/order.rb', line 42

def sample_data(loan_id, product_id, vendors)
  order_params_manually = {
      'allocation_type': 'manually',
      'loan': loan_id,
      'priority': 'Rush',
      'products': [product_id],
      'due_date': (Time.now + 60*60*24*30).strftime("%Y-%m-%d %H:%M:%S"),
      'additional_fees': [
          {
              'description': 'Large yard',
              'amount': '50'
          },
          {
              'description': 'Outside regular locations',
              'amount': '20'
          }
      ],
      'vendors': vendors
  }
  order_params_automatically = {
      'allocation_type': 'automatically',
      'loan': loan_id,
      'priority': 'Rush',
      'products': [product_id],
      'due_date': (Time.now + 60*60*24*30).strftime("%Y-%m-%d %H:%M:%S"),
      'additional_fees': [
          {
              'description': 'Large yard',
              'amount': '50'
          },
          {
              'description': 'Outside regular locations',
              'amount': '20'
          }
      ]
  }
  {:manual_allocation_type => order_params_manually, :auto_allocation_type => order_params_automatically}
end