public ClientCredentialsResponseData(HttpTextResponse response) : base(response, ResponseType.Json) { ClientId = _responseJson.GetNamedString("client_id"); ClientSecret = _responseJson.GetNamedString("client_secret"); Expiration = (long)_responseJson.GetNamedNumber("client_expiration"); }
static TextResponse ToMASResponse(HttpTextResponse response) { var masResponse = new TextResponse() { Headers = new ReadonlyPropertyCollection(response.Headers), IsSuccessful = response.IsSuccessful, StatusCode = response.StatusCode, Text = response.Text }; return(masResponse); }
public RequestTokenResponseData(HttpTextResponse response) : base(response, ResponseType.Json) { AccessToken = _responseJson.GetNamedString("access_token"); TokenType = _responseJson.GetNamedString("token_type"); ExpiresIn = (int)_responseJson.GetNamedNumber("expires_in"); RefreshToken = _responseJson.GetStringOrNull("refresh_token"); Scope = _responseJson.GetNamedString("scope"); IdToken = _responseJson.GetStringOrNull("id_token"); IdTokenType = _responseJson.GetStringOrNull("id_token_type"); }
public JsonHttpResponseValidation(HttpTextResponse response) { if (response == null) { throw AssertionExceptionFactory.Create("Expected response to be an instance, but got NULL."); } if (response.ContentType != "application/json") { throw AssertionExceptionFactory.CreateForResponse(response, "Expected response content type to be '{0}', but got '{1}'.", NullString.IfNull(response.ContentType)); } Response = response; }
public AuthorizationProvidersResponseData(HttpTextResponse response) : base(response, ResponseType.Json) { // TODO not supported yet // Sample response below // { // "idp": "all", // "providers": [ // { // "provider": { // "id": "facebook", // "auth_url": "https://test.pulsenow.co.uk:443/facebook/login?sessionID=44b04c62-2a5b-40f0-aa32-ec10fdf5cf36" // } // }, // { // "provider": { // "id": "google", // "auth_url": "https://test.pulsenow.co.uk:443/google/login?sessionID=44b04c62-2a5b-40f0-aa32-ec10fdf5cf36" // } // }, // { // "provider": { // "id": "salesforce", // "auth_url": "https://test.pulsenow.co.uk:443/salesforce/login?sessionID=44b04c62-2a5b-40f0-aa32-ec10fdf5cf36" // } // }, // { // "provider": { // "id": "linkedin", // "auth_url": "https://test.pulsenow.co.uk:443/linkedin/login?sessionID=44b04c62-2a5b-40f0-aa32-ec10fdf5cf36" // } // }, // { // "provider": { // "id": "enterprise", // "auth_url": "https://test.pulsenow.co.uk:443/enterprise/login?sessionID=44b04c62-2a5b-40f0-aa32-ec10fdf5cf36" // } // }, // { // "provider": { // "id": "qrcode", // "auth_url": "https://test.pulsenow.co.uk:443/auth/device/authorize?sessionID=44b04c62-2a5b-40f0-aa32-ec10fdf5cf36", // "poll_url": "https://test.pulsenow.co.uk:443/auth/device/authorization/10965ae36d7f4371b84abf840fbfdd49f4f72a259abb406cada6e63fbe3b924f" // } // } // ] // } }
public UserInfoResponseData(HttpTextResponse response) : base(response, ResponseType.Json) { Sub = _responseJson.GetNamedString("sub"); Name = _responseJson.GetStringOrNull("name"); if (Name == null) { Name = _responseJson.GetStringOrNull("given_name"); } FamilyName = _responseJson.GetStringOrNull("family_name"); Nickname = _responseJson.GetStringOrNull("nickname"); PerferredUsername = _responseJson.GetStringOrNull("preferred_username"); Email = _responseJson.GetStringOrNull("email"); Phone = _responseJson.GetStringOrNull("phone"); var addressObj = _responseJson.GetNamedObject("address"); if (addressObj != null) { Address = new AddressResponseData(addressObj); } }
public RegisterResponseData(HttpTextResponse response) : base(response, ResponseType.PlainText) { Certificate = response.Text; string deviceId; if (response.Headers.TryGetValue("device-identifier", out deviceId)) { DeviceIdentifier = deviceId; } else if (response.Headers.TryGetValue("mag-identifier", out deviceId)) { DeviceIdentifier = deviceId; } string deviceStatus; if (response.Headers.TryGetValue("device-status", out deviceStatus)) { DeviceStatus = deviceStatus; } }
public UnregisterResponseData(HttpTextResponse response) : base(response, ResponseType.Json) { }
internal InfluxDbClientException(HttpTextResponse response, string reason = null) : this(response.RequestMethod, response.StatusCode, response.RequestUri, reason ?? response.Reason, response.Content) { }
private ErrorResult GetErrorResult(HttpTextResponse response) { var errorResponse = Requester.JsonSerializer.Deserialize<InfluxDbErrorResponse>(response.Content); var errorResult = errorResponse?.Results.FirstOrDefault(); return errorResult; }
protected virtual void EnsureSuccessful(HttpTextResponse response) { if (!response.IsSuccess) throw new InfluxDbClientException(response); //InfluxDB reports 204 for awesomeness and 200 for "I understood the request, but something might have failed". if (response.StatusCode == HttpStatusCode.NoContent) return; var errorResult = GetErrorResult(response); if (!string.IsNullOrWhiteSpace(errorResult?.Error)) throw new InfluxDbClientException(response, errorResult.Error); }
protected virtual void EnsureSuccessfulRead(HttpTextResponse response) { if (!response.IsSuccess) throw new InfluxDbClientException(response); }
public static HttpTextResponse TheResponse(this HttpTextResponse response, Action <HttpTextResponseValidation> should) { should(new HttpTextResponseValidation(response)); return(response); }