Class: Merge::Ticketing::ErrorValidationProblem

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/ticketing/types/error_validation_problem.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, detail:, problem_type:, source: OMIT, additional_properties: nil) ⇒ Merge::Ticketing::ErrorValidationProblem

Parameters:

  • source (Merge::Ticketing::ValidationProblemSource) (defaults to: OMIT)
  • title (String)
  • detail (String)
  • problem_type (String)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/merge_ruby_client/ticketing/types/error_validation_problem.rb', line 32

def initialize(title:, detail:, problem_type:, source: OMIT, additional_properties: nil)
  @source = source if source != OMIT
  @title = title
  @detail = detail
  @problem_type = problem_type
  @additional_properties = additional_properties
  @_field_set = {
    "source": source,
    "title": title,
    "detail": detail,
    "problem_type": problem_type
  }.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



19
20
21
# File 'lib/merge_ruby_client/ticketing/types/error_validation_problem.rb', line 19

def additional_properties
  @additional_properties
end

#detailString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/merge_ruby_client/ticketing/types/error_validation_problem.rb', line 15

def detail
  @detail
end

#problem_typeString (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/merge_ruby_client/ticketing/types/error_validation_problem.rb', line 17

def problem_type
  @problem_type
end

#sourceMerge::Ticketing::ValidationProblemSource (readonly)



11
12
13
# File 'lib/merge_ruby_client/ticketing/types/error_validation_problem.rb', line 11

def source
  @source
end

#titleString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/merge_ruby_client/ticketing/types/error_validation_problem.rb', line 13

def title
  @title
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Ticketing::ErrorValidationProblem

Deserialize a JSON object to an instance of ErrorValidationProblem

Parameters:

  • json_object (String)

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/merge_ruby_client/ticketing/types/error_validation_problem.rb', line 52

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["source"].nil?
    source = nil
  else
    source = parsed_json["source"].to_json
    source = Merge::Ticketing::ValidationProblemSource.from_json(json_object: source)
  end
  title = parsed_json["title"]
  detail = parsed_json["detail"]
  problem_type = parsed_json["problem_type"]
  new(
    source: source,
    title: title,
    detail: detail,
    problem_type: problem_type,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


86
87
88
89
90
91
# File 'lib/merge_ruby_client/ticketing/types/error_validation_problem.rb', line 86

def self.validate_raw(obj:)
  obj.source.nil? || Merge::Ticketing::ValidationProblemSource.validate_raw(obj: obj.source)
  obj.title.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.")
  obj.detail.is_a?(String) != false || raise("Passed value for field obj.detail is not the expected type, validation failed.")
  obj.problem_type.is_a?(String) != false || raise("Passed value for field obj.problem_type is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ErrorValidationProblem to a JSON object

Returns:

  • (String)


76
77
78
# File 'lib/merge_ruby_client/ticketing/types/error_validation_problem.rb', line 76

def to_json(*_args)
  @_field_set&.to_json
end