Class: Suitcase::Hotel::PaymentOption
- Inherits:
-
Object
- Object
- Suitcase::Hotel::PaymentOption
- Extended by:
- Helpers
- Defined in:
- lib/suitcase/hotel/payment_option.rb
Constant Summary
Constants included from Helpers
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.find(info) ⇒ Object
Public: Find PaymentOptions for a specific currency.
Instance Method Summary collapse
-
#initialize(code, name) ⇒ PaymentOption
constructor
Internal: Create a PaymentOption.
Methods included from Helpers
base_url, build_session_params, generate_signature, handle_errors, main_url, parameterize, parameterize_rooms, parse_response, update_session, url
Constructor Details
#initialize(code, name) ⇒ PaymentOption
Internal: Create a PaymentOption.
code - The String code from the API response (e.g. “VI”). name - The String name of the PaymentOption.
12 13 14 |
# File 'lib/suitcase/hotel/payment_option.rb', line 12 def initialize(code, name) @code, @name = code, name end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
4 5 6 |
# File 'lib/suitcase/hotel/payment_option.rb', line 4 def code @code end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/suitcase/hotel/payment_option.rb', line 4 def name @name end |
Class Method Details
.find(info) ⇒ Object
Public: Find PaymentOptions for a specific currency.
info - A Hash of information with one key: :currency_code.
Returns an Array of PaymentOption’s.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/suitcase/hotel/payment_option.rb', line 21 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 update_session(types_raw, info[:session]) types_raw["HotelPaymentResponse"].map do |raw| types = raw[0] != "PaymentType" ? [] : raw[1] types.map do |type| PaymentOption.new(type["code"], type["name"]) end end.flatten end |