Exemple #1
0
        public async Task <ServicesModel> GetServicesAsync(
            CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var @params = new
            {
                getServices = true
            };

            var response = await SendRequestAsync(@object : @params)
                           .ConfigureAwait(continueOnCapturedContext: false);

            TrackerException.IfErrorThrowException(jObject: response);

            return(response.ToObject <ServicesModel>());
        }
Exemple #2
0
        public async Task <TrackerModel> GetByTrackCodeAsync(
            string trackCode,
            TrackLanguages trackLanguages,
            CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrWhiteSpace(value: trackCode))
            {
                throw new ArgumentException(
                          message: "Value cannot be null or whitespace.",
                          paramName: nameof(trackCode));
            }
            if (!Enum.IsDefined(enumType: typeof(TrackLanguages), value: trackLanguages))
            {
                throw new InvalidEnumArgumentException(
                          argumentName: nameof(trackLanguages),
                          invalidValue: (int)trackLanguages,
                          enumClass: typeof(TrackLanguages));
            }
            cancellationToken.ThrowIfCancellationRequested();

            var language = Enum.GetName(enumType: typeof(TrackLanguages), value: trackLanguages)?.ToLowerInvariant() ??
                           string.Empty;

            var @params = new
            {
                code = trackCode,
                lng  = language
            };

            var response = await SendAuthorizeRequestAsync(@object : @params)
                           .ConfigureAwait(continueOnCapturedContext: false);

            TrackerException.IfErrorThrowException(jObject: response);

            return(response.ToObject <TrackerModel>());
        }
Exemple #3
0
        public async Task <TrackerModel> GetByTrackCodeAsync(
            string trackCode,
            CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrWhiteSpace(value: trackCode))
            {
                throw new ArgumentException(
                          message: "Value cannot be null or whitespace.",
                          paramName: nameof(trackCode));
            }
            cancellationToken.ThrowIfCancellationRequested();

            var @params = new
            {
                code = trackCode
            };

            var response = await SendAuthorizeRequestAsync(@object : @params)
                           .ConfigureAwait(continueOnCapturedContext: false);

            TrackerException.IfErrorThrowException(jObject: response);

            return(response.ToObject <TrackerModel>());
        }