示例#1
0
        public async Task <HttpResponseMessage> GetSalt(string login)
        {
            var uri = BaseUri.Append("salt", login);

            using (var httpClient = new HttpClient())
            {
                return(await httpClient.GetAsync(uri));
            }
        }
示例#2
0
 public string Delete(string endpoint)
 {
     ValidateConfiguration();
     if (_cookieJar.Count == 0)
     {
         CollectCookie();
     }
     return(UploadString(BaseUri.Append(endpoint), "DELETE", ""));
 }
示例#3
0
        /// <summary>
        /// Update specified test item.
        /// </summary>
        /// <param name="id">ID of test item to update.</param>
        /// <param name="model">Information about test item.</param>
        /// <returns>A message from service.</returns>
        public virtual async Task <MessageResponse> UpdateAsync(long id, UpdateTestItemRequest model)
        {
            var uri      = BaseUri.Append($"{ProjectName}/item/{id}/update");
            var body     = ModelSerializer.Serialize <UpdateTestItemRequest>(model);
            var response = await HttpClient.PutAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <MessageResponse>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
示例#4
0
        /// <summary>
        /// updates the project preference for user
        /// </summary>
        /// <param name="model"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public virtual async Task <MessageResponse> UpdatePreferencesAsync(string projectName, string userName, long filterId)
        {
            var uri = BaseUri.Append($"project/{projectName}/preference/{userName}/{filterId}");

            var response = await HttpClient.PutAsync(uri, new StringContent(string.Empty)).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <MessageResponse>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
示例#5
0
        /// <summary>
        /// Merge several launches.
        /// </summary>
        /// <returns>A message from service.</returns>
        public virtual async Task <MessageResponse> AnalyzeAsync(AnalyzeLaunchRequest request)
        {
            var uri      = BaseUri.Append($"{ProjectName}/launch/analyze");
            var body     = ModelSerializer.Serialize <AnalyzeLaunchRequest>(request);
            var response = await HttpClient.PostAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <MessageResponse>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
示例#6
0
        /// <summary>
        /// gets all user preferences
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public virtual async Task <PreferenceResponse> GetAllPreferences(string projectName, string userName)
        {
            var uri = BaseUri.Append($"project/{projectName}/preference/{userName}");

            var response = await HttpClient.GetAsync(uri).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <PreferenceResponse>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
示例#7
0
        /// <summary>
        /// Creates a new launch.
        /// </summary>
        /// <param name="model">Information about representation of launch.</param>
        /// <returns>Representation of just created launch.</returns>
        public async Task <Launch> StartLaunchAsync(StartLaunchRequest model)
        {
            var uri      = BaseUri.Append($"{Project}/launch");
            var body     = ModelSerializer.Serialize <StartLaunchRequest>(model);
            var response = await _httpClient.PostAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <Launch>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
示例#8
0
 public async Task <byte[]> PostAsync(string endpoint, byte[] body)
 {
     ValidateConfiguration();
     if (_cookieJar.Count == 0)
     {
         CollectCookie();
     }
     return(await UploadDataTaskAsync(BaseUri.Append(endpoint), body));
 }
        /// <summary>
        /// Returns the list of tests tags for specified launch.
        /// </summary>
        /// <param name="launchId">ID of launch.</param>
        /// <param name="tagContains">Tags should contain specified text.</param>
        /// <returns></returns>
        public virtual async Task <List <string> > GetUniqueTagsAsync(string launchId, string tagContains)
        {
            var uri = BaseUri.Append($"{Project}/item/tags?launch={launchId}&filter.cnt.tags={tagContains}");

            var response = await _httpClient.GetAsync(uri).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <List <string> >(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
示例#10
0
        /// <summary>
        /// Stopes specified launch even if inner tests are not finished yet.
        /// </summary>
        /// <param name="id">ID of specified launch.</param>
        /// <param name="request">Information about representation of launch to finish.</param>
        /// <returns>A message from service.</returns>
        public virtual async Task <LaunchFinishedResponse> StopAsync(long id, FinishLaunchRequest request)
        {
            var uri      = BaseUri.Append($"{ProjectName}/launch/{id}/stop");
            var body     = ModelSerializer.Serialize <FinishLaunchRequest>(request);
            var response = await HttpClient.PutAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <LaunchFinishedResponse>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
        /// <summary>
        /// Assign issues to specified test items.
        /// </summary>
        /// <param name="model">Information about test items and their issues.</param>
        /// <returns>A list of assigned issues.</returns>
        public virtual async Task <List <Issue> > AssignTestItemIssuesAsync(AssignTestItemIssuesRequest model)
        {
            var uri      = BaseUri.Append($"{Project}/item");
            var body     = ModelSerializer.Serialize <AssignTestItemIssuesRequest>(model);
            var response = await _httpClient.PutAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <List <Issue> >(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="values"></param>
        /// <returns>https://connect.squareup.com/v1/modifier-lists/{modifier_list_id}/modifier-options</returns>
        protected override Uri GetUri(params string[] values)
        {
            switch (values.Length)
            {
            case 1: return(BaseUri.Append(values[0], "modifier-lists", values[1], "modifier-options"));

            default: throw new ArgumentException();
            }
        }
示例#13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="values"></param>
        /// <returns>https://connect.squareup.com/v1/{{location_id}}/webhooks</returns>
        protected override Uri GetUri(params string[] values)
        {
            switch (values.Length)
            {
            case 1: return(BaseUri.Append("webhooks"));

            default: throw new ArgumentException();
            }
        }
示例#14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="values"></param>
        /// <returns>https://connect.squareup.com/v1/{{location_id}}/webhooks</returns>
        protected override Uri GetUri(params string[] values)
        {
            switch (values.Length)
            {
            case 1: return(BaseUri.Append("oauth2", "clients", values[0], "plans", values.Length > 1 ? values[1] : null));

            default: throw new ArgumentException();
            }
        }
示例#15
0
        /// <summary>
        /// Deletes the specified filter by id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public virtual async Task <MessageResponse> DeleteAsync(long id)
        {
            var uri = BaseUri.Append($"{ProjectName}/filter/{id}");

            var response = await HttpClient.DeleteAsync(uri).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <MessageResponse>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
        /// <summary>
        /// Creates a new test item.
        /// </summary>
        /// <param name="id">ID of parent item.</param>
        /// <param name="model">Information about representation of test item.</param>
        /// <returns>Representation of created test item.</returns>
        public virtual async Task <TestItem> StartTestItemAsync(string id, StartTestItemRequest model)
        {
            var uri      = BaseUri.Append($"{Project}/item/{id}");
            var body     = ModelSerializer.Serialize <StartTestItemRequest>(model);
            var response = await _httpClient.PostAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <TestItem>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
示例#17
0
        /// <summary>
        /// Get the history of test items executions.
        /// </summary>
        /// <param name="testItemIds">IDs of test items.</param>
        /// <param name="depth">How many executions to return.</param>
        /// <param name="full"></param>
        /// <returns>The list of execution history.</returns>
        public virtual async Task <IEnumerable <TestItemHistoryResponse> > GetHistoryAsync(IEnumerable <long> testItemIds, int depth, bool full)
        {
            var uri = BaseUri.Append($"{ProjectName}/item/history?ids={string.Join(",", testItemIds)}&history_depth={depth}&is_full={full}");

            var response = await HttpClient.GetAsync(uri).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <IEnumerable <TestItemHistoryResponse> >(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
示例#18
0
 public byte[] Post(string endpoint, byte[] body)
 {
     ValidateConfiguration();
     if (_cookieJar.Count == 0)
     {
         CollectCookie();
     }
     return(UploadData(BaseUri.Append(endpoint), body));
 }
示例#19
0
 public async Task <string> PostAsync(string endpoint, string body)
 {
     ValidateConfiguration();
     if (_cookieJar.Count == 0)
     {
         await CollectCookieAsync();
     }
     return(await UploadStringTaskAsync(BaseUri.Append(endpoint), body));
 }
示例#20
0
 public string Post(string endpoint, string body)
 {
     ValidateConfiguration();
     if (_cookieJar.Count == 0)
     {
         CollectCookie();
     }
     return(UploadString(BaseUri.Append(endpoint), body));
 }
        /// <summary>
        /// Get the history of test item executions.
        /// </summary>
        /// <param name="testItemId">ID of test item.</param>
        /// <param name="depth">How many executions to return.</param>
        /// <param name="full"></param>
        /// <returns>The list of execution history.</returns>
        public virtual async Task <List <TestItemHistory> > GetTestItemHistoryAsync(string testItemId, int depth, bool full)
        {
            var uri = BaseUri.Append($"{Project}/item/history?ids={testItemId}&history_depth={depth}&is_full={full}");

            var response = await _httpClient.GetAsync(uri).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <List <TestItemHistory> >(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
示例#22
0
 public async Task <string> DeleteAsync(string endpoint)
 {
     ValidateConfiguration();
     if (_cookieJar.Count == 0)
     {
         await CollectCookieAsync();
     }
     return(await UploadStringTaskAsync(BaseUri.Append(endpoint), "DELETE", ""));
 }
示例#23
0
        public async Task <HttpResponseMessage> GetMembers(string householdId, string key)
        {
            var uri = BaseUri.Append("members", householdId);

            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Add("x-functions-key", key);
                return(await httpClient.GetAsync(uri));
            }
        }
示例#24
0
        public async Task <HttpResponseMessage> AcceptInvitation(string from, string to, string rowKey, string key)
        {
            var uri = BaseUri.Append("accept", from, to, rowKey);

            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Add("x-functions-key", key);
                return(await httpClient.GetAsync(uri));
            }
        }
示例#25
0
        public async Task <HttpResponseMessage> Invite(string invitersLogin, string invitedLogin, string key)
        {
            var uri = BaseUri.Append("invite", invitersLogin, invitedLogin);

            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Add("x-functions-key", key);
                return(await httpClient.GetAsync(uri));
            }
        }
示例#26
0
        /// <summary>
        /// Creates the specified user filter.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual async Task <UserFilterCreatedResponse> CreateAsync(CreateUserFilterRequest model)
        {
            var uri = BaseUri.Append($"{ProjectName}/filter");

            var body     = ModelSerializer.Serialize <CreateUserFilterRequest>(model);
            var response = await HttpClient.PostAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <UserFilterCreatedResponse>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
        /// <summary>
        /// updates the project preference for user
        /// </summary>
        /// <param name="model"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public virtual async Task <UpdatePreferencesResponse> UpdatePreferencesAsync(UpdatePreferenceRequest model, string userName)
        {
            var uri  = BaseUri.Append($"project/{Project}/preference/{userName}");
            var body = ModelSerializer.Serialize <UpdatePreferenceRequest>(model);

            var response = await _httpClient.PutAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <UpdatePreferencesResponse>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
示例#28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="values"></param>
        /// <returns>https://connect.squareup.com/v1/{{location_id}}/business</returns>
        protected override Uri GetUri(params string[] values)
        {
            switch (values.Length)
            {
            case 0: return(BaseUri.Append("me"));

            case 1: return(BaseUri.Append(values[0], "business"));

            default: throw new ArgumentException();
            }
        }
示例#29
0
        public async Task <HttpResponseMessage> Add(string login, string key, AddCashFlowDto dto)
        {
            var uri     = BaseUri.Append("add", login);
            var content = new StringContent(JsonConvert.SerializeObject(dto));

            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Add("x-functions-key", key);
                return(await httpClient.PostAsync(uri, content));
            }
        }
示例#30
0
        /// <summary>
        /// Finishes specified launch.
        /// </summary>
        /// <param name="id">ID of specified launch.</param>
        /// <param name="model">Information about representation of launch to finish.</param>
        /// <param name="force">Force finish launch even if test items are in progress.</param>
        /// <returns>A message from service.</returns>
        public async Task <Message> FinishLaunchAsync(string id, FinishLaunchRequest model, bool force = false)
        {
            var uri = BaseUri.Append($"{Project}/launch/{id}");

            uri = force == true?uri.Append("/stop") : uri.Append("/finish");

            var body     = ModelSerializer.Serialize <FinishLaunchRequest>(model);
            var response = await _httpClient.PutAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <Message>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }