Last active
October 10, 2015 17:08
-
-
Save t2-support-gists/3723801 to your computer and use it in GitHub Desktop.
DC Vb RESTFul App 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ****************************************************************************************** | |
| * Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2013 | |
| * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/ | |
| * Copyright 2013 AT&T Intellectual Property. All rights reserved. http://developer.att.com | |
| * For more information contact [email protected]<mailto:[email protected]> | |
| ****************************************************************************************** | |
| AT&T API Platform Samples - DC App 1 | |
| ------------------------------------- | |
| This application demonstrates the usage of Device Capabilities API of AT&T platform. | |
| The application allows an AT&T subscriber to retrieve the device specific information | |
| about the mobile device. | |
| This file describes how to set up, configure and run the VB.NET Applications of the | |
| AT&T API Platform sample applications. It covers all steps required to register the | |
| application on developer site and, based on the generated API keys and secrets, | |
| create and run one's own full-fledged sample applications. | |
| 1. Configuration | |
| 2. Installation | |
| 3. Parameters | |
| 4. Running the application | |
| 1. Configuration | |
| Configuration consists of a few steps necessary to get an application registered | |
| on developer site 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/ 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". | |
| Be careful while filling in the "OAuth Redirect URL" field. It should contain the | |
| URL that the oAuth provider will redirect users to when he/she successfully | |
| authenticates and authorizes your application. | |
| NOTE: You MUST select Device Capability in the list of services under field | |
| 'Services' in order to use this sample application code. | |
| 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 Platform APIs. | |
| 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. | |
| 2. Installation | |
| ** Requirements | |
| To run the this sample application you need an IIS Server. | |
| Download the application files from the download link published in AT&T portal | |
| into webdomain of your IIS server. | |
| 3. Parameters | |
| Each sample application contains an web.config file. This file | |
| is located in the 'app' folder. This file holds configurable | |
| parameters described in an easy-to-read format. Please modify the | |
| web.config file using the comments specified within the file. | |
| Note: If your application is promoted from Sandbox environment to Production | |
| environment and you decide to use production application settings, you must | |
| update parameters as per production application details. | |
| 4. Running the application | |
| Suppose you copied the sample app files in your IIS server webroot/dc/app1/ folder. | |
| In order to run the sample application, type in'http://IIS_HOSTNAME/dc/app1/Default.aspx'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="DC_App1" %> | |
| <!-- | |
| Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2013 | |
| TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/ | |
| Copyright 2013 AT&T Intellectual Property. All rights reserved. http://developer.att.com | |
| For more information contact [email protected] | |
| --> | |
| <!--[if lt IE 7]> <html class="ie6" lang="en"> <![endif]--> | |
| <!--[if IE 7]> <html class="ie7" lang="en"> <![endif]--> | |
| <!--[if IE 8]> <html class="ie8" lang="en"> <![endif]--> | |
| <!--[if gt IE 8]><!--> | |
| <html lang="en"> | |
| <!--<![endif]--> | |
| <head> | |
| <title>AT&T Sample DC Application - Get Device Capabilities Application</title> | |
| <meta id="viewport" name="viewport" content="width=device-width,minimum-scale=1,maximum-scale=1" /> | |
| <link rel="stylesheet" type="text/css" href="style/common.css" /> | |
| <script type="text/javascript"> | |
| var _gaq = _gaq || []; | |
| _gaq.push(['_setAccount', 'UA-33466541-1']); | |
| _gaq.push(['_trackPageview']); | |
| (function () { | |
| var ga = document.createElement('script'); | |
| ga.type = 'text/javascript'; | |
| ga.async = true; | |
| ga.src = ('https:' == document.location.protocol ? 'https://ssl' | |
| : 'http://www') | |
| + '.google-analytics.com/ga.js'; | |
| var s = document.getElementsByTagName('script')[0]; | |
| s.parentNode.insertBefore(ga, s); | |
| })(); | |
| </script> | |
| </head> | |
| <body> | |
| <form id="form1" runat="server"> | |
| <div id="pageContainer"> | |
| <div id="header"> | |
| <div class="logo"> | |
| </div> | |
| <div id="menuButton" class="hide"> | |
| <a id="jump" href="#nav">Main Navigation</a> | |
| </div> | |
| <ul class="links" id="nav"> | |
| <li><a href="#" target="_blank">Full Page<img src="images/max.png" /></a> <span class="divider"> | |
| | </span> </li> | |
| <li><a runat="server" target="_blank" id="SourceLink">Source<img src="images/opensource.png" /></a> | |
| <span class="divider">| </span> </li> | |
| <li><a runat="server" target="_blank" id="DownloadLink">Download<img src="images/download.png" /></a> | |
| <span class="divider">| </span> </li> | |
| <li><a runat="server" target="_blank" id="HelpLink">Help</a> </li> | |
| <li id="back"><a href="#top">Back to top</a> </li> | |
| </ul> | |
| <!-- end of links --> | |
| </div> | |
| <!-- end of header --> | |
| <div id="content"> | |
| <div id="contentHeading"> | |
| <h1> | |
| AT&T Sample DC Application - Get Device Capabilities Application</h1> | |
| <div class="border"> | |
| </div> | |
| <div id="introtext"> | |
| <div> | |
| <b>Server Time: </b><%= String.Format("{0:ddd, MMMM dd, yyyy HH:mm:ss}", DateTime.UtcNow) + " UTC" %></div> | |
| <div> | |
| <b>Client Time:</b> | |
| <script language="JavaScript" type="text/javascript"> | |
| var myDate = new Date(); | |
| document.write(myDate); | |
| </script> | |
| </div> | |
| <div> | |
| <b>User Agent:</b> | |
| <script language="JavaScript" type="text/javascript"> | |
| document.write("" + navigator.userAgent); | |
| </script> | |
| </div> | |
| </div> | |
| <!-- end of introtext --> | |
| </div> | |
| <!-- end of contentHeading --> | |
| <!-- SAMPLE APP CONTENT STARTS HERE! --> | |
| <div class="formBox" id="formBox"> | |
| <div id="formContainer" class="formContainer"> | |
| <h2> | |
| Feature 1: Get Device Capabilities</h2> | |
| <div class="lightBorder"> | |
| </div> | |
| <div class="note"> | |
| <strong>OnNet Flow:</strong> Request Device Capabilities details from the AT&T | |
| network for the mobile device of an AT&T subscriber who is using an AT&T | |
| direct Mobile data connection to access this application. | |
| <br /> | |
| <strong>OffNet Flow:</strong> Where the end-user is not on an AT&T Mobile data | |
| connection or using a Wi-Fi or tethering connection while accessing this application. | |
| This will result in an HTTP 400 error. | |
| </div> | |
| <!-- end note --> | |
| <% If Not String.IsNullOrEmpty(getDCSuccess) Then%> | |
| <div class="successWide"> | |
| <strong>SUCCESS:</strong> | |
| <br /> | |
| Device parameters listed below. | |
| </div> | |
| <table class="kvp" id="kvp"> | |
| <thead> | |
| <tr> | |
| <th> | |
| Parameter | |
| </th> | |
| <th> | |
| Value | |
| </th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <% For Each pair As KeyValuePair(Of String, String) In getDCResponse%> | |
| <tr> | |
| <td data-value="Parameter"> | |
| <%= pair.Key.ToString()%> | |
| </td> | |
| <td data-value="Value"> | |
| <%= pair.Value.ToString()%> | |
| </td> | |
| </tr> | |
| <% Next%> | |
| </tbody> | |
| </table> | |
| <% End If%> | |
| <% If Not String.IsNullOrEmpty(getDCError) Then%> | |
| <div class="errorWide"> | |
| <b>ERROR:</b><br /> | |
| <%= getDCError %> | |
| </div> | |
| <% End If%> | |
| </div> | |
| <!-- end of formContainer --> | |
| </div> | |
| <!-- end of formBox --> | |
| <!-- SAMPLE APP CONTENT ENDS HERE! --> | |
| </div> | |
| <!-- end of content --> | |
| <div class="border"> | |
| </div> | |
| <div id="footer"> | |
| <div id="powered_by"> | |
| Powered by AT&T Cloud Architecture | |
| </div> | |
| <p> | |
| The Application hosted on this site are working examples intended to be used for | |
| reference in creating products to consume AT&T Services and not meant to be | |
| used as part of your product. The data in these pages is for test purposes only | |
| and intended only for use as a reference in how the services perform. | |
| <br /> | |
| <br /> | |
| For download of tools and documentation, please go to <a href="https://developer.att.com/" | |
| target="_blank">https://developer.att.com</a> | |
| <br /> | |
| For more information contact <a href="mailto:[email protected]">[email protected]</a> | |
| <br /> | |
| <br /> | |
| © 2013 AT&T Intellectual Property. All rights reserved. <a href="https://developer.att.com/" | |
| target="_blank">https://developer.att.com</a> | |
| </p> | |
| </div> | |
| <!-- end of footer --> | |
| </div> | |
| <!-- end of page_container --> | |
| </form> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ' <copyright file="Default.aspx.vb" company="AT&T"> | |
| ' Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2013 | |
| ' TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/ | |
| ' Copyright 2013 AT&T Intellectual Property. All rights reserved. http://developer.att.com | |
| ' For more information contact [email protected] | |
| ' </copyright> | |
| #Region "Application References" | |
| Imports System.Configuration | |
| Imports System.Globalization | |
| Imports System.IO | |
| Imports System.Net | |
| Imports System.Net.Security | |
| Imports System.Security.Cryptography.X509Certificates | |
| Imports System.Text | |
| Imports System.Web.Script.Serialization | |
| Imports System.Web | |
| Imports System.Collections.Generic | |
| Imports System.Collections | |
| #End Region | |
| ''' <summary> | |
| ''' Access Token Types | |
| ''' </summary> | |
| Public Enum AccessTokenType | |
| ''' <summary> | |
| ''' Access Token Type is based on Authorize Credential Mode | |
| ''' </summary> | |
| Authorize_Credential | |
| ''' <summary> | |
| ''' Access Token Type is based on Refresh Token | |
| ''' </summary> | |
| Refresh_Token | |
| End Enum | |
| ''' <summary> | |
| ''' Device Capabilities Application class. | |
| ''' This application will allow an user to get the device capabilities. | |
| ''' </summary> | |
| Partial Public Class DC_App1 | |
| Inherits System.Web.UI.Page | |
| #Region "Application Instance Variables" | |
| ''' <summary> | |
| ''' Instance variables | |
| ''' </summary> | |
| Private endPoint As String, apiKey As String, secretKey As String, authorizeRedirectUri As String, authCode As String, scope As String | |
| ''' <summary> | |
| ''' OAuth access token | |
| ''' </summary> | |
| Private accessToken As String | |
| Public indentLevel As Integer = 0 | |
| Public tbOutput As String = String.Empty | |
| Public getDCSuccess As String = String.Empty | |
| Public getDCError As String = String.Empty | |
| Public getDCResponse As New Dictionary(Of String, String)() | |
| ''' <summary> | |
| ''' OAuth refresh token | |
| ''' </summary> | |
| Private refreshToken As String | |
| ''' <summary> | |
| ''' Expirytimes of refresh and access tokens | |
| ''' </summary> | |
| Private refreshTokenExpiryTime As String, accessTokenExpiryTime As String | |
| #End Region | |
| #Region "Neglect SSL error" | |
| ''' <summary> | |
| ''' Neglect the ssl handshake error with authentication server | |
| ''' </summary> | |
| Function CertificateValidationCallBack( _ | |
| ByVal sender As Object, _ | |
| ByVal certificate As X509Certificate, _ | |
| ByVal chain As X509Chain, _ | |
| ByVal sslPolicyErrors As SslPolicyErrors _ | |
| ) As Boolean | |
| Return True | |
| End Function | |
| #End Region | |
| #Region "Application Events" | |
| ''' <summary> | |
| ''' This method will be executed upon loading of the page. | |
| ''' Reads the config file and assigns to local variables. | |
| ''' </summary> | |
| ''' <param name="sender">sender object</param> | |
| ''' <param name="e">event arguments</param> | |
| Protected Sub Page_Load(sender As Object, e As EventArgs) | |
| Try | |
| 'ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallBack) | |
| Me.BypassCertificateError() | |
| Dim ableToReadConfig As Boolean = Me.ReadConfigFile() | |
| If ableToReadConfig = False Then | |
| Return | |
| End If | |
| If Not IsPostBack Then | |
| If Request.QueryString("error") IsNot Nothing AndAlso Session("vb_dc_state") IsNot Nothing Then | |
| Session("vb_dc_state") = Nothing | |
| Dim errorString As String = Request.Url.Query.Remove(0, 1) | |
| getDCError = HttpUtility.UrlDecode(errorString) | |
| Return | |
| End If | |
| If Session("Vb_DC_App1_AccessToken") Is Nothing Then | |
| 'Retrive the query string 'code' from redirect response of AT&T authorization endpoint | |
| ' get the AccessToken and device info | |
| If Not String.IsNullOrEmpty(Convert.ToString(Request("code"))) Then | |
| authCode = Request("code").ToString() | |
| If GetAccessToken(AccessTokenType.Authorize_Credential) Then | |
| GetDeviceInfo() | |
| Else | |
| getDCError = "Failed to get Access token" | |
| End If | |
| Else | |
| Session("Vb_DC_App1_AccessToken") = Nothing | |
| GetAuthCode() | |
| End If | |
| Else | |
| GetDeviceInfo() | |
| End If | |
| Else | |
| Session("Vb_DC_App1_AccessToken") = Nothing | |
| GetAuthCode() | |
| End If | |
| Catch ex As Exception | |
| getDCError = ex.ToString() | |
| End Try | |
| End Sub | |
| Private Sub BypassCertificateError() | |
| Dim bypassSSL As String = ConfigurationManager.AppSettings("IgnoreSSL") | |
| If (Not String.IsNullOrEmpty(bypassSSL)) AndAlso (String.Equals(bypassSSL, "true", StringComparison.OrdinalIgnoreCase)) Then | |
| ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallBack) | |
| End If | |
| End Sub | |
| #End Region | |
| #Region "Application specific methods" | |
| ''' <summary> | |
| ''' Read config file and assign to local variables | |
| ''' </summary> | |
| ''' <remarks> | |
| ''' <para>Validates if the values are configured in web.config file and displays a warning message if not configured.</para> | |
| ''' </remarks> | |
| ''' <returns>true/false; true if able to read and assign; else false</returns> | |
| Private Function ReadConfigFile() As Boolean | |
| Me.endPoint = ConfigurationManager.AppSettings("endPoint") | |
| If String.IsNullOrEmpty(Me.endPoint) Then | |
| getDCError = "endPoint is not defined in configuration file" | |
| Return False | |
| End If | |
| Me.apiKey = ConfigurationManager.AppSettings("apiKey") | |
| If String.IsNullOrEmpty(Me.apiKey) Then | |
| getDCError = "apiKey is not defined in configuration file" | |
| Return False | |
| End If | |
| Me.secretKey = ConfigurationManager.AppSettings("secretKey") | |
| If String.IsNullOrEmpty(Me.secretKey) Then | |
| getDCError = "secretKey is not defined in configuration file" | |
| Return False | |
| End If | |
| Me.authorizeRedirectUri = ConfigurationManager.AppSettings("authorizeRedirectUri") | |
| If String.IsNullOrEmpty(Me.authorizeRedirectUri) Then | |
| getDCError = "authorizeRedirectUri is not defined in configuration file" | |
| Return False | |
| End If | |
| Me.scope = ConfigurationManager.AppSettings("scope") | |
| If String.IsNullOrEmpty(Me.scope) Then | |
| Me.scope = "DC" | |
| End If | |
| If Not String.IsNullOrEmpty(ConfigurationManager.AppSettings("SourceLink")) Then | |
| SourceLink.HRef = ConfigurationManager.AppSettings("SourceLink") | |
| Else | |
| ' Default value | |
| SourceLink.HRef = "#" | |
| End If | |
| If Not String.IsNullOrEmpty(ConfigurationManager.AppSettings("DownloadLink")) Then | |
| DownloadLink.HRef = ConfigurationManager.AppSettings("DownloadLink") | |
| Else | |
| ' Default value | |
| DownloadLink.HRef = "#" | |
| End If | |
| If Not String.IsNullOrEmpty(ConfigurationManager.AppSettings("HelpLink")) Then | |
| HelpLink.HRef = ConfigurationManager.AppSettings("HelpLink") | |
| Else | |
| ' Default value | |
| HelpLink.HRef = "#" | |
| End If | |
| Return True | |
| End Function | |
| ''' <summary> | |
| ''' This method gets access token based on either client credentials mode or refresh token. | |
| ''' </summary> | |
| ''' <param name="type">AccessTokenType; either Client_Credential or Refresh_Token</param> | |
| ''' <returns>true/false; true if able to get access token, else false</returns> | |
| Private Function GetAccessToken(type As AccessTokenType) As Boolean | |
| Dim postStream As Stream = Nothing | |
| Dim streamWriter As StreamWriter = Nothing | |
| Dim fileStream As FileStream = Nothing | |
| Try | |
| Dim currentServerTime As DateTime = DateTime.UtcNow.ToLocalTime() | |
| Dim accessTokenRequest As WebRequest = System.Net.HttpWebRequest.Create(String.Empty & Me.endPoint & "/oauth/token") | |
| accessTokenRequest.Method = "POST" | |
| Dim oauthParameters As String = String.Empty | |
| If type = AccessTokenType.Authorize_Credential Then | |
| oauthParameters = "client_id=" & Me.apiKey.ToString() & "&client_secret=" & Me.secretKey & "&code=" & Me.authCode & "&grant_type=authorization_code&scope=" & Me.scope | |
| Else | |
| oauthParameters = "grant_type=refresh_token&client_id=" & Me.apiKey & "&client_secret=" & Me.secretKey & "&refresh_token=" & Me.refreshToken | |
| End If | |
| accessTokenRequest.ContentType = "application/x-www-form-urlencoded" | |
| Dim encoding As New UTF8Encoding() | |
| Dim postBytes As Byte() = encoding.GetBytes(oauthParameters) | |
| accessTokenRequest.ContentLength = postBytes.Length | |
| postStream = accessTokenRequest.GetRequestStream() | |
| postStream.Write(postBytes, 0, postBytes.Length) | |
| Dim accessTokenResponse As WebResponse = accessTokenRequest.GetResponse() | |
| Using accessTokenResponseStream As New StreamReader(accessTokenResponse.GetResponseStream()) | |
| Dim jsonAccessToken As String = accessTokenResponseStream.ReadToEnd() | |
| Dim deserializeJsonObject As New JavaScriptSerializer() | |
| Dim deserializedJsonObj As AccessTokenResponse = DirectCast(deserializeJsonObject.Deserialize(jsonAccessToken, GetType(AccessTokenResponse)), AccessTokenResponse) | |
| Dim accessTokenExpireTime As DateTime = DateTime.Now | |
| Session("Vb_DC_App1_AccessToken") = deserializedJsonObj.access_token.ToString() | |
| Dim expiryMilliSeconds As Double = Convert.ToDouble(deserializedJsonObj.expires_in) | |
| Session("refresh_token") = deserializedJsonObj.refresh_token.ToString() | |
| If expiryMilliSeconds = 0 Then | |
| Session("accessTokenExpireTime") = accessTokenExpireTime.AddYears(100) | |
| Else | |
| Session("accessTokenExpireTime") = accessTokenExpireTime.AddMilliseconds(expiryMilliSeconds) | |
| End If | |
| Return True | |
| End Using | |
| Catch we As WebException | |
| Dim errorResponse As String = String.Empty | |
| Try | |
| Using sr2 As New StreamReader(we.Response.GetResponseStream()) | |
| errorResponse = sr2.ReadToEnd() | |
| sr2.Close() | |
| End Using | |
| Catch | |
| errorResponse = "Unable to get response" | |
| End Try | |
| getDCError = errorResponse & Environment.NewLine & we.Message | |
| Catch ex As Exception | |
| getDCError = ex.Message | |
| Finally | |
| If postStream IsNot Nothing Then | |
| postStream.Close() | |
| End If | |
| If streamWriter IsNot Nothing Then | |
| streamWriter.Close() | |
| End If | |
| If fileStream IsNot Nothing Then | |
| fileStream.Close() | |
| End If | |
| End Try | |
| Return False | |
| End Function | |
| ''' <summary> | |
| ''' Redirects to authentication server to get the access code | |
| ''' </summary> | |
| Private Sub GetAuthCode() | |
| Session("vb_dc_state") = "FetchAuthCode" | |
| Response.Redirect(Me.endPoint & "/oauth/authorize?scope=" & Me.scope & "&client_id=" & Me.apiKey & "&redirect_url=" & Me.authorizeRedirectUri) | |
| End Sub | |
| ''' <summary> | |
| ''' This method invokes DeviceInfo API of AT&T platform to get the device information. | |
| ''' </summary> | |
| Private Sub GetDeviceInfo() | |
| Try | |
| Dim deviceInfoRequestObject As HttpWebRequest = DirectCast(System.Net.WebRequest.Create(Me.endPoint & "/rest/2/Devices/Info"), HttpWebRequest) | |
| deviceInfoRequestObject.Method = "GET" | |
| deviceInfoRequestObject.Headers.Add("Authorization", "Bearer " & Convert.ToString(Session("Vb_DC_App1_AccessToken"))) | |
| Dim deviceInfoResponse As HttpWebResponse = DirectCast(deviceInfoRequestObject.GetResponse(), HttpWebResponse) | |
| Using accessTokenResponseStream As New StreamReader(deviceInfoResponse.GetResponseStream()) | |
| Dim deviceInfo_jsonObj As String = accessTokenResponseStream.ReadToEnd() | |
| Dim deserializeJsonObject As New JavaScriptSerializer() | |
| Dim dict As Dictionary(Of String, Object) = deserializeJsonObject.Deserialize(Of Dictionary(Of String, Object))(deviceInfo_jsonObj) | |
| DisplayDictionary(dict) | |
| getDCSuccess = "success" | |
| End Using | |
| Catch we As WebException | |
| Dim errorResponse As String = String.Empty | |
| Try | |
| Using sr2 As New StreamReader(we.Response.GetResponseStream()) | |
| errorResponse = sr2.ReadToEnd() | |
| sr2.Close() | |
| End Using | |
| Catch | |
| errorResponse = "Unable to get response" | |
| End Try | |
| getDCError = errorResponse & Environment.NewLine & we.Message | |
| Catch ex As Exception | |
| getDCError = ex.Message | |
| End Try | |
| End Sub | |
| #End Region | |
| Private Sub DisplayDictionary(dict As Dictionary(Of String, Object)) | |
| For Each strKey As String In dict.Keys | |
| Dim strOutput As String = "".PadLeft(indentLevel * 8) & strKey & ":" | |
| Dim o As Object = dict(strKey) | |
| If TypeOf o Is Dictionary(Of String, Object) Then | |
| DisplayDictionary(DirectCast(o, Dictionary(Of String, Object))) | |
| ElseIf TypeOf o Is ArrayList Then | |
| For Each oChild As Object In DirectCast(o, ArrayList) | |
| If TypeOf oChild Is String Then | |
| 'tbOutput = tbOutput + strOutput + ","; | |
| strOutput = DirectCast(oChild, String) | |
| ElseIf TypeOf oChild Is Dictionary(Of String, Object) Then | |
| 'tbOutput = tbOutput + "\r\n"; | |
| DisplayDictionary(DirectCast(oChild, Dictionary(Of String, Object))) | |
| End If | |
| Next | |
| Else | |
| 'strOutput = o.ToString(); | |
| getDCResponse.Add(strKey.ToString(), o.ToString()) | |
| End If | |
| Next | |
| End Sub | |
| End Class | |
| #Region "Access Token Data Structure" | |
| ''' <summary> | |
| ''' AccessTokenResponse Object, returned upon calling get auth token api. | |
| ''' </summary> | |
| Public Class AccessTokenResponse | |
| ''' <summary> | |
| ''' Gets or sets the value of access_token | |
| ''' </summary> | |
| Public Property access_token() As String | |
| Get | |
| Return m_access_token | |
| End Get | |
| Set(value As String) | |
| m_access_token = Value | |
| End Set | |
| End Property | |
| Private m_access_token As String | |
| ''' <summary> | |
| ''' Gets or sets the value of refresh_token | |
| ''' </summary> | |
| Public Property refresh_token() As String | |
| Get | |
| Return m_refresh_token | |
| End Get | |
| Set(value As String) | |
| m_refresh_token = Value | |
| End Set | |
| End Property | |
| Private m_refresh_token As String | |
| ''' <summary> | |
| ''' Gets or sets the value of expires_in | |
| ''' </summary> | |
| Public Property expires_in() As String | |
| Get | |
| Return m_expires_in | |
| End Get | |
| Set(value As String) | |
| m_expires_in = Value | |
| End Set | |
| End Property | |
| Private m_expires_in As String | |
| End Class | |
| #End Region | |
| #Region "Device Capabilities Response Structure" | |
| ''' <summary> | |
| ''' This object is used to return the Device Capabilities details from the network for a particular mobile terminal. | |
| ''' </summary> | |
| Public Class DeviceCapabilities | |
| ''' <summary> | |
| ''' Gets or sets the value of DeviceInfo object. | |
| ''' This Root Object will return two nested objects i-e DeviceId and Capabilities. | |
| ''' </summary> | |
| Public Property DeviceInfo() As DeviceInfo | |
| Get | |
| Return m_DeviceInfo | |
| End Get | |
| Set(value As DeviceInfo) | |
| m_DeviceInfo = Value | |
| End Set | |
| End Property | |
| Private m_DeviceInfo As DeviceInfo | |
| End Class | |
| ''' <summary> | |
| ''' Encapsulates the device capabilities response from API gateway. | |
| ''' </summary> | |
| Public Class DeviceInfo | |
| ''' <summary> | |
| ''' Gets or sets the value of DeviceId. | |
| ''' </summary> | |
| Public Property DeviceId() As DeviceId | |
| Get | |
| Return m_DeviceId | |
| End Get | |
| Set(value As DeviceId) | |
| m_DeviceId = Value | |
| End Set | |
| End Property | |
| Private m_DeviceId As DeviceId | |
| ''' <summary> | |
| ''' Gets or sets the value of Capabilities object. | |
| ''' </summary> | |
| Public Property Capabilities() As Capabilities | |
| Get | |
| Return m_Capabilities | |
| End Get | |
| Set(value As Capabilities) | |
| m_Capabilities = Value | |
| End Set | |
| End Property | |
| Private m_Capabilities As Capabilities | |
| End Class | |
| ''' <summary> | |
| ''' Encapsulates the first 8 digits of the IMEI of the mobile device. | |
| ''' </summary> | |
| Public Class DeviceId | |
| ''' <summary> | |
| ''' Gets or sets the value of TypeAllocationCode. | |
| ''' This will return ONLY the first 8 digits of the International Mobile Equipment Identity of the mobile device in question. | |
| ''' </summary> | |
| Public Property TypeAllocationCode() As String | |
| Get | |
| Return m_TypeAllocationCode | |
| End Get | |
| Set(value As String) | |
| m_TypeAllocationCode = Value | |
| End Set | |
| End Property | |
| Private m_TypeAllocationCode As String | |
| End Class | |
| ''' <summary> | |
| ''' Capabilities object is returned as part of Device #Capabilities AT&T's API. | |
| ''' The Device Capabilities attributes, which include Name, Vendor, Model, FirmwareVersion, | |
| ''' UaProf, MmsCapable, AssistedGps, Location Technology, Device Browser and WAP Push Capable to | |
| ''' allow developers to deliver applications that are tailored to a specific customer device. | |
| ''' </summary> | |
| Public Class Capabilities | |
| ''' <summary> | |
| ''' Gets or sets the value of Name. | |
| ''' AT&T's abbreviated code for the mobile device manufacturer and model number. These may or may not correspond to the device manufacturer's name and model number provided in the href. | |
| ''' </summary> | |
| Public Property Name() As String | |
| Get | |
| Return m_Name | |
| End Get | |
| Set(value As String) | |
| m_Name = Value | |
| End Set | |
| End Property | |
| Private m_Name As String | |
| ''' <summary> | |
| ''' Gets or sets the value of Vendor. | |
| ''' AT&T's abbreviated code for the mobile device manufacturer. | |
| ''' </summary> | |
| Public Property Vendor() As String | |
| Get | |
| Return m_Vendor | |
| End Get | |
| Set(value As String) | |
| m_Vendor = Value | |
| End Set | |
| End Property | |
| Private m_Vendor As String | |
| ''' <summary> | |
| ''' Gets or sets the value of Model. | |
| ''' AT&T's model number for the mobile device. | |
| ''' </summary> | |
| Public Property Model() As String | |
| Get | |
| Return m_Model | |
| End Get | |
| Set(value As String) | |
| m_Model = Value | |
| End Set | |
| End Property | |
| Private m_Model As String | |
| ''' <summary> | |
| ''' Gets or sets the value of FirmwareVersion. | |
| ''' AT&T's shall map the AT&T's specific device firmware release number (if available) to this parameter. | |
| ''' This may or may not correspond to the mobile device manufacturer's firmware release numbers. | |
| ''' </summary> | |
| Public Property FirmwareVersion() As String | |
| Get | |
| Return m_FirmwareVersion | |
| End Get | |
| Set(value As String) | |
| m_FirmwareVersion = Value | |
| End Set | |
| End Property | |
| Private m_FirmwareVersion As String | |
| ''' <summary> | |
| ''' Gets or sets the value of UaProf. | |
| ''' Contains a URL to the device manufacturer website which may provide specific | |
| ''' capability details for the mobile device in the request. | |
| ''' </summary> | |
| Public Property UaProf() As String | |
| Get | |
| Return m_UaProf | |
| End Get | |
| Set(value As String) | |
| m_UaProf = Value | |
| End Set | |
| End Property | |
| Private m_UaProf As String | |
| ''' <summary> | |
| ''' Gets or sets the value of MmsCapable. | |
| ''' A value that indicates whether the device is MMS capable “Y” or “N”. | |
| ''' </summary> | |
| Public Property MmsCapable() As String | |
| Get | |
| Return m_MmsCapable | |
| End Get | |
| Set(value As String) | |
| m_MmsCapable = Value | |
| End Set | |
| End Property | |
| Private m_MmsCapable As String | |
| ''' <summary> | |
| ''' Gets or sets the value of AssistedGps. | |
| ''' A value that indicates whether the device is assisted-GPS capable “Y” or “N”. | |
| ''' </summary> | |
| Public Property AssistedGps() As String | |
| Get | |
| Return m_AssistedGps | |
| End Get | |
| Set(value As String) | |
| m_AssistedGps = Value | |
| End Set | |
| End Property | |
| Private m_AssistedGps As String | |
| ''' <summary> | |
| ''' Gets or sets the value of LocationTechnology. | |
| ''' A value that indicates the location technology network that is supported by the device. | |
| ''' The value is expressed in terms of network Location service technology types (i.e. “SUPL” or “SUPL2”) as supporting the Location query on 3G devices and 4G (LTE) devices respectively. | |
| ''' </summary> | |
| Public Property LocationTechnology() As String | |
| Get | |
| Return m_LocationTechnology | |
| End Get | |
| Set(value As String) | |
| m_LocationTechnology = Value | |
| End Set | |
| End Property | |
| Private m_LocationTechnology As String | |
| ''' <summary> | |
| ''' Gets or sets the value of DeviceBrowser. | |
| ''' A value that indicates the name of the browser that is resident on the device e.g. “RIM” for Blackberry devices. | |
| ''' </summary> | |
| Public Property DeviceBrowser() As String | |
| Get | |
| Return m_DeviceBrowser | |
| End Get | |
| Set(value As String) | |
| m_DeviceBrowser = Value | |
| End Set | |
| End Property | |
| Private m_DeviceBrowser As String | |
| ''' <summary> | |
| ''' Gets or sets the value of WAPPushCapable. | |
| ''' A value that indicates whether the device is WAP Push capable “Y” or “N”. | |
| ''' </summary> | |
| Public Property WapPushCapable() As String | |
| Get | |
| Return m_WapPushCapable | |
| End Get | |
| Set(value As String) | |
| m_WapPushCapable = Value | |
| End Set | |
| End Property | |
| Private m_WapPushCapable As String | |
| End Class | |
| #End Region |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0"?> | |
| <!-- | |
| For more information on how to configure your ASP.NET application, please | |
| visit http://go.microsoft.com/fwlink/?LinkId=169433 | |
| --> | |
| <configuration> | |
| <system.web> | |
| <compilation debug="true" targetFramework="4.0"/> | |
| <customErrors mode="Off"/> | |
| </system.web> | |
| <appSettings> | |
| <!-- Set this parameter value to "true", if you need to bypass the SSL certificate. Default FALSE --> | |
| <add key="IgnoreSSL" value="false"/> | |
| <!-- This is mandatory key and value should be equal | |
| to DC Service registered application 'API key' | |
| example: value=""--> | |
| <add key="apikey" value=""/> | |
| <!-- This is mandatory key and value should be equal | |
| to DC Service registered application 'Secret key' | |
| example: value=""--> | |
| <add key="secretkey" value=""/> | |
| <!-- This is mandatory key and value should be equal | |
| to https://api.att.com for production environment or | |
| https://api-uat.san1.attcompute.com for uat environment | |
| example: value="https://api-uat.san1.attcompute.com"--> | |
| <add key="endPoint" value="" /> | |
| <!-- This is mandatory key and value should be equal | |
| to DC Service registered application 'OAuth Redirect URL' | |
| example: value="https://IIS-Server/webroot/dc/app1/Default.aspx"--> | |
| <add key="authorizeRedirectUri" value=""/> | |
| <!-- This is mandatory key and value should be equal | |
| to DC Service registered application scope--> | |
| <add key="scope" value="DC"/> | |
| <!-- This is an optional key, which points to the file path, and | |
| application uses this key's value to create/update the file | |
| with access token information, so, make sure to give write access | |
| to the folder defined. | |
| If the key is not defined, DCApp1AccessToken.txt will be created | |
| at root folder, so, make sure to give write access to the root folder. | |
| example: value="DCApp1AccessToken.txt" --> | |
| <add key="AccessTokenFilePath" value ="DCApp1AccessToken.txt"/> | |
| <!-- This is optional key, which specifies the expiry time of refresh | |
| token in Hrs. Default value is 24Hrs. | |
| example: value="24"--> | |
| <add key="refreshTokenExpiresIn" value="24"/> | |
| <add key="SourceLink" value=""/> | |
| <add key="DownloadLink" value=""/> | |
| <add key="HelpLink" value=""/> | |
| </appSettings> | |
| </configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment