예제 #1
0
        public StarshipApiModel FindStarshipById(int id)
        {
            var apiConfig  = GetApiConfig();
            var uri        = new Uri($"{apiConfig.host}{apiConfig.starshipsUrl}{id}");
            var httpResult = _httpGateway.Get <StarshipApiModel>(uri, null);

            if (!httpResult.Success)
            {
                throw new GatewayUnavailableException($"Cannot connect to the SWApi.co: {httpResult?.Message ?? "No message available."}");
            }

            return(httpResult.Result);
        }
예제 #2
0
        public async Task <IResponse> SendRequest(string api, string method, params Parameter[] parameters)
        {
            string apiCall;
            string queryParams;
            string apiPath;

            BuildApiUrl(api, method, parameters, out apiPath, out apiCall, out queryParams);

            var json = await Http.Get(apiPath, apiCall + "&" + queryParams);

            var result = JsonConvert.DeserializeObject <Response>(json);

            return(result);
        }