Class: BatchResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/batch_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ BatchResponse

Returns a new instance of BatchResponse.



41
42
43
44
45
46
47
48
49
# File 'lib/batch_response.rb', line 41

def initialize(params = {})
  @updated = params[:updated] || []
  @not_updated = params[:not_updated] || []
  @async = params[:async] || false
  @preview = params[:preview] || false
  @errors = Hash.new(0)
  @validation_errors = Hash.new(0)
  @total_attempted = params[:total_attempted] || 0
end

Instance Attribute Details

#asyncObject

Returns Boolean processing is handled asyn.

Returns:

  • Boolean processing is handled asyn



15
16
17
# File 'lib/batch_response.rb', line 15

def async
  @async
end

#capObject

#return nil, integer



36
37
38
# File 'lib/batch_response.rb', line 36

def cap
  @cap
end

#cap_reasonObject

Returns String.

Returns:

  • String



39
40
41
# File 'lib/batch_response.rb', line 39

def cap_reason
  @cap_reason
end

#errorsObject

Returns Hash operational error messages (e.g., missing required params) - triggers 422 when non-empty.

Returns:

  • Hash operational error messages (e.g., missing required params) - triggers 422 when non-empty



27
28
29
# File 'lib/batch_response.rb', line 27

def errors
  @errors
end

#klassObject

Name of the class called, if used



4
5
6
# File 'lib/batch_response.rb', line 4

def klass
  @klass
end

#methodObject

Name of the method called



7
8
9
# File 'lib/batch_response.rb', line 7

def method
  @method
end

#not_updatedObject

Returns Array ids of the objects not update.

Returns:

  • Array ids of the objects not update



23
24
25
# File 'lib/batch_response.rb', line 23

def not_updated
  @not_updated
end

#previewObject

Returns Boolean no writes were made.

Returns:

  • Boolean no writes were made



11
12
13
# File 'lib/batch_response.rb', line 11

def preview
  @preview
end

#total_attemptedObject

Returns the value of attribute total_attempted.



33
34
35
# File 'lib/batch_response.rb', line 33

def total_attempted
  @total_attempted
end

#updatedObject

Returns Array ids of the objects updated.

Returns:

  • Array ids of the objects updated



19
20
21
# File 'lib/batch_response.rb', line 19

def updated
  @updated
end

#validation_errorsObject

Returns Hash per-item validation error messages summarized by times encountered - does not trigger 422.

Returns:

  • Hash per-item validation error messages summarized by times encountered - does not trigger 422



31
32
33
# File 'lib/batch_response.rb', line 31

def validation_errors
  @validation_errors
end

Instance Method Details

#to_jsonObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/batch_response.rb', line 51

def to_json
  {
    klass:,
    method:,
    preview:,
    async:,
    updated:,
    not_updated:,
    errors:,
    validation_errors:,
    total_attempted:,
    cap:,
    cap_reason:,
  }
end