Class: KondutoPassenger

Inherits:
Object
  • Object
show all
Defined in:
lib/konduto-ruby/konduto_passenger.rb

Constant Summary collapse

TYPE_DOCUMENT =
[:passport, :id]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ KondutoPassenger

Returns a new instance of KondutoPassenger.


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/konduto-ruby/konduto_passenger.rb', line 7

def initialize(*args)
  if args[0].nil?
    self.loyalty = KondutoLoyalty.new
  else
    if args[0][:loyalty].nil?
      self.loyalty = KondutoLoyalty.new
    else
      self.loyalty = KondutoLoyalty.new args[0][:loyalty]
      args[0].delete :loyalty
    end
    args[0].each do |k,v|
      instance_variable_set("@#{k}", v) unless v.nil?
    end
  end
end

Instance Attribute Details

#dobObject

Returns the value of attribute dob


4
5
6
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4

def dob
  @dob
end

#documentObject

Returns the value of attribute document


4
5
6
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4

def document
  @document
end

#document_typeObject

Returns the value of attribute document_type


4
5
6
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4

def document_type
  @document_type
end

#frequent_travellerObject

Returns the value of attribute frequent_traveller


4
5
6
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4

def frequent_traveller
  @frequent_traveller
end

#loyaltyObject

Returns the value of attribute loyalty


4
5
6
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4

def loyalty
  @loyalty
end

#nameObject

Returns the value of attribute name


4
5
6
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4

def name
  @name
end

#nationalityObject

Returns the value of attribute nationality


4
5
6
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4

def nationality
  @nationality
end

#special_needsObject

Returns the value of attribute special_needs


4
5
6
# File 'lib/konduto-ruby/konduto_passenger.rb', line 4

def special_needs
  @special_needs
end

Instance Method Details

#to_hashObject


23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/konduto-ruby/konduto_passenger.rb', line 23

def to_hash
  hash = {
      name: self.name,
      document: self.document,
      document_type: self.document_type,
      dob: self.dob,
      nationality: self.nationality,
      frequent_traveller: self.frequent_traveller,
      special_needs: self.special_needs,
      loyalty: self.loyalty.to_hash
  }
  KondutoUtils.remove_nil_keys_from_hash(hash)
end

#to_jsonObject


37
38
39
# File 'lib/konduto-ruby/konduto_passenger.rb', line 37

def to_json
  self.to_hash.to_json
end