Class: GolfSwitch::CourseList

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

Returns a new instance of CourseList.



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

def initialize(attributes = {})
  attributes.each do |name, value|
    begin
      send("#{name}=", value)
    end
  end
  @max_distance_type = "M" unless ["M","K"].include?(@max_distance_type)
  @country_id ||="USA"
end

Instance Attribute Details

#api_responseObject

Returns the value of attribute api_response.



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

def api_response
  @api_response
end

#areaObject

Returns the value of attribute area.



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

def area
  @area
end

#country_idObject

Returns the value of attribute country_id.



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

def country_id
  @country_id
end

Returns the value of attribute featured_only.



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

def featured_only
  @featured_only
end

#latitudeObject

Returns the value of attribute latitude.



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

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



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

def longitude
  @longitude
end

#max_distanceObject

Returns the value of attribute max_distance.



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

def max_distance
  @max_distance
end

#max_distance_typeObject

Returns the value of attribute max_distance_type.



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

def max_distance_type
  @max_distance_type
end

#postal_codeObject

Returns the value of attribute postal_code.



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

def postal_code
  @postal_code
end

#region_idObject

Returns the value of attribute region_id.



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

def region_id
  @region_id
end

#show_all_statusObject

Returns the value of attribute show_all_status.



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

def show_all_status
  @show_all_status
end

#show_dis_connectedObject

Returns the value of attribute show_dis_connected.



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

def show_dis_connected
  @show_dis_connected
end

#sortObject

Returns the value of attribute sort.



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

def sort
  @sort
end

Instance Method Details

#commitObject



40
41
42
# File 'lib/golf_switch/course_list.rb', line 40

def commit
  super("course_list")
end

#get_optionsObject



32
33
34
35
36
37
38
# File 'lib/golf_switch/course_list.rb', line 32

def get_options
  {
    "Req"=>
      option_attributes

  }
end

#option_attributesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/golf_switch/course_list.rb', line 16

def option_attributes
  options = {}
  options.merge!("CountryId"=>@country_id) unless @country_id.blank?
  options.merge!("RegionId"=>@region_id) unless @region_id.blank?
  options.merge!("Area"=>@area) unless @area.blank?
  options.merge!("Latitude"=>@latitude) unless @latitude.blank?
  options.merge!("Longitude"=>@longitude) unless @longitude.blank?
  options.merge!("PostalCode"=>@postal_code) unless @postal_code.blank?
  options.merge!("MaxDistance"=>@max_distance) unless @max_distance.blank?
  options.merge!("MaxDistanceType"=>@max_distance_type) if !@max_distance.blank? && !@max_distance_type.blank?
  options.merge!("ShowDisConnected"=>@show_dis_connected) unless @show_dis_connected.blank?
  options.merge!("FeaturedOnly"=>@featured_only) unless @featured_only.blank?
  options.merge!("Sort"=>@sort) if !@sort.blank? && ["N",""].include?(@sort)
  options
end

#parse_errorObject



44
45
46
# File 'lib/golf_switch/course_list.rb', line 44

def parse_error
  @response[:course_list_response][:course_list_result]
end

#parse_responseObject



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/golf_switch/course_list.rb', line 48

def parse_response
  begin
    unless error?
      @api_response = CourseListCourse.parse_courses(@response[:course_list_response][:course_list_result])
    else
      puts "Error #{error_message}"
    end
  rescue

  end
end