Class: GolfSwitch::BookGolfItem

Inherits:
Object
  • Object
show all
Defined in:
lib/golf_switch/book_golf_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ BookGolfItem

Returns a new instance of BookGolfItem.



7
8
9
10
11
12
13
14
15
16
# File 'lib/golf_switch/book_golf_item.rb', line 7

def initialize(attributes={})
  attributes.each do |name, value|
    begin
      send("#{name}=", value)
    rescue
      puts "invalid attribute #{name} in player"
    end
  end
  @players ||=[]
end

Instance Attribute Details

#alt_rate_type ⇒ Object

Returns the value of attribute alt_rate_type.



3
4
5
# File 'lib/golf_switch/book_golf_item.rb', line 3

def alt_rate_type
  @alt_rate_type
end

#book_notes ⇒ Object

Returns the value of attribute book_notes.



6
7
8
# File 'lib/golf_switch/book_golf_item.rb', line 6

def book_notes
  @book_notes
end

#chrg_curr ⇒ Object

Returns the value of attribute chrg_curr.



4
5
6
# File 'lib/golf_switch/book_golf_item.rb', line 4

def chrg_curr
  @chrg_curr
end

#course_id ⇒ Object

Returns the value of attribute course_id.



3
4
5
# File 'lib/golf_switch/book_golf_item.rb', line 3

def course_id
  @course_id
end

#curr ⇒ Object

Returns the value of attribute curr.



4
5
6
# File 'lib/golf_switch/book_golf_item.rb', line 4

def curr
  @curr
end

#flags ⇒ Object

Returns the value of attribute flags.



5
6
7
# File 'lib/golf_switch/book_golf_item.rb', line 5

def flags
  @flags
end

#ignore_pricing ⇒ Object

Returns the value of attribute ignore_pricing.



6
7
8
# File 'lib/golf_switch/book_golf_item.rb', line 6

def ignore_pricing
  @ignore_pricing
end

#num_players ⇒ Object

Returns the value of attribute num_players.



3
4
5
# File 'lib/golf_switch/book_golf_item.rb', line 3

def num_players
  @num_players
end

#package_id ⇒ Object

Returns the value of attribute package_id.



6
7
8
# File 'lib/golf_switch/book_golf_item.rb', line 6

def package_id
  @package_id
end

#payment ⇒ Object

Returns the value of attribute payment.



6
7
8
# File 'lib/golf_switch/book_golf_item.rb', line 6

def payment
  @payment
end

#play_date ⇒ Object

Returns the value of attribute play_date.



3
4
5
# File 'lib/golf_switch/book_golf_item.rb', line 3

def play_date
  @play_date
end

#play_time ⇒ Object

Returns the value of attribute play_time.



3
4
5
# File 'lib/golf_switch/book_golf_item.rb', line 3

def play_time
  @play_time
end

#players ⇒ Object

Returns the value of attribute players.



6
7
8
# File 'lib/golf_switch/book_golf_item.rb', line 6

def players
  @players
end

#pp_charge ⇒ Object

Returns the value of attribute pp_charge.



4
5
6
# File 'lib/golf_switch/book_golf_item.rb', line 4

def pp_charge
  @pp_charge
end

#pp_net_rt ⇒ Object

Returns the value of attribute pp_net_rt.



4
5
6
# File 'lib/golf_switch/book_golf_item.rb', line 4

def pp_net_rt
  @pp_net_rt
end

#pp_non_ref ⇒ Object

Returns the value of attribute pp_non_ref.



4
5
6
# File 'lib/golf_switch/book_golf_item.rb', line 4

def pp_non_ref
  @pp_non_ref
end

#pp_price ⇒ Object

Returns the value of attribute pp_price.



4
5
6
# File 'lib/golf_switch/book_golf_item.rb', line 4

def pp_price
  @pp_price
end

#pp_txn_fee ⇒ Object

Returns the value of attribute pp_txn_fee.



4
5
6
# File 'lib/golf_switch/book_golf_item.rb', line 4

def pp_txn_fee
  @pp_txn_fee
end

#promo_code ⇒ Object

Returns the value of attribute promo_code.



3
4
5
# File 'lib/golf_switch/book_golf_item.rb', line 3

def promo_code
  @promo_code
end

#tot_charge ⇒ Object

Returns the value of attribute tot_charge.



5
6
7
# File 'lib/golf_switch/book_golf_item.rb', line 5

def tot_charge
  @tot_charge
end

#tot_net_rt ⇒ Object

Returns the value of attribute tot_net_rt.



5
6
7
# File 'lib/golf_switch/book_golf_item.rb', line 5

def tot_net_rt
  @tot_net_rt
end

#tot_non_ref ⇒ Object

Returns the value of attribute tot_non_ref.



5
6
7
# File 'lib/golf_switch/book_golf_item.rb', line 5

def tot_non_ref
  @tot_non_ref
end

#tot_price ⇒ Object

Returns the value of attribute tot_price.



5
6
7
# File 'lib/golf_switch/book_golf_item.rb', line 5

def tot_price
  @tot_price
end

#tot_txn_fee ⇒ Object

Returns the value of attribute tot_txn_fee.



5
6
7
# File 'lib/golf_switch/book_golf_item.rb', line 5

def tot_txn_fee
  @tot_txn_fee
end

Instance Method Details

#option_attributes ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/golf_switch/book_golf_item.rb', line 18

def option_attributes
  @ignore_pricing =false if @ignore_pricing.blank?
  options = {}
  options.merge!("CourseId"=>@course_id) unless @course_id.blank?
  options.merge!("PlayDate"=>(DateTime.parse(@play_date).strftime("%Y-%m-%dT00:00:00")))
  options.merge!("PlayTime"=>@play_time)
  options.merge!("NumPlayers"=>@num_players)
  options.merge!("AltRateType"=>@alt_rate_type) unless @alt_rate_type.blank?
  options.merge!("PromoCode"=>@promo_code) unless @promo_code.blank?
  options.merge!("PpPrice"=>@pp_price)
  options.merge!("Curr"=>@curr||"USD")
  options.merge!("PpTxnFee"=>@pp_txn_fee)
  options.merge!("PpCharge"=>@pp_charge)
  options.merge!("ChrgCurr"=>@chrg_curr || "USD")
  options.merge!("PpNonRef"=>@pp_non_ref)
  options.merge!("PpNetRt"=>@pp_net_rt)
  options.merge!("TotPrice"=>@tot_price)
  options.merge!("TotTxnFee"=>@tot_txn_fee)
  options.merge!("TotCharge"=>@tot_charge)
  options.merge!("TotNonRef"=>@tot_non_ref)
  options.merge!("TotNetRt"=>@tot_net_rt)
  options.merge!("Flags"=>@flags) unless @flags.blank?
  options.merge!("PackageId"=>@package_id) unless @package_id.blank?
  options.merge!("BookNotes"=>@book_notes) unless @book_notes.blank?
  options.merge!("IgnorePricing"=>@ignore_pricing)
  options["Players"]={"Player"=>Array(@players).collect{|x| x.option_attributes}}
  options["Payments"]={"Payment"=>@payment.option_attributes}

  options
end