Class: Zaikio::Warehouse::ConsumptionRequest

Inherits:
Base
  • Object
show all
Defined in:
lib/zaikio/warehouse/consumption_request.rb

Defined Under Namespace

Classes: CanNotBeCanceled

Instance Method Summary collapse

Methods inherited from Base

disable_http_methods, readonly!, request

Instance Method Details

#cancel(params = {}) ⇒ Object

Raises:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/zaikio/warehouse/consumption_request.rb', line 25

def cancel(params = {})
  response = if material_requirement.id
               # cancelation_reference, cancelation_reference_link, person_id
               self.class.send(:send_request, :post,
                               "material_requirements/#{material_requirement.id}/consumption_requests/#{id}/cancel", # rubocop:disable Layout/LineLength
                               consumption_request_cancel: params)
             else
               self.class.send(:send_request, :post, "consumption_request_cancelations/#{id}",
                               consumption_request_cancelation: params)
             end

  raise CanNotBeCanceled, response.body if (200..201).exclude?(response.status)

  Spyke::Result.new_from_response(response)
end