Class: NewStoreApi::CancellationPolicySettingsReasonsEnum

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

Overview

CancellationPolicySettingsReasons.

Constant Summary collapse

CANCELLATION_POLICY_SETTINGS_REASONS_ENUM =
[
  # TODO: Write general description for INSUFFICIENT_STOCK
  INSUFFICIENT_STOCK = 'insufficient_stock'.freeze,

  # TODO: Write general description for FAILED_FULFILLMENT_NODE_MAPPING
  FAILED_FULFILLMENT_NODE_MAPPING = 'failed_fulfillment_node_mapping'.freeze,

  # TODO: Write general description for SHIPPING_OFFER_UPDATE_ERROR
  SHIPPING_OFFER_UPDATE_ERROR = 'shipping_offer_update_error'.freeze,

  # TODO: Write general description for ERROR
  ERROR = 'error'.freeze,

  # TODO: Write general description for
  # NOT_ENOUGH_STOCK_TO_CREATE_ALLOCATION
  NOT_ENOUGH_STOCK_TO_CREATE_ALLOCATION = 'not_enough_stock_to_create_allocation'.freeze,

  # TODO: Write general description for LIMIT_OF_SHIPMENTS_EXCEEDED
  LIMIT_OF_SHIPMENTS_EXCEEDED = 'limit_of_shipments_exceeded'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = INSUFFICIENT_STOCK) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/new_store_api/models/cancellation_policy_settings_reasons_enum.rb', line 36

def self.from_value(value, default_value = INSUFFICIENT_STOCK)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'insufficient_stock' then INSUFFICIENT_STOCK
  when 'failed_fulfillment_node_mapping' then FAILED_FULFILLMENT_NODE_MAPPING
  when 'shipping_offer_update_error' then SHIPPING_OFFER_UPDATE_ERROR
  when 'error' then ERROR
  when 'not_enough_stock_to_create_allocation' then NOT_ENOUGH_STOCK_TO_CREATE_ALLOCATION
  when 'limit_of_shipments_exceeded' then LIMIT_OF_SHIPMENTS_EXCEEDED
  else
    default_value
  end
end

.validate(value) ⇒ Object



30
31
32
33
34
# File 'lib/new_store_api/models/cancellation_policy_settings_reasons_enum.rb', line 30

def self.validate(value)
  return false if value.nil?

  CANCELLATION_POLICY_SETTINGS_REASONS_ENUM.include?(value)
end