public static Secrets Get( string provider ) { var restClient = new TempusGameItRestClient(); var restRequest = new RestRequest(Method.GET) { Resource = string.Format("/auth/{0}/keys", provider), RequestFormat = DataFormat.Json }; var response = restClient.Execute<Secrets>(restRequest); return (response.StatusCode == HttpStatusCode.OK) ? response.Data : null; }
List<Game> LoadFromService() { var client = new TempusGameItRestClient(); var request = new RestRequest("/api/games"); var response = client.Execute<List<restful.Game>>( request ); var translatedEntities = response.Data.Select (g => new Game { Id = g._id, Executable32Bit = g.ExecutableName, Executable64Bit = g.executableName_64 ?? "", Launcher = g.Launcher, Name = g.Name, BoxArt = new Uri (g.boxart), ExternalId = g.externalId, }).ToList (); return translatedEntities; }
AddSessionResponse SubmitSession(string json) { var client = new TempusGameItRestClient(); var request = new AddSessionRequest(json); var response = client.Execute<AddSessionResponse> (request); if ((response.StatusCode == HttpStatusCode.OK) && (response.Data != null)) { logger.InfoFormat ("Successfully submitted '{0}' session '{1}'", response.Data.data.game.Name, response.Data.data._id); } else if((response.StatusCode == HttpStatusCode.Forbidden) && (response.Data != null)) { logger.WarnFormat ("There was a problem with your session submission. The message is as follows: {0}", response.Data.message ?? "<no message>"); } else { logger.WarnFormat ("Unable to submit session. The server returned a response status of {0} with a status code of '{1}' with a message of '{2}'", response.ResponseStatus, response.StatusCode, response.StatusDescription); } return response.Data; }
public bool SubmitSession( string json ) { var client = new TempusGameItRestClient(); var request = new RestRequest(Method.POST) {Resource = "/api/sessions/add", RequestFormat = DataFormat.Json}; request.AddHeader("authorization", string.Format("bearer {0}", Authentication.Token)); request.AddParameter("application/json", json, ParameterType.RequestBody); var response = client.Execute(request); var wasSubmissionSuccessful = ( response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Accepted ); if( !wasSubmissionSuccessful ) { logger.WarnFormat("Unable to submit session. The server returned a response status of {0} with a status code of '{1}' with a message of '{2}'", response.ResponseStatus, response.StatusCode, response.StatusDescription); } return wasSubmissionSuccessful; }
private void PerformUploadAndAttachToSession(List<FileInfo> files, string sessionId, string gameId, string username) { var screenshots = new List<Screenshot>(); int totalScreenshots = files.Count; for (int i = 0; i < totalScreenshots; i++) { FileInfo screenshot = files[i]; _messageBus.SendMessage(new ScreenshotUploadProgessEventArgs(screenshot.Name, i, totalScreenshots)); Screenshot savedScreenshot = this.UploadFiles(screenshot.FullName, gameId, username); if (savedScreenshot != null) { screenshots.Add(savedScreenshot); } } var restClient = new TempusGameItRestClient(); var request = new ScreenshotPostRequest(sessionId, screenshots, Authentication.Token); var screenshotResponse = restClient.Execute<List<Screenshot>>(request); }
void GetTempusGameItUserInfo(string loginUri, UserInfo userInfo) { var request = new RestRequest(Method.POST) { Resource = loginUri, RequestFormat = DataFormat.Json }; request.AddParameter("application/json", string.Format("{{\"id\" : \"{0}\"}}", userInfo.Id), ParameterType.RequestBody); var client = new TempusGameItRestClient(); var response = client.Execute<AccessToken>(request); if (response.StatusCode == HttpStatusCode.Unauthorized) { throw new AuthenticationException (response.Data == null ? "An unexpected error occurred logging in" : response.Data.message); } else { _token = response.Data.token; var userRequest = new RestRequest (string.Format ("/api/users/{0}", response.Data.username), Method.GET); _user = client.Execute<User>(userRequest).Data; } }