예제 #1
0
 /// <summary>
 /// Retreives the statements from a continue URL
 /// </summary>
 /// <param name="moreUrl"></param>
 /// <returns></returns>
 public StatementResult GetStatements(string moreUrl)
 {
     string getResult = HttpMethods.GetRequest(null, endpoint.GetLeftPart(UriPartial.Authority) + moreUrl, authentification, versionString);
     TinCanJsonConverter converter = new TinCanJsonConverter();
     StatementResult result = null;
     switch (version)
     {
         case TCAPIVersion.TinCan095:
             result = (StatementResult)converter.DeserializeJSON(getResult, typeof(StatementResult));
             break;
         case TCAPIVersion.TinCan090:
             result = (StatementResult)((Model.TinCan090.StatementResult)converter.DeserializeJSON(getResult, typeof(Model.TinCan090.StatementResult)));
             break;
     }
     return result;
 }
예제 #2
0
 /// <summary>
 /// Retreives a statement with a given ID
 /// </summary>
 /// <param name="statementId">Statement to retreive</param>
 /// <returns>The statement with this ID</returns>
 public Statement GetStatement(string statementId)
 {
     Statement statement = new Statement();
     statement.Id = statementId;
     TinCanJsonConverter converter = new TinCanJsonConverter();
     string statementToGet = converter.SerializeToJSON(statement);
     NameValueCollection nvc = new NameValueCollection();
     nvc["statementId"] = statementId;
     string result = HttpMethods.GetRequest(nvc, endpoint + STATEMENTS, authentification, versionString);
     Statement statementResult = null;
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             statementResult = (Statement)((Model.TinCan090.Statement)converter.DeserializeJSON(result, typeof(Model.TinCan090.Statement)));
             break;
         case TCAPIVersion.TinCan095:
             statementResult = (Statement)converter.DeserializeJSON(result, typeof(Statement));
             break;
     }
     return statementResult;
 }
예제 #3
0
 /// <summary>
 /// Retreives all statements based matched by the query
 /// </summary>
 /// <param name="queryObject">Object to create a statement query with</param>
 /// <returns>A StatementResult with all the statements</returns>
 public StatementResult GetStatements(StatementQueryObject queryObject)
 {
     NameValueCollection nvc = queryObject.ToNameValueCollection(version);
     string resultAsJSON = HttpMethods.GetRequest(nvc, endpoint + STATEMENTS, authentification, versionString);
     TinCanJsonConverter converter = new TinCanJsonConverter();
     StatementResult result = null;
     switch (version)
     {
         case TCAPIVersion.TinCan095:
             result = (StatementResult)converter.DeserializeJSON(resultAsJSON, typeof(StatementResult));
             break;
         case TCAPIVersion.TinCan090:
             result = (StatementResult)((Model.TinCan090.StatementResult)converter.DeserializeJSON(resultAsJSON, typeof(Model.TinCan090.StatementResult)));
             break;
     }
     return result;
 }
예제 #4
0
 /// <summary>
 /// Retrieves a list of all actor profile document keys
 /// </summary>
 /// <param name="actor">The actor that owns the document keys</param>
 /// <param name="since">Optional start date</param>
 /// <returns>An array of profile document keys</returns>
 public string[] GetActorProfileIds(Actor actor, NullableDateTime since)
 {
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     string[] getResult;
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)actor);
             break;
         default:
             nvc["actor"] = converter.SerializeToJSON(actor);
             break;
     }
     if (since != null)
         nvc["since"] = since.Value.ToString(Constants.ISO8601_DATE_FORMAT);
     getResult = (string[])converter.DeserializeJSON(HttpMethods.GetRequest(nvc, endpoint + ACTOR_PROFILE, authentification, versionString), typeof(string[]));
     return getResult;
 }
예제 #5
0
        /// <summary>
        /// Retreives a complete actor given a partial actor
        /// </summary>
        /// <param name="partialActor">An actor containing at least one inverse functional property</param>
        /// <returns></returns>
        public Actor GetActor(Actor partialActor)
        {
            TinCanJsonConverter converter = new TinCanJsonConverter();
            NameValueCollection nvc = new NameValueCollection();
            string getResult;
            Actor result = null;

            switch (version)
            {
                case TCAPIVersion.TinCan090:
                    nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)partialActor);
                    break;
                default:
                    nvc["actor"] = converter.SerializeToJSON(partialActor);
                    break;
            }
            getResult = HttpMethods.GetRequest(nvc, endpoint + ACTORS, authentification, versionString);
            switch (version)
            {
                case TCAPIVersion.TinCan095:
                    result = (Actor)converter.DeserializeJSON(getResult, typeof(Actor));
                    break;
                case TCAPIVersion.TinCan090:
                    result = (Actor)((Model.TinCan090.Actor)converter.DeserializeJSON(getResult, typeof(Model.TinCan090.Actor)));
                    break;
            }

            return result;
        }
예제 #6
0
 /// <summary>
 /// Gets all the activity states for an activity
 /// </summary>
 /// <param name="activityId">The activity ID</param>
 /// <param name="actor">The actor</param>
 /// <param name="registrationId">The registration ID</param>
 /// <param name="since">Exclusive start date</param>
 /// <returns>An array of activity state document keys</returns>
 public string[] GetActivityStateIds(string activityId, Actor actor, string registrationId, NullableDateTime since)
 {
     string[] stateIds;
     string getResult;
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     nvc["activityId"] = activityId;
     switch (version)
     {
         case TCAPIVersion.TinCan090:
             nvc["actor"] = converter.SerializeToJSON((Model.TinCan090.Actor)actor);
             break;
         default:
             nvc["actor"] = converter.SerializeToJSON(actor);
             break;
     }
     if (!string.IsNullOrEmpty(registrationId))
         nvc["registrationId"] = registrationId;
     if (since != null)
         nvc["since"] = since.Value.ToString(Constants.ISO8601_DATE_FORMAT);
     getResult = HttpMethods.GetRequest(nvc, endpoint + ACTIVITY_STATE, authentification, versionString);
     stateIds = (string[])converter.DeserializeJSON(getResult, typeof(string[]));
     return stateIds;
 }
예제 #7
0
 /// <summary>
 /// Gets all of the profile document keys for an activity
 /// </summary>
 /// <param name="activityId">The activity ID</param>
 /// <param name="since">Optional start date parameter</param>
 /// <returns></returns>
 public string[] GetActivityProfileIds(string activityId, NullableDateTime since)
 {
     string[] profileIds;
     string getResult;
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     nvc["activityId"] = activityId;
     if (since != null)
         nvc["since"] = since.Value.ToString(Constants.ISO8601_DATE_FORMAT);
     getResult = HttpMethods.GetRequest(nvc, endpoint + ACTIVITY_PROFILE, authentification, versionString);
     profileIds = (string[])converter.DeserializeJSON(getResult, typeof(string[]));
     return profileIds;
 }
예제 #8
0
 /// <summary>
 /// Gets an Activity
 /// </summary>
 /// <param name="activityId">The activity ID</param>
 /// <returns></returns>
 public Activity GetActivity(string activityId)
 {
     Activity result = new Activity();
     string getResult;
     TinCanJsonConverter converter = new TinCanJsonConverter();
     NameValueCollection nvc = new NameValueCollection();
     nvc["activityId"] = activityId;
     getResult = HttpMethods.GetRequest(nvc, endpoint + ACTIVITY, authentification, versionString);
     result = (Activity)converter.DeserializeJSON(getResult, typeof(Activity));
     return result;
 }