internal async static Task <T> baseGetRequest <T>(string endpoint, DateTime?since, int page, int perPage, Embed[] embed) where T : DefaultObjectWrapper
        {
            var requestString = new StringBuilder($"{endpoint}?");

            if (page < 1)
            {
                page = 1;
            }

            requestString.Append($"page={page}&");

            if (perPage > 100)
            {
                perPage = 100;
            }

            requestString.Append($"perPage={perPage}&");

            if (since != null && since.HasValue)
            {
                requestString.Append($"since={since.Value.ToString("yyyy-MM-dd")}");
            }

            if (embed != null && embed.Length > 0)
            {
                requestString.Append($"embed={string.Join(",", embed)}");
            }

            return(await CapsuleClient.makeRequest <T>(requestString.ToString(), "GET"));
        }
        public async static Task <bool> RemoveAdditionalPartyAsync(long opportunityId, long partyId)
        {
            var endpoint = new StringBuilder($"{BASE_ENDPOINT}/{opportunityId}/parties/{partyId}");

            var apiResponse = await CapsuleClient.makeRequest(endpoint.ToString(), "DELETE");

            return(apiResponse);
        }
        public async static Task <OpportunityWrapper> SearchOpportunitiesAsync(string query, int page = 1, int perPage = 20)
        {
            var endpoint = $"{BASE_ENDPOINT}/search?q={query}&page={page}&perPage={perPage}";

            var foundOpportunities = await CapsuleClient.makeRequest <OpportunityWrapper>(endpoint, "GET");

            return(foundOpportunities);
        }
        public async static Task <Opportunity> CreateAsync(Opportunity opportunity)
        {
            var wrapperObject = OpportunityWrapper.Load(opportunity);

            var response = await CapsuleClient.makeRequest <OpportunityWrapper>(BASE_ENDPOINT,
                                                                                "POST",
                                                                                wrapperObject);

            return(response.Opportunity);
        }
        public async static Task <Party> UpdateAsync(long partyId, Party party)
        {
            var wrapperObject = PartyWrapper.Load(party);

            var response = await CapsuleClient.makeRequest <PartyWrapper>($"{BASE_ENDPOINT}/{partyId}",
                                                                          "PUT",
                                                                          wrapperObject);

            return(response.Party);
        }
        public async static Task <Party> CreateAsync(Party party)
        {
            var wrapperObject = PartyWrapper.Load(party);

            var response = await CapsuleClient.makeRequest <PartyWrapper>(BASE_ENDPOINT,
                                                                          "POST",
                                                                          wrapperObject);

            return(response.Party);
        }
        public async static Task <Opportunity> ShowAsync(long opportunityId, Embed[] embed = null)
        {
            var endpoint = new StringBuilder($"{BASE_ENDPOINT}/{opportunityId}");

            if (embed != null)
            {
                endpoint.Append($"?embed={String.Join(",", embed)}");
            }

            var apiResponse = await CapsuleClient.makeRequest <OpportunityWrapper>(endpoint.ToString(), "get");

            return(apiResponse.Opportunity);
        }
        public async static Task <CaseWrapper> ListAssociatedCasesAsync(long opportunityId, int page = 1, int perPage = 20, Embed[] embed = null)
        {
            var endpoint = new StringBuilder($"{BASE_ENDPOINT}/{opportunityId}/kases?page={page}&perPage={perPage}");

            if (embed != null)
            {
                endpoint.Append($"?embed={String.Join(",", embed)}");
            }

            var apiResponse = await CapsuleClient.makeRequest <CaseWrapper>(endpoint.ToString(), "GET"); //

            return(apiResponse);
        }
        public async static Task <Opportunity> UpdateAsync(long opportunityId, Opportunity opportunity)
        {
            // Duration bases cannot be updated
            opportunity.DurationBasis = null;

            var wrapperObject = OpportunityWrapper.Load(opportunity);

            var response = await CapsuleClient.makeRequest <OpportunityWrapper>($"{BASE_ENDPOINT}/{opportunityId}",
                                                                                "PUT",
                                                                                wrapperObject);

            return(response.Opportunity);
        }
示例#10
0
        public async static Task <PartyWrapper> ListEmployeesAsync(long partyId, int page = 1, int perPage = 20, Embed[] embed = null)
        {
            var endpoint = new StringBuilder($"{BASE_ENDPOINT}/{partyId}/people?page={page}&perPage={perPage}");

            if (embed != null)
            {
                endpoint.Append($"?embed={String.Join(",", embed)}");
            }

            var employees = await CapsuleClient.makeRequest <PartyWrapper>(endpoint.ToString(), "GET");

            return(employees);
        }
示例#11
0
        public async static Task <Party> ShowAsync(long partyId, Embed[] embed = null)
        {
            var endpoint = new StringBuilder($"{BASE_ENDPOINT}/{partyId}");

            if (embed != null)
            {
                endpoint.Append($"?embed={String.Join(",", embed)}");
            }

            var party = await CapsuleClient.makeRequest <PartyWrapper>(endpoint.ToString(), "get");

            return(party.Party);
        }
示例#12
0
        public async static Task <PartyWrapper> ListAdditionalPartiesAsync(long caseId, int page = 1, int perPage = 20, Embed[] embed = null)
        {
            var endpoint = new StringBuilder($"{BASE_ENDPOINT}/{caseId}/parties?page={page}&perPage={perPage}");

            if (embed != null)
            {
                endpoint.Append($"&embed={String.Join(",", embed)}");
            }

            var parties = await CapsuleClient.makeRequest <PartyWrapper>(endpoint.ToString(), "get");

            return(parties);
        }
        public async static Task <OpportunityWrapper> ShowMultipleAsync(long[] opportunityIds, Embed[] embed = null)
        {
            if (opportunityIds.Length > 10)
            {
                throw new ArgumentException("A max of 10 opportunity id's can be sent at any one time");
            }

            var endpoint = new StringBuilder($"{BASE_ENDPOINT}/{string.Join(",", opportunityIds)}");

            if (embed != null)
            {
                endpoint.Append($"?embed={String.Join(",", embed)}");
            }

            var opportunity = await CapsuleClient.makeRequest <OpportunityWrapper>(endpoint.ToString(), "get");

            return(opportunity);
        }
        public async static Task <OpportunityWrapper> ListDeletedAsync(DateTime since)
        {
            var deletedOpportunities = await CapsuleClient.makeRequest <OpportunityWrapper>($"{BASE_ENDPOINT}/deleted?since={since.ToString("yyyy/MM/dd")}", "GET");

            return(deletedOpportunities);
        }
        public async static Task <bool> DeleteAsync(long opportunityId)
        {
            var response = await CapsuleClient.makeRequest <OpportunityWrapper>($"{BASE_ENDPOINT}/{opportunityId}", "DELETE");

            return(true);
        }
示例#16
0
        public async static Task <bool> DeleteAdditionalPartyAsync(long caseId, long partyId)
        {
            var endpoint = new StringBuilder($"{BASE_ENDPOINT}/{caseId}/parties/{partyId}");

            return(await CapsuleClient.makeRequest(endpoint.ToString(), "delete"));;
        }