Skip to content

Separate core from services #530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ message = [skip ci] docs: Update version numbers from {current_version} -> {new_

[bumpversion:file:Doxyfile]

[bumpversion:file:Scripts/Utilities/Constants.cs]
[bumpversion:file:Common/Common.cs]
search = {current_version}
replace = {new_version}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Core"]
path = Core
url = [email protected]:mediumTaj/IBM.Cloud.SDK.Unity.git
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ rvm:
cache:
directories:
- ./Unity
git:
submodules: false
before_install:
# Use sed to replace the SSH URL with the public URL, then initialize submodules
- sed -i -e 's/[email protected]:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
- chmod a+x ./Travis/installUnity.sh
- npm install -g [email protected]
install:
Expand All @@ -24,7 +29,7 @@ before_script:
script:
- ./Travis/createProject.sh
- ./Travis/installSDK.sh
- ./Travis/runTests.sh
# - ./Travis/runTests.sh
# - ./Travis/build.sh
deploy:
- provider: script
Expand Down
20 changes: 10 additions & 10 deletions Assistant/v2/Assistant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public AssistantService(Credentials credentials)
}
else
{
throw new WatsonException("Please provide a username and password or authorization token to use the Assistant service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials");
throw new IBMException("Please provide a username and password or authorization token to use the Assistant service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials");
}
}

Expand Down Expand Up @@ -155,7 +155,7 @@ public bool CreateSession(Callback<SessionResponse> callback, String assistantId

private void OnCreateSessionResponse(RESTConnector.Request req, RESTConnector.Response resp)
{
WatsonResponse<SessionResponse> response = new WatsonResponse<SessionResponse>
DetailedResponse<SessionResponse> response = new DetailedResponse<SessionResponse>
{
Result = new SessionResponse()
};
Expand All @@ -168,14 +168,14 @@ private void OnCreateSessionResponse(RESTConnector.Request req, RESTConnector.Re
fsResult r = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data);
if (!r.Succeeded)
{
throw new WatsonException(r.FormattedMessages);
throw new IBMException(r.FormattedMessages);
}

object obj = response.Result;
r = serializer.TryDeserialize(data, obj.GetType(), ref obj);
if (!r.Succeeded)
{
throw new WatsonException(r.FormattedMessages);
throw new IBMException(r.FormattedMessages);
}

customData.Add("json", data);
Expand Down Expand Up @@ -252,7 +252,7 @@ public bool DeleteSession(Callback<object> callback, String assistantId, String

private void OnDeleteSessionResponse(RESTConnector.Request req, RESTConnector.Response resp)
{
WatsonResponse<object> response = new WatsonResponse<object>
DetailedResponse<object> response = new DetailedResponse<object>
{
Result = new object()
};
Expand All @@ -265,14 +265,14 @@ private void OnDeleteSessionResponse(RESTConnector.Request req, RESTConnector.Re
fsResult r = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data);
if (!r.Succeeded)
{
throw new WatsonException(r.FormattedMessages);
throw new IBMException(r.FormattedMessages);
}

object obj = response.Result;
r = serializer.TryDeserialize(data, obj.GetType(), ref obj);
if (!r.Succeeded)
{
throw new WatsonException(r.FormattedMessages);
throw new IBMException(r.FormattedMessages);
}

customData.Add("json", data);
Expand Down Expand Up @@ -363,7 +363,7 @@ public bool Message(Callback<MessageResponse> callback, String assistantId, Stri

private void OnMessageResponse(RESTConnector.Request req, RESTConnector.Response resp)
{
WatsonResponse<MessageResponse> response = new WatsonResponse<MessageResponse>();
DetailedResponse<MessageResponse> response = new DetailedResponse<MessageResponse>();
response.Result = new MessageResponse();
fsData data = null;
Dictionary<string, object> customData = ((RequestObject<MessageResponse>)req).CustomData;
Expand All @@ -378,14 +378,14 @@ private void OnMessageResponse(RESTConnector.Request req, RESTConnector.Response
fsResult r = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data);
if (!r.Succeeded)
{
throw new WatsonException(r.FormattedMessages);
throw new IBMException(r.FormattedMessages);
}

object obj = response.Result;
r = serializer.TryDeserialize(data, obj.GetType(), ref obj);
if (!r.Succeeded)
{
throw new WatsonException(r.FormattedMessages);
throw new IBMException(r.FormattedMessages);
}

customData.Add("json", data);
Expand Down
3 changes: 2 additions & 1 deletion ThirdParty/FullSerializer/Converters.meta → Common.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions Common/Common.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright 2019 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

using IBM.Cloud.SDK.Utilities;
using System.Collections.Generic;
using UnityEngine;

namespace IBM.Watson
{
public class Common : MonoBehaviour
{
/// <summary>
/// The SDK version.
/// </summary>
public const string Version = "watson-apis-unity-sdk-2.12.0";
/// <summary>
/// Tracking for onboarding.
/// </summary>
public const string TrackingQueryParam = "target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Unity";
/// <summary>
/// Returns a set of default headers to use with each request.
/// </summary>
/// <param name="serviceName">The service name to be used in X-IBMCloud-SDK-Analytics header.</param>
/// <param name="serviceVersion">The service version to be used in X-IBMCloud-SDK-Analytics header.</param>
/// <param name="operation">The operation name to be used in X-IBMCloud-SDK-Analytics header.</param>
/// <returns></returns>
public static Dictionary<string, string> GetDefaultheaders(string serviceName, string serviceVersion, string operationId)
{
Dictionary<string, string> defaultHeaders = new Dictionary<string, string>();
defaultHeaders.Add("X-IBMCloud-SDK-Analytics",
string.Format("service_name={0};service_version={1};operation_id={2}",
serviceName,
serviceVersion,
operationId));
defaultHeaders.Add("User-Agent",
string.Format(
"{0} {1} {2} {3}",
Version,
SystemInformation.Os,
SystemInformation.OsVersion,
Application.unityVersion
));
return defaultHeaders;
}
}
}
2 changes: 1 addition & 1 deletion Core/RequestObject.cs.meta → Common/Common.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Core
Submodule Core added at 21800a
79 changes: 0 additions & 79 deletions Core/BaseService.cs

This file was deleted.

29 changes: 0 additions & 29 deletions Core/CallbackDelegates.cs

This file was deleted.

9 changes: 0 additions & 9 deletions Core/Connection.meta

This file was deleted.

Loading