Class: GolfSwitch::GetCoursePolicy

Inherits:
Request
  • Object
show all
Defined in:
lib/golf_switch/get_course_policy.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 = {}) ⇒ GetCoursePolicy

Returns a new instance of GetCoursePolicy.



5
6
7
8
9
10
11
12
13
# File 'lib/golf_switch/get_course_policy.rb', line 5

def initialize(attributes={})
  attributes.each do |name, value|
    begin
      send("#{name}=", value)
    rescue
      puts "Add #{name} is not valid"
    end
  end
end

Instance Attribute Details

#alt_rate_typeObject

Returns the value of attribute alt_rate_type.



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

def alt_rate_type
  @alt_rate_type
end

#api_responseObject

Returns the value of attribute api_response.



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

def api_response
  @api_response
end

#course_idObject

Returns the value of attribute course_id.



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

def course_id
  @course_id
end

#play_dateObject

Returns the value of attribute play_date.



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

def play_date
  @play_date
end

Instance Method Details

#commitObject



29
30
31
# File 'lib/golf_switch/get_course_policy.rb', line 29

def commit
  super("get_course_policies")
end

#get_optionsObject



14
15
16
17
18
19
20
# File 'lib/golf_switch/get_course_policy.rb', line 14

def get_options
  {
    "Req"=>
      option_attributes

  }
end

#option_attributesObject



21
22
23
24
25
26
27
# File 'lib/golf_switch/get_course_policy.rb', line 21

def option_attributes
   options = {}
  options.merge!("CourseId"=>@course_id) unless @course_id.blank?
  options.merge!("PlayDate"=>DateTime.parse(@play_date).strftime("%Y-%m-%dT00:00:00")) unless @play_date.blank?
  options.merge!("AltRateType"=>@alt_rate_type) unless @alt_rate_type.blank?
  options
end

#parse_errorObject



33
34
35
# File 'lib/golf_switch/get_course_policy.rb', line 33

def parse_error
  @response[:get_course_policies_response][:get_course_policies_result]
end

#parse_responseObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/golf_switch/get_course_policy.rb', line 37

def parse_response
  begin
    unless error?
      @api_response = GolfSwitch::CoursePolicyResponse.new(@response[:get_course_policies_response][:get_course_policies_result])
    else
      puts "Error #{error_message}"
    end
  rescue
    puts "Parse Error On Getting golf info Response"
  end
end