spv.vds.VdsClient
Classspv.vds.VdsClient
> spv.ds.DsClient
spv.vds.VdsClient(service_url, in_settings)
VdsClient provides a layer of abstraction between GUI code and session-/protocol-handling. The configurator system is stateful. Session state is shared between server and client, this is a source of complexity and can hopefully be removed at some point in the future. VdsClient provides synchronization of session state between server and client by centralizing management of the shared state inside this class. Member functions are stateful if the member function name begins with "session". Other member functions are state- and session-less and can be called at any time, in any order. Most session dependent functions also require a loaded configuration. Preconditions should be documented for each member function in this class. The configurator system can be simplified as the following three phases: A. The user finds the configurator application on the web or in the showroom. B. The user choose and change the product components (called items) until the user is satisfied or leaved the application. C. The user saves the configuration for a later time or choose to place an order or request a sales contact for the built configuration. Technical usage example 1, Starting a new configuration session and interacting with the user. (Step-by-step example of phase B): 1. Construct an instance of spv.vds.Client 2. Call sessionInit 3. Call getIntroPage to retrieve the available start configurations 4. Generate images for the start configurations using getConfigImage 5. Display the available start configuration images to the user using the appropriate techniques for the GUI implementation. 6. The user chooses a start configuration 7. Send that start configuration to sessionLoadConfig 8. On success, call sessionGetRootMenuItems and sessionGetImage 9. Populate the GUI root menu with menu items and wait for the image response 10. On image success, load and display the configuration image 11. The user makes a choice about which menu to open 12. Call sessionToggleItem for the user chosen MenuItem (both menus and product components are MenuItems) 13. On success, call sessionGetStateUpdate to populate the currently open menu with menu items. 14. The user clicks an item in the currently open menu, send that MenuItem to sessionToggleItem and handle response. 15. On success, update the currently open menu with new MenuItems (most menu items will usually be unchanged, but some may change state and some may disappear while others may be added). Call sessionGetImage to get the new configuration image and wait for response. 16. On image success, load and display the configuration image 17. The user clicks a new item and the sessionToggleItem cycle continues until the user closes the application or decides to place an order for the built configuration. (this step is customized action for each configurator application, eg. cars and bathroom products require different types of shopping cart solutions) @export
service_url
{!string
}
in_settings
{spv.ds.DsClientSettings
=}
.assertInitializedSession()
[protected]Inherited from spv.ds.DsClient
.
Throw exception if session is not initialized.
.constructDefaultImageParams()
Inherited from spv.ds.DsClient
.
Create a ImageParams instance with default values, however, defaults are likely not good enough for most contexts. Preconditions: None. @export
spv.ds.ImageParams
}
.constructFailureWrapperForQueue(wrap_me)
[protected]Inherited from spv.ds.DsClient
.
Constructs the standard failure callback wrapper for queued session requests
wrap_me
{function
(Error
)}
function
(Error
)}
.errorHandler(on_failure)
[protected]Inherited from spv.ds.DsClient
.
on_failure
{function
(Error
)}
function
(Error
)}
.generatePublicConfig(on_success, on_failure)
Inherited from spv.ds.DsClient
.
Save the current configuration for the logged in user as a public config. The generated name is returned as a string to the on_success function. Preconditions: Initialized session, loaded configuration, logged in user. @export
on_success
{function
(string
)}
on_failure
{function
(Error
)}
.getCampaigns(feed_id, on_success, on_failure)
Requests available campaigns using the related feed id. Each campaign item will be test loaded in the configurator server to verify its correctness in combination with the available content data before returning the results to the client. See documentation for spv.vds.CapmaignCollection for more information. @export
feed_id
{string
}
on_success
{function
(spv.vds.CampaignCollection
)}
on_failure
{function
(Error
)}
.getConfigImage(conf, img_params, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Requests an image for a serialized configuration. Preconditions: None. @export
conf
{spv.ds.Config
}
img_params
{spv.ds.ImageParams
}
on_success
{function
(spv.ds.ImageResult
)}
on_failure
{function
(Error
)}
.getFreshConfigs(limit, scale_width, scale_height, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Requests the most recently built car configurations. @export
limit
{number
}
scale_width
{number
}
scale_height
{number
}
on_success
{function
(Array
.<spv.ds.FreshConfig
>)}
on_failure
{function
(Error
)}
.getIntroPage(on_success, on_failure)
Inherited from spv.ds.DsClient
.
Requests the "Intro page" data including available start-configurations, typically one config for each car model. Preconditions: None. @export
on_success
{function
(spv.ds.IntroPage
)}
on_failure
{function
(Error
)}
.getReadMore(item_id, model, category, on_success, on_failure)
Inherited from spv.ds.DsClient
.
item_id
{string
}
model
{string
}
category
{string
}
on_success
{function
(Array
.<spv.ds.ReadMoreResource
>)}
on_failure
{function
(Error
)}
.getRetailers(on_success, on_failure)
Requests all available retailers Preconditions: None. @export
on_success
{function
(Array
.<spv.vds.VolvoRetailer
>)}
on_failure
{function
(Error
)}
.getSessionId()
Inherited from spv.ds.DsClient
.
Get the session id or throw if null @export
string
}
.getSpecification(config, price_localization_id, on_success, on_failure)
Get the VolvoCarSpec for a config. Preconditions: None. @export
config
{spv.ds.Config
}
price_localization_id
{string
}
on_success
{function
(spv.vds.VolvoCarSpec
)}
on_failure
{function
(Error
)}
.getUserConfigList(username, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Gets all configurations stored in the database by the given username. This is a heavy operation and is included here for utility purposes. @export
username
{string
}
on_success
{function
(Array
.<spv.ds.SavedConfig
>)}
on_failure
{function
(Error
)}
.requestServiceInfo(service_group_id, on_success, on_failure)
Requests a specific service from a load balancing relay service and returns the url via the on_success callback. @export
service_group_id
{string
}
on_success
{function
(spv.vds.ServiceInfo
)}
on_failure
{function
(Error
)}
.resetPassword(token, new_password, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Resets user password. Token is retrieved via email, sent by sessionSendResetPasswordMail. @export
token
{string
}
new_password
{string
}
on_success
{Function
}
on_failure
{function
(Error
)}
.sessionAddGuiGroupSubscriptions(group_ids, on_success, on_failure)
Inherited from spv.ds.DsClient
.
group_ids
{Array
.<string
>}
on_success
{function
()}
on_failure
{function
(Error
)}
.sessionApplySuggestion(suggestion, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Apply a configuration change suggestion on the current configuration. Preconditions: Initialized session, loaded configuration, caller code has a valid instance of spv.ds.Suggestion retrieved by calling sessionToggleItem, no requests that modify the session configuration has been dispatched between suggestion construction and the call to this function. @export
suggestion
{spv.ds.Suggestion
}
on_success
{Function
}
on_failure
{function
(Error
)}
.sessionAutomaticHeartbeat(on_heartbeat, on_failure)
[protected]Inherited from spv.ds.DsClient
.
on_heartbeat
{function
()}
on_failure
{function
(Error
)}
.sessionClearGuiGroupSubscriptions(on_success, on_failure)
Inherited from spv.ds.DsClient
.
on_success
{function
()}
on_failure
{function
(Error
)}
.sessionCreateUser(user_name, password, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Create a new user in the user database. May not be required to create a user, depending on backend settings. @export
user_name
{string
}
password
{string
}
on_success
{Function
}
on_failure
{function
(Error
)}
.sessionDequeueNextRequest()
[protected]Inherited from spv.ds.DsClient
.
Session requests that require synchronization must use this function This function is not allowed to throw exceptions.
.sessionEnqueueRequest(request)
[protected]Inherited from spv.ds.DsClient
.
Session requests that require synchronization must use this function
request
{Function
}
.sessionGeneratePdf(on_success, on_failure)
Inherited from spv.ds.DsClient
.
Create a pdf using current session state and returns the pdf url through a callback if a pdf was generated successfully. Preconditions: Initialized session, loaded configuration. @export
on_success
{function
(string
)}
on_failure
{function
(Error
)}
.sessionGetAuxiliaryData()
[protected]Inherited from spv.ds.DsClient
.
Returns the auxiliary data arriving with the latest bop. Preconditions: Initialized session, loaded configuration.
Object
.<string
, Object
>}
.sessionGetCCInfo(on_success, on_failure)
Gets the current company cars information for the active configuration. @export
on_success
{function
(Object
)}
on_failure
{function
(Error
)}
.sessionGetCCItemInfo(item_id, on_success, on_failure)
Gets the current company cars information for a MenuItem. @export
item_id
{!string
}
on_success
{function
(Object
)}
on_failure
{function
(Error
)}
.sessionGetConfig(encoding, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Requests the current session config Available encodings are: "" : internal encoding, only for debug Preconditions: Initialized session, loaded config. @export
encoding
{string
}
on_success
{function
(spv.ds.Config
)}
on_failure
{function
(Error
)}
.sessionGetConfigNames(on_success, on_failure)
Inherited from spv.ds.DsClient
.
Get the saved configs for the logged in user Preconditions: Initialized session, logged in user. @export
on_success
{function
(Array
.<string
>)}
on_failure
{function
(Error
)}
.sessionGetConfigQuickInfo(config_name, on_success, on_failure)
Get some quick info about a saved configuration, such as model name and engine. Preconditions: Initialized session @export
config_name
{string
}
on_success
{function
(spv.vds.ConfigQuickInfoResult
)}
on_failure
{function
(Error
)}
.sessionGetFacebookShareData(on_success, on_failure)
Inherited from spv.ds.DsClient
.
Requests the text, images etc used for facebook sharing. Preconditions: Initialized session, loaded configuration. @export
on_success
{function
(spv.ds.FacebookShareData
)}
on_failure
{function
(Error
)}
.sessionGetFreshConfigs(limit, scale_width, scale_height, on_success, on_failure)
[deprecated]Deprecated. @export
Inherited from spv.ds.DsClient
.
Requests the most recently built car configurations.
limit
{number
}
scale_width
{number
}
scale_height
{number
}
on_success
{function
(Array
.<spv.ds.FreshConfig
>)}
on_failure
{function
(Error
)}
.sessionGetImage(img_params, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Builds an image for the current configuration state in this session. Preconditions: Initialized session, loaded configuration. @export
img_params
{spv.ds.ImageParams
}
on_success
{function
(spv.ds.ImageResult
)}
on_failure
{function
(Error
)}
.sessionGetImageSerieInfos()
Inherited from spv.ds.DsClient
.
Get image serie info for the current configuration Preconditions: Initialized session, loaded configuration. @export
Array
.<spv.ds.ImageSerieInfo
>}
.sessionGetIntroDisclaimer()
Inherited from spv.ds.DsClient
.
Gets the disclaimer to be displayed when the configurator is started. @export
spv.ds.Disclaimer
}
.sessionGetItemInfo(item_ids, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Get complete item info for items by item id Preconditions: Initialized session, loaded configuration. @export
item_ids
{Array
.<string
>}
on_success
{function
(Array
.<spv.ds.MenuItem
>)}
on_failure
{function
(Error
)}
.sessionGetLoan(on_success, on_failure)
Get the current loan parameters and calculation result Preconditions: Initialized session @export
on_success
{function
(spv.ds.Loan
)}
on_failure
{function
(Error
)}
.sessionGetLongText(item_id)
Inherited from spv.ds.DsClient
.
Get 'long_text' text for item_id or empty string on failure Texts are configuration dependent. In practice updating texts is only needed after loading a configuration, not when simply toggling an item in the configuration. Preconditions: Initialized session, loaded configuration. @export
item_id
{string
}
string
}
.sessionGetMediumText(item_id)
Inherited from spv.ds.DsClient
.
Get 'medium_text' text for item_id or empty string on failure Texts are configuration dependent. In practice updating texts is only needed after loading a configuration, not when simply toggling an item in the configuration. Preconditions: Initialized session, loaded configuration. @export
item_id
{string
}
string
}
.sessionGetModelDisclaimer(model_id)
Inherited from spv.ds.DsClient
.
Get the disclaimer specific for a model. If no model id is passed, it'll default to the active configuration's model. @export
model_id
{string
=}
spv.ds.Disclaimer
}
.sessionGetPresentationStructure(filter_name, query, on_success, on_failure)
Inherited from spv.ds.DsClient
.
filter_name
{string
}
query
{Array
<string
>}
on_success
{function
(spv.ds.PresentationStructure
)}
on_failure
{function
(Error
)}
.sessionGetRootMenuItems()
Inherited from spv.ds.DsClient
.
Get the root menu items for the current configuration Preconditions: Initialized session, loaded config. @export
Array
.<spv.ds.MenuItem
>}
.sessionGetShortText(item_id)
Inherited from spv.ds.DsClient
.
Get 'short_text' text for item_id or empty string on failure Texts are configuration dependent. In practice updating texts is only needed after loading a configuration, not when simply toggling an item in the configuration. Preconditions: Initialized session, loaded configuration. @export
item_id
{string
}
string
}
.sessionGetStateUpdate()
Inherited from spv.ds.DsClient
.
Get the last state update. Call this function on successful load of configs or on successful sessionToggleItem. Preconditions: Initialized session, loaded configuration. @export
spv.ds.SessionStateUpdate
}
.sessionGetSummary(on_success, on_failure)
Inherited from spv.ds.DsClient
.
Get the summary for the current session and configuration Preconditions: Initialized session, loaded configuration. @export
on_success
{function
(spv.ds.Summary
)}
on_failure
{function
(Error
)}
.sessionGetUrlSettings()
Inherited from spv.ds.DsClient
.
Get base urls needed for most HTTP GET paths to images Preconditions: Initialized session. @export
spv.ds.UrlSettings
}
.sessionGetUserConfigImage(config_name, img_params, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Requests an image for a saved configuration Preconditions: Initialized session, logged in user. @export
config_name
{string
}
img_params
{spv.ds.ImageParams
}
on_success
{function
(spv.ds.ImageResult
)}
on_failure
{function
(Error
)}
.sessionHasLoggedInUser(on_success, on_failure)
Inherited from spv.ds.DsClient
.
Check with backend if the session has a logged in user. Preconditions: Initialized session. @export
on_success
{function
(boolean
)}
on_failure
{function
(Error
)}
.sessionInit(menu_query, readmore_mode, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Initialize session. This must be called before calling any other member function with "session". For most other session calls a configuration needs to be loaded as well. This is not done in the constructor in order to allow state-/session-less calls without initializing a session. Preconditions: None. @export
menu_query
{string
}
readmore_mode
{spv.ds.ipprot_nova.input.BopReadMoreMode
}
on_success
{function
(spv.ds.IntroPage
)}
on_failure
{function
(Error
)}
.sessionLoadConfig(config, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Loads a configuration into the current session and replaces to current configuration state. Preconditions: Initialized session. @export
config
{spv.ds.Config
}
on_success
{function
(spv.ds.ConfigLoadResult
)}
on_failure
{function
(Error
)}
.sessionLoadConfigByName(config_name, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Loads a configuration into the current session and replaces to current configuration state. The config is referenced by it's name retrieved from sessionGetConfigNames. Preconditions: Initialized session, logged in user. @export
config_name
{string
}
on_success
{function
(spv.ds.ConfigLoadResult
)}
on_failure
{function
(Error
)}
.sessionLoadPublicConfig(public_config_id, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Loads a configuration from the "public" database into the current session replacing the current configuration state. "Public Configs" are anonymous configurations saved without any user information that can be loaded by a unique key. Preconditions: Initialized session. @export
public_config_id
{string
}
on_success
{function
(spv.ds.ConfigLoadResult
)}
on_failure
{function
(Error
)}
.sessionLogin(user_name, password_or_success, success_or_failure, failure)
Inherited from spv.ds.DsClient
.
User login Password may be required depending on backend settings. May create the user if it doesn't exist, depending on backend settings. success and failure callbacks are always at the end. sessionLogin( session_id, name, password, success, failure ); sessionLogin( session_id, name, success, failure ); Preconditions: Initialized session. @export
user_name
{string
}
password_or_success
{string
|Function
}
success_or_failure
{Function
|function
(Error
)}
failure
{function
(Error
)=}
.sessionLogout(on_success, on_failure)
Inherited from spv.ds.DsClient
.
Logout the user from the session. @export
on_success
{Function
}
on_failure
{function
(Error
)}
.sessionRemoveConfigByName(config_name, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Remove a saved configuration for the logged in user Preconditions: Initialized session, logged in user. @export
config_name
{string
}
on_success
{Function
}
on_failure
{function
(Error
)}
.sessionResetLoan(on_success, on_failure)
Resets the loan parameters used for private loan calculations Preconditions: Initialized session. @export
on_success
{function
(spv.ds.Loan
)}
on_failure
{function
(Error
)}
.sessionResetRequestQueue()
[protected]Inherited from spv.ds.DsClient
.
Resets session request queue
.sessionResume(session_id, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Initialize with existing session. Used instead of sessionInit. Preconditions: Client not initialized. @export
session_id
{string
}
on_success
{function
(spv.ds.IntroPage
)}
on_failure
{function
(Error
)}
.sessionSaveConfigByName(config_name, allow_overwrite, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Save the current configuration for the logged in user Preconditions: Initialized session, loaded configuration, logged in user. @export
config_name
{string
}
allow_overwrite
{boolean
}
on_success
{Function
}
on_failure
{function
(Error
)}
.sessionSendHeartBeat(on_success, on_failure)
Inherited from spv.ds.DsClient
.
Call this function to keep the session alive Preconditions: Initialized session. @export
on_success
{function
()}
on_failure
{function
(Error
)}
.sessionSendMailToCustomer(customer_email, want_newsletter, want_summary_pdf, mail_link_url,
on_success, on_failure)
Sends a volvo retailer newsletter and/or summary mail to the customer. @export
customer_email
{string
}
want_newsletter
{boolean
}
want_summary_pdf
{boolean
}
mail_link_url
{string
}
on_success
{function
()}
on_failure
{function
(Error
)}
.sessionSendMailToCustomerAndRetailer(customer_first_name, customer_surname, customer_email,
customer_phone, preferred_contact_time, preferred_contact_media,
want_newsletter, want_summary_pdf, retailer_id, mail_link_url,
on_success, on_failure)
Sends a volvo retailer newsletter and/or summary mail to the customer and retailer. @export
customer_first_name
{string
}
customer_surname
{string
}
customer_email
{string
}
customer_phone
{string
}
preferred_contact_time
{string
}
preferred_contact_media
{string
}
want_newsletter
{boolean
}
want_summary_pdf
{boolean
}
retailer_id
{string
}
mail_link_url
{string
}
on_success
{function
()}
on_failure
{function
(Error
)}
.sessionSendResetPasswordMail(password_form_url, user_name, language, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Precondition: Initialized session @export
password_form_url
{string
}
user_name
{string
}
language
{string
}
on_success
{Function
}
on_failure
{function
(Error
)}
.sessionSetLoan(down_payment, interest_rate, number_of_months, on_success,
on_failure)
Sets the loan parameters used for private loan calculations Preconditions: Initialized session. @export
down_payment
{number
}
interest_rate
{number
}
number_of_months
{number
}
on_success
{function
(spv.ds.Loan
)}
on_failure
{function
(Error
)}
.sessionSetPriceLocalization(price_localization_id, on_success, on_failure)
Inherited from spv.ds.DsClient
.
Choose which collection of price rules to use for the current session Preconditions: Initialized session. @export
price_localization_id
{string
}
on_success
{Function
}
on_failure
{function
(Error
)}
.sessionSetRetailerBusinessGroup(business_group_retailer_id, on_success, on_failure)
Sets retailer business group id and retailer mode for the current session. @export
business_group_retailer_id
{string
}
on_success
{Function
}
on_failure
{function
(Error
)}
.sessionToggleItem(menu_item, on_success, on_suggestions, on_failure)
Inherited from spv.ds.DsClient
.
Try to change item state for one item in the current configuration. An item has two states, On or Off, eg. an item is part of the current configuration or it is not. The result of this operation can only be determined by the server. Any call to this function may result in suggestions being returned through the callback on_suggestions. If suggestions Preconditions: Initialized session, loaded configuration, caller code has a valid instance of spv.ds.MenuItem. @export
menu_item
{spv.ds.MenuItem
}
on_success
{Function
}
on_suggestions
{function
(Array
.<spv.ds.Suggestion
>)}
on_failure
{function
(Error
)}
.sessionUpdateBop(on_success, on_failure)
[protected]Inherited from spv.ds.DsClient
.
Requests a fresh bop and stores the new state in the client.
on_success
{function
()}
on_failure
{function
(Error
)}
.sessionUpdateCCInputParams(params, on_success, on_failure)
Updates the given parameters for Company Cars pricing. This method always return the current company car parameter state. You may pass an empty object to retrieve the available parameters and their current value. The value are default initialized. You're only required to send the changed paramaters. Unmentioned parameters will not change. The input parameters are passed as a flat Object, basically a dictionary, with the parameter names and values. The names and types for each parameter can be found in the CCInputParam array returned by this function. Warning: This function may potentially generate very long URL queries if jsonp is activated for the client. Preconditions: sessionEnableCCPrices must be called before using this method. @export
params
{Object
.<string
,Object
>}
on_success
{function
(Object
.<string
,spv.vds.CCInputParam
>)}
on_failure
{function
(Error
)}
.startAutomaticHeartbeat(interval, on_heartbeat, on_failure)
Inherited from spv.ds.DsClient
.
Starts the automatic heartbeat for the session. Don't forget to call stopAutomaticHeartbeat if you attempt to destroy or replace the DsClient object. If you don't, there'll be an orphaned DsClient object heartbeating forever. (Well, until the browser session ends. ) @public
interval
{number
}
on_heartbeat
{function
()}
on_failure
{function
(Error
)}
.stopAutomaticHeartbeat()
Inherited from spv.ds.DsClient
.