Ejemplo n.º 1
0
        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
        }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 public GetRequest(ApiServiceEnvironment env, string resource, string authToken)
     : base(env, Method.GET, resource, authToken)
 {
 }
Ejemplo n.º 4
0
 public DeleteRequest(ApiServiceEnvironment env, string resource, string authToken)
     : base(env, Method.DELETE, resource, authToken)
 {
 }
Ejemplo n.º 5
0
 public RequestFactory(ApiServiceEnvironment environment, ApiServiceEnvironment dbEnvironment)
 {
     Environment = environment;
     DbEnvironment = dbEnvironment;
 }