public async Task <NotificationCreateResultModel> CreateAsync([NotNull] NotificationCreateModel model,
                                                                      [NotNull] ElectOneSignalAppOption appInfo)
        {
            model.AppId = appInfo.AppId;

            try
            {
                var result =
                    await ElectOneSignalConstants.DefaultApiUrl
                    .ConfigureRequest(config =>
                {
                    config.JsonSerializer = ElectOneSignalConstants.NewtonsoftJsonSerializer;
                })
                    .AppendPathSegment("notifications")
                    .WithHeader("Authorization", $"Basic {appInfo.ApiKey}")
                    .PostJsonAsync(model)
                    .ReceiveJson <NotificationCreateResultModel>()
                    .ConfigureAwait(true);

                return(result);
            }
            catch (FlurlHttpException e)
            {
                var response = await e.GetResponseStringAsync().ConfigureAwait(true);

                throw new HttpRequestException(response);
            }
        }
        public async Task <NotificationViewResultModel> GetAsync([NotNull] string id,
                                                                 [NotNull] ElectOneSignalAppOption appInfo)
        {
            try
            {
                var result =
                    await ElectOneSignalConstants.DefaultApiUrl
                    .ConfigureRequest(config =>
                {
                    config.JsonSerializer = ElectOneSignalConstants.NewtonsoftJsonSerializer;
                })
                    .AppendPathSegment($"notifications/{id}?app_id={appInfo.AppId}")
                    .WithHeader("Authorization", $"Basic {appInfo.ApiKey}")
                    .GetAsync()
                    .ReceiveJson <NotificationViewResultModel>()
                    .ConfigureAwait(true);

                return(result);
            }
            catch (FlurlHttpException e)
            {
                var response = await e.GetResponseStringAsync().ConfigureAwait(true);

                throw new HttpRequestException(response);
            }
        }
        public async Task <NotificationCreateResultModel> CreateAsync([NotNull] NotificationCreateModel model,
                                                                      [NotNull] string appId, [NotNull] string appKey)
        {
            var appInfo = new ElectOneSignalAppOption(appId, appKey);

            return(await CreateAsync(model, appInfo));
        }
        public async Task <NotificationViewResultModel> GetAsync([NotNull] string id, [NotNull] string appId,
                                                                 [NotNull] string appKey)
        {
            var appInfo = new ElectOneSignalAppOption(appId, appKey);

            return(await GetAsync(id, appInfo));
        }
Exemple #5
0
        public async Task <DeviceAddResultModel> AddAsync([NotNull] DeviceAddModel model, [NotNull] string appId,
                                                          [NotNull] string appKey)
        {
            var appInfo = new ElectOneSignalAppOption(appId, appKey);

            return(await AddAsync(model, appInfo));
        }
Exemple #6
0
        public async Task <DeviceInfoModel> GetAsync([NotNull] string id, [NotNull] string appId,
                                                     [NotNull] string appKey)
        {
            var appInfo = new ElectOneSignalAppOption(appId, appKey);

            return(await GetAsync(id, appInfo));
        }
Exemple #7
0
        public async Task EditAsync([NotNull] string id, [NotNull] DeviceEditModel model, [NotNull] string appId,
                                    [NotNull] string appKey)
        {
            var appInfo = new ElectOneSignalAppOption(appId, appKey);

            await EditAsync(id, model, appInfo);
        }
Exemple #8
0
        public async Task EditAsync([NotNull] string id, [NotNull] DeviceEditModel model,
                                    [NotNull] ElectOneSignalAppOption appInfo)
        {
            model.AppId = appInfo.AppId;

            try
            {
                await ElectOneSignalConstants.DefaultApiUrl
                .ConfigureRequest(config =>
                {
                    config.JsonSerializer = ElectOneSignalConstants.NewtonsoftJsonSerializer;
                })
                .AppendPathSegment($"players/{id}")
                .WithHeader("Authorization", $"Basic {appInfo.ApiKey}")
                .PutJsonAsync(model)
                .ConfigureAwait(true);
            }
            catch (FlurlHttpException e)
            {
                var response = await e.GetResponseStringAsync().ConfigureAwait(true);

                throw new HttpRequestException(response);
            }
        }