Class: Courier::AuditEvents::AuditEvent
- Inherits:
-
Object
- Object
- Courier::AuditEvents::AuditEvent
- Defined in:
- lib/trycourier/audit_events/types/audit_event.rb
Instance Attribute Summary collapse
-
#actor ⇒ Object
readonly
Returns the value of attribute actor.
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#audit_event_id ⇒ Object
readonly
Returns the value of attribute audit_event_id.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AuditEvents::AuditEvent
Deserialize a JSON object to an instance of AuditEvent.
-
.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.
Instance Method Summary collapse
- #initialize(audit_event_id:, source:, timestamp:, type:, actor: nil, target: nil, additional_properties: nil) ⇒ AuditEvents::AuditEvent constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of AuditEvent to a JSON object.
Constructor Details
#initialize(audit_event_id:, source:, timestamp:, type:, actor: nil, target: nil, additional_properties: nil) ⇒ AuditEvents::AuditEvent
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 20 def initialize(audit_event_id:, source:, timestamp:, type:, actor: nil, target: nil, additional_properties: nil) # @type [AuditEvents::Actor] @actor = actor # @type [AuditEvents::Target] @target = target # @type [String] @audit_event_id = audit_event_id # @type [String] @source = source # @type [String] @timestamp = # @type [String] @type = type # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#actor ⇒ Object (readonly)
Returns the value of attribute actor.
10 11 12 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 10 def actor @actor end |
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
10 11 12 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 10 def additional_properties @additional_properties end |
#audit_event_id ⇒ Object (readonly)
Returns the value of attribute audit_event_id.
10 11 12 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 10 def audit_event_id @audit_event_id end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 10 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
10 11 12 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 10 def target @target end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
10 11 12 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 10 def @timestamp end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 10 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ AuditEvents::AuditEvent
Deserialize a JSON object to an instance of AuditEvent
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 41 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["actor"].nil? actor = nil else actor = parsed_json["actor"].to_json actor = AuditEvents::Actor.from_json(json_object: actor) end if parsed_json["target"].nil? target = nil else target = parsed_json["target"].to_json target = AuditEvents::Target.from_json(json_object: target) end audit_event_id = struct.auditEventId source = struct.source = struct. type = struct.type new(actor: actor, target: target, audit_event_id: audit_event_id, source: source, timestamp: , type: 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.
82 83 84 85 86 87 88 89 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 82 def self.validate_raw(obj:) obj.actor.nil? || AuditEvents::Actor.validate_raw(obj: obj.actor) obj.target.nil? || AuditEvents::Target.validate_raw(obj: obj.target) obj.audit_event_id.is_a?(String) != false || raise("Passed value for field obj.audit_event_id is not the expected type, validation failed.") obj.source.is_a?(String) != false || raise("Passed value for field obj.source is not the expected type, validation failed.") obj..is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of AuditEvent to a JSON object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/trycourier/audit_events/types/audit_event.rb', line 67 def to_json(*_args) { "actor": @actor, "target": @target, "auditEventId": @audit_event_id, "source": @source, "timestamp": @timestamp, "type": @type }.to_json end |