Class: Merge::Hris::PaginatedLocationList

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/hris/types/paginated_location_list.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(next_: OMIT, previous: OMIT, results: OMIT, additional_properties: nil) ⇒ Merge::Hris::PaginatedLocationList

Parameters:

  • next_ (String) (defaults to: OMIT)
  • previous (String) (defaults to: OMIT)
  • results (Array<Merge::Hris::Location>) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



29
30
31
32
33
34
35
36
37
# File 'lib/merge_ruby_client/hris/types/paginated_location_list.rb', line 29

def initialize(next_: OMIT, previous: OMIT, results: OMIT, additional_properties: nil)
  @next_ = next_ if next_ != OMIT
  @previous = previous if previous != OMIT
  @results = results if results != OMIT
  @additional_properties = additional_properties
  @_field_set = { "next": next_, "previous": previous, "results": results }.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



17
18
19
# File 'lib/merge_ruby_client/hris/types/paginated_location_list.rb', line 17

def additional_properties
  @additional_properties
end

#next_String (readonly)

Returns:

  • (String)


11
12
13
# File 'lib/merge_ruby_client/hris/types/paginated_location_list.rb', line 11

def next_
  @next_
end

#previousString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/merge_ruby_client/hris/types/paginated_location_list.rb', line 13

def previous
  @previous
end

#resultsArray<Merge::Hris::Location> (readonly)

Returns:



15
16
17
# File 'lib/merge_ruby_client/hris/types/paginated_location_list.rb', line 15

def results
  @results
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Hris::PaginatedLocationList

Deserialize a JSON object to an instance of PaginatedLocationList

Parameters:

  • json_object (String)

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/merge_ruby_client/hris/types/paginated_location_list.rb', line 43

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  next_ = parsed_json["next"]
  previous = parsed_json["previous"]
  results = parsed_json["results"]&.map do |item|
    item = item.to_json
    Merge::Hris::Location.from_json(json_object: item)
  end
  new(
    next_: next_,
    previous: previous,
    results: results,
    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)


73
74
75
76
77
# File 'lib/merge_ruby_client/hris/types/paginated_location_list.rb', line 73

def self.validate_raw(obj:)
  obj.next_&.is_a?(String) != false || raise("Passed value for field obj.next_ is not the expected type, validation failed.")
  obj.previous&.is_a?(String) != false || raise("Passed value for field obj.previous is not the expected type, validation failed.")
  obj.results&.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PaginatedLocationList to a JSON object

Returns:

  • (String)


63
64
65
# File 'lib/merge_ruby_client/hris/types/paginated_location_list.rb', line 63

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