Class: Gusto::EntityErrorObject

Inherits:
Object
  • Object
show all
Defined in:
lib/fern_gusto/types/entity_error_object.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_key: OMIT, category: OMIT, message: OMIT, metadata: OMIT, errors: OMIT, additional_properties: nil) ⇒ Gusto::EntityErrorObject

Parameters:

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fern_gusto/types/entity_error_object.rb', line 47

def initialize(error_key: OMIT, category: OMIT, message: OMIT, metadata: OMIT, errors: OMIT, additional_properties: nil)
  @error_key = error_key if error_key != OMIT
  @category = category if category != OMIT
  @message = message if message != OMIT
  @metadata =  if  != OMIT
  @errors = errors if errors != OMIT
  @additional_properties = additional_properties
  @_field_set = { "error_key": error_key, "category": category, "message": message, "metadata": , "errors": errors }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



26
27
28
# File 'lib/fern_gusto/types/entity_error_object.rb', line 26

def additional_properties
  @additional_properties
end

#categoryObject (readonly)

errors.



15
16
17
# File 'lib/fern_gusto/types/entity_error_object.rb', line 15

def category
  @category
end

#error_keyObject (readonly)

attribute/parameter related to the error.



10
11
12
# File 'lib/fern_gusto/types/entity_error_object.rb', line 10

def error_key
  @error_key
end

#errorsObject (readonly)

levels of nested errors.



24
25
26
# File 'lib/fern_gusto/types/entity_error_object.rb', line 24

def errors
  @errors
end

#messageObject (readonly)

end user.



18
19
20
# File 'lib/fern_gusto/types/entity_error_object.rb', line 18

def message
  @message
end

#metadataObject (readonly)

example, to identify an entity ‘entity_type` and `entity_uuid` will be provided.



21
22
23
# File 'lib/fern_gusto/types/entity_error_object.rb', line 21

def 
  @metadata
end

Class Method Details

.from_json(json_object:) ⇒ Gusto::EntityErrorObject

Parameters:

  • json_object (String)

Returns:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/fern_gusto/types/entity_error_object.rb', line 62

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  error_key = parsed_json["error_key"]
  category = parsed_json["category"]
  message = parsed_json["message"]
   = parsed_json["metadata"]
  errors = parsed_json["errors"]&.map do | item |
  item = item.to_json
  Gusto::EntityErrorObjectErrorsItem.from_json(json_object: item)
end
  new(
    error_key: error_key,
    category: category,
    message: message,
    metadata: ,
    errors: errors,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


94
95
96
97
98
99
100
# File 'lib/fern_gusto/types/entity_error_object.rb', line 94

def self.validate_raw(obj:)
  obj.error_key&.is_a?(String) != false || raise("Passed value for field obj.error_key is not the expected type, validation failed.")
  obj.category&.is_a?(String) != false || raise("Passed value for field obj.category is not the expected type, validation failed.")
  obj.message&.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.")
  obj.&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.")
  obj.errors&.is_a?(Array) != false || raise("Passed value for field obj.errors is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


85
86
87
# File 'lib/fern_gusto/types/entity_error_object.rb', line 85

def to_json
  @_field_set&.to_json
end