developergarden_sdk 0.0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +47 -103
- data/Rakefile +5 -3
- data/lib/authenticated_service.rb +5 -1
- data/lib/basic_response.rb +2 -4
- data/lib/basic_service.rb +47 -22
- data/lib/conference_call_service/add_conference_template_participant_response.rb +19 -0
- data/lib/conference_call_service/commit_conference_response.rb +17 -0
- data/lib/conference_call_service/conference_call_service.rb +481 -0
- data/lib/conference_call_service/conference_constants.rb +70 -0
- data/lib/conference_call_service/conference_details.rb +36 -0
- data/lib/conference_call_service/conference_schedule.rb +73 -0
- data/lib/conference_call_service/create_conference_response.rb +20 -0
- data/lib/conference_call_service/create_conference_template_response.rb +21 -0
- data/lib/conference_call_service/get_conference_list_response.rb +36 -0
- data/lib/conference_call_service/get_conference_status_response.rb +43 -0
- data/lib/conference_call_service/get_conference_template_list_response.rb +36 -0
- data/lib/conference_call_service/get_conference_template_participant_response.rb +19 -0
- data/lib/conference_call_service/get_conference_template_response.rb +27 -0
- data/lib/conference_call_service/get_participant_status_response.rb +29 -0
- data/lib/conference_call_service/get_running_conference_response.rb +25 -0
- data/lib/conference_call_service/new_participant_response.rb +20 -0
- data/lib/conference_call_service/participant.rb +28 -0
- data/lib/conference_call_service/participant_details.rb +59 -0
- data/lib/conference_call_service/remove_conference_response.rb +17 -0
- data/lib/conference_call_service/remove_conference_template_participant_response.rb +17 -0
- data/lib/conference_call_service/remove_conference_template_response.rb +20 -0
- data/lib/conference_call_service/remove_participant_response.rb +17 -0
- data/lib/conference_call_service/update_conference_response.rb +17 -0
- data/lib/conference_call_service/update_conference_template_participant_response.rb +17 -0
- data/lib/conference_call_service/update_conference_template_response.rb +17 -0
- data/lib/conference_call_service/update_participant_response.rb +17 -0
- data/lib/ip_location_service/ip_address.rb +50 -0
- data/lib/ip_location_service/ip_address_location.rb +50 -0
- data/lib/ip_location_service/ip_location_response.rb +47 -0
- data/lib/ip_location_service/ip_location_service.rb +79 -0
- data/lib/ip_location_service/region.rb +23 -0
- data/lib/local_search_service/local_search_response.rb +30 -0
- data/lib/local_search_service/local_search_service.rb +91 -0
- data/lib/quota_service/quota_information.rb +3 -3
- data/lib/service_environment.rb +0 -1
- data/lib/service_exception.rb +1 -1
- data/lib/sms_service/sms_response.rb +2 -2
- data/lib/sms_service/sms_service.rb +7 -10
- data/lib/token_service/token_service.rb +20 -22
- data/lib/voice_call_service/call_status_response.rb +11 -11
- data/lib/voice_call_service/voice_call_response.rb +3 -3
- data/lib/voice_call_service/voice_call_service.rb +41 -41
- metadata +42 -12
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../basic_response'
|
2
|
+
|
3
|
+
module ConferenceCallService
|
4
|
+
class NewParticipantResponse < BasicResponse
|
5
|
+
|
6
|
+
attr_accessor :participant_id
|
7
|
+
|
8
|
+
# Constructor.
|
9
|
+
# ===Parameters
|
10
|
+
# <tt>response_xml</tt>:: Xml as returned by the corresponding method call.
|
11
|
+
# <tt>raise_exception_on_error</tt>:: Raise an exception if an error occurs or not?
|
12
|
+
def initialize(response_xml, raise_exception_on_error = true)
|
13
|
+
doc = response_xml.document
|
14
|
+
@error_code = ConferenceCallService.xpath_query(doc, "statusCode").to_s
|
15
|
+
@error_message = ConferenceCallService.xpath_query(doc, "statusMessage").to_s
|
16
|
+
@participant_id = ConferenceCallService.xpath_query(doc, "participantId").to_s
|
17
|
+
raise_on_error(response_xml) if raise_exception_on_error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ConferenceCallService
|
2
|
+
class Participant
|
3
|
+
attr_accessor :id, :details, :status
|
4
|
+
|
5
|
+
# Constructor
|
6
|
+
def initialize(id, details, status)
|
7
|
+
@id = id
|
8
|
+
@details = details
|
9
|
+
@status = status
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
"Participant - id:#{@id.to_s} details:#{@details.to_s}, status:#{@status.to_s}"
|
14
|
+
end
|
15
|
+
|
16
|
+
#### Static methods
|
17
|
+
|
18
|
+
def self.build_from_xml(xml_doc)
|
19
|
+
if xml_doc then
|
20
|
+
id = ConferenceCallService.xpath_query(xml_doc, "participantId").to_s
|
21
|
+
details = ParticipantDetails.build_from_xml( ConferenceCallService.xpath_query(xml_doc, "detail") )
|
22
|
+
status = { :muted => ConferenceCallService.xpath_query(xml_doc, "status/value").to_s }
|
23
|
+
|
24
|
+
new(id, details, status)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module ConferenceCallService
|
2
|
+
class ParticipantDetails
|
3
|
+
attr_accessor :firstname, :lastname, :number, :email, :flags
|
4
|
+
|
5
|
+
@@IS_INITIATOR = 1
|
6
|
+
@@IS_NOT_INITIATOR = 0
|
7
|
+
|
8
|
+
# Constructor
|
9
|
+
def initialize(firstname, lastname, number, email, flags = @@IS_NOT_INITIATOR)
|
10
|
+
@firstname = firstname
|
11
|
+
@lastname = lastname
|
12
|
+
@number = number
|
13
|
+
@email = email
|
14
|
+
@flags = flags
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"#{@firstname.to_s} #{@lastname.to_s}, #{@number.to_s}, #{@email.to_s}, #{@flags.to_s}. "
|
19
|
+
end
|
20
|
+
|
21
|
+
# Adds all participant details to the given xml_doc object.
|
22
|
+
# === Parameters
|
23
|
+
# <tt>xml_doc</tt>:: An XmlMason object as given by a handsoap method invokation.
|
24
|
+
def add_to_handsoap_xml(xml_doc)
|
25
|
+
xml_doc.add('firstName', @firstname.to_s)
|
26
|
+
xml_doc.add('lastName', @lastname.to_s)
|
27
|
+
xml_doc.add('number', @number.to_s)
|
28
|
+
xml_doc.add('email', @email.to_s)
|
29
|
+
xml_doc.add('flags', @flags.to_s)
|
30
|
+
end
|
31
|
+
|
32
|
+
#### Static methods
|
33
|
+
|
34
|
+
def self.IS_INITIATOR
|
35
|
+
@@IS_INITIATOR
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.IS_NOT_INITIATOR
|
39
|
+
@@IS_NOT_INITIATOR
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.build_from_xml(xml_doc)
|
43
|
+
|
44
|
+
# Depending on the answer there might be a nil object, a NodeSelection or a NokogiriDriver.
|
45
|
+
# For the parsing a NodeSelection and a NokogiriDriver behave similar but in order to prevent further nil errors
|
46
|
+
# we have to see whether the elment is really present. For a nodeselection this is done by using .size > 0
|
47
|
+
# which won't work for the nokogiri driver. Maybe handsoap will clean this up in future releases.
|
48
|
+
if xml_doc && ( (xml_doc.is_a?(Handsoap::XmlQueryFront::NodeSelection) && xml_doc.size > 0) || xml_doc.is_a?(Handsoap::XmlQueryFront::NokogiriDriver ) ) then
|
49
|
+
|
50
|
+
firstname = ConferenceCallService.xpath_query(xml_doc, "firstName").to_s
|
51
|
+
lastname = ConferenceCallService.xpath_query(xml_doc, "lastName").to_s
|
52
|
+
number = ConferenceCallService.xpath_query(xml_doc, "number").to_s
|
53
|
+
email = ConferenceCallService.xpath_query(xml_doc, "email").to_s
|
54
|
+
flags = ConferenceCallService.xpath_query(xml_doc, "flags").to_s
|
55
|
+
new(firstname, lastname, number, email , flags)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../basic_response'
|
2
|
+
|
3
|
+
|
4
|
+
module ConferenceCallService
|
5
|
+
class RemoveConferenceResponse < BasicResponse
|
6
|
+
# Constructor.
|
7
|
+
# ===Parameters
|
8
|
+
# <tt>response_xml</tt>:: Xml as returned by the corresponding method call.
|
9
|
+
# <tt>raise_exception_on_error</tt>:: Raise an exception if an error occurs or not?
|
10
|
+
def initialize(response_xml, raise_exception_on_error = true)
|
11
|
+
doc = response_xml.document
|
12
|
+
@error_code = ConferenceCallService.xpath_query(doc, "statusCode").to_s
|
13
|
+
@error_message = ConferenceCallService.xpath_query(doc, "statusMessage").to_s
|
14
|
+
raise_on_error(response_xml) if raise_exception_on_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../basic_response'
|
2
|
+
|
3
|
+
module ConferenceCallService
|
4
|
+
class RemoveConferenceTemplateParticipantResponse < BasicResponse
|
5
|
+
|
6
|
+
# Constructor
|
7
|
+
# ===Parameters
|
8
|
+
# <tt>response_xml</tt>:: Xml as returned by the corresponding method call.
|
9
|
+
# <tt>raise_exception_on_error</tt>:: Raise an exception if an error occurs or not?
|
10
|
+
def initialize(response_xml, raise_exception_on_error = true)
|
11
|
+
doc = response_xml.document
|
12
|
+
@error_code = ConferenceCallService.xpath_query(doc, "statusCode").to_s
|
13
|
+
@error_message = ConferenceCallService.xpath_query(doc, "statusMessage").to_s
|
14
|
+
raise_on_error(response_xml) if raise_exception_on_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../basic_response'
|
2
|
+
|
3
|
+
module ConferenceCallService
|
4
|
+
class RemoveConferenceTemplateResponse < BasicResponse
|
5
|
+
|
6
|
+
attr_accessor :template_id
|
7
|
+
|
8
|
+
# Constructor.
|
9
|
+
# ===Parameters
|
10
|
+
# <tt>response_xml</tt>:: Xml as returned by the corresponding method call.
|
11
|
+
# <tt>raise_exception_on_error</tt>:: Raise an exception if an error occurs or not?
|
12
|
+
def initialize(response_xml, raise_exception_on_error = true)
|
13
|
+
doc = response_xml.document
|
14
|
+
@error_code = ConferenceCallService.xpath_query(doc, "statusCode").to_s
|
15
|
+
@error_message = ConferenceCallService.xpath_query(doc, "statusMessage").to_s
|
16
|
+
@template_id = ConferenceCallService.xpath_query(doc, "template").to_s
|
17
|
+
raise_on_error(response_xml) if raise_exception_on_error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../basic_response'
|
2
|
+
|
3
|
+
module ConferenceCallService
|
4
|
+
class RemoveParticipantResponse < BasicResponse
|
5
|
+
|
6
|
+
# Constructor.
|
7
|
+
# ===Parameters
|
8
|
+
# <tt>response_xml</tt>:: Xml as returned by the corresponding method call.
|
9
|
+
# <tt>raise_exception_on_error</tt>:: Raise an exception if an error occurs or not?
|
10
|
+
def initialize(response_xml, raise_exception_on_error = true)
|
11
|
+
doc = response_xml.document
|
12
|
+
@error_code = ConferenceCallService.xpath_query(doc, "statusCode").to_s
|
13
|
+
@error_message = ConferenceCallService.xpath_query(doc, "statusMessage").to_s
|
14
|
+
raise_on_error(response_xml) if raise_exception_on_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../basic_response'
|
2
|
+
|
3
|
+
module ConferenceCallService
|
4
|
+
class UpdateConferenceResponse < BasicResponse
|
5
|
+
|
6
|
+
# Constructor.
|
7
|
+
# ===Parameters
|
8
|
+
# <tt>response_xml</tt>:: Xml as returned by the corresponding method call.
|
9
|
+
# <tt>raise_exception_on_error</tt>:: Raise an exception if an error occurs or not?
|
10
|
+
def initialize(response_xml, raise_exception_on_error = true)
|
11
|
+
doc = response_xml.document
|
12
|
+
@error_code = ConferenceCallService.xpath_query(doc, "statusCode").to_s
|
13
|
+
@error_message = ConferenceCallService.xpath_query(doc, "statusMessage").to_s
|
14
|
+
raise_on_error(response_xml) if raise_exception_on_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../basic_response'
|
2
|
+
|
3
|
+
module ConferenceCallService
|
4
|
+
class UpdateConferenceTemplateParticipantResponse < BasicResponse
|
5
|
+
|
6
|
+
# Constructor
|
7
|
+
# ===Parameters
|
8
|
+
# <tt>response_xml</tt>:: Xml as returned by the corresponding method call.
|
9
|
+
# <tt>raise_exception_on_error</tt>:: Raise an exception if an error occurs or not?
|
10
|
+
def initialize(response_xml, raise_exception_on_error = true)
|
11
|
+
doc = response_xml.document
|
12
|
+
@error_code = ConferenceCallService.xpath_query(doc, "statusCode").to_s
|
13
|
+
@error_message = ConferenceCallService.xpath_query(doc, "statusMessage").to_s
|
14
|
+
raise_on_error(response_xml) if raise_exception_on_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../basic_response'
|
2
|
+
|
3
|
+
module ConferenceCallService
|
4
|
+
class UpdateConferenceTemplateResponse < BasicResponse
|
5
|
+
|
6
|
+
# Constructor
|
7
|
+
# ===Parameters
|
8
|
+
# <tt>response_xml</tt>:: Xml as returned by the corresponding method call.
|
9
|
+
# <tt>raise_exception_on_error</tt>:: Raise an exception if an error occurs or not?
|
10
|
+
def initialize(response_xml, raise_exception_on_error = true)
|
11
|
+
doc = response_xml.document
|
12
|
+
@error_code = ConferenceCallService.xpath_query(doc, "statusCode").to_s
|
13
|
+
@error_message = ConferenceCallService.xpath_query(doc, "statusMessage").to_s
|
14
|
+
raise_on_error(response_xml) if raise_exception_on_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../basic_response'
|
2
|
+
|
3
|
+
module ConferenceCallService
|
4
|
+
class UpdateParticipantResponse < BasicResponse
|
5
|
+
|
6
|
+
# Constructor.
|
7
|
+
# ===Parameters
|
8
|
+
# <tt>response_xml</tt>:: Xml as returned by the corresponding method call.
|
9
|
+
# <tt>raise_exception_on_error</tt>:: Raise an exception if an error occurs or not?
|
10
|
+
def initialize(response_xml, raise_exception_on_error = true)
|
11
|
+
doc = response_xml.document
|
12
|
+
@error_code = ConferenceCallService.xpath_query(doc, "statusCode").to_s
|
13
|
+
@error_message = ConferenceCallService.xpath_query(doc, "statusMessage").to_s
|
14
|
+
raise_on_error(response_xml) if raise_exception_on_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module IpLocationService
|
2
|
+
|
3
|
+
# Represents an ip address to be passed to the LocateIp-Operation of the IpLocation-Service.
|
4
|
+
class IpAddress
|
5
|
+
|
6
|
+
@@IP_V4 = 4
|
7
|
+
@@IP_V6 = 6
|
8
|
+
|
9
|
+
attr_accessor :ip_address, :ip_type
|
10
|
+
|
11
|
+
# === Parameters
|
12
|
+
# <tt>ip_address</tt>::
|
13
|
+
# <tt>ip_type</tt>:: IP version of the given address. Valid options are :ipv4 and ipv6. Currently only :ipv4 is supported.
|
14
|
+
def initialize(ip_address, ip_type = @@IP_V4)
|
15
|
+
@ip_address = ip_address
|
16
|
+
@ip_type = ip_type
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
@ip_address.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
#### Class methods
|
24
|
+
|
25
|
+
def self.IP_V4
|
26
|
+
@@IP_V4
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.IP_V6
|
30
|
+
@@IP_V6
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
# === Parameters
|
36
|
+
# <tt>ip_address</tt>:: ip_address as string or IpAddress object.
|
37
|
+
def self.build_from_ip_address(from_ip_address)
|
38
|
+
ret = nil
|
39
|
+
if from_ip_address.is_a?(String)
|
40
|
+
ret = new(from_ip_address)
|
41
|
+
elsif from_ip_address.is_a?(IpAddress)
|
42
|
+
ret = from_ip_address.dup
|
43
|
+
else
|
44
|
+
raise("Unknown class #{from_ip_address.class.to_s} for ip address. Can be string or IpAddress.")
|
45
|
+
end
|
46
|
+
|
47
|
+
return ret
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module IpLocationService
|
2
|
+
class IpAddressLocation
|
3
|
+
|
4
|
+
attr_accessor :address, :ip_type, :is_in_region, :is_in_city, :is_in_geo, :radius
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@address = nil
|
8
|
+
@ip_type = nil
|
9
|
+
@is_in_region = nil
|
10
|
+
@is_in_city = nil
|
11
|
+
@is_in_geo = nil
|
12
|
+
@radius = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
ret = "Address: #{@address.to_s}, IP-Type: #{@ip_type.to_s}, #{@is_in_region.to_s}, "
|
17
|
+
ret += "City: #{@is_in_city.to_s}, Geo: #{@is_in_geo.to_s}, Radius: #{@radius.to_s}"
|
18
|
+
ret
|
19
|
+
end
|
20
|
+
|
21
|
+
#### Static methods
|
22
|
+
|
23
|
+
# Builds an IpAddressLocation object from a given
|
24
|
+
# xml document.
|
25
|
+
# === Parameter
|
26
|
+
# <tt>xml_doc</tt>:: XmlQueryFront object as received from a prior query of handsoap's service response.
|
27
|
+
def self.build_from_xml(xml_doc)
|
28
|
+
ipa = IpAddressLocation.new
|
29
|
+
|
30
|
+
if xml_doc then
|
31
|
+
|
32
|
+
# We are passing "false" do search relative to the xml_doc position. Without this flag the resulting
|
33
|
+
# xpath query would beginn with a "//" which would always look the search term relative from the beginning
|
34
|
+
# of the document. This is not what we want right here. We would rather like to search relative to the
|
35
|
+
# partial tree we have with xml_doc pointing to the IpAddressLocation tag of the response xml.
|
36
|
+
# This is also true for Region's build method.
|
37
|
+
ipa.address = IpLocationService.xpath_query(xml_doc, "ipAddress", false).to_s
|
38
|
+
ipa.ip_type = IpLocationService.xpath_query(xml_doc, "ipType", false).to_s
|
39
|
+
|
40
|
+
# TODO As soon as the API supports them.
|
41
|
+
# ipa.radius = IpLocationService.xpath_query(xml_doc, "radius", false).to_s
|
42
|
+
# ... isInGeo, isInCity
|
43
|
+
|
44
|
+
region_xml_doc = IpLocationService.xpath_query(xml_doc, "isInRegion", false)
|
45
|
+
ipa.is_in_region = Region.build_from_xml(region_xml_doc)
|
46
|
+
end
|
47
|
+
return ipa
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../basic_response'
|
2
|
+
|
3
|
+
module IpLocationService
|
4
|
+
class IpLocationResponse < BasicResponse
|
5
|
+
attr_accessor :ip_address_locations
|
6
|
+
|
7
|
+
# Constructor.
|
8
|
+
# ===Parameters
|
9
|
+
# <tt>response_xml</tt>:: Xml as returned by a <tt>ip_location</tt>-method call.
|
10
|
+
# <tt>raise_exception_on_error</tt>:: Raise an exception if an error occurs or not?
|
11
|
+
def initialize(response_xml, raise_exception_on_error = true)
|
12
|
+
|
13
|
+
doc = response_xml.document
|
14
|
+
|
15
|
+
@error_code = IpLocationService.xpath_query(doc, "statusCode").to_s
|
16
|
+
@error_message = IpLocationService.xpath_query(doc, "statusMessage").to_s
|
17
|
+
@ip_address_locations = []
|
18
|
+
|
19
|
+
ip_address_location_doc = IpLocationService.xpath_query(doc, "ipAddressLocation")
|
20
|
+
|
21
|
+
ip_address_location_doc.each do |ip_address_location|
|
22
|
+
@ip_address_locations << IpAddressLocation.build_from_xml(ip_address_location)
|
23
|
+
end
|
24
|
+
|
25
|
+
raise_on_error(response_xml) if raise_exception_on_error
|
26
|
+
end
|
27
|
+
|
28
|
+
# Alias for accessing the first element of the ip_address_location array.
|
29
|
+
def ip_address_location
|
30
|
+
@ip_address_locations.first
|
31
|
+
end
|
32
|
+
|
33
|
+
# Alias for accessing the first element of the ip_address_location array.
|
34
|
+
def ip_address_location=(location)
|
35
|
+
@ip_address_locations[0] = location
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
ret = "Status: #{@error_code}, Message: #{@error_message}\nLocations:\n"
|
40
|
+
@ip_address_locations.each do |ipl|
|
41
|
+
ret += "\t#{ipl}\n"
|
42
|
+
end
|
43
|
+
ret
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../authenticated_service'
|
2
|
+
require File.dirname(__FILE__) + '/ip_address'
|
3
|
+
require File.dirname(__FILE__) + '/ip_location_response'
|
4
|
+
require File.dirname(__FILE__) + '/ip_address_location'
|
5
|
+
require File.dirname(__FILE__) + '/region'
|
6
|
+
|
7
|
+
Handsoap.http_driver = :httpclient
|
8
|
+
|
9
|
+
# Print http and soap requests and reponses if ruby has been started with -d option.
|
10
|
+
Handsoap::Service.logger = $stdout if $DEBUG
|
11
|
+
|
12
|
+
module IpLocationService
|
13
|
+
|
14
|
+
# Client to access the developer garden ip location service.
|
15
|
+
#
|
16
|
+
# See also:
|
17
|
+
# * https://www.developergarden.com/openapi/iplocation
|
18
|
+
# * http://www.developergarden.com/static/docu/de/ch04s02s06.html
|
19
|
+
class IpLocationService < AuthenticatedService
|
20
|
+
|
21
|
+
@@IP_LOCATION_SCHEMA = 'http://iplocation.developer.telekom.com/schema/'
|
22
|
+
|
23
|
+
@@IP_LOCATION_SERVICE_ENDPOINT = {
|
24
|
+
:uri => "https://gateway.developer.telekom.com/p3gw-mod-odg-iplocation/services/IPLocation",
|
25
|
+
:version => 1
|
26
|
+
}
|
27
|
+
|
28
|
+
endpoint @@IP_LOCATION_SERVICE_ENDPOINT
|
29
|
+
|
30
|
+
# Retrieves spatial information about the given ip address.
|
31
|
+
# ===Parameters
|
32
|
+
# <tt>ip_address</tt>:: IpAddress-object or array of IpAddress-objects for which to perform an ip location. Can be a single ip address or an array.
|
33
|
+
# of ip addresses.
|
34
|
+
# <tt>environment</tt>:: Service environment as defined in ServiceLevel.
|
35
|
+
# <tt>account</tt>:: IP address for which to perform an ip location.
|
36
|
+
def locate_ip(ip_addresses, environment = ServiceEnvironment.MOCK, account = nil)
|
37
|
+
ip_location_response = nil
|
38
|
+
|
39
|
+
response = invoke_authenticated("locateIP") do |request, doc|
|
40
|
+
request.add('environment', environment)
|
41
|
+
|
42
|
+
# If only a single ip has been passed create an array from it to have a more uniform processing afterwards.
|
43
|
+
ip_addresses = [ip_addresses] unless ip_addresses.is_a?(Array)
|
44
|
+
|
45
|
+
ip_addresses.each do |ip_address|
|
46
|
+
|
47
|
+
# If there are string ips convert them to IpAddress objects.
|
48
|
+
ip_address = IpAddress.new(ip_address) if ip_address.is_a?(String)
|
49
|
+
|
50
|
+
request.add('address') do |address|
|
51
|
+
address.add('ipType', ip_address.ip_type)
|
52
|
+
address.add('ipAddress', ip_address.ip_address)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
request.add('account', account) if (account && !account.empty?)
|
56
|
+
end
|
57
|
+
|
58
|
+
ip_location_response = IpLocationResponse.new(response)
|
59
|
+
|
60
|
+
return ip_location_response
|
61
|
+
end
|
62
|
+
|
63
|
+
#### Static Methods
|
64
|
+
|
65
|
+
def self.IP_LOCATON_SCHEMA
|
66
|
+
return @@IP_LOCATON_SCHEMA
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
# Performs a xpath query in the ip location namespace for the given document and query string.
|
71
|
+
# === Parameters
|
72
|
+
# <tt>doc</tt>:: XmlQueryFront document.
|
73
|
+
# <tt>query_string</tt>:: Element to look for
|
74
|
+
# <tt>global_search</tt>:: Searches within all levels using "//" if <tt>global_search = true</tt>.
|
75
|
+
def self.xpath_query(doc, query_string, global_search = true)
|
76
|
+
self.xpath_query_for_schema(@@IP_LOCATION_SCHEMA, doc, query_string, global_search)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|