JSMA customer

Overview

The JSMA customer provides functionality for handling customers

What can JSMA customer do for me?

You could easily use the JSMA customer to edit a customer

Index

Usage

writing data

Here is an example on how to write data to a JSMA customer:

...
var feedbackMailBody = mailTemplateBody.content;

mail.send(feedback.email, mailTemplateSubject.content, feedbackMailBody, mailSenderName, mailSender);
mail.send(mailSender, mailTemplateSubject.content, feedbackMailBody + mailServiceTemplateBody.content, mailSenderName, mailSender);

if (customer) {
customer.addHistoryEntry(feedbackMailBody + mailServiceTemplateBody.content);
} 
...

reading data

Here is an example on how to read data from a JSMA customer:

... 
var loginname = customer.loginName();
...

Methods

The JSMA customer provides the following methods:

bool customer.active

With this function you can check whether a customer is active

Example

... 
if (customer.active === true)
{
  ...
}
...

customer.addHistoryEntry(text, [user])

Adds an entry to a customer's IFE history. This serves as a documentation tool for communication as well as the customer's interaction with the website (e.g. creating/saving/deleting projects).

Example

... 
var feedbackMailBody = mailTemplateBody.content;

mail.send(feedback.email, mailTemplateSubject.content, feedbackMailBody, mailSenderName, mailSender);
mail.send(mailSender, mailTemplateSubject.content, feedbackMailBody + mailServiceTemplateBody.content, mailSenderName, mailSender);

if (customer) {
  customer.addHistoryEntry(feedbackMailBody + mailServiceTemplateBody.content);
}
...

Parameter text (required)

Parameter user (optional)

bool customer.confirmed

Returns a boolean value depending on whether the customer is confirmed

Example

... 
if (customer.confirmed === true)
{
  ...
}
...

date customer.confirmedDate

Returns the date of when the customer was confirmed

Example

... 
customer.confirmedDate
...

string customer.displayName

Returns the display name of the customer

Example

... 
customer.displayName
...

string customer.email

Returns the e-mail of the customer

Example

... 
customer.email
...

object customer.errors

Returns an object containing the errors of a customer

Example

... 
customer.errors
...

customer.flexAttributes

Returns an array of the flex attributes of a customer

Example

... 
customer.flexAttributes
...

string customer.get(key)

Returns the value of key as string or null if no value is set under the key.

Example

... 
customer.get(key)
...

Parameter key:string (required)

The key to be looked up in the flexAttributes of the customer.

boolean customer.has(key)

Returns a boolean value depending on whether key is present for a given customer

Example

... 
customer.has(key)
...

Parameter key:string (required)

The key to be checked in the flexAttributes of the customer.

customer.id

Returns the ID of a customer

Example

... 
customer.id
...

customer.increment(key)

Increments the vale of a given key by one.

Example

... 
customer.increment(key)
...

Parameter key:string (required)

The key to be incremented in the flexAttributes of the customer.

date customer.lastLogin()

Returns the date of the last login of the customer

Example

... 
customer.lastLogin()
...

string customer.login

With this function you can login a customer

Example

... 
customer.login
...

int customer.loginCount

Returns the number of logins of a customer

Example

... 
customer.loginCount
...

int customer.loginFailureCount

Returns the numer of login failuers of a customer

Example

... 
customer.loginFailureCount
...

string customer.loginName

Returns the login-name of a customer

Example

... 
customer.loginName
...

customer.logout()

With this function you can logout the customer

Example

... 
customer.logout()
...

int[] customer.orderIds

Returns an arry of order-ids that belong to the customer

Example

... 
customer.orderIds
...

portal customer.portal

Returns the portal the customer belongs to

Example

... 
customer.portal
...

customer.remove(key)

Removes the key from the flexAttributes of the customer

Example

... 
customer.remove(key)
...

Parameter key:string (required)

The key to be removed from the flexAttributes of the customer.

customer.set(key, value)

Sets the value of a specified key for a given customer.

Example

... 
customer.set(key, value, [options])
...

Parameter key:string (required)

The key to be set in the flexAttributes of the customer.

Parameter value:string (required)

The value to be set for the key

void customer.setActive(bool=true)

Activates a customer

Example

... 
customer.setActive(true)
...

Parameter bool (optional, default: true)

customer.setConfirmed(bool=true)

Sets the confirmed-value of a customer

Example

... 
customer.setConfirmed(true)
...

Parameter bool (optional, default: true)

customer.setDisplayName(name)

Sets the display-name of a customer

Example

... 
customer.setDisplayName(name)
...

Parameter name (required)

customer.setEmail(email)

Sets the e-mail of a customer

Example

... 
customer.setEmail(email)
...

Parameter email (required)

customer.setLoginName(name)

Sets the login-name of a customer

Example

... 
customer.setLoginName(name)
...

Parameter name (required)

customer.setPassword(password)

Sets the password of a customer

Example

... 
customer.setPassword(password)
...

Parameter password (required)

The new password. It is hashed using bcrypt and the hash is saved in the database.

customer.validatePassword(password)

Validates the given password

Example

... 
customer.validatePassword(password)
...

Parameter password (required)

The password to be checked. It is hashed using bcrypt and the hased value is compared to the one in the database.