ListCustomers

SmithCart > Integration > REST Endpoints
Usage
Lists all customers
Basic URI
/customers.json?top={top}&skip={skip}&orderby={orderby}
Parameters
int top               The maximum number of rows to return
long skip            The start row index
string orderby    A sort expression
HTTP Example
https://domain.com/DesktopModules/Smith.BuyNow/Services/v1/Checkout.svc/custome.json?top=10&skip=0&orderby=-order_date
AUTH
Bearer JWT
 
C# Code
 
JavaScript Code
<script>
   (function ($) {
       var CLIENT_ID = "4SnPA6lqpY76ODEr",
           SERVICE_URI = "https://domain.com/DesktopModules/Smith.BuyNow/Services/v1/",
           DATA_LIMIT = "10",
           SKIP = "0",
           ORDER_BY = "-order_date";

       function listCustomers (endPoint, clientID, top, skip, orderBy) {
           var jwt = sessionStorage.getItem("jwt");
           if (!jwt) {
               var uri = endPoint + "Authorize.ashx?"
                   + "response_type=token"
                   + "&client_id=" + clientID
                   + "&redirect_uri=" + encodeURIComponent(window.location)
                   + "&scope=" + encodeURIComponent("customers create edit delete");
               window.location = uri;
               return;
           }

           $.ajax({
               type: "GET",
               url: endPoint + "/Checkout.svc/customers.json?top="
                    + top + "&skip=" + skip + "&orderby=" + orderBy,
               headers: { "Authorization": "Bearer " + jwt },
               contentType: "application/json; charset=utf-8",
               dataType: "json"
           }).fail(function (jqXHR, textStatus) {
               console.log("SmithCart API: " + textStatus);
           });
       }

       $(function () {
           var params = {},
               queryString = location.hash.substring(1),
               regex = /([^&=]+)=([^&]*)/g,
               m;

           while (m = regex.exec(queryString)) {
               params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
           }
           if (params["access_token"]) {
               sessionStorage.setItem("jwt", params["access_token"]);
           }

           listCustomers (SERVICE_URI, CLIENT_ID, DATA_LIMIT, SKIP, ORDER_BY);
       });
   })(jQuery);
</script>
 
 
 
Response
[
    {
        "id": 2,
        "first_name": "test2",
        "last_name": "user2",
        "address1": "123 Some St",
        "address2": "Apt 10",
        "city": "My City",
        "country": "US",
        "state": "CA",
        "zipcode": "12345",
        "home_phone": "(123) 123-1234",
        "cell_phone": null,
        "work_phone": null,
        "email": "test@smith-consulting.com",
        "account_no": "1001",
        "dnn_login": "user1",
        "created_date": "\/Date(1422050753657-0800)\/",
        "ip_address": "127.0.0.1",
        "company_name": "Smith Consulting",
        "modified_by": null,
        "modified_date": null
    },
    {
        "id": 1,
        "first_name": "test1",
        "last_name": "user1",
        "address1": "123 Some St",
        "address2": "Apt 2",
        "city": "My City",
        "country": "US",
        "state": "CA",
        "zipcode": "12345",
        "home_phone": "(123) 123-1234",
        "cell_phone": null,
        "work_phone": null,
        "email": "test2@smith-consulting.com",
        "account_no": "1000",
        "dnn_login": "user2",
        "created_date": "\/Date(1422050753657-0800)\/",
        "ip_address": "127.0.0.1",
        "company_name": "Smith Consulting",
        "modified_by": null,
        "modified_date": null
    }
]