Class: GolfSwitch::BookGolf

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

Instance Attribute Summary collapse

Attributes inherited from Request

#client, #config, #request, #response, #soap_error

Instance Method Summary collapse

Methods inherited from Request

#error?, #error_message, #get_authentication_header

Constructor Details

#initialize(attributes = {}) ⇒ BookGolf

Returns a new instance of BookGolf.



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

def initialize(attributes={})
  @book_golf_items = []
end

Instance Attribute Details

#api_responseObject

Returns the value of attribute api_response.



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

def api_response
  @api_response
end

#book_golf_itemsObject

Returns the value of attribute book_golf_items.



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

def book_golf_items
  @book_golf_items
end

Instance Method Details

#commitObject



20
21
22
# File 'lib/golf_switch/book_golf.rb', line 20

def commit
  super("book_golf")
end

#get_optionsObject



8
9
10
11
12
13
# File 'lib/golf_switch/book_golf.rb', line 8

def get_options
  {
    "Req"=>option_attributes

  }
end

#option_attributesObject



14
15
16
17
18
# File 'lib/golf_switch/book_golf.rb', line 14

def option_attributes
  {
    "BookGolfItems"=>{"BookGolfItem"=>Array(@book_golf_items).collect{|bgi| bgi.option_attributes}}
  }
end

#parse_errorObject



24
25
26
# File 'lib/golf_switch/book_golf.rb', line 24

def parse_error
  @response[:book_golf_response][:book_golf_result]
end

#parse_responseObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/golf_switch/book_golf.rb', line 28

def parse_response
  begin
    unless error?
      @api_response = GolfSwitch::GolfBook.parse_golf_books(@response[:book_golf_response][:book_golf_result])
    else
      puts "Error #{error_message}"
    end
  rescue
    puts "Parse Error On Book Golf"
  end
end