Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Method
GET or POST
Comments
Description

logs in a customer and returns their base information

(MyAccount object)

There are two ways to login: GET or POST.

For the GET, the three parameters are submitted. For POST, a CustomerCredentials object is submitted (it's a simple object with three fields).

Cookies

UltraCartShoppingCartId - Cart ID

not required, but if passed along and valid, the same shopping cart will continue to be used. Otherwise, a new cart is created and Set-Cookie headers will accompany a successful login. 
Path Parametersnone 
Query Parameters

For GET:

merchantId

email

password

For POST:

none

 
Headers

none

 
Receives JsonCustomerCredentials 
Returns JsonMyAccount object if successful

A failed login will result in a 401 Unauthorized http status.

Any missing parameers will result in a 400 Bad Request http status.

Example

 

Code Block
themeDJango
languagejavascript
linenumberstrue
  this.login = function (email, password, options) {
    options = options || {};
    var credentials = {merchantId: merchantId, email: email, password: password};
    var account = null;
    jQuery.ajax({
      url: restUrl + '/login',
      data: JSON.stringify(credentials),
      type: 'post',
      async: (options.success || options.failure) ? true : false,
      headers: { "cache-control": "no-cache" },
      contentType: 'application/json; charset=UTF-8',
      cache: false,
      dataType: 'json'
    }).done(function (result) {
              account = result;
              if (options.success) {
                options.success(account);
              }
            })
            .fail(function (jqXHR, textStatus, errorThrown) {
              if (options.failure) {
                options.failure(jqXHR, textStatus, errorThrown);
              }
            });
    return account;
  };

 

 

 

/rest/myaccount/logout

Method
GET or POST
Comments
Description

logs out a customer

 

Cookies

UltraCartShoppingCartId - Cart ID

used to determine which customer to logout
Path Parametersnone 
Query Parameters

none

 
Headers

none

 
Receives Jsonnone 
Returns Jsonnone

 

Example

 

Code Block
themeDJango
languagejavascript
linenumberstrue
    this.logout = function (options) {
    options = options || {};
    // even if logged out, there may be a shopping cart, so return that cart if it's returned from the server.
    var cart = null;
    jQuery.ajax({
      url: '/rest/myaccount/logout',
      type: 'get',
      headers: { "cache-control": "no-cache" },
      async: (options.success || options.failure) ? true : false,
      cache: false,
      dataType: 'json'
    }).done(function (result) {
              cart = result;
              if (options.success) {
                options.success(cart);
              }
            })
            .fail(function (jqXHR, textStatus, errorThrown) {
              if (options.failure) {
                options.failure(jqXHR, textStatus, errorThrown);
              }
            });
    return cart;
  };

 

 

/rest/myaccount/changePassword

Method
POST
Comments
Description

Updates password

This is the only way for a user to change their password

Cookies

UltraCartShoppingCartId - Cart ID

UltraCartMerchantID = Merchant ID

The customer must be successfully logged in to change their password.
Path Parametersnone 
Query Parameters

none

 
Headers

none

 
Receives JsonChangePasswordRequest 
Returns Jsonnothing (204 on success)

A failed login will result in a 401 Unauthorized http status.

Any missing parameers will result in a 400 Bad Request http status.

Any parameters too long will result in a 400 Bad Request http status

Example

 

Code Block
themeDJango
languagejavascript
linenumberstrue
  this.changePassword = function (oldPassword, newPassword, options) {
    options = options || {};
    jQuery.ajax({
      url: '/rest/myaccount/changePassword',
      data: JSON.stringify({oldPassword: oldPassword, newPassword: newPassword}),
      type: 'post',
      async: (options.success || options.failure) ? true : false,
      headers: { "cache-control": "no-cache" },
      cache: false,
      contentType: 'application/json; charset=UTF-8',
      dataType: 'json'
    }).done(function () {
              if (options.success) {
                options.success();
              }
            })
            .fail(function (jqXHR, textStatus, errorThrown) {
              if (options.failure) {
                options.failure(jqXHR, textStatus, errorThrown);
              }
            });
  };

...