Class: TrophyApiClient::AdminIssue

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/admin_issue.rb

Overview

An issue encountered while processing an item in an admin API request.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(severity:, message:, user_id: OMIT, boost_id: OMIT, index: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminIssue

Parameters:

  • user_id (String) (defaults to: OMIT)

    The ID of the user the issue relates to, when applicable.

  • boost_id (String) (defaults to: OMIT)

    The ID of the points boost the issue relates to, when applicable.

  • index (Integer) (defaults to: OMIT)

    The zero-based index of the item the issue relates to, when no resource ID exists yet.

  • severity (TrophyApiClient::AdminIssueSeverity)

    The severity level of the issue.

  • message (String)

    A human-readable description of the issue.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/trophy_api_client/types/admin_issue.rb', line 37

def initialize(severity:, message:, user_id: OMIT, boost_id: OMIT, index: OMIT, additional_properties: nil)
  @user_id = user_id if user_id != OMIT
  @boost_id = boost_id if boost_id != OMIT
  @index = index if index != OMIT
  @severity = severity
  @message = message
  @additional_properties = additional_properties
  @_field_set = {
    "userId": user_id,
    "boostId": boost_id,
    "index": index,
    "severity": severity,
    "message": message
  }.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



22
23
24
# File 'lib/trophy_api_client/types/admin_issue.rb', line 22

def additional_properties
  @additional_properties
end

#boost_idString (readonly)

Returns The ID of the points boost the issue relates to, when applicable.

Returns:

  • (String)

    The ID of the points boost the issue relates to, when applicable.



13
14
15
# File 'lib/trophy_api_client/types/admin_issue.rb', line 13

def boost_id
  @boost_id
end

#indexInteger (readonly)

Returns The zero-based index of the item the issue relates to, when no resource ID exists yet.

Returns:

  • (Integer)

    The zero-based index of the item the issue relates to, when no resource ID exists yet.



16
17
18
# File 'lib/trophy_api_client/types/admin_issue.rb', line 16

def index
  @index
end

#messageString (readonly)

Returns A human-readable description of the issue.

Returns:

  • (String)

    A human-readable description of the issue.



20
21
22
# File 'lib/trophy_api_client/types/admin_issue.rb', line 20

def message
  @message
end

#severityTrophyApiClient::AdminIssueSeverity (readonly)

Returns The severity level of the issue.

Returns:



18
19
20
# File 'lib/trophy_api_client/types/admin_issue.rb', line 18

def severity
  @severity
end

#user_idString (readonly)

Returns The ID of the user the issue relates to, when applicable.

Returns:

  • (String)

    The ID of the user the issue relates to, when applicable.



11
12
13
# File 'lib/trophy_api_client/types/admin_issue.rb', line 11

def user_id
  @user_id
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::AdminIssue

Deserialize a JSON object to an instance of AdminIssue

Parameters:

  • json_object (String)

Returns:



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/trophy_api_client/types/admin_issue.rb', line 59

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  user_id = parsed_json["userId"]
  boost_id = parsed_json["boostId"]
  index = parsed_json["index"]
  severity = parsed_json["severity"]
  message = parsed_json["message"]
  new(
    user_id: user_id,
    boost_id: boost_id,
    index: index,
    severity: severity,
    message: message,
    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)


90
91
92
93
94
95
96
# File 'lib/trophy_api_client/types/admin_issue.rb', line 90

def self.validate_raw(obj:)
  obj.user_id&.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.")
  obj.boost_id&.is_a?(String) != false || raise("Passed value for field obj.boost_id is not the expected type, validation failed.")
  obj.index&.is_a?(Integer) != false || raise("Passed value for field obj.index is not the expected type, validation failed.")
  obj.severity.is_a?(TrophyApiClient::AdminIssueSeverity) != false || raise("Passed value for field obj.severity 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.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AdminIssue to a JSON object

Returns:

  • (String)


80
81
82
# File 'lib/trophy_api_client/types/admin_issue.rb', line 80

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