예제 #1
0
        public async Task <ZsInvoices> GetAllAsync(string apiBaseUrl, string authToken, string organizationId, ZsInvoiceFilter filterType, string filterId, ZsPage page = null)
        {
            apiBaseUrl.CheckConfigApiBaseUrl();
            authToken.CheckConfigAuthToken();
            organizationId.CheckConfigOrganizationId();

            if (string.IsNullOrWhiteSpace(filterId))
            {
                throw new ArgumentNullException("Filter id - Subscription id or Customer id is required");
            }

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

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

                case ZsInvoiceFilter.SubscriptionId:
                    requestUri.Add("subscription_id", filterId);
                    break;
                }

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

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

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

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

            if (string.IsNullOrWhiteSpace(filterId))
            {
                throw new ArgumentNullException("Filter id - Subscription id or Customer id is required");
            }

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

                case ZsInvoiceFilter.SubscriptionId:
                    requestUri = string.Format(CultureInfo.InvariantCulture, ApiResources.ZsGetInvoicesAllBySubscriptionId, filterId);
                    break;
                }

                var response = await httpClient.GetAsync(requestUri);

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

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

                return(processResult.Data);
            }
        }