Class: PaypalServerSdk::Patch

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/patch.rb

Overview

The JSON patch object to apply partial updates to resources.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(op:, path: SKIP, value: SKIP, from: SKIP) ⇒ Patch

Returns a new instance of Patch.



56
57
58
59
60
61
# File 'lib/paypal_server_sdk/models/patch.rb', line 56

def initialize(op:, path: SKIP, value: SKIP, from: SKIP)
  @op = op
  @path = path unless path == SKIP
  @value = value unless value == SKIP
  @from = from unless from == SKIP
end

Instance Attribute Details

#fromString

The JSON Pointer to the target document location from which to move the value. Required for the move operation.

Returns:

  • (String)


30
31
32
# File 'lib/paypal_server_sdk/models/patch.rb', line 30

def from
  @from
end

#opPatchOp

The operation.

Returns:



14
15
16
# File 'lib/paypal_server_sdk/models/patch.rb', line 14

def op
  @op
end

#pathString

The JSON Pointer to the target document location at which to complete the operation.

Returns:

  • (String)


19
20
21
# File 'lib/paypal_server_sdk/models/patch.rb', line 19

def path
  @path
end

#valueObject

The value to apply. The remove, copy, and move operations do not require a value. Since JSON Patch allows any type for value, the type property is not specified.

Returns:

  • (Object)


25
26
27
# File 'lib/paypal_server_sdk/models/patch.rb', line 25

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/paypal_server_sdk/models/patch.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  op = hash.key?('op') ? hash['op'] : nil
  path = hash.key?('path') ? hash['path'] : SKIP
  value = hash.key?('value') ? hash['value'] : SKIP
  from = hash.key?('from') ? hash['from'] : SKIP

  # Create object from extracted values.

  Patch.new(op: op,
            path: path,
            value: value,
            from: from)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
# File 'lib/paypal_server_sdk/models/patch.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['op'] = 'op'
  @_hash['path'] = 'path'
  @_hash['value'] = 'value'
  @_hash['from'] = 'from'
  @_hash
end

.nullablesObject

An array for nullable fields



52
53
54
# File 'lib/paypal_server_sdk/models/patch.rb', line 52

def self.nullables
  []
end

.optionalsObject

An array for optional fields



43
44
45
46
47
48
49
# File 'lib/paypal_server_sdk/models/patch.rb', line 43

def self.optionals
  %w[
    path
    value
    from
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



87
88
89
90
91
# File 'lib/paypal_server_sdk/models/patch.rb', line 87

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} op: #{@op.inspect}, path: #{@path.inspect}, value: #{@value.inspect}, from:"\
  " #{@from.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



81
82
83
84
# File 'lib/paypal_server_sdk/models/patch.rb', line 81

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} op: #{@op}, path: #{@path}, value: #{@value}, from: #{@from}>"
end