Пример #1
0
        /// <summary>
        /// Deletes an object.
        /// </summary>
        /// <param name="objcode">
        /// ObjCode of the object to be deleted.
        /// </param>
        /// <param name="parameters">
        /// Object of parameters that will be converted to a string array
        /// </param>
        /// <returns>
        /// JToken of JSON data returned by the server after a delete method API call.
        /// Example: { "data": { "success": true }}
        /// </returns>
        public JToken Delete(ObjCode objcode, object parameters)
        {
            VerifySignedIn();
            string[] p    = parameterObjectToStringArray(parameters);
            JToken   json = client.DoDelete(string.Format("/{0}", objcode), SessionID, p);

            return(json);
        }
Пример #2
0
        /// <summary>
        /// Gets the object of the given ObjCode and the given id
        /// </summary>
        /// <param name="objcode">
        /// A <see cref="ObjCode"/> representing the type of object you are getting
        /// </param>
        /// <param name="id">
        /// String representing the ID of the object you are getting
        /// </param>
        /// <param name="fieldsToInclude">
        /// The name of the fields to include in the results
        /// </param>
        /// <returns>
        /// A <see cref="JToken"/>
        /// </returns>
        public JToken Get(ObjCode objcode, string id, params string[] fieldsToInclude)
        {
            VerifySignedIn();
            List <string> parameters = new List <string>();
            StringBuilder sb         = new StringBuilder();

            if (fieldsToInclude != null && fieldsToInclude.Length > 0)
            {
                fieldsToInclude.ToList().ForEach(s => sb.Append(s).Append(","));
                sb.Remove(sb.Length - 1, 1);
                string fields = "fields=" + sb.ToString();
                parameters.Add(fields);
            }
            JToken json = client.DoGet(string.Format("/{0}/{1}", objcode, id), SessionID, parameters.ToArray());

            return(json);
        }
Пример #3
0
 /// <summary>
 /// Updates an object that already exists.
 /// </summary>
 /// <param name="objcode">
 /// The ObjCode of the object to update
 /// </param>
 /// <param name="parameters">
 /// Additional parameters of the object to update.
 /// </param>
 /// <returns>
 /// A <see cref="JToken"/>
 /// </returns>
 public JToken Update(ObjCode objcode, object parameters)
 {
     try
     {
         VerifySignedIn();
         string[] p    = parameterObjectToStringArray(parameters);
         JToken   json = client.DoPut(string.Format("/{0}", objcode), SessionID, p);
         return(json); //JSON will be null if updates fail
     }
     catch
     {
         // Modified by Arpita Soni for Ticket #2304 on 06/24/2016
         if (objcode != null && objcode.Value.Equals(ObjCode.PROJECT.Value))
         {
             throw new ClientException("Though tactic is pushed successfully, error in updating attributes of tactic.");
         }
         else
         {
             throw new ClientException("Error updating " + objcode + " in Section: Update");
         }
     }
 }