Class: GolfSwitch::Area

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

Returns a new instance of Area.



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

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

  end
  @area_response = []
end

Instance Attribute Details

#api_responseObject

Returns the value of attribute api_response.



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

def api_response
  @api_response
end

#country_idObject

Returns the value of attribute country_id.



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

def country_id
  @country_id
end

#region_idObject

Returns the value of attribute region_id.



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

def region_id
  @region_id
end

Instance Method Details

#commitObject



31
32
33
# File 'lib/golf_switch/area.rb', line 31

def commit
  super("areas")
end

#get_optionsObject



16
17
18
19
20
21
22
# File 'lib/golf_switch/area.rb', line 16

def get_options
  {
    "Req"=>
      option_attributes

  }
end

#option_attributesObject



24
25
26
27
28
29
# File 'lib/golf_switch/area.rb', line 24

def option_attributes
  options = {}
  options.merge!("CountryId"=>@country_id) unless @country_id.blank?
  options.merge!("RegionId"=>@region_id) unless @region_id.blank?
  options
end

#parse_errorObject



35
36
37
# File 'lib/golf_switch/area.rb', line 35

def parse_error
  @response[:areas_response][:areas_result]
end

#parse_responseObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/golf_switch/area.rb', line 39

def parse_response
  begin
    unless error?
      @api_response = AreaResponse.parse_areas(@response[:areas_response][:areas_result])
    else
      puts "Error #{error_message}"
    end
  rescue
    puts "Parse Error On Area"
  end
end