Class: Courier::Users::Tokens::PatchOperation
- Inherits:
-
Object
- Object
- Courier::Users::Tokens::PatchOperation
- Defined in:
- lib/trycourier/users/tokens/types/patch_operation.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Users::Tokens::PatchOperation
Deserialize a JSON object to an instance of PatchOperation.
-
.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(op:, path:, value: nil, additional_properties: nil) ⇒ Users::Tokens::PatchOperation constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of PatchOperation to a JSON object.
Constructor Details
#initialize(op:, path:, value: nil, additional_properties: nil) ⇒ Users::Tokens::PatchOperation
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/trycourier/users/tokens/types/patch_operation.rb', line 16 def initialize(op:, path:, value: nil, additional_properties: nil) # @type [String] The operation to perform. @op = op # @type [String] The JSON path specifying the part of the profile to operate on. @path = path # @type [String] The value for the operation. @value = value # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
9 10 11 |
# File 'lib/trycourier/users/tokens/types/patch_operation.rb', line 9 def additional_properties @additional_properties end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
9 10 11 |
# File 'lib/trycourier/users/tokens/types/patch_operation.rb', line 9 def op @op end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/trycourier/users/tokens/types/patch_operation.rb', line 9 def path @path end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/trycourier/users/tokens/types/patch_operation.rb', line 9 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ Users::Tokens::PatchOperation
Deserialize a JSON object to an instance of PatchOperation
31 32 33 34 35 36 37 38 |
# File 'lib/trycourier/users/tokens/types/patch_operation.rb', line 31 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) op = struct.op path = struct.path value = struct.value new(op: op, path: path, value: value, 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.
51 52 53 54 55 |
# File 'lib/trycourier/users/tokens/types/patch_operation.rb', line 51 def self.validate_raw(obj:) obj.op.is_a?(String) != false || raise("Passed value for field obj.op is not the expected type, validation failed.") obj.path.is_a?(String) != false || raise("Passed value for field obj.path is not the expected type, validation failed.") obj.value&.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of PatchOperation to a JSON object
43 44 45 |
# File 'lib/trycourier/users/tokens/types/patch_operation.rb', line 43 def to_json(*_args) { "op": @op, "path": @path, "value": @value }.to_json end |