Ejemplo n.º 1
0
        public async Task <ZsSubscriptions> GetAllAsync(string apiBaseUrl, string authToken, string organizationId, ZsSubscriptionFilter filterType, string filterId)
        {
            apiBaseUrl.CheckConfigApiBaseUrl();
            authToken.CheckConfigAuthToken();
            organizationId.CheckConfigOrganizationId();

            using (var httpClient = new HttpClient())
            {
                httpClient.Configure(apiBaseUrl, organizationId, authToken);
                var requestUri = ApiResources.ZsGetSubscriptionsAll;
                switch (filterType)
                {
                case ZsSubscriptionFilter.CustomerId:
                    requestUri = string.Format(CultureInfo.InvariantCulture, ApiResources.ZsGetSubscriptionsAllByCustomerId, filterId);
                    break;
                }

                var response = await httpClient.GetAsync(requestUri);

                var processResult = await response.ProcessResponse <ZsSubscriptions>();

                if (null != processResult.Error)
                {
                    throw processResult.Error;
                }

                return(processResult.Data);
            }
        }
Ejemplo n.º 2
0
 public async Task <ZsSubscriptions> GetAllAsync(ZsSubscriptionFilter filterType, string filterId)
 {
     this.client.Configuration.CheckConfig();
     return(await this.GetAllAsync(this.client.Configuration.ApiBaseUrl, this.client.Configuration.AuthToken, this.client.Configuration.OrganizationId, filterType, filterId));
 }
Ejemplo n.º 3
0
        public async Task <ZsSubscriptions> GetAllAsync(string apiBaseUrl, string authToken, string organizationId, ZsSubscriptionFilter filterType, string filterId, ZsPage page = null)
        {
            apiBaseUrl.CheckConfigApiBaseUrl();
            authToken.CheckConfigAuthToken();
            organizationId.CheckConfigOrganizationId();

            using (var httpClient = new HttpClient())
            {
                httpClient.Configure(apiBaseUrl, organizationId, authToken);

                var requestUri = new QueryStringBuilder(ApiResources.ZsGetSubscriptionsAll);
                switch (filterType)
                {
                case ZsSubscriptionFilter.CustomerId:
                    requestUri.Add("customer_id", filterId);
                    break;
                }

                var response = await httpClient.GetAsync(page.AppendTo(requestUri).ToString());

                var processResult = await response.ProcessResponse <ZsSubscriptions>();

                if (null != processResult.Error)
                {
                    throw processResult.Error;
                }

                return(processResult.Data);
            }
        }