Class: Spree::DataRequests::Fulfill

Inherits:
Workflow
  • Object
show all
Defined in:
app/workflows/spree/data_requests/fulfill.rb

Overview

Carries out a data subject request: builds and attaches the export for an access request, runs the anonymizer for an erasure request.

In the workflow tier for its hooks — a host app that must include data Spree does not model (a loyalty ledger, a support-ticket history) adds it to the payload here, and that is the only place where the shape of a subject access response can be completed.

Marking a request failed is the caller's job, not this flow's: see ProcessJob. A workflow cannot rescue around its own steps, because FailureSignal and Halted descend from Exception and rescuing swallows the result the caller is waiting for.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Workflow

#call, define_argument_readers, #errors, #halt!, hooks, inherited, model_name, #read_attribute_for_validation, #reject!, workflow_key

Methods included from ServiceModule::Base

#call, prepended

Methods included from Workflow::ControlFlow

#failure

Class Method Details

.payload_for(data_request) ⇒ Hash

Builds the payload for a request, hook included.

Exposed as a class method because the admin export renders inline for a staffer who is waiting, rather than going through the queued flow — and an Art. 15 response assembled without the extension point would omit exactly the host-app data the hook exists to attach. Both paths build the same document.

Parameters:

Returns:

  • (Hash)


28
29
30
# File 'app/workflows/spree/data_requests/fulfill.rb', line 28

def self.payload_for(data_request)
  new.send(:export_payload, data_request)
end

Instance Method Details

#perform(data_request:) ⇒ Spree::ServiceModule::Result

Returns the fulfilled request.

Parameters:

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/workflows/spree/data_requests/fulfill.rb', line 35

def perform(data_request:)
  super

  step :ensure_pending
  step :ensure_addressed_to_customer
  step :mark_processing

  run_hooks :before_fulfill

  step :fulfill_request
  step :mark_completed

  run_hooks :after_fulfill

  success(data_request.reload)
end