Assets/Watson/Scripts/Services/PersonalityInsights/PersonalityInsights.cs
/// <summary>
/// Uses Personality Insights to get the source profile.
/// </summary>
/// <returns><c>true</c>, if profile was gotten, <c>false</c> otherwise.</returns>
/// <param name="callback">Callback.</param>
/// <param name="source">Json or Text source. Json data must follow the ContentListContainer Model.</param>
/// <param name="contentType">Content mime type.</param>
/// <param name="contentLanguage">Content language.</param>
/// <param name="accept">Accept mime type.</param>
/// <param name="acceptLanguage">Accept language.</param>
/// <param name="includeRaw">If set to <c>true</c> include raw.</param>
/// <param name="headers">If set to <c>true</c> headers.</param>
/// <param name="data">Data.</param>
Uses Personality Insights to get the source profile.
Uses Personality Insights to get the source profile .
public bool GetProfile(OnGetProfile callback, string source, 
            string contentType = ContentType.TEXT_PLAIN, 
            string contentLanguage = Language.ENGLISH, 
            string accept = ContentType.APPLICATION_JSON, 
            string acceptLanguage = Language.ENGLISH, 
            bool includeRaw = false, 
            bool headers = false, 
            string data = default(string))
        {
            if(callback == null)
                throw new ArgumentNullException("callback");
            if(string.IsNullOrEmpty(source))
                throw new ArgumentNullException("A JSON or Text source is required for GetProfile!");
            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_GET_PROFILE);
            if(connector == null)
                return false;
            GetProfileRequest req = new GetProfileRequest();
            req.Callback = callback;
            req.OnResponse = GetProfileResponse;
            req.Parameters["include_raw"] = includeRaw.ToString();
            req.Parameters["headers"] = headers.ToString();
            req.Headers["Content-Type"] = contentType;
            req.Headers["Content-Language"] = contentLanguage;
            req.Headers["Accept"] = accept;
            req.Headers["Accept-Language"] = acceptLanguage;
            if (source.StartsWith(Application.dataPath))
            {
                string jsonData = default(string);
                jsonData = File.ReadAllText(source);
                req.Send = System.Text.Encoding.UTF8.GetBytes(jsonData);
            }
            else
            {
                req.Send = System.Text.Encoding.UTF8.GetBytes(source);
            }
            return connector.Send(req);
        }
public bool GetProfile ( OnGetProfile callback , string source , string contentType = ContentType . TEXT_PLAIN , string contentLanguage = Language . ENGLISH , string accept = ContentType . APPLICATION_JSON , string acceptLanguage = Language . ENGLISH , bool includeRaw = false , bool headers = false , string data = default ( string ) ) { if ( callback == null ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( source ) ) throw new ArgumentNullException ( " " ) ; RESTConnector connector = RESTConnector . GetConnector ( SERVICE_ID , SERVICE_GET_PROFILE ) ; if ( connector == null ) return false ; GetProfileRequest req = new GetProfileRequest ( ) ; req . Callback = callback ; req . OnResponse = GetProfileResponse ; req . Parameters [ " " ] = includeRaw . ToString ( ) ; req . Parameters [ " " ] = headers . ToString ( ) ; req . Headers [ " " ] = contentType ; req . Headers [ " " ] = contentLanguage ; req . Headers [ " " ] = accept ; req . Headers [ " " ] = acceptLanguage ; if ( source . StartsWith ( Application . dataPath ) ) { string jsonData = default ( string ) ; jsonData = File . ReadAllText ( source ) ; req . Send = System . Text . Encoding . UTF8 . GetBytes ( jsonData ) ; } else { req . Send = System . Text . Encoding . UTF8 . GetBytes ( source ) ; } return connector . Send ( req ) ; }
Uses Personality Insights to get the source profile.
Uses Personality Insights to get the source profile .
None
callback
OnGetProfile
None
source
string
Json or Text source. Json data must follow the ContentListContainer Model.
Json or Text source . Json data must follow the ContentListContainer Model .
contentType
string
Content mime type.
Content mime type .
contentLanguage
string
None
accept
string
Accept mime type.
Accept mime type .
acceptLanguage
string
None
includeRaw
bool
If set to true
If set to true
headers
bool
If set to true
If set to true
data
string
None