Class: Courier::Users::Tokens::PatchUserTokenOpts

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/users/tokens/types/patch_user_token_opts.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(patch:, additional_properties: nil) ⇒ Users::Tokens::PatchUserTokenOpts

Parameters:

  • patch (Array<Users::Tokens::PatchOperation>)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesObject (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

#patchObject (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

Parameters:

  • json_object (JSON)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (JSON)


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