Class: GolfSwitch::Request
- Inherits:
-
Object
- Object
- GolfSwitch::Request
- Defined in:
- lib/golf_switch/request.rb
Direct Known Subclasses
Area, BookGolf, CancelGolf, CourseAvail, CourseAvailList, CourseAvailRequest, CourseInfo, CourseList, GetAltRateType, GetCoursePolicy, GetGolfBooking
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#config ⇒ Object
Returns the value of attribute config.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
-
#soap_error ⇒ Object
Returns the value of attribute soap_error.
Instance Method Summary collapse
- #commit(method_name) ⇒ Object
- #error? ⇒ Boolean
- #error_message ⇒ Object
- #get_authentication_header ⇒ Object
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/golf_switch/request.rb', line 4 def client @client end |
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/golf_switch/request.rb', line 4 def config @config end |
#request ⇒ Object
Returns the value of attribute request.
4 5 6 |
# File 'lib/golf_switch/request.rb', line 4 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/golf_switch/request.rb', line 4 def response @response end |
#soap_error ⇒ Object
Returns the value of attribute soap_error.
4 5 6 |
# File 'lib/golf_switch/request.rb', line 4 def soap_error @soap_error end |
Instance Method Details
#commit(method_name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/golf_switch/request.rb', line 5 def commit(method_name) @soap_error = false @config =GolfSwitch.configuration @client = Savon.client({:wsdl=>@config.get_golf_switch_wsdl}) # Available Operations # [:areas,:course_list,:course_info,:course_avail_list,:course_avail,:book_golf, # :get_golf_booking,:cancel_golf, :get_alt_rate_types,:get_course_policies] begin @request = @client.call(method_name.to_sym) do get_authentication_header.merge() end rescue Savon::SOAPFault => error @request = error.to_hash @soap_error= true rescue Savon::Error => error @request = error.to_hash @soap_error= true rescue Savon::InvalidResponseError Logger.log "Invalid server response" end @response = @request.body end |
#error? ⇒ Boolean
49 50 51 |
# File 'lib/golf_switch/request.rb', line 49 def error? parse_error[:ret_cd].to_i != 0 || @soap_error end |
#error_message ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/golf_switch/request.rb', line 53 def if @soap_error @request else parse_error[:ret_msg] end end |
#get_authentication_header ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/golf_switch/request.rb', line 30 def get_authentication_header { "Hdr"=>{ "ResellerId"=>@config.reseller_id, "PartnerId"=>@config.partner_id, "SourceCd"=>@config.source_cd || "A", "Lang"=>@config.lang, "UserIp"=>@config.user_ip, "UserSessionId"=>@config.user_session_id, "AccessKey"=>@config.access_key, "Agent"=>@config.agent, "gsSource"=>@config.gs_source, "gsDebug"=>@config.gs_debug || false } } end |