| | | 1 | | using Newtonsoft.Json.Linq; |
| | | 2 | | using OzonDomains.Models; |
| | | 3 | | using Services.ApiServices.ApiSupplierIntegration; |
| | | 4 | | |
| | | 5 | | namespace Services.ApiServices.ZZapApi; |
| | | 6 | | |
| | | 7 | | public sealed class ZZapMoscowSupplierConnector : IApiSupplierConnector |
| | | 8 | | { |
| | | 9 | | public const string SupplierSiteUrl = "https://www.zzap.ru/"; |
| | | 10 | | |
| | | 11 | | private readonly ZZapDataManager _manager; |
| | 8 | 12 | | public ZZapMoscowSupplierConnector(ZZapDataManager manager) => _manager = manager; |
| | | 13 | | |
| | 1 | 14 | | public string ProviderKey => ApiSupplierSettings.ZZapMoscowProviderKey; |
| | 1 | 15 | | public string DisplayName => "ZZap Москва"; |
| | 1 | 16 | | public string DefaultCurrencyCode => "RUB"; |
| | 1 | 17 | | public string SiteUrl => SupplierSiteUrl; |
| | | 18 | | |
| | | 19 | | public async Task<ApiSupplierPingResult> PingAsync(CancellationToken cancellationToken = default) |
| | | 20 | | { |
| | 3 | 21 | | var status = await _manager.GetStatusAsync(cancellationToken); |
| | 3 | 22 | | var online = (status["result"] as JObject)?.Value<bool?>("online") ?? false; |
| | 3 | 23 | | return online |
| | 3 | 24 | | ? new ApiSupplierPingResult(true) |
| | 3 | 25 | | : new ApiSupplierPingResult(false, "ZZap сообщает, что сервис офлайн."); |
| | 3 | 26 | | } |
| | | 27 | | } |