private void OverrideOperatorUrls(ProviderMetadata metadata)
        {
            if (OperatorUrls == null)
            {
                return;
            }

            OperatorUrls.OverrideUrls(metadata);
        }
Пример #2
0
        /// <summary>
        /// Creates an instance of the DiscoveryResponse class by copying an existing DiscoveryResponse instance
        /// </summary>
        /// <param name="response">DiscoveryResponse to copy</param>
        public DiscoveryResponse(DiscoveryResponse response)
        {
            this.Cached        = true;
            this.Ttl           = response.Ttl;
            this.ResponseCode  = response.ResponseCode;
            this.Headers       = response.Headers;
            this.ErrorResponse = response.ErrorResponse;
            this.OperatorUrls  = response.OperatorUrls;

            // Serialize/Deserialize to clone the cached data
            var cachedJson = JsonConvert.SerializeObject(response.ResponseData);

            this.ResponseData = JsonConvert.DeserializeObject <Json.DiscoveryResponseData>(cachedJson);
            //Remove subscriber id from the cached response
            this.ResponseData.subscriber_id = null;
        }
Пример #3
0
        /// <summary>
        /// Creates an instance of the DiscoveryResponse using data from a RestResponse instance
        /// </summary>
        /// <param name="rawResponse">RestResponse with discovery response content</param>
        public DiscoveryResponse(RestResponse rawResponse)
        {
            this.Cached       = false;
            this.ResponseCode = (int)rawResponse.StatusCode;
            this.ResponseData = rawResponse.Content == null ? null : JsonConvert.DeserializeObject <Json.DiscoveryResponseData>(rawResponse.Content);
            this.Headers      = rawResponse.Headers;
            this.Ttl          = CalculateTTL(this.ResponseData?.ttl);

            this.OperatorUrls = OperatorUrls.Parse(this.ResponseData);

            if (this.ResponseData.error != null)
            {
                this.ErrorResponse = new ErrorResponse()
                {
                    Error = ResponseData.error, ErrorDescription = ResponseData.description
                };
            }
        }
        private void ParseResponseData(Json.DiscoveryResponseData responseData)
        {
            this.Ttl = Ttl.HasValue ? Ttl : CalculateTTL(responseData?.ttl);

            if (responseData == null)
            {
                return;
            }

            this.OperatorUrls         = OperatorUrls.Parse(responseData);
            this.ApplicationShortName = responseData.response?.client_name;

            if (responseData.error != null)
            {
                this.ErrorResponse = new ErrorResponse()
                {
                    Error = responseData.error, ErrorDescription = responseData.description
                };
            }
        }