Skip to content

Commit

Permalink
SampleApp Enhancement for ADS in Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
attdevsupport committed Apr 29, 2015
1 parent 08e332b commit 5774ff4
Show file tree
Hide file tree
Showing 13 changed files with 4,015 additions and 483 deletions.
1 change: 1 addition & 0 deletions RESTFul/ADS/Ruby/app1/.gitignore
Expand Up @@ -27,6 +27,7 @@
*.sql
*.sqlite
*.db
*.session

# OS generated files #
######################
Expand Down
2 changes: 1 addition & 1 deletion RESTFul/ADS/Ruby/app1/Gemfile.lock
Expand Up @@ -2,7 +2,7 @@ GEM
remote: https://rubygems.org/
remote: http://lprod.code-api-att.com:8808/
specs:
att-codekit (4.4.2)
att-codekit (4.4.3)
immutable_struct
json
rest-client
Expand Down
141 changes: 70 additions & 71 deletions RESTFul/ADS/Ruby/app1/README
Expand Up @@ -15,41 +15,38 @@
1. Configuration

Configuration consists of a few steps necessary to get an application
registered with the proper services and
endpoints, depending on the type of client-side application
(autonomous/non-autonomous).
registered with the proper services and endpoints, depending on the type of
client-side application (autonomous/non-autonomous).

To register an application, go to https://developer.att.com/developer/mvc/auth/login and login
with your valid username and password.
Next, choose "My Apps" from the bar at the top of the page and click the
"Setup a New Application" button.
To register an application, go to
https://developer.att.com/developer/mvc/auth/login and login with your valid
username and password. Next, choose "My Apps" from the bar at the top of the
page and click the "Setup a New Application" button.

Fill in the form, in particular all fields marked as "required".
Fill in the form, in particular all fields marked as "required".


Having your application registered, you will get back an important pair of
data: an API key and Secret key. They are
necessary to get your applications working with the AT&T API Platform. See
'Adjusting parameters' below to learn how to use
these keys.
Having your application registered, you will get back an important pair of
data: an API key and Secret key. They are necessary to get your applications
working with the AT&T API Platform. See 'Adjusting parameters' below to learn
how to use these keys.

Initially your newly registered application is restricted to the "Sandbox"
environment only. To move it to production,
you may promote it by clicking the "Promote to production" button. Notice
that you will get a different API key and secret,
so these values in your application should be adjusted accordingly.
Initially your newly registered application is restricted to the "Sandbox"
environment only. To move it to production, you may promote it by clicking the
"Promote to production" button. Notice that you will get a different API key
and secret, so these values in your application should be adjusted accordingly.

Depending on the kind of authentication used, an application may be based on
either the Autonomous Client or the Web-Server
Client OAuth flow (see https://developer.att.com/apis/oauth-2/docs).
Depending on the kind of authentication used, an application may be based on
either the Autonomous Client or the Web-Server Client OAuth flow
(see https://developer.att.com/apis/oauth-2/docs).

2. Installation

** Requirements

To run the examples you will need ruby 1.9.3+ and a few ruby gems that the
applications are built upon:
To run the examples you will need ruby 1.9.3+ and a few ruby gems that the
applications are built upon:

- sinatra: (http://www.sinatrarb.com/) used to construct a simple web
application and manage URLs within.

Expand All @@ -65,89 +62,91 @@ either the Autonomous Client or the Web-Server
- rake: compiling tool used to make att-codekit
- yard: documentation tool used by att-codekit

The easiest way to install the required gems is to use bundler.
The easiest way to install the required gems is to use bundler.

First make sure you have bundler installed:
First make sure you have bundler installed:
gem install bundler

Then inside the directory which this README resides run:
Then inside the directory which this README resides run:
bundle install

On a *nix based system you may need to raise your access privliges, such as
prefixing the command with sudo or logging in as root by running su.
On a *nix based system you may need to raise your access privliges, such as
prefixing the command with sudo or logging in as root by running su.

** Installing the att-codekit library
Note: this is only required if you are **not** using bundler and are using ruby 1.9+

The code kit library can be installed by using our hosted gem file.
The code kit library can be installed by using our hosted gem file.

gem sources --add http://lprod.code-api-att.com:8808
gem install att-codekit
gem sources --add http://lprod.code-api-att.com:8808
gem install att-codekit

Note that the codekit is under heavy development and is using a semantic
versioning scheme. Non-backwards compatible changes **will** increase the
major version number.
Note that the codekit is under heavy development and is using a semantic
versioning scheme. Non-backwards compatible changes **will** increase the major
version number.


** Setting up on a different port number

In the case multiple applications need to be run at the same time, you need
to use different port numbers.
In the case multiple applications need to be run at the same time, you need to
use different port numbers.

By default sinatra uses port number 4567; however only one running
application may use this port. In the case that you want to run more than one
sinatra-based application, you will need to update each applications' port
number (located in config.yml).
By default sinatra uses port number 4567; however only one running application
may use this port. In the case that you want to run more than one sinatra-based
application, you will need to update each applications' port number (located in
config.yml).

eg. application 1 - port: 4567, application 2 - port: 4568
eg. application 1 - port: 4567, application 2 - port: 4568

The alternative is to set up your webserver to use a tool such as phusion
passenger. Setting up a webserver, however, is beyond the scope of this
article.
The alternative is to set up your webserver to use a tool such as phusion
passenger. Setting up a webserver, however, is beyond the scope of this
article.


3. Parameters

Each application contains a config.yml file. It holds configurable parameters
described in the easy to read format YAML. You are free to adjust these to
your needs. If you introduce a change make sure to restart the application
for it to take effect.
Each application contains a config.yml file. It holds configurable parameters
described in the easy to read format YAML. You are free to adjust these to your
needs. If you introduce a change make sure to restart the application for it to
take effect.

The following are short descriptions of commonly used parameters:

REQUIRED -
1) FQDN : The main server handling requests, ex: https://api.att.com

2) api_key : set the value as per your registered application 'API
key' field value

3) secret_key : set the value as per your registered application
The following are short descriptions of commonly used parameters:

REQUIRED -

1) FQDN : The main server handling requests, ex: https://api.att.com
2) api_key : set the value as per your registered application
'API key' field value
3) secret_key : set the value as per your registered application
'Secret key' field value

OPTIONAL -
OPTIONAL -

4) port : The port number which the application will run standalone

5) tokens_file : The path where the oauth token will be saved. This option
is only usable in client credential style authentication.
Must have write permissions.

Note: If your application is promoted from the Sandbox environment to
Production environment and you decide to use production application settings,
you must update api_key and secret_key as per production application details.
Note: If your application is promoted from the Sandbox environment to
Production environment and you decide to use production application settings,
you must update api_key and secret_key as per production application details.


4. Running the application

To run the application, open up a terminal window in the application's
directory and type:

ruby (app name).rb
To run the application, open up a terminal window in the application's
directory and type:

Where (app name) is replaced with the current directories app name.
rackup

Your application by default is accessible in a web browser at the url:
http://localhost:4567/
Your application by default is accessible in a web browser at the url
[http://localhost:9292/](http://localhost:9292/). Note that if you receive the
error 'port already in use' or are running multiple instances change 9292 to
any available port number of your choosing and use that port to access it via
localhost.

You may interrupt the application at any time by pressing ctrl-C.
For example:

rackup -p 9293

You may interrupt the application at any time by pressing ctrl-C.

0 comments on commit 5774ff4

Please sign in to comment.