/// <summary> /// event handlers /// </summary> /// <param name="sender"></param> /// <param name="request"></param> public void OnOutgoingRequest(object sender, Requests.Request request) { if (request.GetType() == typeof(Requests.OutgoingCallRequest)) { RegisterOutgoingRequest(request as Requests.OutgoingCallRequest); } }
public void OnOutgoingCall(object sender, Requests.Request request) { if (request.GetType() == typeof(Requests.OutgoingCallRequest) && this.State == PortState.Free) { this.State = PortState.Busy; } }
/// <summary> /// Check <see cref="t:Sdk.Api.IApiRequestSender"/>. /// </summary> /// <returns>Check <see cref="t:Sdk.Api.IApiRequestSender"/>.</returns> /// <param name="request">Check <see cref="t:Sdk.Api.IApiRequestSender"/>.</param> /// <typeparam name="T">Check <see cref="t:Sdk.Api.IApiRequestSender"/>.</typeparam> public async Task <T> SendRequestAsync <T>(Requests.Request <T> request) { if (request.Authenticated && !_credentials.AreValid()) { await _semaphore.WaitAsync().ConfigureAwait(false); if (!_credentials.AreValid()) { try { await RefreshToken().ConfigureAwait(false); } finally { _semaphore.Release(); } } } var httpRequest = CreateHttpRequest(request); var responseString = await _httpSender.SendHttpRequest(httpRequest).ConfigureAwait(false); if (!string.IsNullOrEmpty(responseString)) { return(JsonConvert.DeserializeObject <T>(responseString)); } return(default(T)); }
private HttpRequestMessage CreateHttpRequest <T>(Requests.Request <T> request) { var parameters = _queryDecoder.GetParameters(request.Query); var httpRequestMessage = HttpRequestMessageFactory.Create( _configuration.BaseUrl.ToString(), request.HTTPMethod, parameters, request.Path); if (request.Authenticated) { httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue(_credentials.TokenType, _credentials.AccessToken); } return(httpRequestMessage); }
public Responses.Request Send(Requests.Request request) { return(client.PostBody <Responses.Request>("requests", request)); }
public abstract IHttpAction Handle(Requests.Request request);
private void OnIncomingRequest(object sender, Requests.IncomingRequest request) { IncomingRequest?.Invoke(sender, request); CurrentRequest = request; }
public IHttpAction Execute(Requests.Request request) { return(RequestHandler.Handle(request)); }