Class: NewStoreApi::CancellationPolicySettingsValue

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/cancellation_policy_settings_value.rb

Overview

Order cancellation policies.

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(default = true, reasons_to_overwrite_default = SKIP) ⇒ CancellationPolicySettingsValue

Returns a new instance of CancellationPolicySettingsValue.



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

def initialize(default = true, reasons_to_overwrite_default = SKIP)
  @default = default unless default == SKIP
  unless reasons_to_overwrite_default == SKIP
    @reasons_to_overwrite_default =
      reasons_to_overwrite_default
  end
end

Instance Attribute Details

#defaultTrueClass | FalseClass

Determines whether orders are canceled automatically in case of a conflict.

Returns:

  • (TrueClass | FalseClass)


15
16
17
# File 'lib/new_store_api/models/cancellation_policy_settings_value.rb', line 15

def default
  @default
end

#reasons_to_overwrite_defaultArray[CancellationPolicySettingsReasonsEnum]

A list of reasons to prevent an automatic cancelation of an order (in case default is 'true') or to prevent an order being in the conflict state.



20
21
22
# File 'lib/new_store_api/models/cancellation_policy_settings_value.rb', line 20

def reasons_to_overwrite_default
  @reasons_to_overwrite_default
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/new_store_api/models/cancellation_policy_settings_value.rb', line 52

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  default = hash['default'] ||= true
  reasons_to_overwrite_default =
    hash.key?('reasons_to_overwrite_default') ? hash['reasons_to_overwrite_default'] : SKIP

  # Create object from extracted values.
  CancellationPolicySettingsValue.new(default,
                                      reasons_to_overwrite_default)
end

.namesObject

A mapping from model property names to API property names.



23
24
25
26
27
28
# File 'lib/new_store_api/models/cancellation_policy_settings_value.rb', line 23

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['default'] = 'default'
  @_hash['reasons_to_overwrite_default'] = 'reasons_to_overwrite_default'
  @_hash
end

.nullablesObject

An array for nullable fields



39
40
41
# File 'lib/new_store_api/models/cancellation_policy_settings_value.rb', line 39

def self.nullables
  []
end

.optionalsObject

An array for optional fields



31
32
33
34
35
36
# File 'lib/new_store_api/models/cancellation_policy_settings_value.rb', line 31

def self.optionals
  %w[
    default
    reasons_to_overwrite_default
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



73
74
75
76
77
# File 'lib/new_store_api/models/cancellation_policy_settings_value.rb', line 73

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

#to_sObject

Provides a human-readable string representation of the object.



66
67
68
69
70
# File 'lib/new_store_api/models/cancellation_policy_settings_value.rb', line 66

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} default: #{@default}, reasons_to_overwrite_default:"\
  " #{@reasons_to_overwrite_default}>"
end