Class: Gusto::Event

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

Overview

Representation of an Event

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid:, event_type: OMIT, resource_type: OMIT, resource_uuid: OMIT, entity_type: OMIT, entity_uuid: OMIT, timestamp: OMIT, additional_properties: nil) ⇒ Gusto::Event

Parameters:

  • uuid (String)

    Unique identifier for the event.

  • event_type (String) (defaults to: OMIT)

    Description of the event (e.g., payroll.submitted, or company.form.signed).

  • resource_type (String) (defaults to: OMIT)

    Name of the parent resource of the described entity.

  • resource_uuid (String) (defaults to: OMIT)

    Unique identifier for the parent resource.

  • entity_type (String) (defaults to: OMIT)

    Name of the entity that the event corresponds to.

  • entity_uuid (String) (defaults to: OMIT)

    Unique identifier for the entity.

  • timestamp (Integer) (defaults to: OMIT)

    Time at which this event was created. Measured in seconds since the Unix epoch.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(uuid:, event_type: OMIT, resource_type: OMIT, resource_uuid: OMIT, entity_type: OMIT, entity_uuid: OMIT, timestamp: OMIT, additional_properties: nil)
  @uuid = uuid
  @event_type = event_type if event_type != OMIT
  @resource_type = resource_type if resource_type != OMIT
  @resource_uuid = resource_uuid if resource_uuid != OMIT
  @entity_type = entity_type if entity_type != OMIT
  @entity_uuid = entity_uuid if entity_uuid != OMIT
  @timestamp = timestamp if timestamp != OMIT
  @additional_properties = additional_properties
  @_field_set = { "uuid": uuid, "event_type": event_type, "resource_type": resource_type, "resource_uuid": resource_uuid, "entity_type": entity_type, "entity_uuid": entity_uuid, "timestamp": timestamp }.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



23
24
25
# File 'lib/fern_gusto/types/event.rb', line 23

def additional_properties
  @additional_properties
end

#entity_typeString (readonly)

Returns Name of the entity that the event corresponds to.

Returns:

  • (String)

    Name of the entity that the event corresponds to.



17
18
19
# File 'lib/fern_gusto/types/event.rb', line 17

def entity_type
  @entity_type
end

#entity_uuidString (readonly)

Returns Unique identifier for the entity.

Returns:

  • (String)

    Unique identifier for the entity.



19
20
21
# File 'lib/fern_gusto/types/event.rb', line 19

def entity_uuid
  @entity_uuid
end

#event_typeString (readonly)

Returns Description of the event (e.g., payroll.submitted, or company.form.signed).

Returns:

  • (String)

    Description of the event (e.g., payroll.submitted, or company.form.signed).



11
12
13
# File 'lib/fern_gusto/types/event.rb', line 11

def event_type
  @event_type
end

#resource_typeString (readonly)

Returns Name of the parent resource of the described entity.

Returns:

  • (String)

    Name of the parent resource of the described entity.



13
14
15
# File 'lib/fern_gusto/types/event.rb', line 13

def resource_type
  @resource_type
end

#resource_uuidString (readonly)

Returns Unique identifier for the parent resource.

Returns:

  • (String)

    Unique identifier for the parent resource.



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

def resource_uuid
  @resource_uuid
end

#timestampInteger (readonly)

Returns Time at which this event was created. Measured in seconds since the Unix epoch.

Returns:

  • (Integer)

    Time at which this event was created. Measured in seconds since the Unix epoch.



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

def timestamp
  @timestamp
end

#uuidString (readonly)

Returns Unique identifier for the event.

Returns:

  • (String)

    Unique identifier for the event.



9
10
11
# File 'lib/fern_gusto/types/event.rb', line 9

def uuid
  @uuid
end

Class Method Details

.from_json(json_object:) ⇒ Gusto::Event

Parameters:

  • json_object (String)

Returns:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fern_gusto/types/event.rb', line 56

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  uuid = parsed_json["uuid"]
  event_type = parsed_json["event_type"]
  resource_type = parsed_json["resource_type"]
  resource_uuid = parsed_json["resource_uuid"]
  entity_type = parsed_json["entity_type"]
  entity_uuid = parsed_json["entity_uuid"]
  timestamp = parsed_json["timestamp"]
  new(
    uuid: uuid,
    event_type: event_type,
    resource_type: resource_type,
    resource_uuid: resource_uuid,
    entity_type: entity_type,
    entity_uuid: entity_uuid,
    timestamp: timestamp,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


89
90
91
92
93
94
95
96
97
# File 'lib/fern_gusto/types/event.rb', line 89

def self.validate_raw(obj:)
  obj.uuid.is_a?(String) != false || raise("Passed value for field obj.uuid is not the expected type, validation failed.")
  obj.event_type&.is_a?(String) != false || raise("Passed value for field obj.event_type is not the expected type, validation failed.")
  obj.resource_type&.is_a?(String) != false || raise("Passed value for field obj.resource_type is not the expected type, validation failed.")
  obj.resource_uuid&.is_a?(String) != false || raise("Passed value for field obj.resource_uuid is not the expected type, validation failed.")
  obj.entity_type&.is_a?(String) != false || raise("Passed value for field obj.entity_type is not the expected type, validation failed.")
  obj.entity_uuid&.is_a?(String) != false || raise("Passed value for field obj.entity_uuid is not the expected type, validation failed.")
  obj.timestamp&.is_a?(Integer) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


80
81
82
# File 'lib/fern_gusto/types/event.rb', line 80

def to_json
  @_field_set&.to_json
end