Class: LaunchDarkly::Interfaces::DataSystem::Payload
- Inherits:
-
Object
- Object
- LaunchDarkly::Interfaces::DataSystem::Payload
- Defined in:
- lib/ldclient-rb/interfaces/data_system.rb
Overview
Payload represents a payload delivered in a streaming response.
This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning. It is in early access. If you want access to this feature please join the EAP. launchdarkly.com/docs/sdk/features/data-saving-mode
Instance Attribute Summary collapse
-
#code ⇒ String
readonly
The intent code (IntentCode).
-
#id ⇒ String
readonly
The payload ID.
-
#reason ⇒ String
readonly
The reason.
-
#target ⇒ Integer
readonly
The target.
Class Method Summary collapse
-
.from_h(data) ⇒ Payload
Deserializes a Payload from a Hash.
Instance Method Summary collapse
-
#initialize(id:, target:, code:, reason:) ⇒ Payload
constructor
A new instance of Payload.
-
#to_h ⇒ Hash
Serializes the Payload to a Hash.
Constructor Details
#initialize(id:, target:, code:, reason:) ⇒ Payload
Returns a new instance of Payload.
315 316 317 318 319 320 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 315 def initialize(id:, target:, code:, reason:) @id = id @target = target @code = code @reason = reason end |
Instance Attribute Details
#code ⇒ String (readonly)
Returns The intent code (IntentCode).
304 305 306 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 304 def code @code end |
#id ⇒ String (readonly)
Returns The payload ID.
298 299 300 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 298 def id @id end |
#reason ⇒ String (readonly)
Returns The reason.
307 308 309 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 307 def reason @reason end |
#target ⇒ Integer (readonly)
Returns The target.
301 302 303 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 301 def target @target end |
Class Method Details
.from_h(data) ⇒ Payload
Deserializes a Payload from a Hash.
343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 343 def self.from_h(data) intent_code = data['intentCode'] || data[:intentCode] raise ArgumentError, "Invalid data for Payload: 'intentCode' key is missing or not a string" if intent_code.nil? || !intent_code.is_a?(String) Payload.new( id: data['id'] || data[:id] || "", target: data['target'] || data[:target] || 0, code: intent_code, reason: data['reason'] || data[:reason] || "" ) end |
Instance Method Details
#to_h ⇒ Hash
Serializes the Payload to a Hash.
327 328 329 330 331 332 333 334 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 327 def to_h { id: @id, target: @target, intentCode: @code, reason: @reason, } end |