コード例 #1
0
 public bool CheckCredentials(string email, string password)
 {
     var request = new RestRequest("api/User/CheckCredentials?email={email}&password={password}", Method.GET);
     request.AddUrlSegment("email", email);
     request.AddUrlSegment("password", password);
     return client.Execute<bool>(request).Data;
 }
コード例 #2
0
        /// <summary>
        /// Removes a rule from a load balancer.
        /// </summary>
        /// <param name="load_balancer_id">Unique load balancer's identifier..</param>
        /// <param name="rule_id">Unique rule's identifier.</param>
        /// 
        public LoadBalancerResponse DeleteLoadBalancerRules(string load_balancer_id, string rule_id)
        {
            try
            {
                var request = new RestRequest("/load_balancers/{load_balancer_id}/rules/{rule_id}", Method.DELETE)
                {
                    RequestFormat = DataFormat.Json,
                    JsonSerializer = new CustomSerializer()
                };
                request.AddUrlSegment("load_balancer_id", load_balancer_id);
                request.AddUrlSegment("rule_id", rule_id);
                request.AddHeader("Content-Type", "application/json");

                var result = restclient.Execute<LoadBalancerResponse>(request);
                if (result.StatusCode != HttpStatusCode.Accepted)
                {
                    throw new Exception(result.Content);
                }
                return result.Data;
            }
            catch
            {
                throw;
            }
        }
コード例 #3
0
 /// <summary>
 /// Adds a new load balancer to the IP
 /// </summary>
 /// <param name="server_id">Unique server's identifier.</param>
 ///  <param name="ip_id">Unique server's identifier.</param>
 public ServerResponse CreateLoadBalancer(string server_id, string ip_id, string loadBalancerId)
 {
     try
     {
         var request = new RestRequest("/servers/{server_id}/ips/{ip_id}/load_balancers", Method.POST)
         {
             RequestFormat = DataFormat.Json,
             JsonSerializer = new CustomSerializer()
         };
         request.AddUrlSegment("server_id", server_id);
         request.AddUrlSegment("ip_id", ip_id);
         string load_balancer_id = loadBalancerId;
         request.AddBody(new { load_balancer_id });
         var result = restclient.Execute<ServerResponse>(request);
         if (result.StatusCode != HttpStatusCode.Accepted)
         {
             throw new Exception(result.Content);
         }
         return result.Data;
     }
     catch
     {
         throw;
     }
 }
コード例 #4
0
        /// <summary>
        /// Returns a list of all Champions in the current Version
        /// </summary>
        /// <param name="region">Region of data</param>
        public static List<Champion> GetAllChampions(string region)
        {
            var cacheName = "allChamps_" + region;
            var cached = HttpContext.Current.Cache[cacheName] as List<Champion>;

            if (cached != null)
                return cached;

            var client = ApiTools.GlobalApiClient();

            var request = new RestRequest(UrlFormat, Method.GET);

            request.AddUrlSegment("region", region);
            request.AddUrlSegment("method", "champion");

            request.AddParameter("dataById", true);

            request.AddApiKey();

            var response = client.Execute(request);
            var response2 = client.Execute<dynamic>(request);

            var champs = ParseAllChampsResponse(region, response.Content);

            HttpContext.Current.Cache[cacheName] = champs;

            return champs;
        }
コード例 #5
0
ファイル: File.cs プロジェクト: erpframework/SugarSharp
        /// <summary>
        /// Uploads a file, if the request fails this overload will delete the note record
        /// </summary>
        /// <param name="module">Notes</param>
        /// <param name="id">Record ID</param>
        /// <param name="filePath">Path to file on local disk</param>
        /// <param name="deleteOnFailure">Bool: deletes record if upload fails</param>
        /// <returns>Bool</returns>
        public bool UploadFile(string module, string id, string filePath, bool deleteOnFailure)
        {
            var request = new RestRequest("{module}/{id}/file/filename", Method.POST);
            request.AddUrlSegment("module", module);
            request.AddUrlSegment("id", id);

            request.AddParameter("format", "sugar-html-json");
            request.AddParameter("delete_if_fails", deleteOnFailure);

            if (deleteOnFailure)
            {
                request.AddParameter("oauth_token", Token);
            }

            if (!File.Exists(filePath))
            {
                //@todo create a SugarFileException class
                throw new SugarException("Can not locate file path. Path attempted = " + filePath);
            }

            request.AddFile("filename", filePath);//?

            FileUploadResponse response = Execute<FileUploadResponse>(request);

            return ! string.IsNullOrEmpty(response.filename.name);
        }
        /// <summary>
        /// Removes a process from a monitoring policy.
        /// </summary>
        /// <param name="process_id">Unique process's identifier.</param>
        /// <param name="monitoring_policy_id">Unique monitoring policy's identifier.</param>
        /// 
        public MonitoringPoliciesResponse Delete(string monitoring_policy_id, string process_id)
        {
            try
            {
                var request = new RestRequest("/monitoring_policies/{monitoring_policy_id}/processes/{process_id}", Method.DELETE)
                {
                    RequestFormat = DataFormat.Json,
                    JsonSerializer = new CustomSerializer()
                };
                request.AddUrlSegment("monitoring_policy_id", monitoring_policy_id);
                request.AddUrlSegment("process_id", process_id);
                request.AddHeader("Content-Type", "application/json");

                var result = restclient.Execute<MonitoringPoliciesResponse>(request);
                if (result.StatusCode != HttpStatusCode.Accepted)
                {
                    throw new Exception(result.Content);
                }
                return result.Data;
            }
            catch
            {
                throw;
            }
        }
コード例 #7
0
        public void LoadData()
        {
            var client = new RestClient("http://api.nytimes.com");
            client.ClearHandlers();
            var request = new RestRequest("{a}/{b}/{c}/{d}/{e}/{f}");
            request.AddUrlSegment("a", "svc");
            request.AddUrlSegment("b", "mostpopular");
            request.AddUrlSegment("c", "v2");
            request.AddUrlSegment("d", "mostviewed");
            request.AddUrlSegment("e", "all-sections");
            request.AddUrlSegment("f", "1.json");

            request.AddParameter("api-key", "536306de3cfe2283df9c091afea40e82:9:67546031");
            request.RequestFormat = DataFormat.Json;

            try
            {
                var asyncHandle = client.ExecuteAsync(request, response =>
                {
                    if (response.ResponseStatus == ResponseStatus.Completed)
                    {
                        UpdateArticleList(response.Content);
                        MessageBox.Show(response.Content);
                    }
                    else
                        MessageBox.Show("Tidak dapat terhubung ke server");
                });
            }
            catch {
                MessageBox.Show("Eksekusi Gagal");

            }
        }
コード例 #8
0
        /// <summary>
        /// Removes a rule from a firewall policy.
        /// </summary>
        /// <param name="firewall_id">Unique firewall's identifier.</param>
        /// <param name="rule_id">Unique rule's identifier.</param>
        /// 
        public FirewallPolicyResponse DeleteFirewallPolicyRules(string firewall_id, string rule_id)
        {
            try
            {
                var request = new RestRequest("/firewall_policies/{firewall_id}/rules/{rule_id}", Method.DELETE)
                {
                    RequestFormat = DataFormat.Json,
                    JsonSerializer = new CustomSerializer()
                };
                request.AddUrlSegment("firewall_id", firewall_id);
                request.AddUrlSegment("rule_id", rule_id);
                request.AddHeader("Content-Type", "application/json");

                var result = restclient.Execute<FirewallPolicyResponse>(request);
                if (result.StatusCode != HttpStatusCode.Accepted)
                {
                    throw new Exception(result.Content);
                }
                return result.Data;
            }
            catch
            {
                throw;
            }
        }
コード例 #9
0
        public byte[] DownloadZipball(string owner, string repo, string branch)
        {
            RestClient _client = new RestClient
            {
                BaseUrl = "https://github.com",
                Authenticator = client.Authenticator,
            };
            var request = new RestRequest
            {
                Resource = "/{owner}/{repo}/zipball/{branch}",
                Method = Method.GET
            };

            request.AddUrlSegment("owner", owner);
            request.AddUrlSegment("repo", repo);
            request.AddUrlSegment("branch", branch);

            var response =_client.Execute(request);
            if (response.ContentLength != -1)
            {
                return response.RawBytes;
            }
            else {
                return null;
            }
        }
コード例 #10
0
        private static RestRequest createRequest(string latitude, string longitude)
        {
            //curl "https://cache.fastpokemap.se/?key=allow-all&ts=0&lat=40.7686142466727&lng=-73.98459434509279"
            //-H "Accept: application/json, text/javascript, */*; q=0.01"
            //-H "Connection: keep-alive"
            //-H "Origin: https://fastpokemap.se"
            //-H "Accept-Encoding: gzip, deflate, sdch, br"
            //-H "Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4"
            //-H "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.0 Safari/537.36" --compressed
            var req = new RestSharp.RestRequest("?key={key}&ts={ts}&lat={lat}&lng={lng}", Method.GET);

            req.AddHeader("Accept", HeaderAccept);
            req.AddHeader("Origin", HeaderOriginUrl);
            req.AddHeader("Accept-Encoding", HeaderAcceptEncoding);
            req.AddHeader("Accept-Language", "de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4");
            req.AddHeader("User-Agent", HeaderUserAgent);
            req.AddHeader("authority", HeaderAuthority);

            latitude  = latitude.Replace(",", ".");
            longitude = longitude.Replace(",", ".");

            req.AddUrlSegment("key", ParameterKey);
            req.AddUrlSegment("ts", ParameterTs);
            req.AddUrlSegment("lat", latitude);
            req.AddUrlSegment("lng", longitude);

            req.JsonSerializer.ContentType = "application/json; charset=utf-8";

            return(req);
        }
コード例 #11
0
		public List<MagicHelper_Bot.Models.Product> SearchProduct (IDictionary<string,string> searchParams)
		{			
			var req = new RestRequest ("products/{name}/{idGame}/{idLanguage}/{isExact}", Method.GET);

			foreach (var param in searchParams) {
				if (param.Key.Equals ("subject")) {
					req.AddUrlSegment ("name", param.Value);
				}
			}

			req.AddUrlSegment ("idGame", MtgGameId.ToString ());
			req.AddUrlSegment ("idLanguage", EnglishLanguageId.ToString ());
			req.AddUrlSegment ("isExact", "false");

			AddAuthorizationHeader (req);

			var result = client.Execute<ProductQueryResult> (req);
			if (result.StatusCode != System.Net.HttpStatusCode.OK) {
				System.Console.WriteLine ("Mcm request failed: " + result.StatusCode + ": " + result.StatusDescription);
			}

			var casted = new List<MagicHelper_Bot.Models.Product> ();
			foreach (Product product in result.Data.Products) {
				casted.Add ((MagicHelper_Bot.Models.Product)product);
			}

			return casted;
		}
コード例 #12
0
        /// <summary>
        /// Deletes an IP and forbides API access for it.
        /// </summary>
        /// <param name="user_id">Unique user's identifier.</param>
        /// <param name="ip">Desired IP</param>
        /// 
        public UserResponse DeleteUserIp(string user_id, string ip)
        {
            try
            {
                var request = new RestRequest("/users/{user_id}/api/ips/{ip}", Method.DELETE)
                {
                    RequestFormat = DataFormat.Json,
                    JsonSerializer = new CustomSerializer()
                };
                request.AddUrlSegment("user_id", user_id);
                request.AddUrlSegment("ip", ip);
                request.AddHeader("Content-Type", "application/json");

                var result = restclient.Execute<UserResponse>(request);
                if (result.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception(result.Content);
                }
                return result.Data;
            }
            catch
            {
                throw;
            }
        }
コード例 #13
0
ファイル: SteamRepository.cs プロジェクト: tautvisv/SD2WA
        public MinimizedMatchDtoContainer GetMatches(int? playerID = null, int? matchID = null, int? heroID = null, int? matchCount = null)
        {
            var client = new RestClient(Globals.DotaSteamAPI);
            var request = new RestRequest(Globals.DotaSteamAPIDotaInterfarce + "GetMatchHistory/" + Globals.DotaSteamAPIWeb1 + "?key={raktas}&account_id={player_id}&matches_requested={match_count}&start_at_match_id={match_id}&hero_id={hero_id}", Method.GET);
            request.AddUrlSegment("raktas", Globals.DotaAPIKey);
            if (playerID != null)
            {
                request.AddUrlSegment("player_id", playerID.ToString());
            }
            if (matchID != null)
            {
                request.AddUrlSegment("match_id", matchID.ToString());
            }
            if (heroID != null)
            {
                request.AddUrlSegment("hero_id", heroID.ToString());
            }
            if (matchCount != null)
            {
                request.AddUrlSegment("match_count", matchCount.ToString());
            }
            var response = client.Execute(request);
            var data = JsonConvert.DeserializeObject<MinimizedMatchDtoContainer>(response.Content);

            return data;
        }
コード例 #14
0
        /// <summary>
        /// Unattaches a server from a shared storage.
        /// </summary>
        /// <param name="shared_storage_id">Unique shared storage's identifier.</param>
        /// 
        public SharedStoragesResponse DeleteSharedStoragesServer(string shared_storage_id, string server_id)
        {
            try
            {
                var request = new RestRequest("/shared_storages/{shared_storage_id}/servers/{server_id}", Method.DELETE)
                {
                    RequestFormat = DataFormat.Json,
                    JsonSerializer = new CustomSerializer()
                };
                request.AddUrlSegment("shared_storage_id", shared_storage_id);
                request.AddUrlSegment("server_id", server_id);
                request.AddHeader("Content-Type", "application/json");

                var result = restclient.Execute<SharedStoragesResponse>(request);
                if (result.StatusCode != HttpStatusCode.Accepted)
                {
                    throw new Exception(result.Content);
                }
                return result.Data;
            }
            catch
            {
                throw;
            }
        }
コード例 #15
0
        private void PostLogFile(string macAddress, Guid requestId, Guid logFileId, string fileName)
        {
            string path = GetFilePath(fileName);

            if (!File.Exists(path))
            {
                Logger.Instance.Write("PostLogFile", LogLevel.Medium, "PostLog failed as the log file does not exist.");
                RequestComponent.GetInstance().FinishRequest(macAddress, RequestInputModel.From(requestId, false));
                return;
            }

            var request = new RestRequest("v1/signboards/{macAddress}/logFiles/{logFileId}/file", Method.POST);
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.AddUrlSegment("macAddress", macAddress);
            request.AddUrlSegment("logFileId", logFileId.ToString());
            request.AddBody(DeviceLogModel.From(fileName));
            request.AddFile("file", File.ReadAllBytes(path), Path.GetFileName(path), "multipart/form-data");

            Client.ExecuteAsync<DeviceLogResponseModel>(request, (response) =>
            {
                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    Logger.Instance.Write("PostLogFile", LogLevel.Low, "Uploaded  log file successfully.");
                    RequestComponent.GetInstance().FinishRequest(macAddress, RequestInputModel.From(requestId, true));
                    return;
                }
                else
                {
                    Logger.Instance.Write("PostLog", LogLevel.Medium, "PostLog request failed. ");
                    RequestComponent.GetInstance().FinishRequest(macAddress, RequestInputModel.From(requestId, false));
                    return;
                }
            });
        }
コード例 #16
0
        private RestRequest makeRequest(string requestString)
        {
            RestRequest request = new RestRequest(@"{version}/{format}/" + requestString);
            request.AddUrlSegment("version", apiVersion);
            request.AddUrlSegment("format", format);

            return request;
        }
コード例 #17
0
 /// <summary>
 /// Clear a textarea or text imput element's value.
 /// </summary>
 /// <param name="sessionID">ID of the session to route the command to</param>
 /// <param name="driverElementID">Driver element ID (is found by FindElement method)</param>
 public static void ClearElementText(string sessionID, int driverElementID)
 {
     var client = new RestClient(ServerUrl);
     var request = new RestRequest("wd/hub/session/{id}/element/{elementID}/clear", Method.POST);
     request.AddUrlSegment("id", sessionID);
     request.AddUrlSegment("elementID", driverElementID.ToString("0"));
     client.Execute(request);
 }
コード例 #18
0
        public Task<BuildInfo> GetLastBuild(string accountName, string projectSlug)
        {
            var request = new RestRequest("projects/{accountName}/{projectSlug}", Method.GET);
            request.AddUrlSegment("accountName", accountName);
            request.AddUrlSegment("projectSlug", projectSlug);

            return ExecuteAsync<BuildInfo>(request);
        }
コード例 #19
0
        public static async Task<IRestResponse<ResultValue>> GetCategorys1Datas(string clientId, string benchmarkTypeId)
        {
            var request = new RestRequest(BenchmarkResource.GetBenchmarkTypeDataRequest, Method.POST);
            request.AddUrlSegment("clientId", clientId);
            request.AddUrlSegment("benchmarkTypeId", benchmarkTypeId);

            return await Client.ExecutePostTaskAsync<ResultValue>(request);
        }
コード例 #20
0
ファイル: Repository.cs プロジェクト: cocytus/Git.hub
        /// <summary>
        /// Lists all branches
        /// </summary>
        /// <remarks>Not really sure if that's even useful, mind the 'git branch'</remarks>
        /// <returns>list of all branches</returns>
        public IList<Branch> GetBranches()
        {
            RestRequest request = new RestRequest("/repos/{user}/{repo}/branches");
            request.AddUrlSegment("user", Owner.Login);
            request.AddUrlSegment("repo", Name);

            return _client.Get<List<Branch>>(request).Data;
        }
コード例 #21
0
ファイル: Media.cs プロジェクト: SnapMD/twilio-csharp
 /// <summary>
 /// Get the details for a specific Media instance.
 /// </summary>
 /// <param name="mediaSid">The Sid of the media resource</param>
 /// <returns></returns>
 public virtual Media GetMedia(string messageSid, string mediaSid)
 {
     var request = new RestRequest();
     request.Resource = "Accounts/{AccountSid}/Messages/{MessageSid}/Media/{MediaSid}.json";
     request.AddUrlSegment("MessageSid", messageSid);
     request.AddUrlSegment("MediaSid", mediaSid);
     return Execute<Media>(request);
 }
コード例 #22
0
ファイル: Mailings.cs プロジェクト: MikeSmithDev/EmmaSharp
        /// <summary>
        /// Declare the winner of a split test manually. In the event that the test duration has not elapsed, the current stats for each test will be frozen and the content defined in the user declared winner will sent to the remaining members for the mailing. Please note, any messages that are pending for each of the test variations will receive the content assigned to them when the test was initially constructed.
        /// </summary>
        /// <returns><c>true</c>, if winner was declared, <c>false</c> otherwise.</returns>
        /// <param name="mailingId">Mailing identifier.</param>
        /// <param name="winnerId">Winner identifier.</param>
        /// <remarks>Http403 if the winner cannot be manually declared.</remarks>
        public bool DeclareWinner(string mailingId, string winnerId)
        {
            var request = new RestRequest(Method.POST);
            request.Resource = "/{accountId}/mailings/{mailingId}/winner/{winnerId}";
            request.AddUrlSegment("mailingId", mailingId);
            request.AddUrlSegment("winnerId", winnerId);

            return Execute<bool>(request);
        }
コード例 #23
0
ファイル: Favorite.cs プロジェクト: erpframework/SugarSharp
        /// <summary>
        /// Remove record as favorite
        /// </summary>
        /// <param name="module">Module Name</param>
        /// <param name="id">Record ID</param>
        /// <returns>Record ID</returns>
        public string UnFavorite(string module, string id)
        {
            var request = new RestRequest("{module}/{id}/favorite", Method.DELETE);
            request.AddUrlSegment("module", module);
            request.AddUrlSegment("id", id);

            Bean bean = Execute<Bean>(request);
            return bean.id;
        }
コード例 #24
0
        public Task<BuildInfo> GetBuildByVersion(string accountName, string projectSlug, string buildVersion)
        {
            var request = new RestRequest("projects/{accountName}/{projectSlug}/build/{buildVersion}", Method.GET);
            request.AddUrlSegment("accountName", accountName);
            request.AddUrlSegment("projectSlug", projectSlug);
            request.AddUrlSegment("buildVersion", buildVersion);

            return ExecuteAsync<BuildInfo>(request);
        }
コード例 #25
0
ファイル: TeamService.cs プロジェクト: ryancole/GlobalTaunt
        /// <summary>
        /// Retrieves teams for given summoner ID 
        /// </summary>
        public IList<Team> GetBySummoner(SummonerRegion region, int id)
        {
            var request = new RestRequest("/api/lol/{region}/v2.2/team/by-summoner/{id}", Method.GET);

            request.AddUrlSegment("id", id.ToString());
            request.AddUrlSegment("region", region.ToString().ToLower());

            return Execute<List<Team>>(request);
        }
コード例 #26
0
ファイル: Issue.cs プロジェクト: KindDragon/Git.hub
        public List<IssueComment> GetComments()
        {
            var request = new RestRequest("/repos/{user}/{repo}/issues/{issue}/comments");
            request.AddUrlSegment("user", Repository.Owner.Login);
            request.AddUrlSegment("repo", Repository.Name);
            request.AddUrlSegment("issue", Number.ToString());

            return _client.Get<List<IssueComment>>(request).Data;
        }
コード例 #27
0
        /// <summary>
        /// Remove a caller from a conference
        /// </summary>
        /// <param name="conferenceSid">The Sid of the conference</param>
        /// <param name="callSid">The Sid of the call to remove</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public void KickConferenceParticipant(string conferenceSid, string callSid, Action<bool> callback)
        {
            var request = new RestRequest(Method.POST);
            request.Resource = "Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json";
            request.AddUrlSegment("ConferenceSid", conferenceSid);
            request.AddUrlSegment("CallSid", callSid);

            ExecuteAsync(request, (response) => callback(response.StatusCode == System.Net.HttpStatusCode.NoContent));
        }
コード例 #28
0
ファイル: LeagueService.cs プロジェクト: ryancole/GlobalTaunt
        /// <summary>
        /// Retrieves leagues data for summoner, including leagues for all of summoner's teams 
        /// </summary>
        public IDictionary<string, League> Get(SummonerRegion region, long id)
        {
            var request = new RestRequest("/api/lol/{region}/v2.2/league/by-summoner/{id}", Method.GET);

            request.AddUrlSegment("id", id.ToString());
            request.AddUrlSegment("region", region.ToString().ToLower());

            return Execute<Dictionary<string, League>>(request);
        }
コード例 #29
0
ファイル: PullRequest.cs プロジェクト: KindDragon/Git.hub
        /// <summary>
        /// Retrieves all Commits associated with this pull request.
        /// </summary>
        /// <returns></returns>
        public List<PullRequestCommit> GetCommits()
        {
            var request = new RestRequest("repos/{user}/{repo}/pulls/{pull}/commits");
            request.AddUrlSegment("user", Repository.Owner.Login);
            request.AddUrlSegment("repo", Repository.Name);
            request.AddUrlSegment("pull", Number.ToString());

            return _client.Get<List<PullRequestCommit>>(request).Data;
        }
コード例 #30
0
ファイル: Media.Async.cs プロジェクト: SnapMD/twilio-csharp
        /// <summary>
        /// Delete the specified media instance. Makes a DELETE request to a 
        /// Media Instance resource.
        /// </summary>
        /// <param name="mediaSid">The Sid of the media to delete</param>
        public virtual void DeleteMedia(string messageSid, string mediaSid, Action<DeleteStatus> callback)
        {
            var request = new RestRequest(Method.DELETE);
            request.Resource = "Accounts/{AccountSid}/Messages/{MessageSid}/Media/{MediaSid}.json";
            request.AddUrlSegment("MessageSid", messageSid);
            request.AddUrlSegment("MediaSid", mediaSid);

            ExecuteAsync(request, (response) => { callback(response.StatusCode == System.Net.HttpStatusCode.NoContent ? DeleteStatus.Success : DeleteStatus.Failed); });
        }
コード例 #31
0
        private RestRequest GetRecordRequest(int RecordID)
        {
            var request = new RestRequest("domains/{domain}/records/{id}");
            request.RequestFormat = DataFormat.Json;
            request.AddUrlSegment("domain", _Domain);
            request.AddUrlSegment("id", RecordID.ToString()); // replaces matching token in request.Resource

            return request;
        }
コード例 #32
0
        private IRestRequest SearchContentInternal(string authToken, string searchTerm)
        {
            var request = new RestRequest
            {
                Method   = Method.GET,
                Resource = "search?query={searchTerm}"
            };

            request.AddUrlSegment("searchTerm", searchTerm);
            AddAuthHeader(ref request, authToken);
            return(request);
        }
コード例 #33
0
        public async Task <PlexSearch> GetLibraryAsync(string authToken, Uri plexFullHost, string libraryId)
        {
            var request = new RestRequest
            {
                Method   = Method.GET,
                Resource = "library/sections/{libraryId}/all"
            };

            request.AddUrlSegment("libraryId", libraryId);
            AddAuthHeader(ref request, authToken);

            var lib = await Api.ExecuteAsync <PlexSearchWrapper>(request, plexFullHost);

            return(lib.PlexSearch);
        }
コード例 #34
0
        public Request AddParameter(string parameter, string value, bool urlSegment = false)
        {
            switch (_Method)
            {
            case Method.Post: _RestRequest.AddParameter(parameter, value, ParameterType.QueryString);
                break;

            case Method.Get:
                if (urlSegment)
                {
                    _RestRequest.AddUrlSegment(parameter, value);
                }
                else
                {
                    _RestRequest.AddQueryParameter(parameter, value);
                }
                break;
            }

            return(this);
        }
コード例 #35
0
 /// <inheritdoc />
 public void AddUrlSegment(string name, string value)
 {
     RestRequest.AddUrlSegment(name, value);
 }