Esempio n. 1
0
 public static T For <T>(string baseUrl, RequestModifier requestModifier, ResponseDeserializer?responseDeserializer = null, RequestBodySerializer?requestBodySerializer = null)
 {
     return(new RestClient(baseUrl, requestModifier)
     {
         ResponseDeserializer = responseDeserializer, RequestBodySerializer = requestBodySerializer
     }.For <T>());
 }
Esempio n. 2
0
 /// <summary>
 /// Gets a RestEase client
 /// </summary>
 /// <param name="rootUrl">Root URL on which to base client requests</param>
 /// <param name="responseDeserializer">Optional response deserializer implementation</param>
 /// <param name="requestModifier">Optional delegate called on every request</param>
 /// <typeparam name="TClient">Type of the RestEase-decorated interface</typeparam>
 /// <returns>Instance of the requested RestEase client</returns>
 public static TClient GetRestClient <TClient>(
     string rootUrl,
     ResponseDeserializer responseDeserializer = null,
     RequestModifier requestModifier           = null)
 {
     return((TClient)typeof(TClient).GetRestClient(rootUrl, responseDeserializer, requestModifier));
 }
Esempio n. 3
0
 public static T For <T>(string baseUrl, RequestModifier requestModifier, JsonSerializerSettings jsonSerializerSettings)
 {
     return(new RestClient(baseUrl, requestModifier)
     {
         JsonSerializerSettings = jsonSerializerSettings
     }.For <T>());
 }
        /// <summary>
        /// Initialises a new instance of the <see cref="ModifyingClientHttpHandler"/> class,
        /// using the given delegate to modify requests
        /// </summary>
        /// <param name="requestModifier">Delegate to use to modify requests</param>
        public ModifyingClientHttpHandler(RequestModifier requestModifier)
        {
            if (requestModifier == null)
                throw new ArgumentNullException("requestInterceptor");

            this.requestModifier = requestModifier;
        }
        /// <summary>
        /// Initialises a new instance of the <see cref="ModifyingClientHttpHandler"/> class,
        /// using the given delegate to modify requests
        /// </summary>
        /// <param name="requestModifier">Delegate to use to modify requests</param>
        public ModifyingClientHttpHandler(RequestModifier requestModifier)
        {
            if (requestModifier == null)
            {
                throw new ArgumentNullException("requestInterceptor");
            }

            this.requestModifier = requestModifier;
        }
Esempio n. 6
0
 /// <summary>
 /// Gets a RestEase client
 /// </summary>
 /// <param name="type">Type of the RestEase-decorated interface</param>
 /// <param name="rootUrl">Root URL on which to base client requests</param>
 /// <param name="responseDeserializer">Optional response deserializer implementation</param>
 /// <param name="requestModifier">Optional delegate called on every request</param>
 /// <returns>Instance of the requested RestEase client</returns>
 public static object GetRestClient(
     this Type type,
     string rootUrl,
     ResponseDeserializer responseDeserializer = null,
     RequestModifier requestModifier           = null)
 {
     return(new RestClient(rootUrl, requestModifier ?? NoopRequestModifier)
     {
         ResponseDeserializer = responseDeserializer ?? new BaseJsonResponseDeserializer(),
     }.For(type));
 }
Esempio n. 7
0
        /// <summary>
        /// Initialises a new instance of the <see cref="RestClient"/> class, with the given Base URL and request modifier
        /// </summary>
        /// <param name="baseUrl">Base URL of the API</param>
        /// <param name="requestModifier">Delegate called on every request</param>
        public RestClient(Uri baseUrl, RequestModifier requestModifier)
        {
            if (baseUrl == null)
            {
                throw new ArgumentNullException(nameof(baseUrl));
            }
            if (requestModifier == null)
            {
                throw new ArgumentNullException(nameof(requestModifier));
            }

            this.httpClient = this.Initialize(new ModifyingClientHttpHandler(requestModifier), baseUrl);
        }
Esempio n. 8
0
        /// <summary>
        /// Initialises a new instance of the <see cref="RestClient"/> class, with the given Base URL and request modifier
        /// </summary>
        /// <param name="baseUrl">Base URL of the API</param>
        /// <param name="requestModifier">Delegate called on every request</param>
        public RestClient(string baseUrl, RequestModifier requestModifier)
        {
            if (baseUrl == null)
            {
                throw new ArgumentNullException("baseUrl");
            }
            if (requestModifier == null)
            {
                throw new ArgumentNullException("requestModifier");
            }

            this.httpClient = new HttpClient(new ModifyingClientHttpHandler(requestModifier))
            {
                BaseAddress = new Uri(baseUrl)
            };
        }
Esempio n. 9
0
        public void ApproveWorkflow(WorkflowVM workflowVm, string userId)
        {
            try
            {
                VMToWorkflowMasterMapper workflowMapper = new VMToWorkflowMasterMapper();

                WorkflowMaster request  = workflowMapper.MapVMToWorkflowMaster(workflowVm.WorkflowRequest);
                WorkflowMaster response = workflowMapper.MapVMToWorkflowMaster(workflowVm.WorkflowResponse);

                ResponseBuilder responseBuilder = new ResponseBuilder(response, _ampRepository, userId);
                RequestModifier requestModifier = new RequestModifier(request);

                responseBuilder.BuildApprovalResponse();
                requestModifier.Modify();

                _ampRepository.InsertWorkFlowMaster(responseBuilder.workflow);
                _ampRepository.UpdateWorkFlowMaster(requestModifier.workflow);
                _ampRepository.Save();
            }
            catch (Exception exception)
            {
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Shortcut to create a client using the given URL and request interceptor
 /// </summary>
 /// <typeparam name="T">Interface representing the API</typeparam>
 /// <param name="baseUrl">Base URL</param>
 /// <param name="requestModifier">Delegate called on every request</param>
 /// <returns>An implementation of that interface which you can use to invoke the API</returns>
 public static T For <T>(Uri baseUrl, RequestModifier requestModifier)
 {
     return(new RestClient(baseUrl, requestModifier).For <T>());
 }
 /// <summary>
 /// Initialises a new instance of the <see cref="ModifyingClientHttpHandler"/> class,
 /// using the given delegate to modify requests
 /// </summary>
 /// <param name="requestModifier">Delegate to use to modify requests</param>
 public ModifyingClientHttpHandler(RequestModifier requestModifier)
 {
     this.requestModifier = requestModifier ?? throw new ArgumentNullException(nameof(requestModifier));
 }
Esempio n. 12
0
 /// <summary>
 /// Creates a new DelegateAuthenticator.
 /// </summary>
 /// <param name="modifyRequest">Delegate used to modify the webrequest.</param>
 public DelegateAuthenticator(RequestModifier modifyRequest)
 {
     modifyRequest.ThrowIfNull("modifyRequest");
     modifyRequestDelegate = modifyRequest;
 }