Class: ApimaticApi::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/apimatic_api/models/status.rb

Overview

Status.

Constant Summary collapse

STATUS =
[
  # TODO: Write general description for COMPLETED
  COMPLETED = 'Completed'.freeze,

  # TODO: Write general description for INPROGRESS
  INPROGRESS = 'InProgress'.freeze,

  # TODO: Write general description for VALIDATIONERROR
  VALIDATIONERROR = 'ValidationError'.freeze,

  # TODO: Write general description for SUBSCRIPTIONERROR
  SUBSCRIPTIONERROR = 'SubscriptionError'.freeze,

  # TODO: Write general description for FAILED
  FAILED = 'Failed'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = COMPLETED) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/apimatic_api/models/status.rb', line 32

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

  str = value.to_s.strip

  case str.downcase
  when 'completed' then COMPLETED
  when 'inprogress' then INPROGRESS
  when 'validationerror' then VALIDATIONERROR
  when 'subscriptionerror' then SUBSCRIPTIONERROR
  when 'failed' then FAILED
  else
    default_value
  end
end

.validate(value) ⇒ Object



26
27
28
29
30
# File 'lib/apimatic_api/models/status.rb', line 26

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

  STATUS.include?(value)
end