public TokenRequest(ApiServiceEnvironment env, string clientAppKey, string secret, string username, string password) { Request.Method = Method.POST; Request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); Request.AddHeader("Accept", "application/json"); Request.AddParameter("grant_type", "password"); Request.AddParameter("username", username); Request.AddParameter("password", password); switch (env) { case ApiServiceEnvironment.LocalhostIisExpress: case ApiServiceEnvironment.LocalhostIis: Client = new RestClient("https://localhost:44311/issue/oauth2/token"); Request.AddParameter("scope", "https://localhost:44310/"); break; case ApiServiceEnvironment.Test7: Client = new RestClient("https://test7.ple2.plato.com/issue/oauth2/token"); Request.AddParameter("scope", "https://Fed-api.test7.ple2.plato.com/"); break; case ApiServiceEnvironment.Test4: Client = new RestClient("https://test4.ple2.plato.com/issue/oauth2/token"); Request.AddParameter("scope", "https://Fed-api.test4.ple2.plato.com/"); break; default: throw new ArgumentOutOfRangeException("env", env, null); } Client.Authenticator = new HttpBasicAuthenticator(clientAppKey, secret); // note: this takes care of the Base64 encoded Authorization basic header }
public PostRequest(ApiServiceEnvironment env, string resource, string authToken, object postData) : base(env, Method.POST, resource, authToken) { var jsonData = JsonConvert.SerializeObject(postData); Request.AddParameter("application/json; charset=utf-8", jsonData, ParameterType.RequestBody); Request.RequestFormat = DataFormat.Json; }
public GetRequest(ApiServiceEnvironment env, string resource, string authToken) : base(env, Method.GET, resource, authToken) { }
public DeleteRequest(ApiServiceEnvironment env, string resource, string authToken) : base(env, Method.DELETE, resource, authToken) { }
public RequestFactory(ApiServiceEnvironment environment, ApiServiceEnvironment dbEnvironment) { Environment = environment; DbEnvironment = dbEnvironment; }