Class: Suitcase::PaymentOption

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Defined in:
lib/suitcase/hotel/payment_option.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

base_url, main_url, parse_response, update_session, url

Constructor Details

#initialize(code, name) ⇒ PaymentOption



6
7
8
9
# File 'lib/suitcase/hotel/payment_option.rb', line 6

def initialize(code, name)
  @code = code
  @name = name
end

Instance Attribute Details

#codeObject

Returns the value of attribute code



3
4
5
# File 'lib/suitcase/hotel/payment_option.rb', line 3

def code
  @code
end

#nameObject

Returns the value of attribute name



3
4
5
# File 'lib/suitcase/hotel/payment_option.rb', line 3

def name
  @name
end

Class Method Details

.find(info) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/suitcase/hotel/payment_option.rb', line 11

def self.find(info)
  params = { "currencyCode" => info[:currency_code] }
  if Configuration.cache? and Configuration.cache.cached?(:paymentInfo, params)
    types_raw = Configuration.cache.get_query(:paymentInfo, params)
  else
    types_raw = parse_response(url(:method => "paymentInfo", :params => params, :session => info[:session]))
    Configuration.cache.save_query(:paymentInfo, params, types_raw) if Configuration.cache?      
  end
  options = []
  types_raw["HotelPaymentResponse"].each do |raw|
    types = raw[0] != "PaymentType" ? [] : raw[1]
    types.each do |type|
      options.push PaymentOption.new(type["code"], type["name"])
    end
  end
  update_session(types_raw, info[:session])
  options
end