Exemplo n.º 1
0
        GetSingleSiteJobsAsync(object query, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query);

            return(await ApiGetAsync <List <SingleSiteJob> >(
                       "/place_card_on_single_site_jobs", qd, paging, headers));
        }
Exemplo n.º 2
0
        UpdateSingleSiteJobAsync(object query, PropertyBag body, string safeKey = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query, body);

            return(await ApiPutDelAsync <SingleSiteJob>(
                       "/place_card_on_single_site_jobs/{0}", qd.ID, HttpMethod.Put, body, safeKey, headers));
        }
Exemplo n.º 3
0
        UpdateCardAsync(object query, PropertyBag body, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query, body);

            return(await ApiMultiPutDelAsync <Card>(
                       "/cardsavr_cards", null, qd, HttpMethod.Put, body, null, paging, headers));
        }
Exemplo n.º 4
0
        DeleteCardAsync(object query, string safeKey = null, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query, null, false, true);

            return(await ApiMultiPutDelAsync <Card>(
                       "/cardsavr_cards", null, qd, HttpMethod.Delete, null, safeKey, paging, headers));
        }
Exemplo n.º 5
0
        DeleteCardholderAsync(object query, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query);

            return(await ApiMultiPutDelAsync <Cardholder>(
                       "/cardholders", null, qd, HttpMethod.Delete, null, null, paging, headers));
        }
Exemplo n.º 6
0
        DeleteAddressAsync(object query, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query);

            return(await ApiMultiPutDelAsync <Address>(
                       "/cardsavr_addresses", null, qd, HttpMethod.Delete, null, null, paging, headers));
        }
Exemplo n.º 7
0
        DeleteAccountAsync(object query, string safeKey = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query, null, false, true);

            return(await ApiPutDelAsync <Account>(
                       "/cardsavr_accounts/{0}", qd.ID, HttpMethod.Delete, null, safeKey, headers));
        }
Exemplo n.º 8
0
        UpdateUserPasswordAsync(object query, PropertyBag body, HttpRequestHeaders headers = null)
        {
            body["password"] = body["password_copy"] = MakePasswordKey((string)body["username"], (string)body["password"]);
            QueryDef qd   = new QueryDef(query, body, false, true);
            string   path = "/cardsavr_users/{0}/update_password";

            return(await ApiPutDelAsync <PropertyBag>(path, qd.ID, HttpMethod.Put, body, null, headers));
        }
Exemplo n.º 9
0
        GetMerchantSitesAsync(object query, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query);

            return(await ApiGetAsync <List <MerchantSite> >("/merchant_sites", qd, paging, headers));

            //string url = "https://swch-site-images-mgmt.s3-us-west-2.amazonaws.com/branding/sites.json";
        }
Exemplo n.º 10
0
        UpdateIntegratorsAsync(
            object query, PropertyBag body, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query, body);

            return(await ApiMultiPutDelAsync <Integrator>(
                       "/integrators", null, qd, HttpMethod.Put, body, null, paging, headers));
        }
Exemplo n.º 11
0
        GetCardPlacementResultReportingJobsAsync(
            object query, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query);

            return(await ApiGetAsync <List <CardPlacementResult> >(
                       "/card_placement_result_reporting_jobs", qd, paging, headers));
        }
Exemplo n.º 12
0
        RotateIntegratorsAsync(
            object query, HttpRequestHeaders headers = null)
        {
            QueryDef qd   = new QueryDef(query);
            string   path = "/integrators/{0}/rotate_key";

            return(await ApiPutDelAsync <Integrator>(
                       path, qd.ID, HttpMethod.Put, null, null, headers));
        }
Exemplo n.º 13
0
        UpdateUserAsync(object query, PropertyBag body, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd   = new QueryDef(query, body);
            string   path = "/cardsavr_users";

            if (headers == null)
            {
                headers = new HttpRequestMessage().Headers;
            }
            return(await ApiMultiPutDelAsync <User>(path, null, qd, HttpMethod.Put, body, null, paging, headers));
        }
Exemplo n.º 14
0
        UpdateAccountAsync(object query, PropertyBag body, string envelopeId, string safeKey = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query, body, false, true);

            if (envelopeId != null)
            {
                headers.Add("x-cardsavr-envelope_id", envelopeId);
            }
            return(await ApiPutDelAsync <Account>(
                       "/cardsavr_accounts/{0}", qd.ID, HttpMethod.Put, body, safeKey, headers));
        }
Exemplo n.º 15
0
        UpdateCardholderAsync(object query, PropertyBag body, string newSafeKey = null, string safeKey = null, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd   = new QueryDef(query, body);
            string   path = "/cardholders";

            if (headers == null)
            {
                headers = new HttpRequestMessage().Headers;
            }
            AddNewSafeKeyHeader(headers, newSafeKey);
            return(await ApiMultiPutDelAsync <Cardholder>(path, null, qd, HttpMethod.Put, body, null, paging, headers));
        }
Exemplo n.º 16
0
        public static string AppendQueryString(string path, QueryDef qd)
        {
            if (qd == null || qd.IsEmpty)
            {
                return(path);
            }

            if (qd.IsID)
            {
                return($"{path}?ids={qd.ID}");
            }

            return(AppendQueryString(path, qd.Collection));
        }
Exemplo n.º 17
0
        // Could be exposed publicly to give advanced users more flexibility.
        private async Task <CardSavrResponse <List <T> > > ApiMultiPutDelAsync <T>(
            string path, string pathWithId, QueryDef qd, HttpMethod method, object body,
            string safeKey, Paging paging = null, HttpRequestHeaders headers = null)
            where T : class
        {
            // by default we just tack the id on the end (we assume no trailing slash).
            pathWithId = pathWithId ?? path + "/{0}";

            CardSavrResponse <List <T> > result;

            if (qd.IsID)
            {
                // this is a singular operation, so just do it.
                CardSavrResponse <T> singleResponse = await ApiPutDelAsync <T>(
                    pathWithId, qd.ID, method, body, safeKey, headers);

                // then transform the result into a list.
                result = new CardSavrResponse <List <T> >()
                {
                    StatusCode = singleResponse.StatusCode,
                    Paging     = singleResponse.Paging,
                    Body       = new List <T>()
                    {
                        singleResponse.Body
                    }
                };
            }
            else
            {
                // get all the things implied by the query parameters, the iterate through and perform
                // the operation on each thing successively.
                result = await ApiGetAsync <List <T> >(path, qd, paging, headers);

                foreach (T t in result.Body)
                {
                    // we have to use reflection on a generic type.
                    string id = Convert.ToString(t.GetType().GetProperty("id").GetValue(t));

                    // should probably have some error handling here so we can continue on failure.
                    await ApiPutDelAsync <T>(pathWithId, id, method, body, safeKey, headers);
                }
            }

            return(result);
        }
Exemplo n.º 18
0
        /*========== PRIVATE IMPLEMENTATION ==========*/

        // Could be exposed publicly to give advanced users more flexibility.
        private async Task <CardSavrResponse <T> > ApiGetAsync <T>(
            string path, QueryDef qd, Paging paging = null, HttpRequestHeaders headers = null)
            where T : class
        {
            // allow an empty query: enumerates all entities.
            path = ApiUtil.AppendQueryString(path, qd);
            log.Debug($"path with query: \"{path}\"");

            using (HttpRequestMessage request = CreateRequest(HttpMethod.Get, path, null, headers))
            {
                if (paging != null && paging.GetCount() > 0)
                {
                    request.Headers.Add("x-cardsavr-paging", paging.Stringify());
                }
                using (HttpResponseMessage response = await SendAsync(request))
                {
                    return(await ProcessResponseAsync <T>(request, response));
                }
            }
        }
Exemplo n.º 19
0
        GetIntegratorsAsync(object query, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query);

            return(await ApiGetAsync <List <Integrator> >("/integrators", qd, paging, headers));
        }
Exemplo n.º 20
0
        GetBinsAsync(object query, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query);

            return(await ApiGetAsync <List <BIN> >("/cardsavr_bins", qd, paging, headers));
        }
Exemplo n.º 21
0
        GetCardholdersAsync(object query, Paging paging = null, HttpRequestHeaders headers = null)
        {
            QueryDef qd = new QueryDef(query);

            return(await ApiGetAsync <List <Cardholder> >("/cardholders", qd, paging, headers));
        }