Exemplo n.º 1
0
        public async Task <ZsCustomers> GetAllAsync(string apiBaseUrl, string authToken, string organizationId, QueryStringBuilder queryStringBuilder = null)
        {
            apiBaseUrl.CheckConfigApiBaseUrl();
            authToken.CheckConfigAuthToken();
            organizationId.CheckConfigOrganizationId();

            using (var httpClient = new HttpClient())
            {
                httpClient.Configure(apiBaseUrl, organizationId, authToken);
                var response = await httpClient.GetAsync(string.Format(CultureInfo.InvariantCulture, "{0}{1}", ApiResources.ZsGetCustomersAll, null == queryStringBuilder ? string.Empty : queryStringBuilder.ToString()));

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

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

                return(processResult.Data);
            }
        }
Exemplo n.º 2
0
        public async Task <ZsPlans> GetAllAsync(string apiBaseUrl, string authToken, string organizationId, string productId)
        {
            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 queryBuilder = new QueryStringBuilder();
                queryBuilder.Add("product_id", productId);
                var finalResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}{1}", ApiResources.ZsGetPlansAll, queryBuilder.ToString());
                var response          = await httpClient.GetAsync(finalResourcePath);

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

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

                return(processResult.Data);
            }
        }