Skip to content

Commit c1ddce9

Browse files
committed
removed vcap commented code from examples, remove unnecessary imports from examples
1 parent 2d8fdf9 commit c1ddce9

18 files changed

+18
-645
lines changed

Examples/ServiceExamples/Scripts/ExampleAlchemyDataNews.cs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,11 @@
2121
using IBM.Watson.DeveloperCloud.Logging;
2222
using IBM.Watson.DeveloperCloud.Utilities;
2323
using System.Collections;
24-
using FullSerializer;
25-
using System.IO;
26-
using System;
2724

2825
public class ExampleAlchemyDataNews : MonoBehaviour
2926
{
3027
private string _apikey = null;
3128
private string _url = null;
32-
//private fsSerializer _serializer = new fsSerializer();
3329

3430
private AlchemyAPI _alchemyAPI = null;
3531

@@ -39,33 +35,6 @@ void Start()
3935
{
4036
LogSystem.InstallDefaultReactors();
4137

42-
//VcapCredentials vcapCredentials = new VcapCredentials();
43-
//fsData data = null;
44-
45-
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
46-
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
47-
//var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
48-
//var fileContent = File.ReadAllText(environmentalVariable);
49-
50-
//// Add in a parent object because Unity does not like to deserialize root level collection types.
51-
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
52-
53-
//// Convert json to fsResult
54-
//fsResult r = fsJsonParser.Parse(fileContent, out data);
55-
//if (!r.Succeeded)
56-
// throw new WatsonException(r.FormattedMessages);
57-
58-
//// Convert fsResult to VcapCredentials
59-
//object obj = vcapCredentials;
60-
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
61-
//if (!r.Succeeded)
62-
// throw new WatsonException(r.FormattedMessages);
63-
64-
//// Set credentials from imported credntials
65-
//Credential credential = vcapCredentials.VCAP_SERVICES["alchemy_api"][0].Credentials;
66-
//_apikey = credential.Apikey.ToString();
67-
//_url = credential.Url.ToString();
68-
6938
// Create credential and instantiate service
7039
Credentials credentials = new Credentials(_apikey, _url);
7140

Examples/ServiceExamples/Scripts/ExampleAlchemyLanguage.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public class ExampleAlchemyLanguage : MonoBehaviour
2828
{
2929
private string _apikey = null;
3030
private string _url = null;
31-
//private fsSerializer _serializer = new fsSerializer();
3231

3332
private AlchemyAPI _alchemyAPI;
3433

@@ -106,33 +105,6 @@ void Start()
106105
{
107106
LogSystem.InstallDefaultReactors();
108107

109-
//VcapCredentials vcapCredentials = new VcapCredentials();
110-
//fsData data = null;
111-
112-
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
113-
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
114-
//var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
115-
//var fileContent = File.ReadAllText(environmentalVariable);
116-
117-
//// Add in a parent object because Unity does not like to deserialize root level collection types.
118-
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
119-
120-
//// Convert json to fsResult
121-
//fsResult r = fsJsonParser.Parse(fileContent, out data);
122-
//if (!r.Succeeded)
123-
// throw new WatsonException(r.FormattedMessages);
124-
125-
//// Convert fsResult to VcapCredentials
126-
//object obj = vcapCredentials;
127-
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
128-
//if (!r.Succeeded)
129-
// throw new WatsonException(r.FormattedMessages);
130-
131-
//// Set credentials from imported credntials
132-
//Credential credential = vcapCredentials.VCAP_SERVICES["alchemy_api"][0].Credentials;
133-
//_apikey = credential.Apikey.ToString();
134-
//_url = credential.Url.ToString();
135-
136108
// Create credential and instantiate service
137109
Credentials credentials = new Credentials(_apikey, _url);
138110

Examples/ServiceExamples/Scripts/ExampleConversation.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
using IBM.Watson.DeveloperCloud.Services.Conversation.v1;
2020
using IBM.Watson.DeveloperCloud.Utilities;
2121
using IBM.Watson.DeveloperCloud.Logging;
22-
using System;
2322
using System.Collections;
2423
using FullSerializer;
25-
using System.IO;
2624
using System.Collections.Generic;
2725

2826
public class ExampleConversation : MonoBehaviour
@@ -31,7 +29,6 @@ public class ExampleConversation : MonoBehaviour
3129
private string _password = null;
3230
private string _url = null;
3331
private string _workspaceId = null;
34-
//private string _token = "<authentication-token>";
3532

3633
private Conversation _conversation;
3734
private string _conversationVersionDate = "2017-05-26";
@@ -46,44 +43,9 @@ void Start()
4643
{
4744
LogSystem.InstallDefaultReactors();
4845

49-
//VcapCredentials vcapCredentials = new VcapCredentials();
50-
//fsData data = null;
51-
52-
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
53-
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
54-
//var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
55-
//var fileContent = File.ReadAllText(environmentalVariable);
56-
57-
//// Add in a parent object because Unity does not like to deserialize root level collection types.
58-
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
59-
60-
//// Convert json to fsResult
61-
//fsResult r = fsJsonParser.Parse(fileContent, out data);
62-
//if (!r.Succeeded)
63-
// throw new WatsonException(r.FormattedMessages);
64-
65-
//// Convert fsResult to VcapCredentials
66-
//object obj = vcapCredentials;
67-
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
68-
//if (!r.Succeeded)
69-
// throw new WatsonException(r.FormattedMessages);
70-
71-
//// Set credentials from imported credntials
72-
//Credential credential = vcapCredentials.VCAP_SERVICES["conversation"][1].Credentials;
73-
//_username = credential.Username.ToString();
74-
//_password = credential.Password.ToString();
75-
//_url = credential.Url.ToString();
76-
//_workspaceId = credential.WorkspaceId.ToString();
77-
7846
// Create credential and instantiate service
7947
Credentials credentials = new Credentials(_username, _password, _url);
8048

81-
// Or authenticate using token
82-
//Credentials credentials = new Credentials(_url)
83-
//{
84-
// AuthenticationToken = _token
85-
//};
86-
8749
_conversation = new Conversation(credentials);
8850
_conversation.VersionDate = _conversationVersionDate;
8951

Examples/ServiceExamples/Scripts/ExampleDiscoveryV1.cs

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,18 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
using FullSerializer;
1817
using IBM.Watson.DeveloperCloud.Logging;
1918
using IBM.Watson.DeveloperCloud.Services.Discovery.v1;
2019
using IBM.Watson.DeveloperCloud.Utilities;
2120
using System.Collections;
22-
using System.IO;
2321
using UnityEngine;
2422

2523
public class ExampleDiscoveryV1 : MonoBehaviour
2624
{
2725
private string _username = null;
2826
private string _password = null;
2927
private string _url = null;
30-
//private fsSerializer _serializer = new fsSerializer();
31-
//private string _token = "<authentication-token>";
32-
28+
3329
private Discovery _discovery;
3430
private string _discoveryVersionDate = "2016-12-01";
3531

@@ -71,43 +67,9 @@ private void Start()
7167
{
7268
LogSystem.InstallDefaultReactors();
7369

74-
//VcapCredentials vcapCredentials = new VcapCredentials();
75-
//fsData data = null;
76-
77-
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
78-
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
79-
//var environmentalVariable = System.Environment.GetEnvironmentVariable("VCAP_SERVICES");
80-
//var fileContent = File.ReadAllText(environmentalVariable);
81-
82-
//// Add in a parent object because Unity does not like to deserialize root level collection types.
83-
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
84-
85-
//// Convert json to fsResult
86-
//fsResult r = fsJsonParser.Parse(fileContent, out data);
87-
//if (!r.Succeeded)
88-
// throw new WatsonException(r.FormattedMessages);
89-
90-
//// Convert fsResult to VcapCredentials
91-
//object obj = vcapCredentials;
92-
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
93-
//if (!r.Succeeded)
94-
// throw new WatsonException(r.FormattedMessages);
95-
96-
//// Set credentials from imported credntials
97-
//Credential credential = vcapCredentials.VCAP_SERVICES["discovery"][0].Credentials;
98-
//_username = credential.Username.ToString();
99-
//_password = credential.Password.ToString();
100-
//_url = credential.Url.ToString();
101-
10270
// Create credential and instantiate service
10371
Credentials credentials = new Credentials(_username, _password, _url);
10472

105-
// Or authenticate using token
106-
//Credentials credentials = new Credentials(_url)
107-
//{
108-
// AuthenticationToken = _token
109-
//};
110-
11173
_discovery = new Discovery(credentials);
11274
_discovery.VersionDate = _discoveryVersionDate;
11375
_configurationJsonPath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/Discovery/exampleConfigurationData.json";

Examples/ServiceExamples/Scripts/ExampleDocumentConversion.cs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
using IBM.Watson.DeveloperCloud.Services.DocumentConversion.v1;
2020
using IBM.Watson.DeveloperCloud.Logging;
2121
using IBM.Watson.DeveloperCloud.Utilities;
22-
using FullSerializer;
23-
using System;
24-
using System.IO;
2522
using System.Collections;
2623

2724
public class ExampleDocumentConversion : MonoBehaviour
@@ -30,9 +27,7 @@ public class ExampleDocumentConversion : MonoBehaviour
3027
private string _username = null;
3128
private string _password = null;
3229
private string _url = null;
33-
//private fsSerializer _serializer = new fsSerializer();
34-
//private string _token = "<authentication-token>";
35-
30+
3631
private string _examplePath;
3732
private string _conversionTarget = ConversionTarget.NormalizedHtml;
3833
private bool _convertDocumentTested = false;
@@ -41,43 +36,9 @@ void Start()
4136
{
4237
LogSystem.InstallDefaultReactors();
4338

44-
//VcapCredentials vcapCredentials = new VcapCredentials();
45-
//fsData data = null;
46-
47-
//// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
48-
//// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
49-
//var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
50-
//var fileContent = File.ReadAllText(environmentalVariable);
51-
52-
//// Add in a parent object because Unity does not like to deserialize root level collection types.
53-
//fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
54-
55-
//// Convert json to fsResult
56-
//fsResult r = fsJsonParser.Parse(fileContent, out data);
57-
//if (!r.Succeeded)
58-
// throw new WatsonException(r.FormattedMessages);
59-
60-
//// Convert fsResult to VcapCredentials
61-
//object obj = vcapCredentials;
62-
//r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
63-
//if (!r.Succeeded)
64-
// throw new WatsonException(r.FormattedMessages);
65-
66-
//// Set credentials from imported credntials
67-
//Credential credential = vcapCredentials.VCAP_SERVICES["document_conversion"][0].Credentials;
68-
//_username = credential.Username.ToString();
69-
//_password = credential.Password.ToString();
70-
//_url = credential.Url.ToString();
71-
7239
// Create credential and instantiate service
7340
Credentials credentials = new Credentials(_username, _password, _url);
7441

75-
// Or authenticate using token
76-
//Credentials credentials = new Credentials(_url)
77-
//{
78-
// AuthenticationToken = _token
79-
//};
80-
8142
_documentConversion = new DocumentConversion(credentials);
8243
_examplePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/watson_beats_jeopardy.html";
8344

Examples/ServiceExamples/Scripts/ExampleGetToken.cs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,18 @@
1515
*
1616
*/
1717

18-
using FullSerializer;
1918
using IBM.Watson.DeveloperCloud.Logging;
2019
using IBM.Watson.DeveloperCloud.Services.Conversation.v1;
2120
using IBM.Watson.DeveloperCloud.Utilities;
22-
using System;
2321
using System.Collections;
24-
using System.IO;
2522
using UnityEngine;
2623

2724
public class ExampleGetToken : MonoBehaviour
2825
{
2926
private string _username = null;
3027
private string _password = null;
3128
private string _url = null;
32-
private string _workspaceId;
33-
private fsSerializer _serializer = new fsSerializer();
29+
private string _workspaceId = null;
3430

3531
private AuthenticationToken _authenticationToken;
3632
private bool _receivedAuthToken = false;
@@ -39,38 +35,6 @@ public class ExampleGetToken : MonoBehaviour
3935
void Start ()
4036
{
4137
LogSystem.InstallDefaultReactors();
42-
43-
#region Get credentials from a local file who's path is defined as 'VCAP_SERVICES' in environmental variables
44-
VcapCredentials vcapCredentials = new VcapCredentials();
45-
fsData data = null;
46-
47-
// Get credentials from a credential file defined in environmental variables in the VCAP_SERVICES format.
48-
// See https://www.ibm.com/watson/developercloud/doc/common/getting-started-variables.html.
49-
var environmentalVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
50-
var fileContent = File.ReadAllText(environmentalVariable);
51-
52-
// Add in a parent object because Unity does not like to deserialize root level collection types.
53-
fileContent = Utility.AddTopLevelObjectToJson(fileContent, "VCAP_SERVICES");
54-
55-
// Convert json to fsResult
56-
fsResult r = fsJsonParser.Parse(fileContent, out data);
57-
if (!r.Succeeded)
58-
throw new WatsonException(r.FormattedMessages);
59-
60-
// Convert fsResult to VcapCredentials
61-
object obj = vcapCredentials;
62-
r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
63-
if (!r.Succeeded)
64-
throw new WatsonException(r.FormattedMessages);
65-
66-
// Set credentials from imported credntials
67-
Credential credential = vcapCredentials.VCAP_SERVICES["conversation"][0].Credentials;
68-
_username = credential.Username.ToString();
69-
_password = credential.Password.ToString();
70-
_workspaceId = credential.WorkspaceId.ToString();
71-
_url = credential.Url.ToString();
72-
#endregion
73-
7438
Runnable.Run(Example());
7539
}
7640

Examples/ServiceExamples/Scripts/ExampleLanguageTranslation.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@
2121

2222
public class ExampleLanguageTranslation : MonoBehaviour
2323
{
24-
private LanguageTranslation _translate = new LanguageTranslation(new Credentials());
24+
private LanguageTranslation _languageTranslation;
25+
private string _username = null;
26+
private string _password = null;
27+
private string _url = null;
2528
private string _pharseToTranslate = "How do I get to the disco?";
2629

2730
void Start()
2831
{
32+
// Create credential and instantiate service
33+
Credentials credentials = new Credentials(_username, _password, _url);
34+
_languageTranslation = new LanguageTranslation(credentials);
35+
2936
Debug.Log("English Phrase to translate: " + _pharseToTranslate);
30-
_translate.GetTranslation(_pharseToTranslate, "en", "es", OnGetTranslation);
37+
_languageTranslation.GetTranslation(_pharseToTranslate, "en", "es", OnGetTranslation);
3138
}
3239

3340
private void OnGetTranslation(Translations translation, string customData)

0 commit comments

Comments
 (0)