Example #1
0
        public RawApiResponse GetOrganization(string organizationKey)
        {
            int httpStatusCode;
            var json = Http.Get(ApiHandles.GetOrganization.Replace("{organizationKey}", organizationKey), out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #2
0
        /// <summary>
        /// This call lets you edit the value of a field for a particular box.
        /// </summary>
        /// <param name="boxKey">The key of the box</param>
        /// <param name="fieldKey">	The name of the field</param>
        /// <param name="value">The new value for the field.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">
        /// Please specify a box key!
        /// or
        /// Please specify a field key!
        /// </exception>
        public RawApiResponse EditFieldValueForBox(string boxKey, string fieldKey, Person person)
        {
            List <Person> value = new List <Person>();

            value.Add(person);

            if (string.IsNullOrEmpty(boxKey))
            {
                throw new ArgumentNullException(nameof(boxKey), "Please specify a box key!");
            }
            if (string.IsNullOrEmpty(fieldKey))
            {
                throw new ArgumentNullException(nameof(boxKey), "Please specify a field key!");
            }
            var requestJson = JsonConvert.SerializeObject(new
            {
                value
            }, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            int httpStatusCode;
            var json = Http.Post(ApiHandles.EditFieldValue.Replace("{boxKey}", boxKey).Replace("{fieldKey}", fieldKey), requestJson, out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #3
0
        /// <summary>
        /// This call will give the current user (as defined by the API Key)
        /// </summary>
        /// <returns></returns>
        public RawApiResponse GetCurrentUser()
        {
            int httpStatusCode;
            var json = Http.Get(ApiHandles.GetCurrentUser, out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
        public RawApiResponse GetContact(string contactKey)
        {
            int httpStatusCode;
            var json = Http.Get(ApiHandles.GetContact.Replace("{contactKey}", contactKey), out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #5
0
        /// <summary>
        /// This call lets you get all the snippets for a user
        /// </summary>
        /// <returns></returns>
        public RawApiResponse ListSnippets()
        {
            int httpStatusCode;
            var json = Http.Get(ApiHandles.ListSnippets,
                                out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #6
0
        /// <summary>
        /// This call lets you get all boxes that the current user has access to. The boxes returned here are across all pipelines a user has access to. This is a fairly expensive call so there is a lower API quota limit. If possible, get boxes using the pipeline key instead.
        /// </summary>
        /// <returns></returns>
        public RawApiResponse ListAllBoxesUserHasAccessTo()
        {
            int httpStatusCode;
            var json = Http.Get(ApiHandles.ListAllBoxesUserHasAccessTo,
                                out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #7
0
        /// <summary>
        ///This call lets you delete a particular box. It also deletes all of the relevant data such as files, emails, and tasks for that box.
        /// </summary>
        /// <param name="boxKey">The key of the box</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">Please specify a box key!</exception>
        public RawApiResponse DeleteBox(string boxKey)
        {
            if (string.IsNullOrEmpty(boxKey))
            {
                throw new ArgumentNullException(nameof(boxKey), "Please specify a box key!");
            }
            int httpStatusCode;
            var json = Http.Delete(ApiHandles.DeleteBox.Replace("{boxKey}", boxKey), out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #8
0
        /// <summary>
        /// This call will return the details for the user specified. Note, you are only permissted to request users who belong to the same domain as the user making the request.
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <returns></returns>
        public RawApiResponse GetUser(string userKey)
        {
            if (string.IsNullOrEmpty(userKey))
            {
                throw new ArgumentNullException(nameof(userKey), "Please specify a user key!");
            }
            int httpStatusCode;
            var json = Http.Get(ApiHandles.GetUser.Replace("{userKey}", userKey), out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #9
0
        /// <summary>
        /// This call lists the fields defined in a pipeline. Remember, this is only the definition of the fields - to change the value of the field for a specific box, use the edit field for box endpoint.
        /// </summary>
        /// <param name="pipelineKey">The key of the pipeline</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">Please specify a pipeline key!</exception>
        public RawApiResponse ListFieldsInPipeline(string pipelineKey)
        {
            if (string.IsNullOrEmpty(pipelineKey))
            {
                throw new ArgumentNullException(nameof(pipelineKey), "Please specify a pipeline key!");
            }
            int httpStatusCode;
            var json = Http.Get(ApiHandles.ListAllFieldsInPipeline.Replace("{pipelineKey}", pipelineKey),
                                out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #10
0
        /// <summary>
        /// This call lists the field values for the box specified.
        /// Note: for fields that have no value set, the value property is ommitted from the returned JSON
        /// </summary>
        /// <param name="boxKey">The key of the box</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">Please specify a box key!</exception>
        public RawApiResponse ListFieldValuesForBox(string boxKey)
        {
            if (string.IsNullOrEmpty(boxKey))
            {
                throw new ArgumentNullException(nameof(boxKey), "Please specify a box key!");
            }
            var handle = ApiHandles.ListFieldValues.Replace("{boxKey}", boxKey);
            int httpStatusCode;
            var json = Http.Get(handle,
                                out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #11
0
        /// <summary>
        /// This call lets you get a single snippet.
        /// </summary>
        /// <param name="snippetKey">The key of the pipeline</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">Please specify a snippet key!</exception>
        public RawApiResponse GetSnippet(string snippetKey)
        {
            if (string.IsNullOrEmpty(snippetKey))
            {
                throw new ArgumentNullException(nameof(snippetKey), "Please specify a snippet key!");
            }
            var handle = ApiHandles.GetField.Replace("{SNIPPET_KEY}", snippetKey);
            int httpStatusCode;
            var json = Http.Get(handle,
                                out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #12
0
        /// <summary>
        /// This call lets you get a specific thread.
        /// </summary>
        /// <param name="threadKey">The key of the thread.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">Please specify a thread key!</exception>
        public RawApiResponse GetThread(string threadKey)
        {
            if (string.IsNullOrEmpty(threadKey))
            {
                throw new ArgumentNullException(nameof(threadKey), "Please specify a thread key!");
            }
            var handle = ApiHandles.GetThread.Replace("{threadKey}", threadKey);
            int httpStatusCode;
            var json = Http.Get(handle,
                                out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #13
0
        /// <summary>
        /// This call lets you create a comment associated with a particular box.
        /// </summary>
        /// <param name="boxKey">The key of the box for which you want the threads listed</param>
        /// <param name="message">The message content of the comment</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">Please specify a box key!</exception>
        public RawApiResponse CreateComment(string boxKey, string message)
        {
            if (string.IsNullOrEmpty(boxKey))
            {
                throw new ArgumentNullException(nameof(boxKey), "Please specify a box key!");
            }
            var collection = HttpUtility.ParseQueryString(string.Empty);

            collection.Add("message", message);
            int httpStatusCode;
            var json = Http.Put(ApiHandles.CreateComment.Replace("{boxKey}", boxKey), collection.ToString(), out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #14
0
        /// <summary>
        /// This call will give you access to all pipelines the user of this API key has access to. The stages and fields properties are embedded in the pipeline object for convenience, however, to update these properties you must use the respective endpoints listed in the Stages and Fields sections.
        /// </summary>
        /// <param name="sortBy">The sort by.</param>
        /// <returns></returns>
        public RawApiResponse ListAllPipelines(SortOptions sortBy = null)
        {
            var handle = ApiHandles.ListAllPipelines;

            if (sortBy != null)
            {
                handle += "?sortBy=" + sortBy.Value;
            }
            int httpStatusCode;
            var json = Http.Get(handle,
                                out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #15
0
        /// <summary>
        /// This call lets you delete a field defined in a pipeline. Note: this will also remove the values of this field for every box in the pipeline.
        /// </summary>
        /// <param name="pipelineKey">The pipeline key.</param>
        /// <param name="fieldKey">The Field key.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">Please specify a pipeline key!</exception>
        /// <exception cref="ArgumentNullException">Please specify a Field key!</exception>
        public RawApiResponse DeleteField(string pipelineKey, string fieldKey)
        {
            if (string.IsNullOrEmpty(pipelineKey))
            {
                throw new ArgumentNullException(nameof(pipelineKey), "Please specify a pipeline key!");
            }
            if (string.IsNullOrEmpty(fieldKey))
            {
                throw new ArgumentNullException(nameof(fieldKey), "Please specify a Field key!");
            }
            int httpStatusCode;
            var json = Http.Delete(ApiHandles.DeleteField.Replace("{pipelineKey}", pipelineKey).Replace("{fieldKey}", fieldKey), out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #16
0
        /// <summary>
        /// This call will give you a single pipeline given the key.
        /// </summary>
        /// <param name="name">The name of the pipeline you are creating</param>
        /// <param name="description">The description of the pipeline that is visible when viewing the pipeline.</param>
        /// <param name="orgWide">Whether the pipeline will be shared with all users in the organization (same domain in email address). (Optional)</param>
        /// <param name="fieldNames">The fields each box within the pipeline can have. Fields should be given as a comma-separated array of names and a comma-separated array of corresponding field types (of equal length). To modify after creation use the Field endpoint. (Convenience, Optional)</param>
        /// <param name="fieldTypes">The fields each box within the pipeline can have. Fields should be given as a comma-separated array of names and a comma-separated array of corresponding field types (of equal length). To modify after creation use the Field endpoint. (Convenience, Optional)</param>
        /// <param name="stageNames">The possible stages a box within a pipeline can be in. Stages should be given as a comma-separated array of names. To modify after creation use the Stage endpoint. (Convenience, Optional)</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">Please specify a JSON object in a string for creating a pipeline</exception>
        public RawApiResponse CreatePipeline(string name, string description, bool orgWide, string[] fieldNames = null, string[] fieldTypes = null, string[] stageNames = null)
        {
            var collection = HttpUtility.ParseQueryString(string.Empty);

            collection.Add("name", name);
            collection.Add("description", description);
            collection.Add("orgWide", orgWide.ToLowerString());
            collection.Add("fieldNames", string.Join(",", fieldNames ?? new string[0]));
            collection.Add("fieldTypes", string.Join(",", fieldTypes ?? new string[0]));
            collection.Add("stageNames", string.Join(",", stageNames ?? new string[0]));
            int httpStatusCode;
            var json = Http.Put(ApiHandles.CreatePipeline, collection.ToString(), out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #17
0
        /// <summary>
        /// This call lets you create a field for a pipeline. This defines the field in the pipeline so that you can add values for that field for each box in the pipeline.
        /// </summary>
        /// <param name="pipelineKey">The key of the pipeline this field should belong to</param>
        /// <param name="name">The name of the field you'd like to add to the pipeline</param>
        /// <param name="fieldType">The type of the field, can be any of: TEXT_INPUT, DATE or PERSON</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">Please specify a pipeline key!</exception>
        /// <exception cref="ArgumentNullException">Please specify a pipeline key!</exception>
        public RawApiResponse CreateField(string pipelineKey, string name, FieldType fieldType)
        {
            if (string.IsNullOrEmpty(pipelineKey))
            {
                throw new ArgumentNullException(nameof(pipelineKey), "Please specify a pipeline key!");
            }
            var collection = HttpUtility.ParseQueryString(string.Empty);

            collection.Add("name", name);
            collection.Add("type", fieldType.Value);
            int httpStatusCode;
            var json = Http.Put(ApiHandles.CreateField.Replace("{pipelineKey}", pipelineKey), collection.ToString(), out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #18
0
        /// <summary>
        /// This call lets you edit the properties of a box.
        /// </summary>
        /// <param name="boxKey">The key of the box to be edited</param>
        /// <param name="name">The name of the box (optional)</param>
        /// <param name="notes">The notes of the box (optional)</param>
        /// <param name="stageKey">The key of the stage that this box should be in. A list of valid stage keys can be found from the pipeline that this box belongs to (optional)</param>
        /// <param name="followerKeys">A JSON array of user keys who are following this box. When a user follows a box, they receive notification emails upon major changes to the box (optional)</param>
        /// <returns></returns>
        public RawApiResponse EditBox(string boxKey, string name = null, string notes = null, string stageKey = null, string[] followerKeys = null)
        {
            var requestJson = JsonConvert.SerializeObject(new
            {
                name,
                notes,
                stageKey,
                followerKeys
            }, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            int httpStatusCode;
            var json = Http.Post(ApiHandles.EditBox.Replace("{boxKey}", boxKey), requestJson, out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #19
0
        /// <summary>
        /// This call gives you a specific stage defined in a pipeline
        /// </summary>
        /// <param name="pipelineKey">The key of the pipeline</param>
        /// <param name="stageKey">The key of the stage</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">Please specify a pipeline key!</exception>
        /// <exception cref="ArgumentNullException">Please specify a pipeline key!</exception>
        public RawApiResponse GetStage(string pipelineKey, string stageKey)
        {
            if (string.IsNullOrEmpty(pipelineKey))
            {
                throw new ArgumentNullException(nameof(pipelineKey), "Please specify a pipeline key!");
            }
            if (string.IsNullOrEmpty(stageKey))
            {
                throw new ArgumentNullException(nameof(stageKey), "Please specify a stage key!");
            }
            var handle = ApiHandles.GetStage.Replace("{pipelineKey}", pipelineKey).Replace("{stageKey}", stageKey);
            int httpStatusCode;
            var json = Http.Get(handle,
                                out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #20
0
        /// <summary>
        /// This call lets you get all boxes contained in the specified pipeline.
        /// </summary>
        /// <param name="pipelineKey">The key of the pipeline for which you want the boxes listed</param>
        /// <param name="sortOptions">What order to sort the boxes by. There are two valid sorts creationTimestamp and lastUpdatedTimestamp. Both are in descending order. (optional)</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">Please specify a pipeline key!</exception>
        public RawApiResponse ListAllBoxesInPipeline(string pipelineKey, SortOptions sortOptions = null)
        {
            if (string.IsNullOrEmpty(pipelineKey))
            {
                throw new ArgumentNullException(nameof(pipelineKey), "Please specify a pipeline key!");
            }
            var handle = ApiHandles.ListAllBoxesInPipeline.Replace("{pipelineKey}", pipelineKey);

            if (sortOptions != null)
            {
                handle += "?sortBy=" + sortOptions.Value;
            }
            int httpStatusCode;
            var json = Http.Get(handle,
                                out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #21
0
        /// <summary>
        /// This call lets you edit the properties of a pipeline.
        /// </summary>
        /// <param name="pipelineKey">The key of the pipeline to be edited</param>
        /// <param name="name">The name of the pipeline (optional)</param>
        /// <param name="description">The description of the pipeline (optional)</param>
        /// <param name="stageOrder">A JSON array containing ordering of stage keys. The elements of this array are allowed to be re-ordered only. The order of this array affects the UI of the pipeline in the Web UI. (optional)</param>
        /// <param name="orgWide">A boolean indicating whether this pipeline is shared to everyone in the organization. For Google apps customers this means any other user with the same domain in their email address. This field has no effect for regular Gmail users. (optional)</param>
        /// <param name="aclEntries">This is a JSON array of objects representing who the pipeline is currently shared with. You can add and remove objects in a single update. Each object in this array is required to have 1 property - email. Adding a user to the aclEntries causes them to receive an email informing them that the pipeline has been shared with them. (optional)</param>
        /// <returns></returns>
        public RawApiResponse EditPipeline(string pipelineKey, string name = null, string description = null,
                                           string[] stageOrder             = null, bool?orgWide = null, List <AclEntry> aclEntries = null)
        {
            var requestJson = JsonConvert.SerializeObject(new
            {
                name,
                description,
                stageOrder,
                orgWide,
                aclEntries
            }, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            int httpStatusCode;
            var json = Http.Post(ApiHandles.EditPipeline.Replace("{pipelineKey}", pipelineKey), requestJson, out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #22
0
        /// <summary>
        /// This call lets you edit a specific task.
        /// </summary>
        /// <param name="taskKey">The key of the Task that this Task should be in. A list of valid Task keys can be found from the pipeline that this Task belongs to (optional)</param>
        /// <param name="text">A message attached to the task. When the user is reminded (by email) of the associated box, the message text is also presented. (optional)</param>
        /// <param name="dueDate">The date this reminder should be sent to the user. This is specified using number of milliseconds since epoch. (optional)</param>
        /// <param name="assignedToSharingEntries">Who the task is assigned to</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">Please specify a task key!</exception>
        public RawApiResponse EditTask(string taskKey, List <AclEntry> assignedToSharingEntries, string text = null, long?dueDate = null)
        {
            if (string.IsNullOrEmpty(taskKey))
            {
                throw new ArgumentNullException(nameof(taskKey), "Please specify a task key!");
            }
            var requestJson = JsonConvert.SerializeObject(new
            {
                text,
                dueDate,
                assignedToSharingEntries
            }, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            int httpStatusCode;
            var json = Http.Post(ApiHandles.EditTask.Replace("{taskKey}", taskKey), requestJson, out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #23
0
        /// <summary>
        /// This call lets you edit the name of a field. Note that editing the type of a field is not currently permitted and will throw a 400 error.
        /// </summary>
        /// <param name="pipelineKey">The pipeline key.</param>
        /// <param name="fieldKey">The key of the Field that this Field should be in. A list of valid Field keys can be found from the pipeline that this Field belongs to (optional)</param>
        /// <param name="name">The new name of the field</param>
        /// <returns></returns>
        public RawApiResponse EditField(string pipelineKey, string fieldKey, string name)
        {
            if (string.IsNullOrEmpty(pipelineKey))
            {
                throw new ArgumentNullException(nameof(pipelineKey), "Please specify a pipeline key!");
            }
            if (string.IsNullOrEmpty(fieldKey))
            {
                throw new ArgumentNullException(nameof(fieldKey), "Please specify a Field key!");
            }
            var requestJson = JsonConvert.SerializeObject(new
            {
                name
            }, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            int httpStatusCode;
            var json = Http.Post(ApiHandles.EditField.Replace("{pipelineKey}", pipelineKey).Replace("{fieldKey}", fieldKey), requestJson, out httpStatusCode);

            return(RawStreakApiResponseFactory.BuildRawStreakApiResponse(json, httpStatusCode));
        }
Example #24
0
 internal RawServicesBase(string apiKey, string apiBaseUrl)
 {
     Http       = new Http(apiKey, apiBaseUrl);
     ApiHandles = new ApiHandles();
     RawStreakApiResponseFactory = new RawStreakApiResponseFactory();
 }