developergarden_sdk 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,147 +1 @@
1
- == developergarden_sdk
2
- This library provides access to open development services of the Deutsche Telekom AG.
3
- For more details about the services see
4
-
5
- http://www.developergarden.com
6
-
7
- Depending on your operating system you might want to skip the "sudo" command prior to the
8
- commands listed here.
9
-
10
-
11
- === Installation
12
- sudo gem install developergarden_sdk
13
-
14
- Dependent gems will be installed automatically.
15
-
16
- === Basic usage
17
- You can use the gem from pure Ruby applications and of course from Ruby on Rails apps as well.
18
-
19
- ==== To use the gem from your Ruby app
20
-
21
- require 'rubygems'
22
- gem 'developergarden_sdk'
23
- require 'token_Service/token_service'
24
- require 'sms_service/sms_service'
25
- require 'voice_call_service/voice_call_service'
26
- require 'quota_service/quota_service'
27
- require 'service_environment'
28
-
29
- ==== Ruby Example to send a sms
30
- #!/usr/bin/env ruby -d
31
-
32
- require 'rubygems'
33
- gem 'developergarden_sdk'
34
- require 'token_Service/token_service'
35
- require 'sms_service/sms_service'
36
- require 'service_environment'
37
-
38
- sms = SmsService::SmsService.new("<USER>@t-online.de", "<PASSWORD>")
39
- sms_response = sms.send_sms("+49177 0000001", "Your message text.", "RubySDK", ServiceEnvironment.PRODUCTION, "")
40
-
41
-
42
- === Ruby Example to perform an ip location request
43
-
44
- require 'rubygems'
45
- gem 'developergarden_sdk'
46
- require 'token_service/token_service'
47
- require 'ip_location_service/ip_location_service'
48
-
49
- @ip_location_service = IpLocationService::IpLocationService.new("<USER>@t-online.de", "<PASSWORD>")
50
-
51
- ip = IpLocationService::IpAddress.new("93.222.255.58")
52
- response = @ip_location_service.locate_ip(ip, ServiceEnvironment.PRODUCTION)
53
-
54
- puts response.ip_address_locations.first.address
55
- puts response.ip_address_locations.first.is_in_region.country_code
56
- puts response.ip_address_locations.first.is_in_region.region_name
57
-
58
- # If you except a single ip location (if you have passed a single ip to look up)
59
- # then you can use the following way to access the location
60
- puts response.ip_address_location.address
61
- puts response.ip_address_location.is_in_region.country_code
62
- puts response.ip_address_location.is_in_region.region_name
63
-
64
- === Ruby Example to perform a local search
65
- require 'rubygems'
66
- gem 'developergarden_sdk'
67
- require 'token_service/token_service'
68
- require 'token_service/token_service'
69
- require 'local_search_service/local_search_service'
70
-
71
- @service = LocalSearchService::LocalSearchService.new("<USER>@t-online.de", "<PASSWORD>")
72
-
73
- search_parameter = {
74
- :what => "music",
75
- :near => "Konstanz"
76
- }
77
- response = @service.local_search(search_parameter, ServiceEnvironment.PRODUCTION)
78
-
79
- # Show response xml
80
- puts response.search_result.to_xml
81
- results_where_locs_where = response.search_result.xpath("//RESULTS/WHERE_LOCS/WHERE").first
82
- lat = results_where_locs_where["LAT"]
83
- puts lat
84
-
85
- === Ruby Example to create a conference call
86
- require 'rubygems'
87
- gem 'developergarden_sdk'
88
- require 'token_Service/token_service'
89
- require 'conference_call_service/conference_call_service'
90
-
91
- environment = ServiceEnvironment.PRODUCTION
92
-
93
- service = ConferenceCallService::ConferenceCallService.new("<USERNAME>@t-online.de", "<PASSWORD>")
94
-
95
- conf_details = ConferenceCallService::ConferenceDetails.new("A very important conf", "A very impressive description", 30)
96
-
97
- response = service.create_conference("max.mustermann", conf_details, nil, environment)
98
-
99
- conf_id = response.conference_id
100
-
101
- participant = ConferenceCallService::ParticipantDetails.new('maxi', 'max', '<NUMBER A>', 'max@spin.to', 1)
102
- participant2 = ConferenceCallService::ParticipantDetails.new('roger', 'beep', '<NUMBER B>', 'roger@spin.to', 0)
103
-
104
- service.new_participant(conf_id, participant, environment)
105
- service.new_participant(conf_id, participant2, environment)
106
-
107
- service.commit_conference(conf_id, ServiceEnvironment.PRODUCTION)
108
-
109
- ==== To use your gem from your Ruby on Rails app
110
- In your environment.rb add the following line in the config block:
111
- config.gem 'developergarden_sdk'
112
-
113
- ==== Ruby on Rails Example
114
-
115
- class SmsNotification
116
-
117
- USERNAME = "<USER>@t-online.de"
118
- PASSWORD = "<PASSWORD>"
119
-
120
- # Send SMS to Numbers.
121
- def send_sms(number, message, originator, environment = 2)
122
-
123
- # Create new SmsService instance
124
- @sms = SmsService::SmsService.new(USERNAME, PASSWORD)
125
-
126
- # Send SMS to cell phone
127
- @sms.send_sms(number, message, originator, environment)
128
-
129
- end
130
-
131
- end
132
-
133
- === More Examples
134
- In order to see more examples have a look the unit tests included in the gem's source code.
135
- You might also want to have a look at the actual source code and source code comments.
136
-
137
-
138
- ==More Information
139
- More information about developer garden services can be found at:
140
- http://www.developergarden.com
141
-
142
- ==FAQ
143
- === Did not understand "MustUnderstand" header(s)
144
- Handsoap::Fault: Handsoap::Fault { :code => 'soapenv:MustUnderstand', :reason => 'Did not understand "MustUnderstand" header(s):{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security' }
145
-
146
- You will receive this error message if a mandatory header element is not present or the remote service was unable to process it.
147
- Most likely this will happen if something is wrong during the authentication process such as missing parameters like username, password.
1
+ See README.rdoc
data/Rakefile CHANGED
@@ -13,11 +13,11 @@ require 'fileutils'
13
13
 
14
14
  spec = Gem::Specification.new do |s|
15
15
  s.name = 'developergarden_sdk'
16
- s.version = '0.9.1'
16
+ s.version = '0.9.2'
17
17
  s.homepage = 'http://www.developergarden.com'
18
18
  s.has_rdoc = true
19
19
  s.extra_rdoc_files = ['README', 'LICENSE']
20
- s.summary = 'Offers a ruby client for the open development services such as send SMS, voice call and quota management of the Deutsche Telekom AG. See also http://www.developergarden.com.'
20
+ s.summary = 'Client library for the open development services of Deutsche Telekom AG. The services are: send SMS, voice call, conference call, IP location, local search and quota management. For more information, please see http://www.developergarden.com.'
21
21
  s.description = s.summary
22
22
  s.author = 'Julian Fischer / Aperto move GmbH'
23
23
  s.email = 'ruby@developergarden.com'
@@ -0,0 +1,49 @@
1
+ class AccountBalanceResponse < BasicResponse
2
+ attr_accessor :account_balances
3
+
4
+ # Constructor.
5
+ # ===Parameters
6
+ # <tt>response_xml</tt>:: Xml as returned by a <tt>call_status</tt>-method call.
7
+ # <tt>raise_exception_on_error</tt>:: Xml as returned by a <tt>call_status</tt>-method call.
8
+ def initialize(response_xml, raise_exception_on_error = true)
9
+ doc = response_xml.document
10
+
11
+ @error_code = doc.xpath("//errorCode").to_s
12
+ @error_message = doc.xpath("//errorMessage").to_s
13
+ @account_balances = []
14
+
15
+ # Get a list of all account sections
16
+ accounts_xml = doc.xpath("//getAccountBalanceResponse/Account")
17
+
18
+ # Create Account objects out of the xml response
19
+ if accounts_xml.is_a?(Handsoap::XmlQueryFront::NodeSelection) then
20
+ accounts_xml.each do |account_xml|
21
+ account = Account.build_from_xml(account_xml)
22
+ account_balances << account
23
+ end
24
+ else
25
+ raise "Unexpected response format."
26
+ end
27
+
28
+ raise_on_error(response_xml) if raise_exception_on_error
29
+ end
30
+ end
31
+
32
+ class Account
33
+ attr_accessor :account, :credits
34
+
35
+ def initialize(account, credits)
36
+ @account = account
37
+ @credits = credits
38
+ end
39
+
40
+ def self.build_from_xml(xml_doc)
41
+ account = xml_doc.xpath("Account").to_s
42
+ credits = xml_doc.xpath("Credits").to_s
43
+ return Account.new(account, credits)
44
+ end
45
+
46
+ def to_s
47
+ self.inspect
48
+ end
49
+ end
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../authenticated_service'
2
2
  require File.dirname(__FILE__) + '/../quota_service/quota_information'
3
+ require File.dirname(__FILE__) + '/../quota_service/account_balance_response'
3
4
 
4
5
  Handsoap.http_driver = :httpclient
5
6
 
@@ -26,13 +27,11 @@ module QuotaService
26
27
  # ===Parameters
27
28
  # <tt>module_id</tt>:: module_id of the service for which a quota request to be made, such as "VoiceButlerProduction"
28
29
  def get_quota_information(module_id = "VoiceButlerSandbox")
29
-
30
30
  response = invoke_authenticated("getQuotaInformation") do |message, doc|
31
31
  message.add('moduleId', module_id)
32
32
  end
33
-
34
33
  quota_info = QuotaInformation.new(response)
35
-
34
+
36
35
  return quota_info
37
36
  end
38
37
 
@@ -41,7 +40,6 @@ module QuotaService
41
40
  # <tt>module_id</tt>:: module_id of the service for which a quota request to be made, such as "VoiceButlerProduction"
42
41
  # <tt>quota_max</tt>:: Quota limit to be set
43
42
  def change_quota_pool(module_id = "VoiceButlerSandbox", quota_max = 100)
44
-
45
43
  response = invoke_authenticated("changeQuotaPool") do |message, doc|
46
44
  message.add('moduleId', module_id)
47
45
  message.add('quotaMax', quota_max)
@@ -49,5 +47,17 @@ module QuotaService
49
47
 
50
48
  return BasicResponse.new(response)
51
49
  end
50
+
51
+ # Get balance of the given developergarden account.
52
+ # ===Parameters
53
+ # <tt>account</tt>:: Account ids of the sub accounts to retrieve the balance for.
54
+ # Retrieves the balance of the main account if the account balance is empty.
55
+ def get_account_balance(account = nil)
56
+ response = invoke_authenticated("getAccountBalance") do |message, doc|
57
+ message.add('account', account) if account
58
+ end
59
+
60
+ return AccountBalanceResponse.new(response)
61
+ end
52
62
  end
53
63
  end
@@ -0,0 +1,52 @@
1
+ require File.dirname(__FILE__) + '/../basic_response'
2
+
3
+ # Representing a response from the <tt>SmsService</tt>.
4
+ class SmsGetValidatedNumbersResponse < BasicResponse
5
+
6
+ attr_accessor :validated_numbers
7
+
8
+ # Constructor.
9
+ # ===Parameters
10
+ # <tt>response_xml</tt>:: Xml as returned by a <tt>sms_status</tt>-method call.
11
+ # <tt>raise_exception_on_error</tt>:: Xml as returned by a <tt>sms_status</tt>-method call.
12
+ def initialize(response_xml, raise_exception_on_error = true)
13
+ doc = response_xml.document
14
+
15
+ @error_code = doc.xpath("//statusCode").to_s
16
+ @error_message = doc.xpath("//statusMessage").to_s
17
+ @validated_numbers = []
18
+
19
+ validated_numbers_xml = doc.xpath("//validatedNumbers")
20
+
21
+ if validated_numbers_xml.is_a?(Handsoap::XmlQueryFront::NodeSelection) then
22
+ validated_numbers_xml.each do |validated_number_xml|
23
+ validated_number = ValidatedNumber.build_from_xml(validated_number_xml)
24
+ validated_numbers << validated_number
25
+ end
26
+ else
27
+ raise "Unexpected response format."
28
+ end
29
+
30
+ raise_on_error(response_xml) if raise_exception_on_error
31
+ end
32
+ end
33
+
34
+ class ValidatedNumber
35
+ attr_accessor :number, :validated_until
36
+
37
+ def initialize(number, validated_until)
38
+ @number = number
39
+ @validated_until = validated_until
40
+ end
41
+
42
+ def self.build_from_xml(xml_doc)
43
+ number = xml_doc.xpath("number").to_s
44
+ validated_until = xml_doc.xpath("validUntil").to_s
45
+
46
+ return ValidatedNumber.new(number, validated_until)
47
+ end
48
+
49
+ def to_s
50
+ self.inspect
51
+ end
52
+ end
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/../basic_response'
2
+
3
+ # Representing a response from the <tt>SmsService</tt>.
4
+ class SmsSendValidationResponse < BasicResponse
5
+
6
+ # Constructor.
7
+ # ===Parameters
8
+ # <tt>response_xml</tt>:: Xml as returned by a <tt>sms_status</tt>-method call.
9
+ # <tt>raise_exception_on_error</tt>:: Xml as returned by a <tt>sms_status</tt>-method call.
10
+ def initialize(response_xml, raise_exception_on_error = true)
11
+ doc = response_xml.document
12
+
13
+ @error_code = doc.xpath("//statusCode").to_s
14
+ @error_message = doc.xpath("//statusMessage").to_s
15
+
16
+ raise_on_error(response_xml) if raise_exception_on_error
17
+ end
18
+ end
@@ -0,0 +1,101 @@
1
+ require File.dirname(__FILE__) + '/../authenticated_service'
2
+ require File.dirname(__FILE__) + '/../sms_service/sms_validation_response'
3
+ require File.dirname(__FILE__) + '/../sms_service/sms_get_validated_numbers_response'
4
+
5
+ Handsoap.http_driver = :httpclient
6
+
7
+ # Print http and soap requests and reponses if ruby has been started with -d option.
8
+ Handsoap::Service.logger = $stdout if $DEBUG
9
+
10
+ module SmsService
11
+
12
+ # SmsValidationService allows you to use physical mobile phone numbers as the sender number
13
+ # of a text message.
14
+ #
15
+ # See also:
16
+ # * https://www.developergarden.com/openapi/dokumentation/services#4.2.3.
17
+ class SmsValidationService < AuthenticatedService
18
+
19
+ @@SMS_VALIDATION_SERVICE_SCHEMA = "http://webservice.sms.odg.tonline.de"
20
+
21
+ @@SMS_SERVICE_ENDPOINT = {
22
+ :uri => "https://gateway.developer.telekom.com/p3gw-mod-odg-sms-validation/services/SmsValidationUserService",
23
+ :version => 1
24
+ }
25
+
26
+ endpoint @@SMS_SERVICE_ENDPOINT
27
+
28
+ # Add namespaces to the handsoap XmlMason document.
29
+ def on_create_document(doc)
30
+ super(doc)
31
+ doc.alias 'smsvs', @@SMS_VALIDATION_SERVICE_SCHEMA
32
+ end
33
+
34
+ # Send a validation text message.
35
+ #
36
+ # Note this method does not support a sandbox service environment.
37
+ # Validated numbers can be used in both the production and sandbox environment.
38
+ # For more details please refer to the developergarden docs.
39
+ # ===Parameters
40
+ # <tt>message</tt>:: Message which should be send along the validation key. Message needs to contain two
41
+ # placeholders: #key# and #validUntil#.
42
+ # <tt>number</tt>:: Number to be validated.
43
+ # <tt>originator</tt>:: Originator to be displayed in the receiver's validation text message.
44
+ # <tt>account</tt>:: Optional developergarden subaccount.
45
+ def send_validation_keyword(message, number, originator, environment = ServiceEnvironment.MOCK, account = "")
46
+ response = invoke_authenticated('smsvs:sendValidationKeywordRequest') do |request, doc|
47
+ request.add('message', message)
48
+ request.add('number', number)
49
+ request.add('originator', originator)
50
+ request.add('account', account)
51
+ request.add('environment', environment)
52
+ end
53
+
54
+ return SmsSendValidationResponse.new(response)
55
+ end
56
+
57
+
58
+ # Validate the requested number using the received keyword.
59
+ # ===Parameters
60
+ # <tt>keyword</tt>:: Secret keyword used to finalize the ongoing validation process.
61
+ # <tt>number</tt>:: Number to be validated
62
+ # <tt>environment</tt>:: Note that only the MOCK and PRODUCTION environments can be used. Numbers already validated
63
+ # in the PRODUCTIOn environment can also be used for sending text messages in the SANDBOX ENVIRONMENT.
64
+ # Validations with the keyword <tt>SECRET</tt> in the MOCK environment should always succeed.
65
+ def validate(keyword, number, environment = ServiceEnvironment.MOCK)
66
+ response = invoke_authenticated('smsvs:validateRequest') do |request, doc|
67
+ request.add('keyword', keyword)
68
+ request.add('number', number)
69
+ request.add('environment', environment)
70
+ end
71
+
72
+ return SmsSendValidationResponse.new(response)
73
+ end
74
+
75
+ # Invalidate the given number.
76
+ # ===Parameters
77
+ # <tt>number</tt>:: Number to be invalidated
78
+ # <tt>environment</tt>:: Note that only the MOCK and PRODUCTION environments can be used. Numbers already validated
79
+ # in the PRODUCTIOn environment can also be used for sending text messages in the SANDBOX ENVIRONMENT.
80
+ # Validations with the keyword <tt>SECRET</tt> in the MOCK environment should always succeed.
81
+ def invalidate(number, environment = ServiceEnvironment.MOCK)
82
+ response = invoke_authenticated('smsvs:invalidateRequest') do |request, doc|
83
+ request.add('number', number)
84
+ request.add('environment', environment)
85
+ end
86
+
87
+ return SmsSendValidationResponse.new(response)
88
+ end
89
+
90
+ # Retrieves a list of already validated numbers.
91
+ # ===Parameters
92
+ # <tt>environment</tt>:: Note that only the MOCK and PRODUCTION environments can be used.
93
+ def get_validated_numbers(environment = ServiceEnvironment.MOCK)
94
+ response = invoke_authenticated('smsvs:getValidatedNumbersRequest') do |request, doc|
95
+ request.add('environment', environment)
96
+ end
97
+
98
+ return SmsGetValidatedNumbersResponse.new(response)
99
+ end
100
+ end
101
+ end
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../basic_response'
5
5
  class CallStatusResponse < BasicResponse
6
6
 
7
7
  attr_accessor :connection_time_a, :connection_time_b, :description_a, :description_b, :reason_a, :reason_b
8
- attr_accessor :state_a, :state_b
8
+ attr_accessor :state_a, :state_b, :be164, :bindex
9
9
 
10
10
  # Constructor.
11
11
  # ===Parameters
@@ -25,6 +25,9 @@ class CallStatusResponse < BasicResponse
25
25
  @reason_b = doc.xpath("//reasonb").to_s
26
26
  @state_a = doc.xpath("//statea").to_s
27
27
  @state_b = doc.xpath("//stateb").to_s
28
+ @be164 = doc.xpath("//be164").to_s
29
+ @bindex = doc.xpath("//bindex").to_s
30
+
28
31
 
29
32
  raise_on_error(response_xml) if raise_exception_on_error
30
33
  end
@@ -13,7 +13,7 @@ module VoiceCallService
13
13
  # Establish voice calls between two participants
14
14
  # See also: http://www.developergarden.com/openapi/dokumentation/services#4.2.1.
15
15
  class VoiceCallService < AuthenticatedService
16
- @@VOICE_CALL_SERVICE_ENDPOINT = {
16
+ @@VOICE_CALL_SERVICE_ENDPOINT = { +
17
17
  :uri => "https://gateway.developer.telekom.com/p3gw-mod-odg-voicebutler/services/VoiceButlerService",
18
18
  :version => 1
19
19
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: developergarden_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fischer / Aperto move GmbH
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-22 00:00:00 +01:00
12
+ date: 2010-02-09 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -52,7 +52,7 @@ dependencies:
52
52
  - !ruby/object:Gem::Version
53
53
  version: 4.0.0
54
54
  version:
55
- description: Offers a ruby client for the open development services such as send SMS, voice call and quota management of the Deutsche Telekom AG. See also http://www.developergarden.com.
55
+ description: "Client library for the open development services of Deutsche Telekom AG. The services are: send SMS, voice call, conference call, IP location, local search and quota management. For more information, please see http://www.developergarden.com."
56
56
  email: ruby@developergarden.com
57
57
  executables: []
58
58
 
@@ -102,12 +102,16 @@ files:
102
102
  - lib/ip_location_service/region.rb
103
103
  - lib/local_search_service/local_search_response.rb
104
104
  - lib/local_search_service/local_search_service.rb
105
+ - lib/quota_service/account_balance_response.rb
105
106
  - lib/quota_service/quota_information.rb
106
107
  - lib/quota_service/quota_service.rb
107
108
  - lib/service_environment.rb
108
109
  - lib/service_exception.rb
110
+ - lib/sms_service/sms_get_validated_numbers_response.rb
109
111
  - lib/sms_service/sms_response.rb
110
112
  - lib/sms_service/sms_service.rb
113
+ - lib/sms_service/sms_validation_response.rb
114
+ - lib/sms_service/sms_validation_service.rb
111
115
  - lib/telekom_sdk.rb
112
116
  - lib/token_service/security_token_validator.rb
113
117
  - lib/token_service/token_service.rb
@@ -141,6 +145,6 @@ rubyforge_project:
141
145
  rubygems_version: 1.3.5
142
146
  signing_key:
143
147
  specification_version: 3
144
- summary: Offers a ruby client for the open development services such as send SMS, voice call and quota management of the Deutsche Telekom AG. See also http://www.developergarden.com.
148
+ summary: "Client library for the open development services of Deutsche Telekom AG. The services are: send SMS, voice call, conference call, IP location, local search and quota management. For more information, please see http://www.developergarden.com."
145
149
  test_files: []
146
150