Class: Asdawqw::AsynchronousValidationModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/asdawqw/models/asynchronous_validation_model.rb

Overview

Model for Validation messages

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(product_id = nil, valid = nil, validation_errors = nil) ⇒ AsynchronousValidationModel

Returns a new instance of AsynchronousValidationModel.



30
31
32
33
34
35
36
# File 'lib/asdawqw/models/asynchronous_validation_model.rb', line 30

def initialize(product_id = nil,
               valid = nil,
               validation_errors = nil)
  @product_id = product_id
  @validation_errors = validation_errors
  @valid = valid
end

Instance Attribute Details

#product_idInteger

Id of product in BookingPal

Returns:

  • (Integer)


11
12
13
# File 'lib/asdawqw/models/asynchronous_validation_model.rb', line 11

def product_id
  @product_id
end

#validBoolean

Is product valid

Returns:

  • (Boolean)


19
20
21
# File 'lib/asdawqw/models/asynchronous_validation_model.rb', line 19

def valid
  @valid
end

#validation_errorsString

Error message - explanation what are problems if validation failed.

Returns:



15
16
17
# File 'lib/asdawqw/models/asynchronous_validation_model.rb', line 15

def validation_errors
  @validation_errors
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/asdawqw/models/asynchronous_validation_model.rb', line 39

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  product_id = hash['productId']
  valid = hash['valid']
  validation_errors = hash['validationErrors']

  # Create object from extracted values.
  AsynchronousValidationModel.new(product_id,
                                  valid,
                                  validation_errors)
end

.namesObject

A mapping from model property names to API property names.



22
23
24
25
26
27
28
# File 'lib/asdawqw/models/asynchronous_validation_model.rb', line 22

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['product_id'] = 'productId'
  @_hash['validation_errors'] = 'validationErrors'
  @_hash['valid'] = 'valid'
  @_hash
end