Skip to content

Commit fe1ad54

Browse files
author
attdevsupport
committed
Codekit Ruby - 04112014 Release
1 parent f8e2c3a commit fe1ad54

42 files changed

Lines changed: 1221 additions & 538 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE.txt

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

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Library for easy access to AT&T's cloud services.
44

5+
## Requirements
6+
7+
Ruby 1.9.3 or higher (Ruby 2.1 recommended)
8+
59
## Installation
610
### Easy install
711

@@ -28,6 +32,22 @@ You can install per user by issuing:
2832

2933
Substituting version for the compiled version to install
3034

35+
## Documentation
36+
37+
The Codekit contains inline documentation, which can be generated using
38+
yard doc via the yard command. Install by running
39+
40+
$ gem install yard
41+
42+
For example, to generate the documentation which can then be viewed via browser
43+
run:
44+
45+
$ yard server
46+
47+
Then goto the specified address in your preferred web browser, usually:
48+
49+
http://localhost:8808
50+
3151
## Usage
3252

3353
###Require the library
@@ -69,3 +89,4 @@ Now to create an api service we just pass the oauth token to the api we want to
6989

7090
immn = IMMNService.new(fqdn, authToken)
7191
sms = SMSService.new(fqdn, clientToken)
92+

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require "bundler/gem_tasks"
2-
require 'yard'
32
require 'rake/testtask'
43
require 'rake/clean'
4+
require 'yard'
55

66
CLEAN.include("pkg/*.gem")
77

att-codekit.gemspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ Gem::Specification.new do |spec|
2020
spec.require_paths = ["lib"]
2121

2222
#install dependencies
23-
spec.add_dependency "rake"
24-
spec.add_dependency "bundler", "~> 1.3"
23+
spec.add_development_dependency "rake"
24+
spec.add_development_dependency "yard"
25+
spec.add_development_dependency "bundler", "~> 1.3"
2526

2627
#runtime dependencies
28+
spec.add_runtime_dependency "json"
2729
spec.add_runtime_dependency "immutable_struct"
28-
spec.add_runtime_dependency "mime-types", "~> 1.25"
2930
spec.add_runtime_dependency "rest-client", "~> 1.6"
30-
spec.add_runtime_dependency "json"
3131
end

examples/ads.rb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# This quickstart guide requires the Ruby codekit, which can be found at:
3+
# https://github.com/attdevsupport/codekit-ruby
24

35
# Make sure the att-codekit has been installed then require the class
46
require 'att/codekit'
@@ -7,29 +9,29 @@
79
include Att::Codekit
810

911
# Uncomment to set a proxy if required
10-
# Transport.proxy("http:/proxyaddress.com:port")
12+
# Transport.proxy("http://proxyaddress.com:port")
1113

12-
# Use the app settings from developer.att.com for the following values.
13-
# Make sure ADS is enabled for the app key/secret.
14+
# Use the app account settings from developer.att.com for the following values.
15+
# Make sure ADS is enabled for the App Key and App Secret.
1416

1517
# Enter the value from 'App Key' field
1618
client_id = 'ENTER VALUE!'
1719

18-
# Enter the value from 'Secret' field
20+
# Enter the value from 'App Secret' field
1921
client_secret = 'ENTER VALUE!'
2022

2123
# Set the fqdn to default of https://api.att.com
2224
fqdn = 'https://api.att.com'
2325

24-
# Create service for requesting an OAuth token
26+
# Create service for requesting an OAuth access token
2527
clientcred = Auth::ClientCred.new(fqdn,
2628
client_id,
2729
client_secret)
2830

29-
# Get OAuth token using the ADS scope
31+
# Get OAuth access token using the Advertising API scope
3032
token = clientcred.createToken('ADS')
3133

32-
# Create service for interacting with the ADS api
34+
# Create service for interacting with the Advertising API
3335
ads = Service::ADSService.new(fqdn, token)
3436

3537
# User agent (must be mobile)
@@ -39,17 +41,17 @@
3941
udid = '938382893239492349234923493249'
4042

4143
begin
42-
# Send a request to the API for getting an advertisement using 'auto' as the
43-
# category.
44+
# Send a request to the API Gateway for getting an advertisement using 'auto'
45+
# as the category.
4446
response = ads.getAds('auto', user_agent, udid)
4547

4648
rescue Service::ServiceException => e
4749
puts "There was an error, the api returned the following error code:"
4850
puts "#{e.message}"
4951

5052
else
51-
# It's important to check that ads were returned since a successful response
52-
# does not guarantee ad content
53+
# It's important to check that advertisements were returned since a
54+
# successful response does not guarantee advertisement content
5355
if response.hasAds?
5456

5557
# Simply display the results

examples/cms.rb

Lines changed: 0 additions & 64 deletions
This file was deleted.

examples/dc.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# This quickstart guide requires the Ruby codekit, which can be found at:
3+
# https://github.com/attdevsupport/codekit-ruby
24

35
# Make sure the att-codekit has been installed then require the class
46
require 'att/codekit'
@@ -7,7 +9,7 @@
79
include Att::Codekit
810

911
# Uncomment to set a proxy if required
10-
# Transport.proxy("http:/proxyaddress.com:port")
12+
# Transport.proxy("http://proxyaddress.com:port")
1113

1214
# Use the app settings from developer.att.com for the following values.
1315
# Make sure DC is enabled for the app key/secret.

examples/immn.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# This quickstart guide requires the Ruby codekit, which can be found at:
3+
# https://github.com/attdevsupport/codekit-ruby
24

35
# Make sure the att-codekit has been installed then require the class
46
require 'att/codekit'
@@ -7,18 +9,18 @@
79
include Att::Codekit
810

911
# Uncomment to set a proxy if required
10-
# Transport.proxy("http:/proxyaddress.com:port")
12+
# Transport.proxy("http://proxyaddress.com:port")
1113

1214
# Use the app settings from developer.att.com for the following values.
1315
# Make sure IMMN is enabled for the app key/secret.
1416

1517
# Enter the value from 'App Key' field
1618
client_id = 'ENTER VALUE!'
1719

18-
# Enter the value from 'Secret' field
20+
# Enter the value from 'App Secret' field
1921
client_secret = 'ENTER VALUE!'
2022

21-
# Set the fqdn to default of https://api.att.com
23+
# Set the fqdn to the default of https://api.att.com
2224
fqdn = 'https://api.att.com'
2325

2426
# Set the redirect url for returning after consent flow

examples/mim.rb

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env ruby
2+
# This quickstart guide requires the Ruby codekit, which can be found at:
3+
# https://github.com/attdevsupport/codekit-ruby
4+
5+
# Make sure the att-codekit has been installed then require the class
6+
require 'att/codekit'
7+
8+
# Include the name spaces to reduce the code required (Optional)
9+
include Att::Codekit
10+
11+
# Uncomment to set a proxy if required
12+
# Transport.proxy("http://proxyaddress.com:port")
13+
14+
# Use the app settings from developer.att.com for the following values.
15+
# Make sure IMMN is enabled for the app key/secret.
16+
17+
# Enter the value from 'App Key' field
18+
client_id = 'ENTER VALUE!'
19+
20+
# Enter the value from 'Secret' field
21+
client_secret = 'ENTER VALUE!'
22+
23+
# Set the fqdn to default of https://api.att.com
24+
fqdn = 'https://api.att.com'
25+
26+
# Set the redirect url for returning after consent flow
27+
base_redirect_url = "http://localhost:4567"
28+
29+
# Create service for requesting an OAuth token
30+
authcode = Auth::AuthCode.new(fqdn,
31+
client_id,
32+
client_secret)
33+
34+
35+
# Authenticate the user. note: this requires a browser
36+
37+
# Obtain the url string that will be used for consent flow
38+
consent_url = authcode.consentFlow(:redirect => base_redirect_url)
39+
40+
# display a link with the consent flow url
41+
puts consent_url
42+
43+
# Wait for user input after spawning consent flow
44+
puts "Please input the code in the query parameters after doing consent flow:"
45+
code = gets.strip
46+
47+
# Get the token using the authentication code
48+
token = authcode.createToken(code)
49+
50+
# Create a service for making the API call
51+
mim = Service::MIMService.new(fqdn, token)
52+
53+
# Obtain a list of messages sent to authenticated phone
54+
begin
55+
56+
COUNT = 10
57+
58+
msg_list = mim.getMessageList(COUNT)
59+
60+
rescue Service::ServiceException => e
61+
puts "There was an error, the api returned the following error code:"
62+
puts "#{e.message}"
63+
64+
else
65+
66+
# Simple dump of results
67+
msg_list.each_pair do |attribute, value|
68+
puts "#{attribute}: \t#{value}"
69+
end
70+
71+
end
72+
73+
puts
74+
75+
# Obtain a message by ID
76+
begin
77+
78+
# Note: this is redundant and only an example; message will contain the same
79+
# data as msg_list.messages.first
80+
81+
# Get the first message from above msg_list
82+
message = mim.getMessage(msg_list.messages.first.id)
83+
84+
rescue Service::ServiceException => e
85+
puts "There was an error, the api returned the following error code:"
86+
puts "#{e.message}"
87+
88+
else
89+
90+
# Simple dump of results
91+
message.each_pair do |attribute, value|
92+
puts "#{attribute}: \t#{value}"
93+
end
94+
95+
end
96+
97+
puts
98+
99+
# Obtain content of an mms message
100+
begin
101+
102+
# Note: you will only be able to obtain the content of an mms message
103+
104+
content = mim.getMessageContent(msg_list.messages.first.id)
105+
106+
rescue Service::ServiceException => e
107+
puts "There was an error, the api returned the following error code:"
108+
puts "#{e.message}"
109+
110+
else
111+
112+
# Simple dump of results
113+
puts "Content type: #{content.content_type}"
114+
puts "Content length: #{content.content_length}"
115+
puts "Image? #{content.image?}"
116+
puts "Audio? #{content.audio?}"
117+
puts "Video? #{content.video?}"
118+
puts "Text? #{content.text?}"
119+
puts "SMIL? #{content.smil?}"
120+
121+
end

0 commit comments

Comments
 (0)