Class: Courier::Users::Tokens::PatchUserTokenOpts
- Inherits:
-
Object
- Object
- Courier::Users::Tokens::PatchUserTokenOpts
- Defined in:
- lib/trycourier/users/tokens/types/patch_user_token_opts.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Users::Tokens::PatchUserTokenOpts
Deserialize a JSON object to an instance of PatchUserTokenOpts.
-
.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(patch:, additional_properties: nil) ⇒ Users::Tokens::PatchUserTokenOpts constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of PatchUserTokenOpts to a JSON object.
Constructor Details
#initialize(patch:, additional_properties: nil) ⇒ Users::Tokens::PatchUserTokenOpts
15 16 17 18 19 20 |
# File 'lib/trycourier/users/tokens/types/patch_user_token_opts.rb', line 15 def initialize(patch:, additional_properties: nil) # @type [Array<Users::Tokens::PatchOperation>] @patch = patch # @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.
10 11 12 |
# File 'lib/trycourier/users/tokens/types/patch_user_token_opts.rb', line 10 def additional_properties @additional_properties end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
10 11 12 |
# File 'lib/trycourier/users/tokens/types/patch_user_token_opts.rb', line 10 def patch @patch end |
Class Method Details
.from_json(json_object:) ⇒ Users::Tokens::PatchUserTokenOpts
Deserialize a JSON object to an instance of PatchUserTokenOpts
26 27 28 29 30 31 32 33 34 |
# File 'lib/trycourier/users/tokens/types/patch_user_token_opts.rb', line 26 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) patch = parsed_json["patch"]&.map do |v| v = v.to_json Users::Tokens::PatchOperation.from_json(json_object: v) end new(patch: patch, 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.
47 48 49 |
# File 'lib/trycourier/users/tokens/types/patch_user_token_opts.rb', line 47 def self.validate_raw(obj:) obj.patch.is_a?(Array) != false || raise("Passed value for field obj.patch is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of PatchUserTokenOpts to a JSON object
39 40 41 |
# File 'lib/trycourier/users/tokens/types/patch_user_token_opts.rb', line 39 def to_json(*_args) { "patch": @patch }.to_json end |