private static IRestRequest GuestRegisterRequest() { var request = Backtory.RestRequest("auth/guest-users", Method.POST); request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId); return(request); }
private static IRestRequest RegisterRequest(BacktoryUser registrationParams) { var request = Backtory.RestRequest("auth/users", Method.POST); request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId); request.AddJsonBody(registrationParams); return(request); }
private IRestRequest PlayerRankRequest() { var request = Backtory.RestRequest("game/leaderboards/{leader_board_id}", Method.GET); request = AddDefaultHeaders(request); request.AddParameter("leader_board_id", LeaderboardId, ParameterType.UrlSegment); return(request); }
private static IRestRequest LogoutRequest(string refreshToken) { var request = Backtory.RestRequest("auth/logout", Method.DELETE); request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId); request.AddParameter("refresh-token", refreshToken, ParameterType.QueryString); request.OnBeforeDeserialization = response => { response.ContentType = "text/plain"; }; return(request); }
private IRestRequest CompleteRegRequest(GuestCompletionParam guestRegistrationParam) { var request = Backtory.RestRequest("auth/guest-users/complete-registration", Method.POST); request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId); request.AddHeader(KeyAuthorization, AuthorizationHeader()); request.AddJsonBody(guestRegistrationParam); return(request); }
private IRestRequest AroundMeRequest(int count) { var request = Backtory.RestRequest("game/leaderboards/around-me/{leader_board_id}", Method.GET); request = AddDefaultHeaders(request); request.AddParameter("leader_board_id", LeaderboardId, ParameterType.UrlSegment); request.AddQueryParameter("count", count.ToString()); return(request); }
private IRestRequest UpdateUserRequest(BacktoryUser toBeUpdateUser) { var request = Backtory.RestRequest("auth/users/{user_id}", Method.PUT); request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId); request.AddHeader(KeyAuthorization, AuthorizationHeader()); request.AddParameter("user_id", toBeUpdateUser.UserId, ParameterType.UrlSegment); request.AddJsonBody(toBeUpdateUser); return(request); }
internal static IRestRequest UserByUsernameRequest(string username, string accessToken = null) { var request = Backtory.RestRequest("auth/users/by-username/{username}", Method.GET); request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId); request.AddHeader(KeyAuthorization, accessToken != null ? "Bearer " + accessToken : AuthorizationHeader()); request.AddParameter("username", username, ParameterType.UrlSegment); return(request); }
internal static IRestRequest NewAccessTokenRequest() { var request = Backtory.RestRequest("auth/login", Method.POST); request.AlwaysMultipartFormData = true; request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId); request.AddHeader(Backtory.AuthClientKeyString, BacktoryConfig.BacktoryAuthClientKey); request.AddHeader("X-Backtory-Authentication-Refresh", "1"); request.AddParameter("refresh_token", BacktoryUser.GetRefreshToken(), ParameterType.GetOrPost); return(request); }
private IRestRequest SendEventRequest(BacktoryGameEvent backtoryGameEvent) { var request = Backtory.RestRequest("game/events", Method.POST); request.AddHeader(Backtory.GameInstanceIdString, BacktoryConfig.BacktoryGameInstanceId); request.AddHeader(BacktoryUser.KeyAuthorization, BacktoryUser.AuthorizationHeader()); request.AddHeader("Accept", Backtory.ApplicationJson); request.AddJsonBody(backtoryGameEvent); return(request); }
// restsharp normally doesn't support multipart request without file // by setting AlwaysMultipart we force it to do so private static IRestRequest LoginRequest(string username, string password) { var loginRequest = Backtory.RestRequest("auth/login", Method.POST); loginRequest.AlwaysMultipartFormData = true; loginRequest.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId); loginRequest.AddHeader("X-Backtory-Authentication-Key", BacktoryConfig.BacktoryAuthClientKey); loginRequest.AddParameter("username", username, ParameterType.GetOrPost); loginRequest.AddParameter("password", password, ParameterType.GetOrPost); return(loginRequest); }
private RestRequest ChangePassRequest(string oldPassword, string newPassword) { // var request = Backtory.RestRequest("change-password", Method.POST); var request = Backtory.RestRequest("auth/change-password", Method.POST); request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId); request.AddHeader(KeyAuthorization, AuthorizationHeader()); //sdfljasjglkjksladg // Why content type in response is null despite line below??? request.OnBeforeDeserialization = response => { response.ContentType = "text/plain"; }; request.AddJsonBody(new Dictionary <string, string>() { // it's common to refer as "oldPassword" not "lastPassword". But what can I do? :) { "lastPassword", oldPassword }, { "newPassword", newPassword } }); return(request); }
private IRestRequest ChangePassRequest(string oldPassword, string newPassword) { var request = Backtory.RestRequest("auth/change-password", Method.POST); request.AddHeader(Backtory.AuthInstanceIdString, BacktoryConfig.BacktoryAuthInstanceId); request.AddHeader(KeyAuthorization, AuthorizationHeader()); // we don't want to restsharp treat the empty response as json and try to deserialize it. request.OnBeforeDeserialization = response => { response.ContentType = "text/plain"; }; request.AddJsonBody(new Dictionary <string, string>() { // it's common to refer as "oldPassword" not "lastPassword". But what can I do? :) { "lastPassword", oldPassword }, { "newPassword", newPassword } }); return(request); }
// all methods could be static but we get a threading exception from PlayerPrefs /* GetString can only be called from the main thread. * Constructors and field initializers will be executed from the loading thread when loading a scene. * Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. */ private IRestRequest CloudCodeRequest(string functionName, object requestBody, Type responseType) { var request = Backtory.RestRequest("cloud-code/{cloud_instance_id}/{function_name}", Method.POST); request.Timeout = 20 * 1000; // 20 seconds request.AddParameter("cloud_instance_id", BacktoryConfig.BacktoryCloudcodeInstanceId, ParameterType.UrlSegment); request.AddParameter("function_name", functionName, ParameterType.UrlSegment); request.AddHeader(BacktoryUser.KeyAuthorization, BacktoryUser.AuthorizationHeader()); if (requestBody.GetType() != typeof(string)) { request.AddJsonBody(requestBody); request.OnBeforeDeserialization = irestresponse => irestresponse.ContentType = Backtory.ApplicationJson; } else { request.AddParameter(Backtory.TextPlain, requestBody, ParameterType.RequestBody); request.OnBeforeDeserialization = irestresponse => irestresponse.ContentType = Backtory.TextPlain; } return(request); }