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

            using (var httpClient = new HttpClient())
            {
                httpClient.Configure(apiBaseUrl, organizationId, authToken);
                var response = await httpClient.GetAsync(page.AppendTo(ApiResources.ZsGetCouponsAll));

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

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

                return(processResult.Data);
            }
        }
예제 #2
0
 public async Task <ZsCoupons> GetAllAsync(ZsPage page = null)
 {
     this.client.Configuration.CheckConfig();
     return(await this.GetAllAsync(this.client.Configuration.ApiBaseUrl, this.client.Configuration.AuthToken, this.client.Configuration.OrganizationId, page));
 }
예제 #3
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));
 }
예제 #4
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);
            }
        }
예제 #5
0
 public async Task <ZsContactPersons> GetAllAsync(string customerId, ZsPage page = null)
 {
     this.client.Configuration.CheckConfig();
     return(await this.GetAllAsync(this.client.Configuration.ApiBaseUrl, this.client.Configuration.AuthToken, this.client.Configuration.OrganizationId, customerId, page));
 }
예제 #6
0
        public async Task <ZsPlans> GetAllAsync(string apiBaseUrl, string authToken, string organizationId, string productId, ZsPage page = null)
        {
            apiBaseUrl.CheckConfigApiBaseUrl();
            authToken.CheckConfigAuthToken();
            organizationId.CheckConfigOrganizationId();

            if (string.IsNullOrWhiteSpace(productId))
            {
                throw new ArgumentNullException("Plan product id is required");
            }

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

                var requestUri = new QueryStringBuilder(ApiResources.ZsGetPlansAll);
                requestUri.Add("product_id", productId);

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

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

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

                return(processResult.Data);
            }
        }