コード例 #1
0
        public async Task <Response> GetApiResponse(ApiCategoryEnum apiCategoryEnum, bool isList)
        {
            Response response = null;
            await Task.Run(async() =>
            {
                try
                {
                    if (!_extension.isEnumValid <ApiCategoryEnum>(apiCategoryEnum) || apiCategoryEnum == ApiCategoryEnum.NotAvailable)
                    {
                        response = _extension.SetResponse(false, message: "Data is Not Valid");
                    }

                    // Data Hatalı Değilse Aşağıdaki Kod Çalışsın.
                    if (response == null)
                    {
                        string url          = _extension.GenerateApiUrl(apiCategoryEnum, isList);
                        var fetchedResponse = await _extension.FetchJsonData(url);

                        switch (apiCategoryEnum)
                        {
                        case ApiCategoryEnum.Summary:
                            response = _extension.ExtractJsonAsClass <Summary>((string)fetchedResponse.Data, isList).Result;
                            break;
                        }
                    }
                }
                catch (Exception exception)
                {
                    _extension.LogException(exception);
                    response = _extension.SetResponse(false, message: _extension.getExceptionMessage(exception));
                }
            });

            return(response);
        }
コード例 #2
0
 public async Task <Response> GetApiResponse(ApiCategoryEnum apiCategoryEnum, bool isList)
 {
     return(await _fetchProcess.GetApiResponse(apiCategoryEnum, isList));
 }