Class: NewStoreApi::PlatformEventDto
- Defined in:
- lib/new_store_api/models/platform_event_dto.rb
Overview
PlatformEventDto Model.
Instance Attribute Summary collapse
-
#name ⇒ EventName1Enum
The name of the external event.
-
#payload ⇒ Object
The name of the external event.
-
#published_at ⇒ DateTime
Timestamp of the publishing of the event.
-
#tenant ⇒ String
Tenant identifier.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(name = nil, payload = nil, published_at = nil, tenant = nil) ⇒ PlatformEventDto
constructor
A new instance of PlatformEventDto.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_published_at ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(name = nil, payload = nil, published_at = nil, tenant = nil) ⇒ PlatformEventDto
Returns a new instance of PlatformEventDto.
49 50 51 52 53 54 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 49 def initialize(name = nil, payload = nil, published_at = nil, tenant = nil) @name = name @payload = payload @published_at = published_at @tenant = tenant end |
Instance Attribute Details
#name ⇒ EventName1Enum
The name of the external event.
15 16 17 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 15 def name @name end |
#payload ⇒ Object
The name of the external event.
19 20 21 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 19 def payload @payload end |
#published_at ⇒ DateTime
Timestamp of the publishing of the event.
23 24 25 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 23 def published_at @published_at end |
#tenant ⇒ String
Tenant identifier.
27 28 29 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 27 def tenant @tenant end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 57 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil payload = hash.key?('payload') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:PlatformEventDtoPayload), hash['payload'] ) : nil published_at = if hash.key?('published_at') (DateTimeHelper.from_rfc3339(hash['published_at']) if hash['published_at']) end tenant = hash.key?('tenant') ? hash['tenant'] : nil # Create object from extracted values. PlatformEventDto.new(name, payload, published_at, tenant) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['payload'] = 'payload' @_hash['published_at'] = 'published_at' @_hash['tenant'] = 'tenant' @_hash end |
.nullables ⇒ Object
An array for nullable fields
45 46 47 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 45 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 40 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 83 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.name, ->(val) { EventName1Enum.validate(val) }) and UnionTypeLookUp.get(:PlatformEventDtoPayload) .validate(value.payload) and APIHelper.valid_type?(value.published_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.tenant, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['name'], ->(val) { EventName1Enum.validate(val) }) and UnionTypeLookUp.get(:PlatformEventDtoPayload) .validate(value['payload']) and APIHelper.valid_type?(value['published_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['tenant'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
119 120 121 122 123 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 119 def inspect class_name = self.class.name.split('::').last "<#{class_name} name: #{@name.inspect}, payload: #{@payload.inspect}, published_at:"\ " #{@published_at.inspect}, tenant: #{@tenant.inspect}>" end |
#to_custom_published_at ⇒ Object
77 78 79 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 77 def to_custom_published_at DateTimeHelper.to_rfc3339(published_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
112 113 114 115 116 |
# File 'lib/new_store_api/models/platform_event_dto.rb', line 112 def to_s class_name = self.class.name.split('::').last "<#{class_name} name: #{@name}, payload: #{@payload}, published_at: #{@published_at},"\ " tenant: #{@tenant}>" end |