Class: TrophyApiClient::PointsRange

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, to:, users:, additional_properties: nil) ⇒ TrophyApiClient::PointsRange



27
28
29
30
31
32
33
# File 'lib/trophy_api_client/types/points_range.rb', line 27

def initialize(from:, to:, users:, additional_properties: nil)
  @from = from
  @to = to
  @users = users
  @additional_properties = additional_properties
  @_field_set = { "from": from, "to": to, "users": users }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



15
16
17
# File 'lib/trophy_api_client/types/points_range.rb', line 15

def additional_properties
  @additional_properties
end

#fromInteger (readonly)



9
10
11
# File 'lib/trophy_api_client/types/points_range.rb', line 9

def from
  @from
end

#toInteger (readonly)



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

def to
  @to
end

#usersInteger (readonly)



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

def users
  @users
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::PointsRange

Deserialize a JSON object to an instance of PointsRange



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  from = parsed_json["from"]
  to = parsed_json["to"]
  users = parsed_json["users"]
  new(
    from: from,
    to: to,
    users: users,
    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.


66
67
68
69
70
# File 'lib/trophy_api_client/types/points_range.rb', line 66

def self.validate_raw(obj:)
  obj.from.is_a?(Integer) != false || raise("Passed value for field obj.from is not the expected type, validation failed.")
  obj.to.is_a?(Integer) != false || raise("Passed value for field obj.to is not the expected type, validation failed.")
  obj.users.is_a?(Integer) != false || raise("Passed value for field obj.users is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PointsRange to a JSON object



56
57
58
# File 'lib/trophy_api_client/types/points_range.rb', line 56

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