GetCustomerByID

SmithCart > Integration > REST Endpoints
Usage
Retrieve a customers by ID
Basic URI
/customers/{cid}.json
Parameters
int cid               The customer ID
HTTP Example
https://domain.com/DesktopModules/Smith.BuyNow/Services/v1/Checkout.svc/customers/1.json
AUTH
Bearer JWT
 
C# Code
 
JavaScript Code
<script>
   (function ($) {
       var CLIENT_ID = "4SnPA6lqpY76ODEr",
           SERVICE_URI = "https://domain.com/DesktopModules/Smith.BuyNow/Services/v1/",
           CUSTOMER_ID = "1";

       function getCustomer (endPoint, clientID, cID) {
           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("orders create edit delete");
               window.location = uri;
               return;
           }

           $.ajax({
               type: "GET",
               url: endPoint + "/Checkout.svc/customers/" + cID + ".json",
               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"]);
           }

           getCustomer (SERVICE_URI, CLIENT_ID, CUSTOMER_ID);
       });
   })(jQuery);
</script>
 
 
 
Response
[
    "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
]