Skip to content

Commit a843920

Browse files
author
attdevsupport
committed
Ruby Code kit with Addressbook changes
1 parent fe1ad54 commit a843920

File tree

18 files changed

+1603
-321
lines changed

18 files changed

+1603
-321
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Licensed by AT&T under the 'Software Development Kit Tools Agreement.' 2014.
2-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTIONS:
2+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTIONS:
33
http://developer.att.com/sdk_agreement/
44

examples/dc.rb

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,73 @@
11
#!/usr/bin/env ruby
2-
# This quickstart guide requires the Ruby codekit, which can be found at:
2+
# This Quickstart Guide for the Device Capabilities API requires the Ruby
3+
# code kit, which can be found at:
34
# https://github.com/attdevsupport/codekit-ruby
45

5-
# Make sure the att-codekit has been installed then require the class
6+
# Make sure that the att-codekit has been installed, then require the class.
67
require 'att/codekit'
78

8-
# Include the name spaces to reduce the code required (Optional)
9+
# Include the name spaces to reduce the code required (Optional).
910
include Att::Codekit
1011

11-
# Uncomment to set a proxy if required
12+
# If a proxy is required, uncomment the following line.
1213
# Transport.proxy("http://proxyaddress.com:port")
1314

14-
# Use the app settings from developer.att.com for the following values.
15-
# Make sure DC is enabled for the app key/secret.
15+
# Use the app account settings from developer.att.com for the following values.
16+
# Make sure that the API scope is set to DC for the Device Capabilities API
17+
# before retrieving the App Key and App Secret.
1618

17-
# Enter the value from 'App Key' field
19+
# Enter the value from 'App Key' field obtained at developer.att.com
20+
# in your app account.
1821
client_id = 'ENTER VALUE!'
1922

20-
# Enter the value from 'Secret' field
23+
# Enter the value from 'App Secret' field obtained at developer.att.com
24+
# in your app account.
2125
client_secret = 'ENTER VALUE!'
2226

23-
# Set the fqdn to default of https://api.att.com
27+
# Set the fully-qualified domain name to: https://api.att.com
2428
fqdn = 'https://api.att.com'
2529

26-
# Set the redirect url for returning after consent flow
30+
# Set the redirect URI for returning after consent flow.
2731
redirect_url = "http://localhost:4567"
2832

29-
# Create service for requesting an OAuth token
33+
# Create the service for requesting an OAuth access token.
3034
authcode = Auth::AuthCode.new(fqdn,
3135
client_id,
3236
client_secret,
3337
:redirect => redirect_url)
3438

3539

36-
# Authenticate the user. note: this requires a browser
40+
# Authenticate the user. Note: This requires a Web browser.
3741

38-
# Obtain the url string that will be used for consent flow
42+
# Obtain the url string that is used for consent flow.
3943
consent_url = authcode.consentFlow
4044

41-
# display a link with the consent flow url
45+
# Display a link with the consent flow URI.
4246
puts consent_url
4347

44-
# Wait for user input after spawning consent flow
48+
# Wait for user input after spawning consent flow.
4549
puts "Please input the code in the query parameters after doing consent flow:"
4650
code = gets.strip
4751

48-
# Get the token using the authentication code
52+
# Get the OAuth access token using the OAuth authentication code.
4953
token = authcode.createToken(code)
5054

51-
# Create a service for making the API call
55+
# Create the service for making the method request.
5256
dc = Service::DCService.new(fqdn, token)
5357

54-
# Use exception handling to see if anything went wrong with the request
58+
# Use exception handling to see if anything went wrong with the method request.
5559
begin
5660

57-
# Make api call to get authenticated device's capabilities
61+
# Make the method request to get the capabilities of the authenticated device.
5862
response = dc.getDeviceCapabilities
5963

6064
rescue Service::ServiceException => e
61-
puts "There was an error, the api returned the following error code:"
65+
puts "There was an error, the API Gateway returned the following error code:"
6266
puts "#{e.message}"
6367

6468
else
6569

66-
# Simple dump of results
70+
# Display of results.
6771
puts ""
6872
puts "Device ID: #{response.device_id.type_allocation_code}"
6973
puts "Device Capabilities:"

examples/immn.rb

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,80 @@
11
#!/usr/bin/env ruby
2-
# This quickstart guide requires the Ruby codekit, which can be found at:
2+
# This Quickstart Guide for the In-App Messaging API requires the Ruby
3+
# code kit, which can be found at:
34
# https://github.com/attdevsupport/codekit-ruby
45

5-
# Make sure the att-codekit has been installed then require the class
6+
# Make sure that the att-codekit has been installed, then require the class.
67
require 'att/codekit'
78

8-
# Include the name spaces to reduce the code required (Optional)
9+
# Include the name spaces to reduce the code required (Optional).
910
include Att::Codekit
1011

11-
# Uncomment to set a proxy if required
12+
# If a proxy is required, uncomment the following line.
1213
# Transport.proxy("http://proxyaddress.com:port")
1314

1415
# Use the app settings from developer.att.com for the following values.
15-
# Make sure IMMN is enabled for the app key/secret.
16+
# Make sure that the API scope is set to IMMN for the In-App Messaging API
17+
# before retrieving the App Key and App Secret.
1618

17-
# Enter the value from 'App Key' field
19+
# Enter the value from 'App Key' field obtained at developer.att.com
20+
# in your app account.
1821
client_id = 'ENTER VALUE!'
1922

20-
# Enter the value from 'App Secret' field
23+
# Enter the value from 'App Secret' field obtained at developer.att.com
24+
# in your app account.
2125
client_secret = 'ENTER VALUE!'
2226

23-
# Set the fqdn to the default of https://api.att.com
27+
# Set the fully-qualified domain name to: https://api.att.com.
2428
fqdn = 'https://api.att.com'
2529

26-
# Set the redirect url for returning after consent flow
30+
# Set the redirect URI for returning after consent flow.
2731
redirect_url = "http://localhost:4567"
2832

29-
# Create service for requesting an OAuth token
33+
# Create the service for requesting an OAuth access token.
3034
authcode = Auth::AuthCode.new(fqdn,
3135
client_id,
3236
client_secret,
3337
:redirect => redirect_url)
3438

3539

36-
# Authenticate the user. note: this requires a browser
40+
# Authenticate the user. Note: This requires a Web browser.
3741

38-
# Obtain the url string that will be used for consent flow
42+
# Obtain the url string that is used for consent flow.
3943
consent_url = authcode.consentFlow
4044

41-
# display a link with the consent flow url
45+
# Display a link with the consent flow URI.
4246
puts consent_url
4347

44-
# Wait for user input after spawning consent flow
48+
# Wait for user input after spawning consent flow.
4549
puts "Please input the code in the query parameters after doing consent flow:"
4650
code = gets.strip
4751

48-
# Get the token using the authentication code
52+
# Get the OAuth access token using the OAuth authentication code.
4953
token = authcode.createToken(code)
5054

51-
# Setup the addresses that we want to send
55+
# Specify the addresses where the message is sent.
5256
addresses = "555-555-5555,444-555-5555"
5357

54-
# Alternatively we can use an array
58+
# Alternatively, the addresses can be specified using an array.
5559
# addresses = [5555555555,"444-555-5555"]
5660

57-
# Create a service for making the API call
61+
# Create the service for making the method request.
5862
immn = Service::IMMNService.new(fqdn, token)
5963

60-
# Use exception handling to see if anything went wrong with the request
64+
# Use exception handling to see if anything went wrong with the request.
6165
begin
6266

63-
# Make api calls to send a sms and mms
64-
sms = immn.sendMessage(addresses, :message => "This is a sms message from immn example")
65-
mms = immn.sendMessage(addresses, :subject => "This is a mms message from immn example")
67+
# Make method requests to send SMS and MMS messages.
68+
sms = immn.sendMessage(addresses, :message => "This is a SMS message from the In-App Messaging example")
69+
mms = immn.sendMessage(addresses, :subject => "This is a MMS message from the In-App Messaging example")
6670

6771
rescue Service::ServiceException => e
68-
puts "There was an error, the api returned the following error code:"
72+
puts "There was an error, the API Gateway returned the following error code:"
6973
puts "#{e.message}"
7074

7175
else
7276

73-
# Simple dump of results
77+
# Display of results.
7478
puts "The response id of the sms message was: #{sms.id}"
7579
puts "The response id of the mms message was: #{mms.id}"
7680

examples/mim.rb

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,72 @@
11
#!/usr/bin/env ruby
2-
# This quickstart guide requires the Ruby codekit, which can be found at:
2+
# This Quickstart Guide requires the Ruby code kit,
3+
# which can be found at:
34
# https://github.com/attdevsupport/codekit-ruby
45

5-
# Make sure the att-codekit has been installed then require the class
6+
# Make sure that the att-codekit has been installed, then require the class.
67
require 'att/codekit'
78

8-
# Include the name spaces to reduce the code required (Optional)
9+
# Include the name spaces to reduce the code required (Optional).
910
include Att::Codekit
1011

11-
# Uncomment to set a proxy if required
12+
# If a proxy is required, uncomment the following line to set the proxy.
1213
# Transport.proxy("http://proxyaddress.com:port")
1314

14-
# Use the app settings from developer.att.com for the following values.
15-
# Make sure IMMN is enabled for the app key/secret.
15+
# Use the app account settings from developer.att.com for the following values.
16+
# Make sure that the API scope is set to MIM before retrieving the App Key and App Secret.
1617

17-
# Enter the value from 'App Key' field
18+
# Enter the value from 'App Key' field obtained at developer.att.com
19+
# in your app account.
1820
client_id = 'ENTER VALUE!'
1921

20-
# Enter the value from 'Secret' field
22+
# Enter the value from 'App Secret' field obtained at developer.att.com
23+
# in your app account.
2124
client_secret = 'ENTER VALUE!'
2225

23-
# Set the fqdn to default of https://api.att.com
26+
# Set the fully-qualified domain name to: https://api.att.com
2427
fqdn = 'https://api.att.com'
2528

26-
# Set the redirect url for returning after consent flow
29+
# Set the redirect URI for returning after consent flow.
2730
base_redirect_url = "http://localhost:4567"
2831

29-
# Create service for requesting an OAuth token
32+
# Create the service for requesting an OAuth access token.
3033
authcode = Auth::AuthCode.new(fqdn,
3134
client_id,
3235
client_secret)
3336

3437

35-
# Authenticate the user. note: this requires a browser
38+
# Authenticate the user. Note: This requires a Web browser.
3639

37-
# Obtain the url string that will be used for consent flow
40+
# Obtain the url string that is used for consent flow.
3841
consent_url = authcode.consentFlow(:redirect => base_redirect_url)
3942

40-
# display a link with the consent flow url
43+
# Display the link with the consent flow URI.
4144
puts consent_url
4245

43-
# Wait for user input after spawning consent flow
46+
# Wait for user input after spawning consent flow.
4447
puts "Please input the code in the query parameters after doing consent flow:"
4548
code = gets.strip
4649

47-
# Get the token using the authentication code
50+
# Get the OAuth access token using the OAuth authentication code.
4851
token = authcode.createToken(code)
4952

50-
# Create a service for making the API call
53+
# Create a service for making the method request.
5154
mim = Service::MIMService.new(fqdn, token)
5255

53-
# Obtain a list of messages sent to authenticated phone
56+
# Obtain a list of the messages sent to the authenticated phone.
5457
begin
5558

5659
COUNT = 10
5760

5861
msg_list = mim.getMessageList(COUNT)
5962

6063
rescue Service::ServiceException => e
61-
puts "There was an error, the api returned the following error code:"
64+
puts "There was an error, the API Gateway returned the following error code:"
6265
puts "#{e.message}"
6366

6467
else
6568

66-
# Simple dump of results
69+
# Display the results.
6770
msg_list.each_pair do |attribute, value|
6871
puts "#{attribute}: \t#{value}"
6972
end
@@ -72,22 +75,23 @@
7275

7376
puts
7477

75-
# Obtain a message by ID
78+
# Obtain a message by ID.
7679
begin
7780

78-
# Note: this is redundant and only an example; message will contain the same
81+
# Note: this property also returns the first message in the list and can be used to
82+
# confirm the return value of the getMessage example that follows.
7983
# data as msg_list.messages.first
8084

81-
# Get the first message from above msg_list
85+
# Get the first message from the previous msg_list.
8286
message = mim.getMessage(msg_list.messages.first.id)
8387

8488
rescue Service::ServiceException => e
85-
puts "There was an error, the api returned the following error code:"
89+
puts "There was an error, the API Gateway returned the following error code:"
8690
puts "#{e.message}"
8791

8892
else
8993

90-
# Simple dump of results
94+
# Display the results.
9195
message.each_pair do |attribute, value|
9296
puts "#{attribute}: \t#{value}"
9397
end
@@ -96,20 +100,20 @@
96100

97101
puts
98102

99-
# Obtain content of an mms message
103+
# Obtain the content of an MMS message.
100104
begin
101105

102-
# Note: you will only be able to obtain the content of an mms message
106+
# Note: You will be able to only obtain the content of an MMS message.
103107

104108
content = mim.getMessageContent(msg_list.messages.first.id)
105109

106110
rescue Service::ServiceException => e
107-
puts "There was an error, the api returned the following error code:"
111+
puts "There was an error, the API Gateway returned the following error code:"
108112
puts "#{e.message}"
109113

110114
else
111115

112-
# Simple dump of results
116+
# Display the results.
113117
puts "Content type: #{content.content_type}"
114118
puts "Content length: #{content.content_length}"
115119
puts "Image? #{content.image?}"

0 commit comments

Comments
 (0)