private static HttpServerResponse GetDefaultResponse(IRestResponse response) { var serverResponse = HttpServerResponse.Create(response.StatusCode); serverResponse.Date = DateTime.Now; serverResponse.IsConnectionClosed = true; return serverResponse; }
static void DownloadAllFilesLocal(Dictionary<string, string> downloadList, string chosenFilePath, string chosenFolderName, IRestResponse loginResponse) { string filePath; Console.WriteLine(""); //Regex setup for removing multiple spaces RegexOptions options = RegexOptions.None; Regex regex = new Regex(@"[ ]{2,}", options); if (chosenFolderName == string.Empty) { filePath = string.Concat(chosenFilePath, ""); } else { Directory.CreateDirectory(string.Concat(chosenFilePath, "\\", chosenFolderName)); filePath = string.Concat(chosenFilePath, "\\", chosenFolderName, "\\"); } foreach (KeyValuePair<string, string> keyValuePair in downloadList) { string tempFilePath = filePath; RestClient client = new RestClient(keyValuePair.Value); RestRequest request = new RestRequest(Method.GET); request.AddCookie(loginResponse.Cookies[0].Name, loginResponse.Cookies[0].Value); Uri uri = client.Execute(request).ResponseUri; tempFilePath = string.Concat(tempFilePath, uri.Segments.Last<string>()); WebClient webClient = new WebClient(); webClient.Headers.Add(HttpRequestHeader.Cookie, string.Concat(loginResponse.Cookies[0].Name, "=", loginResponse.Cookies[0].Value)); webClient.DownloadFile(uri, regex.Replace(HttpUtility.HtmlDecode(HttpUtility.UrlDecode(tempFilePath)),@" ")); Program.ConsoleSetColor(ConsoleColor.Gray); Console.WriteLine(HttpUtility.UrlDecode(string.Concat(uri.Segments.Last<string>(), " complete"))); } }
internal ResponseShim(IRestResponse resp, IRequestShim req, string baseUrl, Exception error) { this.Request = req; if (resp != null) { this.Code = resp.StatusCode; this.Message = resp.StatusDescription; //this.Content = Convert.ToBase64String(resp.RawBytes); this.Content = UTF8Encoding.UTF8.GetString( resp.RawBytes, 0, resp.RawBytes.Length); this.IsSuccess = resp.IsSuccess; } this.BaseUrl = baseUrl; this.Error = error; var restErr = error as RestServiceException; if (restErr != null) { this.Code = restErr.Code; this.Message = restErr.Message; } }
public static void CheckForErrors(IRestResponse response, int errorType) { if (response.StatusCode != HttpStatusCode.OK) { // object error type { error : {} } if (errorType == 1) { var errorObj = JsonConvert.DeserializeObject<ErrorAsObject>(response.Content); if (errorObj.Error != null && errorObj.Error.Type.Equals("not_found")) { throw new NotFoundException(response.StatusCode, new[] { errorObj.Error.Message }, ""); } else { throw new InvalidApiRequestException(response.StatusCode, new[] { errorObj.Error.Message }, ""); } } // value error type { error : "", error_description : "" } if (errorType == 2) { var errorObj = JsonConvert.DeserializeObject<ErrorAsValue>(response.Content); if (errorObj.Error.Equals("access_denied")) { throw new InvalidApiRequestException(response.StatusCode, new[] { errorObj.Description }, ""); } throw new InvalidApiRequestException(response.StatusCode, new[] { errorObj.Description }, ""); } } }
/// <summary> /// Initializes a new instance of the <see cref="RestException"/> class. /// </summary> /// Simply takes the parameters and stores them in the attributes. /// <param name="message">The message detailing the problem.</param> /// <param name="request">The request that caused the problem,</param> /// <param name="response">The response (if any) that was received.</param> /// <param name="user">The <see cref="User"/> that attempted the operation.</param> /// <param name="apiKey">The API key used for the connection.</param> public RestException(string message, RestRequest request, IRestResponse response, string user, string apiKey) : base(message) { this.Request = request; this.Response = response; this.User = user; this.APIKey = apiKey; }
private void LogRequest(RestClient restClient, IRestRequest request, IRestResponse response, long durationMs) { var requestToLog = new { resource = request.Resource, // Parameters are custom anonymous objects in order to have the parameter type as a nice string // otherwise it will just show the enum value parameters = request.Parameters.Select(parameter => new { name = parameter.Name, value = parameter.Value, type = parameter.Type.ToString() }), // ToString() here to have the method as a nice string otherwise it will just show the enum value method = request.Method.ToString(), // This will generate the actual Uri used in the request uri = restClient.BuildUri(request), }; var responseToLog = new { statusCode = response.StatusCode, content = response.Content, headers = response.Headers, // The Uri that actually responded (could be different from the requestUri if a redirection occurred) responseUri = response.ResponseUri, errorMessage = response.ErrorMessage, }; Trace.Write(string.Format("Request completed in {0} ms, Request: {1}, Response: {2}", durationMs, JsonConvert.SerializeObject(requestToLog), JsonConvert.SerializeObject(responseToLog))); }
private void SetUserFriendlyErrorMessage(IRestResponse response) { UserFriendlyErrorMessage = ""; string content = response.Content; //string content = @"{ ""error"": { ""code"": ""20020"", ""message"": ""Insufficient balance"" } }"; string code = ""; string errorMessage = ""; //set clear error messages for our users if (response.StatusCode == HttpStatusCode.PaymentRequired) { GetErrorCodeAndMessage(content, out code, out errorMessage); if (code == "20020") { //original: "Insufficient balance" this.UserFriendlyErrorMessage = "You have insufficient balance in your Neteller account to complete the transaction. Please deposit funds and try again."; this.Warning = true; //warning = we don't log a fatal error } } else { //the errorMessage returned is better than no error message at all usually if (!string.IsNullOrEmpty(errorMessage)) this.UserFriendlyErrorMessage = errorMessage; } }
private static bool IsBadResponse(IRestResponse response, bool errorNotFound = false) { return (response.ResponseStatus != ResponseStatus.Completed || (errorNotFound && response.StatusCode == HttpStatusCode.NotFound) || response.StatusCode == HttpStatusCode.BadRequest || response.StatusCode == HttpStatusCode.PaymentRequired); }
private void LatestRecipeIdReceived(IRestResponse response) { try { int parsedId = int.Parse(response.Content); string dynamicRecipes = this.settings.GetDynamicRecipes(); Recipe recipeLookUp = null; List<Recipe> dynamicRecipeList = null; if (!string.IsNullOrEmpty(dynamicRecipes)) { XDocument dataDocument = XDocument.Parse(dynamicRecipes); var recipes = from recipe in dataDocument.Descendants("recipe") select recipe; dynamicRecipeList = recipes.Select(this.ParseRecipe).ToList(); recipeLookUp = dynamicRecipeList.SingleOrDefault(r => r.Id == parsedId); } if (recipeLookUp == null) { this.StartGetLatestRecipe(parsedId); } else { this.recipeList.AddRange(dynamicRecipeList); this.SortAndSendList(); } } catch (FormatException error) { this.SortAndSendList(); } }
public List<Dictionary<string, object>> Parse(IRestResponse<dynamic> responseToParse, ParserRules ruleset) { if (responseToParse.ResponseStatus != ResponseStatus.Completed) throw new ApplicationException("Response was not [Completed]"); if (responseToParse.Data == null) throw new ApplicationException("Response data could not be parsed"); var resultset = responseToParse.Data as IEnumerable<dynamic>; if (resultset == null) throw new ApplicationException("Response data could not be identified as collection"); List<Dictionary<string, object>> l = new List<Dictionary<string, object>>(); foreach (Dictionary<string, object> item in resultset) { var newItem = new Dictionary<string, object>(); foreach (var field in ruleset.Fields) { if (item.ContainsKey(field.Selector)) { newItem.Add(field.Selector, item[field.Selector]); } } if (newItem.Any()) l.Add(newItem); } return l; }
private void throwOnError(IRestResponse response) { if (response.ResponseStatus != ResponseStatus.Completed || response.StatusCode != System.Net.HttpStatusCode.OK) { throw new ChallongeApiException(response); } }
public When(IRestClient client, IRestRequest request, IRestResponse response) { this.client = client; this.request = request; this.response = response; data = new Object(); }
public HullException(IRestResponse response, string message) : base(message) { this.StatusCode = response.StatusCode; this.StatusMessage = response.StatusDescription; this.ResponseContent = response.Content; }
public ValidationException(IRestResponse response) { StatusCode = response.StatusCode; ErrorMessage = response.StatusCode.ToString(); ResponseContent = response.Content; ValidationError = new List<ObjectValidationError>(); }
public EncodeTaskData EncodeTaskDataDeserealize(IRestResponse response) { EncodeTaskData encodeTaskData; encodeTaskData = _deserializer.Deserialize<EncodeTaskData>(response); return encodeTaskData; }
private static void ParseXmlForErrorsNode(IRestResponse response) { var errors = new List<string>(); var xml = new XmlDocument(); string filteredXmlContent = GetXmlContentWithoutNamespaces(response.Content); xml.LoadXml(filteredXmlContent); //xml.LoadXml(response.Content); foreach (XmlNode item in xml.SelectNodes("//Error")) { if (!string.IsNullOrEmpty(item.InnerText)) { errors.Add(item.InnerText); } } if (errors.Count == 0) { XmlNode errorsNode = xml.SelectSingleNode("//Errors"); if (errorsNode != null) { foreach (XmlNode error in errorsNode.SelectNodes("//string")) { errors.Add(error.InnerText); } } } if (errors.Count > 0) { throw new APIException(errors[0], errors); } }
public ValidationException(IRestResponse response, List<ObjectValidationError> validationError) { StatusCode = response.StatusCode; ErrorMessage = response.ErrorMessage; ResponseContent = response.Content; ValidationError = validationError; }
public EloquaApiException(IRestResponse response) : base(response.Content) { StatusCode = response.StatusCode; ErrorMessage = response.ErrorMessage; ResponseContent = response.Content; }
public static Table Parse(IRestResponse response) { Table table = new Table(); StringReader reader = new StringReader(response.Content); string readLine = reader.ReadLine(); if (readLine != null) { string[] collection = readLine.Split(Separator); foreach (string column in collection) { table.Columns.Add(column.TrimStart('"').TrimEnd('"')); } } string line = reader.ReadLine(); while (!string.IsNullOrEmpty(line)) { Row row = new Row(line); table.Rows.Add(row); line = reader.ReadLine(); } return table; }
private void OnContentUpdate(IRestResponse<FarseerTopList> resp) { if(resp.ResponseStatus == ResponseStatus.Completed) { var result = resp.Data; if(result.code == 0) { Application.Current.Dispatcher.Invoke(()=> { foreach (var obj in result.ret.list) { _farseerNodeList.Add(new FarseerNodeViewModel(obj)); } }); } else { //TODO Failed } } else if(resp.ResponseStatus == ResponseStatus.TimedOut) { //TODO timeout } }
private void BeforeSerialization(IRestResponse response) { if (response.StatusCode >= HttpStatusCode.BadRequest) { throw new ApiClientException(string.Format("Unexpected response status {0}", (int)response.StatusCode)); } }
public ConnectionErrorException(IRestResponse response) : base(response.ErrorMessage) { StatusCode = response.StatusCode; ErrorMessage = response.ErrorMessage; ResponseContent = response.Content; }
private void EndProfile(RequestItem pending, IRestResponse response, EventWaitHandle signal) { TimeSpan elapsed = pending.Elapsed; network.Profile(response, pending.Started, elapsed); network.ProfilePendingRemove(pending); signal.Set(); }
public RestException(IRestRequest request, IRestResponse response) : base(string.Format("The endpoint at '{0}' didn't respond with 'OK'. Instead it was '{1}'.", response.ResponseUri, response.StatusCode), response.ErrorException??new Exception(response.Content)) { Request = request; Response = response; }
public bool BaseCompare(IRestResponse mockResponse, IRestResponse response) { return response.ContentLength != 0 && mockResponse.ErrorException == response.ErrorException && mockResponse.ErrorMessage == response.ErrorMessage && mockResponse.ResponseStatus.Equals(response.ResponseStatus); }
protected override void Setup() { this._subject = this.APIClient.Authorizations().CreateAuthorization(new AuthorizationCreateOptions { Note = "Testing API" }); }
static string BadResponse(IRestResponse response, string pre) { string ret = null; if (response.StatusCode != System.Net.HttpStatusCode.OK) Log.Write(LogSeverity.Error, ret = (pre+response.ErrorMessage)); return ret; }
public void ReadHandler(IRestResponse<List<Score>> response, RestRequestAsyncHandle handle) { Debug.Log("In ReadHandler"); _scores = response.Data; Debug.Log(_scores); }
protected void HandleError(IRestResponse response) { if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.Created) { throw new ActivitiRestClientException(response.StatusDescription); } }
/// <summary> /// Uploads a document and obtains the document's ID. The document uploaded through this call is referred to as /// transient since it is available only for 7 days after the upload. The returned transient document ID can be used in /// the API calls where the uploaded file needs to be referred. The transient document request is a multipart request /// consisting of three parts - filename, mime type and the file stream. You can only upload one file at a time in this /// request. /// </summary> /// <param name="authorization"> /// An <a href=\"#\" onclick=\"this.href=oauthDoc()\" /// oncontextmenu=\"this.href=oauthDoc()\" target=\"oauthDoc\">OAuth Access Token /// </a> with any of the following scopes:<ul><li style='list-style-type: square'><a /// href=\"#\" onclick=\"this.href=oauthDoc('agreement_write')\" /// oncontextmenu=\"this.href=oauthDoc('agreement_write')\" target=\"oauthDoc\ /// ">agreement_write</a></li><li style='list-style-type: square'><a href /// =\"#\" onclick=\"this.href=oauthDoc('agreement_sign')\" oncontextmenu /// =\"this.href=oauthDoc('agreement_sign')\" target=\"oauthDoc\"> /// agreement_sign</a></li><li style='list-style-type: square'><a href=\"#\ /// " onclick=\"this.href=oauthDoc('widget_write')\" oncontextmenu=\" /// this.href=oauthDoc('widget_write')\" target=\"oauthDoc\">widget_write</a> /// </li><li style='list-style-type: square'><a href=\"#\" onclick=\ /// "this.href=oauthDoc('library_write')\" oncontextmenu=\"this.href=oauthDoc( /// 'library_write')\" target=\"oauthDoc\">library_write</a></li></ul> /// in the format <b>'Bearer {accessToken}'. /// </param> /// <param name="file">The file part of the multipart request for document upload. You can upload only one file at a time.</param> /// <param name="xApiUser"> /// The userId or email of API caller using the account or group token in the format <b> /// userid:{userId} OR email:{email}.</b> If it is not specified, then the caller is inferred from the token. /// </param> /// <param name="xOnBehalfOfUser"> /// The userId or email in the format <b>userid:{userId} OR email:{email}.</b> of /// the user that has shared his/her account /// </param> /// <param name="fileName"> /// A name for the document being uploaded. Maximum number of characters in the name is restricted /// to 255. /// </param> /// <param name="mimeType"> /// The mime type of the document being uploaded. If not specified here then mime type is picked up /// from the file object. If mime type is not present there either then mime type is inferred from file name extension. /// </param> /// <returns>TransientDocumentResponse</returns> public TransientDocumentResponse CreateTransientDocument(string authorization, Stream file, string xApiUser, string xOnBehalfOfUser, string fileName, string mimeType) { // verify the required parameter 'authorization' is set if (authorization == null) { throw new ApiException(400, "Missing required parameter 'authorization' when calling CreateTransientDocument"); } // verify the required parameter 'file' is set if (file == null) { throw new ApiException(400, "Missing required parameter 'file' when calling CreateTransientDocument"); } string path = "/transientDocuments"; path = path.Replace("{format}", "json"); Dictionary <string, string> queryParams = new Dictionary <string, string>(); Dictionary <string, string> headerParams = new Dictionary <string, string>(); Dictionary <string, string> formParams = new Dictionary <string, string>(); Dictionary <string, FileParameter> fileParams = new Dictionary <string, FileParameter>(); string postBody = null; if (authorization != null) { headerParams.Add("Authorization", ApiClient.ParameterToString(authorization)); // header parameter } if (xApiUser != null) { headerParams.Add("x-api-user", ApiClient.ParameterToString(xApiUser)); // header parameter } if (xOnBehalfOfUser != null) { headerParams.Add("x-on-behalf-of-user", ApiClient.ParameterToString(xOnBehalfOfUser)); // header parameter } if (fileName != null) { formParams.Add("File-Name", ApiClient.ParameterToString(fileName)); // form parameter } if (mimeType != null) { formParams.Add("Mime-Type", ApiClient.ParameterToString(mimeType)); // form parameter } if (file != null) { fileParams.Add("File", ApiClient.ParameterToFile("File", file)); } // authentication setting, if any string[] authSettings = { }; // make the HTTP request IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if ((int)response.StatusCode >= 400) { throw new ApiException((int)response.StatusCode, "Error calling CreateTransientDocument: " + response.Content, response.Content); } if ((int)response.StatusCode == 0) { throw new ApiException((int)response.StatusCode, "Error calling CreateTransientDocument: " + response.ErrorMessage, response.ErrorMessage); } return((TransientDocumentResponse)ApiClient.Deserialize(response.Content, typeof(TransientDocumentResponse), response.Headers)); }
/// <summary> /// Get back a message indicating that the API is working. /// </summary> /// <exception cref="Com.RusticiSoftware.Cloud.V2.Client.ApiException">Thrown when fails to make API call</exception> /// <returns>Task of ApiResponse (PingSchema)</returns> public async System.Threading.Tasks.Task <ApiResponse <PingSchema> > PingAppIdAsyncWithHttpInfo() { var localVarPath = "/ping"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } // authentication (APP_NORMAL) required // http basic authentication required if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password)) { localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password); } // authentication (OAUTH) required // oauth required if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken; } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("PingAppId", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <PingSchema>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (PingSchema)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(PingSchema)))); }
/// <summary> /// Read Reads the entity with the given 'id' and returns it. /// </summary> /// <exception cref="Customweb.Wallee.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="spaceId"></param> /// <param name="id">The id of the manual task which should be returned.</param> /// <returns>Task of ApiResponse (ManualTask)</returns> public async System.Threading.Tasks.Task <ApiResponse <ManualTask> > ReadAsyncWithHttpInfo(long?spaceId, long?id) { // verify the required parameter 'spaceId' is set if (spaceId == null) { throw new ApiException(400, "Missing required parameter 'spaceId' when calling ManualTaskService->Read"); } // verify the required parameter 'id' is set if (id == null) { throw new ApiException(400, "Missing required parameter 'id' when calling ManualTaskService->Read"); } var localVarPath = "/manual-task/read"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json;charset=utf-8" }; String localVarHttpContentType = ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "*/*" }; String localVarHttpHeaderAccept = ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (spaceId != null) { localVarQueryParams.Add("spaceId", ApiClient.ParameterToString(spaceId)); // query parameter } if (id != null) { localVarQueryParams.Add("id", ApiClient.ParameterToString(id)); // query parameter } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await ApiClient.CallApiAsync(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("Read", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <ManualTask>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (ManualTask)ApiClient.Deserialize(localVarResponse, typeof(ManualTask)))); }
/// <summary> /// This operation retrieves all transactions for a specified period of time. /// </summary> /// <exception cref="shippingapi.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="developerId">developerId</param> /// <param name="xPBUnifiedErrorStructure">Set this to true to use the standard [error object](https://shipping.pitneybowes.com/reference/error-object.html#standard-error-object) if an error occurs. (optional, default to true)</param> /// <param name="fromDate">fromDate (optional)</param> /// <param name="shipDetails"> (optional, default to 0)</param> /// <param name="page"> (optional)</param> /// <param name="size"> (optional, default to 20)</param> /// <param name="printStatus">printStatus (optional)</param> /// <param name="toDate">toDate (optional)</param> /// <param name="transactionType">transactionType (optional)</param> /// <param name="merchantId">The value of the postalReportingNumber element in the [merchant object](https://shipping.pitneybowes.com/reference/resource-objects.html). This value is also the merchant's Shipper ID. (optional)</param> /// <param name="sort">Defines a property to sort on and the sort order. Sort order can be ascending (asc) or descending (desc). Use the following form- * **sort=<property_name>,<sort_direction>** For example- **sort=transactionId,desc** (optional)</param> /// <param name="parcelTrackingNumber">Parcel tracking number of the shipment. (optional)</param> /// <param name="transactionId">The unique string that identifies all the transactions associated with a given shipment. The string comprises the developer ID and the shipment's X-PB-TransactionId, separated by an underscore (_). For example- * **transactionId=44397664_ad5aa07-ad7414-a78a-c22b3** (optional)</param> /// <returns>Task of ApiResponse (PageRealTransactionDetailReport)</returns> public async System.Threading.Tasks.Task <ApiResponse <PageRealTransactionDetailReport> > GetTransactionReportAsyncWithHttpInfo(string developerId, bool?xPBUnifiedErrorStructure = default(bool?), DateTime?fromDate = default(DateTime?), int?shipDetails = default(int?), int?page = default(int?), int?size = default(int?), string printStatus = default(string), DateTime?toDate = default(DateTime?), string transactionType = default(string), string merchantId = default(string), string sort = default(string), string parcelTrackingNumber = default(string), string transactionId = default(string)) { // verify the required parameter 'developerId' is set if (developerId == null) { throw new ApiException(400, "Missing required parameter 'developerId' when calling TransactionReportsApi->GetTransactionReport"); } var localVarPath = "/v4/ledger/developers/{developerId}/transactions/reports"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (developerId != null) { localVarPathParams.Add("developerId", this.Configuration.ApiClient.ParameterToString(developerId)); // path parameter } if (fromDate != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "fromDate", fromDate)); // query parameter } if (shipDetails != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "shipDetails", shipDetails)); // query parameter } if (page != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "page", page)); // query parameter } if (size != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "size", size)); // query parameter } if (printStatus != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "printStatus", printStatus)); // query parameter } if (toDate != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "toDate", toDate)); // query parameter } if (transactionType != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "transactionType", transactionType)); // query parameter } if (merchantId != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "merchantId", merchantId)); // query parameter } if (sort != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "sort", sort)); // query parameter } if (parcelTrackingNumber != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "parcelTrackingNumber", parcelTrackingNumber)); // query parameter } if (xPBUnifiedErrorStructure != null) { localVarHeaderParams.Add("X-PB-UnifiedErrorStructure", this.Configuration.ApiClient.ParameterToString(xPBUnifiedErrorStructure)); // header parameter } if (transactionId != null) { localVarHeaderParams.Add("transactionId", this.Configuration.ApiClient.ParameterToString(transactionId)); // header parameter } // authentication (oAuth2ClientCredentials) required // oauth required if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken; } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("GetTransactionReport", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <PageRealTransactionDetailReport>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), (PageRealTransactionDetailReport)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(PageRealTransactionDetailReport)))); }
/// <summary> /// Create an instance of 'hclSupportedDriverName' /// </summary> /// <exception cref="intersight.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body">hclSupportedDriverName to add</param> /// <returns>Task of ApiResponse</returns> public async System.Threading.Tasks.Task <ApiResponse <Object> > HclSupportedDriverNamesPostAsyncWithHttpInfo(HclSupportedDriverName body) { // verify the required parameter 'body' is set if (body == null) { throw new ApiException(400, "Missing required parameter 'body' when calling HclSupportedDriverNameApi->HclSupportedDriverNamesPost"); } var localVarPath = "/hcl/SupportedDriverNames"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (body != null && body.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter } else { localVarPostBody = body; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("HclSupportedDriverNamesPost", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null)); }
/// <summary> /// List insurance levels Return available insurance levels for all ship types - -- This route is cached for up to 3600 seconds /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="acceptLanguage">Language to use in the response (optional, default to en-us)</param> /// <param name="datasource">The server name you would like data from (optional, default to tranquility)</param> /// <param name="ifNoneMatch">ETag from a previous request. A 304 will be returned if this matches the current ETag (optional)</param> /// <param name="language">Language to use in the response, takes precedence over Accept-Language (optional, default to en-us)</param> /// <returns>Task of ApiResponse (List<GetInsurancePrices200Ok>)</returns> public async System.Threading.Tasks.Task <ApiResponse <List <GetInsurancePrices200Ok> > > GetInsurancePricesAsyncWithHttpInfo(string acceptLanguage = null, string datasource = null, string ifNoneMatch = null, string language = null) { var localVarPath = "/v1/insurance/prices/"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (datasource != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "datasource", datasource)); // query parameter } if (language != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "language", language)); // query parameter } if (acceptLanguage != null) { localVarHeaderParams.Add("Accept-Language", Configuration.ApiClient.ParameterToString(acceptLanguage)); // header parameter } if (ifNoneMatch != null) { localVarHeaderParams.Add("If-None-Match", Configuration.ApiClient.ParameterToString(ifNoneMatch)); // header parameter } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("GetInsurancePrices", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <List <GetInsurancePrices200Ok> >(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (List <GetInsurancePrices200Ok>)Configuration.ApiClient.Deserialize(localVarResponse, typeof(List <GetInsurancePrices200Ok>)))); }
/// <summary> /// Create or update a FattMerchant payment method for a user Stores customer information and creates a payment method that can be used to pay invoices through the payments endpoints. <br><br><b>Permissions Needed:</b> FATTMERCHANT_ADMIN or owner /// </summary> /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="request">Request containing payment method information for user (optional)</param> /// <returns>ApiResponse of PaymentMethodResource</returns> public ApiResponse <PaymentMethodResource> CreateOrUpdateFattMerchantPaymentMethodWithHttpInfo(FattMerchantPaymentMethodRequest request = null) { var localVarPath = "/payment/provider/fattmerchant/payment-methods"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (request != null && request.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(request); // http body (model) parameter } else { localVarPostBody = request; // byte array } // authentication (oauth2_client_credentials_grant) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // authentication (oauth2_password_grant) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath, Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("CreateOrUpdateFattMerchantPaymentMethod", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <PaymentMethodResource>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (PaymentMethodResource)Configuration.ApiClient.Deserialize(localVarResponse, typeof(PaymentMethodResource)))); }
public ErrorException(IRestResponse response) : base(GetMessageFromRestResponse(response)) { }
/// <summary> /// Deserialize the JSON string into a proper object. /// </summary> /// <param name="response">The HTTP response.</param> /// <param name="type">Object type.</param> /// <returns>Object representation of the JSON string.</returns> public object Deserialize(IRestResponse response, Type type) { IList <Parameter> headers = response.Headers; if (type == typeof(byte[])) // return byte array { return(response.RawBytes); } // TODO: ? if (type.IsAssignableFrom(typeof(Stream))) if (type == typeof(Stream)) { if (headers != null) { var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath) ? Path.GetTempPath() : Configuration.TempFolderPath; var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$"); foreach (var header in headers) { var match = regex.Match(header.ToString()); if (match.Success) { string fileName = filePath + SanitizeFilename(match.Groups[1].Value.Replace("\"", "").Replace("'", "")); File.WriteAllBytes(fileName, response.RawBytes); return(new FileStream(fileName, FileMode.Open)); } } } var stream = new MemoryStream(response.RawBytes); return(stream); } if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object { return(DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind)); } if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type { return(ConvertType(response.Content, type)); } // at this point, it must be a model (json) try { if (type.IsGenericType && type.GetGenericTypeDefinition().IsAssignableFrom(typeof(List <>))) { Type baseGenericType = type.GetGenericArguments()[0]; serializerSettings.Converters = new List <JsonConverter> { (JsonConverter)Activator.CreateInstance(typeof(SingleOrArrayConverter <>).MakeGenericType(baseGenericType)) }; } return(JsonConvert.DeserializeObject(response.Content, type, serializerSettings)); } catch (Exception e) { throw new ApiException(500, e.Message); } }
public void ThenIGetAnOkResponse() { _response = Client.Execute <dynamic>(_request); Assert.AreEqual(HttpStatusCode.OK, _response.StatusCode); }
/// <summary> /// Move's the components in this Snippet into a new Process Group and discards the snippet /// </summary> /// <exception cref="ApiException">Thrown when fails to make API call</exception> /// <param name="id">The snippet id.</param> /// <param name="body">The snippet configuration details.</param> /// <returns>Task of ApiResponse (SnippetEntity)</returns> public async System.Threading.Tasks.Task <ApiResponse <SnippetEntity> > UpdateSnippetAsyncWithHttpInfo(string id, SnippetEntity body) { // verify the required parameter 'id' is set if (id == null) { throw new ApiException(400, "Missing required parameter 'id' when calling SnippetsApi->UpdateSnippet"); } // verify the required parameter 'body' is set if (body == null) { throw new ApiException(400, "Missing required parameter 'body' when calling SnippetsApi->UpdateSnippet"); } var localVarPath = "/snippets/{id}"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (id != null) { localVarPathParams.Add("id", this.Configuration.ApiClient.ParameterToString(id)); // path parameter } if (body != null && body.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter } else { localVarPostBody = body; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (this.ExceptionFactory != null) { Exception exception = this.ExceptionFactory("UpdateSnippet", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <SnippetEntity>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (SnippetEntity)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(SnippetEntity)))); }
private void BtnGetRemoteConfiguration_Click(object sender, EventArgs e) { TL.LogMessage("GetConfiguration", "Start of btnGetRemoteConfgiuration_Click"); try { int clientNumber = 0; TL.LogMessage("GetConfiguration", "Connecting to device: " + ipAddressString + ":" + portNumber.ToString()); string clientHostAddress = string.Format("{0}://{1}:{2}", serviceType, ipAddressString, portNumber.ToString()); TL.LogMessage("GetConfiguration", "Client host address: " + clientHostAddress); RestClient client = new RestClient(clientHostAddress) { PreAuthenticate = true }; TL.LogMessage("GetConfiguration", "Creating Authenticator"); client.Authenticator = new HttpBasicAuthenticator(userName, password); TL.LogMessage("GetConfiguration", "Setting timeout"); RemoteClientDriver.SetClientTimeout(client, 10); string managementUri = string.Format("{0}{1}/{2}", SharedConstants.REMOTE_SERVER_MANAGEMENT_URL_BASE, SharedConstants.API_VERSION_V1, SharedConstants.REMOTE_SERVER_MANGEMENT_GET_CONFIGURATION); RestRequest request = new RestRequest(managementUri.ToLowerInvariant(), Method.GET) { RequestFormat = DataFormat.Json }; request.AddParameter(SharedConstants.CLIENTID_PARAMETER_NAME, clientNumber.ToString()); uint transaction = RemoteClientDriver.TransactionNumber(); request.AddParameter(SharedConstants.CLIENTTRANSACTION_PARAMETER_NAME, transaction.ToString()); TL.LogMessage("GetConfiguration", "Client Txn ID: " + transaction.ToString() + ", Sending command to remote server"); IRestResponse response = client.Execute(request); string responseContent; if (response.Content.Length > 100) { responseContent = response.Content.Substring(0, 100); } else { responseContent = response.Content; } TL.LogMessage("GetConfiguration", string.Format("Response Status: '{0}', Response: {1}", response.StatusDescription, responseContent)); if ((response.ResponseStatus == ResponseStatus.Completed) & (response.StatusCode == System.Net.HttpStatusCode.OK)) { ConfigurationResponse configurationResponse = JsonConvert.DeserializeObject <ConfigurationResponse>(response.Content); ConcurrentDictionary <string, ConfiguredDevice> configuration = configurationResponse.Value; TL.LogMessage("GetConfiguration", "Number of device records: " + configuration.Count); using (Profile profile = new Profile()) { foreach (string deviceType in profile.RegisteredDeviceTypes) { TL.LogMessage("GetConfiguration", "Adding item: " + deviceType); registeredDeviceTypes.Add(deviceType); // Remember the device types on this system } foreach (ServedDeviceClient item in this.Controls.OfType <ServedDeviceClient>()) { TL.LogMessage(0, 0, 0, "GetConfiguration", "Starting Init"); item.InitUI(this, TL); TL.LogMessage(0, 0, 0, "GetConfiguration", "Completed Init"); item.DeviceType = configuration[item.Name].DeviceType; item.ProgID = configuration[item.Name].ProgID; item.DeviceNumber = configuration[item.Name].DeviceNumber; TL.LogMessage("GetConfiguration", "Completed"); } TL.LogMessage("GetConfiguration", "Before RecalculateDevice Numbers"); RecalculateDeviceNumbers(); TL.LogMessage("GetConfiguration", "After RecalculateDevice Numbers"); } // Handle exceptions received from the driver by the remote server if (configurationResponse.DriverException != null) { TL.LogMessageCrLf("GetConfiguration", string.Format("Exception Message: {0}, Exception Number: 0x{1}", configurationResponse.ErrorMessage, configurationResponse.ErrorNumber.ToString("X8"))); } } else { if (response.ErrorException != null) { TL.LogMessageCrLf("GetConfiguration", "RestClient exception: " + response.ErrorMessage + "\r\n " + response.ErrorException.ToString()); // throw new ASCOM.DriverException(string.Format("Communications exception: {0} - {1}", response.ErrorMessage, response.ResponseStatus), response.ErrorException); } else { TL.LogMessage("GetConfiguration" + " Error", string.Format("RestRequest response status: {0}, HTTP response code: {1}, HTTP response description: {2}", response.ResponseStatus.ToString(), response.StatusCode, response.StatusDescription)); // throw new ASCOM.DriverException("ServerConfigurationForm Error - Status: " + response.ResponseStatus + " " + response.StatusDescription); } } } catch (Exception ex) { TL.LogMessage("GetConfiguration", "Exception: " + ex.ToString()); } TL.LogMessage("GetConfiguration", "End of btnGetRemoteConfgiuration_Click"); }
/// <summary> /// Deletes account. Please use with care. This is irreversible operation (all customer data will be lost after account deletion). /// </summary> /// <exception cref="Hosting.PublicAPI.Sample.Generated.Invokers.ApiException">Thrown when fails to make API call</exception> /// <param name="accountID">The account's id.</param> /// <param name="reason">Gets or sets the account's leaving reason.</param> /// <param name="comments">Gets or sets the account's leaving comments. (optional)</param> /// <returns>Task of ApiResponse (Object)</returns> public async System.Threading.Tasks.Task<ApiResponse<Object>> AccountsV1DeleteAccountAsyncWithHttpInfo (string accountID, string reason, string comments = null) { // verify the required parameter 'accountID' is set if (accountID == null) throw new ApiException(400, "Missing required parameter 'accountID' when calling AccountsApi->AccountsV1DeleteAccount"); // verify the required parameter 'reason' is set if (reason == null) throw new ApiException(400, "Missing required parameter 'reason' when calling AccountsApi->AccountsV1DeleteAccount"); var localVarPath = "/v1/api/accounts/{accountID}"; var localVarPathParams = new Dictionary<String, String>(); var localVarQueryParams = new Dictionary<String, String>(); var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary<String, String>(); var localVarFileParams = new Dictionary<String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json", "text/json", "application/xml", "text/xml" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (accountID != null) localVarPathParams.Add("accountID", Configuration.ApiClient.ParameterToString(accountID)); // path parameter if (reason != null) localVarQueryParams.Add("reason", Configuration.ApiClient.ParameterToString(reason)); // query parameter if (comments != null) localVarQueryParams.Add("comments", Configuration.ApiClient.ParameterToString(comments)); // query parameter // authentication (Authorization) required if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Authorization"))) { localVarHeaderParams["Authorization"] = Configuration.GetApiKeyWithPrefix("Authorization"); } // make the HTTP request IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, Method.DELETE, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int) localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("AccountsV1DeleteAccount", localVarResponse); if (exception != null) throw exception; } return new ApiResponse<Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (Object) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Object))); }
public void WhenPOSTAPIIsInvokedWithCurrencyData() { Response = APIAdapter.callCurrencyConversionPOSTAPI(RestClient, CurrencyRequest); }
private async static Task <List <QuestionModel> > DeselializeAsync(IRestResponse response) { return(await JsonSerializer.DeserializeAsync <List <QuestionModel> >( new MemoryStream(Encoding.UTF8.GetBytes(response.Content)), new JsonSerializerOptions { PropertyNameCaseInsensitive = true })); }
/// <summary> /// Allows for extending response processing for <see cref="ApiClient"/> generated code. /// </summary> /// <param name="request">The RestSharp request object</param> /// <param name="response">The RestSharp response object</param> partial void InterceptResponse(IRestRequest request, IRestResponse response);
private void CreateIndex(string houseIndex) { var client = new RestClient($"{_config.ESURL}/{houseIndex}"); var request = new RestRequest(Method.PUT); IRestResponse response = client.Execute(request); }
/// <summary> /// CreateMobileAuthorizationCode Generates code to authorize a mobile application to connect to a Square card reader Authorization codes are one-time-use and expire __60 minutes__ after being issued. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Bearer ACCESS_TOKEN ``` Replace `ACCESS_TOKEN` with a [valid production authorization credential](https://docs.connect.squareup.com/get-started#step-4-understand-the-different-application-credentials). /// </summary> /// <exception cref="Square.Connect.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body">An object containing the fields to POST for the request. See the corresponding object definition for field details.</param> /// <returns>ApiResponse of CreateMobileAuthorizationCodeResponse</returns> public ApiResponse <CreateMobileAuthorizationCodeResponse> CreateMobileAuthorizationCodeWithHttpInfo(CreateMobileAuthorizationCodeRequest body) { // verify the required parameter 'body' is set if (body == null) { throw new ApiException(400, "Missing required parameter 'body' when calling MobileAuthorizationApi->CreateMobileAuthorizationCode"); } var localVarPath = "/mobile/authorization-code"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } localVarHeaderParams.Add("Square-Version", "2018-12-05"); if (body != null && body.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter } else { localVarPostBody = body; // byte array } // authentication (oauth2) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("CreateMobileAuthorizationCode", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <CreateMobileAuthorizationCodeResponse>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (CreateMobileAuthorizationCodeResponse)Configuration.ApiClient.Deserialize(localVarResponse, typeof(CreateMobileAuthorizationCodeResponse)))); }
public T Deserialize <T>(IRestResponse response) => JsonConvert.DeserializeObject <T>(response.Content);
public T ParseResponse <T>(IRestResponse response) { T parsedResponse = deserial.Deserialize <T>(response); return(parsedResponse); }
/// <summary> /// Querystatsfor:neteth0 TODO: Add Description /// </summary> /// <param name="itemInterval"></param> /// <param name="itemEndTime"></param> /// <param name="itemNames1"></param> /// <param name="itemNames2"></param> /// <param name="itemStartTime"></param> /// <param name="itemFunction"></param> /// <param name="contentType"></param> /// <returns></returns> public void ApplianceMonitoringQueryGet(string itemInterval, DateTime?itemEndTime, string itemNames1, string itemNames2, DateTime?itemStartTime, string itemFunction, string contentType) { // verify the required parameter 'itemInterval' is set if (itemInterval == null) { throw new ApiException(400, "Missing required parameter 'itemInterval' when calling ApplianceMonitoringQueryGet"); } // verify the required parameter 'itemEndTime' is set if (itemEndTime == null) { throw new ApiException(400, "Missing required parameter 'itemEndTime' when calling ApplianceMonitoringQueryGet"); } // verify the required parameter 'itemNames1' is set if (itemNames1 == null) { throw new ApiException(400, "Missing required parameter 'itemNames1' when calling ApplianceMonitoringQueryGet"); } // verify the required parameter 'itemNames2' is set if (itemNames2 == null) { throw new ApiException(400, "Missing required parameter 'itemNames2' when calling ApplianceMonitoringQueryGet"); } // verify the required parameter 'itemStartTime' is set if (itemStartTime == null) { throw new ApiException(400, "Missing required parameter 'itemStartTime' when calling ApplianceMonitoringQueryGet"); } // verify the required parameter 'itemFunction' is set if (itemFunction == null) { throw new ApiException(400, "Missing required parameter 'itemFunction' when calling ApplianceMonitoringQueryGet"); } // verify the required parameter 'contentType' is set if (contentType == null) { throw new ApiException(400, "Missing required parameter 'contentType' when calling ApplianceMonitoringQueryGet"); } string path = "/appliance/monitoring/query"; path = path.Replace("{format}", "json"); Dictionary <string, string> queryParams = new Dictionary <string, string>(); Dictionary <string, string> headerParams = new Dictionary <string, string>(); Dictionary <string, string> formParams = new Dictionary <string, string>(); Dictionary <string, FileParameter> fileParams = new Dictionary <string, FileParameter>(); string postBody = null; if (itemInterval != null) { queryParams.Add("item.interval", ApiClient.ParameterToString(itemInterval)); // query parameter } if (itemEndTime != null) { queryParams.Add("item.end_time", ApiClient.ParameterToString(itemEndTime)); // query parameter } if (itemNames1 != null) { queryParams.Add("item.names.1", ApiClient.ParameterToString(itemNames1)); // query parameter } if (itemNames2 != null) { queryParams.Add("item.names.2", ApiClient.ParameterToString(itemNames2)); // query parameter } if (itemStartTime != null) { queryParams.Add("item.start_time", ApiClient.ParameterToString(itemStartTime)); // query parameter } if (itemFunction != null) { queryParams.Add("item.function", ApiClient.ParameterToString(itemFunction)); // query parameter } if (contentType != null) { headerParams.Add("Content-Type", ApiClient.ParameterToString(contentType)); // header parameter } // authentication setting, if any string[] authSettings = new string[] { "auth" }; // make the HTTP request IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { throw new ApiException((int)response.StatusCode, "Error calling ApplianceMonitoringQueryGet: " + response.Content, response.Content); } else if (response.StatusCode == 0) { throw new ApiException((int)response.StatusCode, "Error calling ApplianceMonitoringQueryGet: " + response.ErrorMessage, response.ErrorMessage); } return; }
public static MessageKeyboard ServiceLinks(string TVName, string date) { var client = new RestSharp.RestClient("https://www.googleapis.com/customsearch/v1"); var request = new RestRequest(Method.GET); request.AddQueryParameter("key", _google_key); request.AddQueryParameter("cx", _google_sid_series); request.AddQueryParameter("q", $"{TVName} {date.Substring(0, 4)} сериал смотреть"); request.AddQueryParameter("num", "10"); IRestResponse response = client.Execute(request); ServiceClass.service_data.IncGoogleRequests(); GoogleResponse results; try { results = JsonConvert.DeserializeObject <GoogleResponse>(response.Content); } catch (Exception) { return(null); } var dict = new Dictionary <string, string>(); foreach (var item in results.items) { if (Regex.IsMatch(item.link, @"https://megogo.net/ru/view/.+") && !dict.ContainsKey("MEGOGO")) { dict["MEGOGO"] = item.link; } else if (Regex.IsMatch(item.link, @"https://www.tvigle.ru/video/.+") && !dict.ContainsKey("TVIGLE")) { dict["TVIGLE"] = item.link; } else if (Regex.IsMatch(item.link, @"https://wink.rt.ru/media_items/.+") && !dict.ContainsKey("WINK")) { dict["WINK"] = item.link; } else if (Regex.IsMatch(item.link, @"https://okko.tv/serial/.+") && !dict.ContainsKey("OKKO")) { dict["OKKO"] = item.link; } else if (Regex.IsMatch(item.link, @"https://hd.kinopoisk.ru/film/.+") && !dict.ContainsKey("КИНОПОИСК")) { dict["КИНОПОИСК"] = item.link; } else if (Regex.IsMatch(item.link, @"https://www.kinopoisk.ru/series/.+") && !dict.ContainsKey("КИНОПОИСК") && item.title.Contains("смотреть онлайн")) { dict["КИНОПОИСК"] = item.link; } else if (Regex.IsMatch(item.link, @"https://www.netflix.com/ru/title/.+") && !dict.ContainsKey("NETFLIX")) { dict["NETFLIX"] = item.link; } else if (Regex.IsMatch(item.link, @"https://www.amediateka.ru/watch/series.+") && !dict.ContainsKey("AMEDIATEKA")) { dict["AMEDIATEKA"] = item.link; } else if (Regex.IsMatch(item.link, @"https://more.tv/.+") && !dict.ContainsKey("MORE")) { dict["MORE"] = item.link; } else if (Regex.IsMatch(item.link, @"https://www.tvzavr.ru/film/.+") && !dict.ContainsKey("TVZAVR")) { dict["TVZAVR"] = item.link; } if (dict.Count == 2) { break; } } return(dict.Count == 0 ? null : Keyboards.ServiceLinks(dict)); }
/// <summary> /// Search Searches for the entities as specified by the given query. /// </summary> /// <exception cref="Customweb.Wallee.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="spaceId"></param> /// <param name="query">The query restricts the usage reports which are returned by the search.</param> /// <returns>Task of ApiResponse (List<SubscriptionMetricUsageReport>)</returns> public async System.Threading.Tasks.Task<ApiResponse<List<SubscriptionMetricUsageReport>>> SearchAsyncWithHttpInfo (long? spaceId, EntityQuery query) { // verify the required parameter 'spaceId' is set if (spaceId == null) { throw new ApiException(400, "Missing required parameter 'spaceId' when calling SubscriptionMetricUsageService->Search"); } // verify the required parameter 'query' is set if (query == null) { throw new ApiException(400, "Missing required parameter 'query' when calling SubscriptionMetricUsageService->Search"); } var localVarPath = "/subscription-metric-usage/search"; var localVarPathParams = new Dictionary<String, String>(); var localVarQueryParams = new Dictionary<String, String>(); var localVarHeaderParams = new Dictionary<String, String>(); var localVarFormParams = new Dictionary<String, String>(); var localVarFileParams = new Dictionary<String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json;charset=utf-8" }; String localVarHttpContentType = ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json;charset=utf-8" }; String localVarHttpHeaderAccept = ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (spaceId != null) localVarQueryParams.Add("spaceId", ApiClient.ParameterToString(spaceId)); // query parameter if (query != null && query.GetType() != typeof(byte[])) { localVarPostBody = ApiClient.Serialize(query); // http body (model) parameter } else { localVarPostBody = query; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse) await ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int) localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("Search", localVarResponse); if (exception != null) throw exception; } return new ApiResponse<List<SubscriptionMetricUsageReport>>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (List<SubscriptionMetricUsageReport>) ApiClient.Deserialize(localVarResponse, typeof(List<SubscriptionMetricUsageReport>))); }
/// <summary> /// Обновляет список популярных сериалов /// </summary> public static void UpdatePopularTV() { var res = new Dictionary <int, TVObject>(); //добавление первой страницы сериалов var clientA = new RestSharp.RestClient("https://api.tmdb.org/3/tv/popular"); var requestA = new RestRequest(Method.GET); requestA.AddQueryParameter("api_key", Bot._mdb_key); requestA.AddQueryParameter("page", "1"); IRestResponse responseA = clientA.Execute(requestA); MDBResultsTV deserializedA; try { deserializedA = JsonConvert.DeserializeObject <MDBResultsTV>(responseA.Content); } catch (Exception) { return; } if (deserializedA == null || deserializedA.total_pages == 0) { return; } var list = deserializedA.results; //добавление второй страницы сериалов var clientB = new RestSharp.RestClient("https://api.tmdb.org/3/tv/popular"); var requestB = new RestRequest(Method.GET); requestB.AddQueryParameter("api_key", Bot._mdb_key); requestB.AddQueryParameter("page", "2"); IRestResponse responseB = clientB.Execute(requestB); MDBResultsTV deserializedB; try { deserializedB = JsonConvert.DeserializeObject <MDBResultsTV>(responseB.Content); } catch (Exception) { deserializedB = null; } if (deserializedB != null && deserializedB.total_pages != 0) { //объединение двух списков-страниц в один список list.AddRange(deserializedB.results); } //параллельный обход списка foreach (var result in list) { //запрос сериала по его названию var KPclient1 = new RestSharp.RestClient("https://kinopoiskapiunofficial.tech/api/v2.1/films/search-by-keyword"); var KPrequest1 = new RestRequest(Method.GET); KPrequest1.AddHeader("X-API-KEY", Bot._kp_key); KPrequest1.AddHeader("accept", "application/json"); KPrequest1.AddQueryParameter("keyword", result.original_name); var KPresponse1 = KPclient1.Execute(KPrequest1); TVResults.Results deserialized; try { deserialized = JsonConvert.DeserializeObject <TVResults.Results>(KPresponse1.Content); } catch (Exception) { deserialized = null; } //проверка успешности десериализации if (deserialized != null && deserialized.pagesCount > 0) { //выбор сериала из результатов ответа на запрос, такого, что это сериал/мини-сериал и что его еще нет в результирующем словаре int id = 0; foreach (var f in deserialized.films) { if (f.nameRu.EndsWith("(сериал)") || f.nameRu.EndsWith("(мини-сериал)")) { id = f.filmId; break; } } if (id != 0 && !res.ContainsKey(id)) { //запрос выбранного сериала по его ID var KPclient2 = new RestSharp.RestClient($"https://kinopoiskapiunofficial.tech/api/v2.1/films/{id}"); var KPrequest2 = new RestRequest(Method.GET); KPrequest2.AddHeader("X-API-KEY", Bot._kp_key); KPrequest2.AddHeader("accept", "application/json"); KPrequest2.AddQueryParameter("append_to_response", "RATING"); var KPresponse2 = KPclient2.Execute(KPrequest2); TV.TVObject film; try { film = JsonConvert.DeserializeObject <TV.TVObject>(KPresponse2.Content); } catch (Exception) { film = null; } if (film != null) { film.Priority = 1; string photoID2; //Video trailer = null; film.data.VKPhotoID = Attachments.PopularTVPosterID(film, out photoID2); //ID Не обрезанного постера film.data.VKPhotoID_2 = photoID2; //проверка валидности загруженной фотографии if (film.data.VKPhotoID != null && film.data.VKPhotoID_2 != null) { //Methods.GetTrailer(film.data.filmId, ref trailer); //film.TrailerInfo = trailer; res[id] = film; } } } } } PopularTV = res; }
/// <summary> /// Search on a string Search for entities that match a given sub-string. - -- This route is cached for up to 3600 seconds /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="categories">Type of entities to search for</param> /// <param name="characterId">An EVE character ID</param> /// <param name="search">The string to search on</param> /// <param name="acceptLanguage">Language to use in the response (optional, default to en-us)</param> /// <param name="datasource">The server name you would like data from (optional, default to tranquility)</param> /// <param name="ifNoneMatch">ETag from a previous request. A 304 will be returned if this matches the current ETag (optional)</param> /// <param name="language">Language to use in the response, takes precedence over Accept-Language (optional, default to en-us)</param> /// <param name="strict">Whether the search should be a strict match (optional, default to false)</param> /// <param name="token">Access token to use if unable to set a header (optional)</param> /// <returns>ApiResponse of GetCharactersCharacterIdSearchOk</returns> public ApiResponse <GetCharactersCharacterIdSearchOk> GetCharactersCharacterIdSearchWithHttpInfo(List <string> categories, int?characterId, string search, string acceptLanguage = null, string datasource = null, string ifNoneMatch = null, string language = null, bool?strict = null, string token = null) { // verify the required parameter 'categories' is set if (categories == null) { throw new ApiException(400, "Missing required parameter 'categories' when calling SearchApi->GetCharactersCharacterIdSearch"); } // verify the required parameter 'characterId' is set if (characterId == null) { throw new ApiException(400, "Missing required parameter 'characterId' when calling SearchApi->GetCharactersCharacterIdSearch"); } // verify the required parameter 'search' is set if (search == null) { throw new ApiException(400, "Missing required parameter 'search' when calling SearchApi->GetCharactersCharacterIdSearch"); } var localVarPath = "/v3/characters/{character_id}/search/"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (characterId != null) { localVarPathParams.Add("character_id", Configuration.ApiClient.ParameterToString(characterId)); // path parameter } if (categories != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("multi", "categories", categories)); // query parameter } if (datasource != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "datasource", datasource)); // query parameter } if (language != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "language", language)); // query parameter } if (search != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "search", search)); // query parameter } if (strict != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "strict", strict)); // query parameter } if (token != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "token", token)); // query parameter } if (acceptLanguage != null) { localVarHeaderParams.Add("Accept-Language", Configuration.ApiClient.ParameterToString(acceptLanguage)); // header parameter } if (ifNoneMatch != null) { localVarHeaderParams.Add("If-None-Match", Configuration.ApiClient.ParameterToString(ifNoneMatch)); // header parameter } // authentication (evesso) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("GetCharactersCharacterIdSearch", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <GetCharactersCharacterIdSearchOk>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (GetCharactersCharacterIdSearchOk)Configuration.ApiClient.Deserialize(localVarResponse, typeof(GetCharactersCharacterIdSearchOk)))); }
public T Deserialize <T>(IRestResponse response) { var type = typeof(T); return((T)JsonConvert.DeserializeObject(response.Content, type, SerializerSettings)); }
/// <summary> /// Search on a string Search for entities that match a given sub-string. - -- This route is cached for up to 3600 seconds /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="categories">Type of entities to search for</param> /// <param name="search">The string to search on</param> /// <param name="acceptLanguage">Language to use in the response (optional, default to en-us)</param> /// <param name="datasource">The server name you would like data from (optional, default to tranquility)</param> /// <param name="ifNoneMatch">ETag from a previous request. A 304 will be returned if this matches the current ETag (optional)</param> /// <param name="language">Language to use in the response, takes precedence over Accept-Language (optional, default to en-us)</param> /// <param name="strict">Whether the search should be a strict match (optional, default to false)</param> /// <returns>Task of ApiResponse (GetSearchOk)</returns> public async System.Threading.Tasks.Task <ApiResponse <GetSearchOk> > GetSearchAsyncWithHttpInfo(List <string> categories, string search, string acceptLanguage = null, string datasource = null, string ifNoneMatch = null, string language = null, bool?strict = null) { // verify the required parameter 'categories' is set if (categories == null) { throw new ApiException(400, "Missing required parameter 'categories' when calling SearchApi->GetSearch"); } // verify the required parameter 'search' is set if (search == null) { throw new ApiException(400, "Missing required parameter 'search' when calling SearchApi->GetSearch"); } var localVarPath = "/v2/search/"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (categories != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("multi", "categories", categories)); // query parameter } if (datasource != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "datasource", datasource)); // query parameter } if (language != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "language", language)); // query parameter } if (search != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "search", search)); // query parameter } if (strict != null) { localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "strict", strict)); // query parameter } if (acceptLanguage != null) { localVarHeaderParams.Add("Accept-Language", Configuration.ApiClient.ParameterToString(acceptLanguage)); // header parameter } if (ifNoneMatch != null) { localVarHeaderParams.Add("If-None-Match", Configuration.ApiClient.ParameterToString(ifNoneMatch)); // header parameter } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("GetSearch", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <GetSearchOk>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (GetSearchOk)Configuration.ApiClient.Deserialize(localVarResponse, typeof(GetSearchOk)))); }
/// <summary> /// Returns a list of api endpoints for a specified service and aoo /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="aooUID">Aoo unique identifier</param> /// <param name="serviceUID">Service unique identifier</param> /// <param name="xAuthorization">access_token</param> /// <returns>Task of ApiResponse (ServicesDiscoveryResponse)</returns> public async System.Threading.Tasks.Task <ApiResponse <ServicesDiscoveryResponse> > GetAooServiceApiAsyncWithHttpInfo(Guid?aooUID, string serviceUID, string xAuthorization) { // verify the required parameter 'aooUID' is set if (aooUID == null) { throw new ApiException(400, "Missing required parameter 'aooUID' when calling ServicesApi->GetAooServiceApi"); } // verify the required parameter 'serviceUID' is set if (serviceUID == null) { throw new ApiException(400, "Missing required parameter 'serviceUID' when calling ServicesApi->GetAooServiceApi"); } // verify the required parameter 'xAuthorization' is set if (xAuthorization == null) { throw new ApiException(400, "Missing required parameter 'xAuthorization' when calling ServicesApi->GetAooServiceApi"); } var localVarPath = "/api/v1/discovery/aoos/{aooUID}/services/{serviceUID}"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json", "text/json", "application/xml", "text/xml" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (aooUID != null) { localVarPathParams.Add("aooUID", Configuration.ApiClient.ParameterToString(aooUID)); // path parameter } if (serviceUID != null) { localVarPathParams.Add("serviceUID", Configuration.ApiClient.ParameterToString(serviceUID)); // path parameter } if (xAuthorization != null) { localVarHeaderParams.Add("X-Authorization", Configuration.ApiClient.ParameterToString(xAuthorization)); // header parameter } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("GetAooServiceApi", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <ServicesDiscoveryResponse>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (ServicesDiscoveryResponse)Configuration.ApiClient.Deserialize(localVarResponse, typeof(ServicesDiscoveryResponse)))); }
public void WhenCurrencyConversionAPIIsInvokedForGivenData() { Response = APIAdapter.callCurrencyConversionGETAPI(RestClient); }
/// <summary> /// Deletes the components in a snippet and discards the snippet /// </summary> /// <exception cref="ApiException">Thrown when fails to make API call</exception> /// <param name="id">The snippet id.</param> /// <param name="disconnectedNodeAcknowledged">Acknowledges that this node is disconnected to allow for mutable requests to proceed. (optional, default to false)</param> /// <returns>Task of ApiResponse (SnippetEntity)</returns> public async System.Threading.Tasks.Task <ApiResponse <SnippetEntity> > DeleteSnippetAsyncWithHttpInfo(string id, bool?disconnectedNodeAcknowledged = null) { // verify the required parameter 'id' is set if (id == null) { throw new ApiException(400, "Missing required parameter 'id' when calling SnippetsApi->DeleteSnippet"); } var localVarPath = "/snippets/{id}"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "*/*" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (id != null) { localVarPathParams.Add("id", this.Configuration.ApiClient.ParameterToString(id)); // path parameter } if (disconnectedNodeAcknowledged != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "disconnectedNodeAcknowledged", disconnectedNodeAcknowledged)); // query parameter } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.DELETE, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (this.ExceptionFactory != null) { Exception exception = this.ExceptionFactory("DeleteSnippet", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <SnippetEntity>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (SnippetEntity)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(SnippetEntity)))); }
public void setProductInfo(IRestResponse<_REST_ProductInfo> ProductInfo) { imgProduct.Source = new BitmapImage(new Uri(ProductInfo.Data.imageUrl)); lblProductName.Content = ProductInfo.Data.name; lblProductInfo2.Content = ProductInfo.Data.price; lblProductInfo3.Content = ProductInfo.Data.price; string season = ""; string lookType = ""; switch (ProductInfo.Data.season) { case 0: season = "봄"; break; case 1: season = "여름"; break; case 2: season = "가을"; break; case 3: season = "겨울"; break; } if (ProductInfo.Data.lookType == 1) lookType = "하의"; else lookType = "상의"; lblProductInfo1.Content = ProductInfo.Data.year + " " + season + "시즌 상품"; lblProductInfo1.Content += "\n" + lookType; lblProductInfo1.Content += "\n" + ProductInfo.Data.shotCount + "번 찍힘"; }