/**
* @fileoverview This file contains the IPad Protocol Adaptor and its related
* utility function. There is quite a lot of code dedicated to
* data structure conversion, this is intentional and provides a
* layer of abstraction between the exported web service code and
* GUI code. It is unclear at the time of writing if the VIViD
* protocol will be implemented in this client or if the ipad
* protocol will be implemented in the stand alone server. This
* abstraction of the protocol implementation will allow for both
* options.
*
* TODO: add more assertions of protocol data conversions later.
*
* @author anders.rejdebrant@spark-vision.com (Anders Rejdebrant)
*/
goog.provide( 'spv.vds.impl.IPPNovaAdaptor' );
goog.require('spv.vds.impl.IVdsProtocol');
goog.require('spv.vds.impl.IPPCommon');
goog.require('spv.ds.impl.IPPCommon');
goog.require('spv.vds.Campaign');
goog.require('spv.vds.CampaignCollection');
goog.require('spv.vds.ConfigQuickInfoResult');
goog.require('spv.ds.Loan');
goog.require('spv.ds.ipprot_nova.output.OutBop');
goog.require('spv.vds.CCInputParam');
goog.require('spv.vds.VolvoCarSpec');
goog.require('spv.vds.VolvoCarSpecItem');
goog.require('spv.vds.VolvoCarSpecTechData');
goog.require('spv.vds.ipprot_nova.IpadClient');
goog.require('spv.vds.ipprot_nova.output.ConfigQuickInfo');
goog.require('spv.vds.ipprot_nova.output.ConfigQuickInfoResult');
goog.require('spv.vds.ipprot_nova.specification.Item');
goog.require('spv.vds.ipprot_nova.specification.TechnicalDataAttribute');
goog.require('spv.vds.ipprot_nova.specification.CarSpecification');
goog.require('spv.vds.ipprot_nova.retailerdatahandler.VolvoRetailer');
goog.require('spv.vds.ipprot_nova.volvocampaigns.Campaign');
goog.require('spv.vds.ipprot_nova.volvocampaigns.CampaignCollection');
goog.require('spv.vds.ipprot_nova.volvocampaigns.DigitalShowroomValues');
/**
*
* @constructor
* @implements {spv.vds.impl.IVdsProtocol}
* @param {string} service_url
*/
spv.vds.impl.IPPNovaAdaptor = function(service_url)
{
var use_jsonp = true;
var ipad_client = new spv.vds.ipprot_nova.IpadClient(service_url, use_jsonp);
this._impl = ipad_client;
};
/**
*
* @param {spv.ds.ipprot_nova.output.OutBop} update_bop
* @param {function(spv.ds.SessionStateUpdate, spv.ds.impl.AuxData)} on_state_update
*/
spv.vds.impl.IPPNovaAdaptor.prototype.updateStateFromBop = function (
update_bop,
on_state_update)
{
if (!update_bop) return;
var ssu = spv.ds.impl.IPPCommon.convertToSessionStateUpdate(update_bop);
var aux_data = spv.ds.impl.IPPCommon.extractAuxiliaryData(update_bop);
on_state_update(ssu, aux_data);
}
/** METHODS FOR MANAGING VDS PRICES */
/**
* @param {string} session_id
* @param {function(spv.vds.VdsPriceMode)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionGetCurrentPriceMode = function(
session_id,
on_success,
on_failure)
{
this._impl.get_current_price_mode(
session_id,
on_success,
on_failure);
}
/**
* Setting price mode can potentially require changing the configuration since there can
* be introduced new items and rules applicable only to this price mode and current configuration
* might become invalid. This method attempts to set a new price mode and can activate the mode directly
* or return back suggestions that should be applied to the configuration to make it valid and/or
* any optional changes that were required in the current price mode but will become optional in the
* new price mode.
*
* @param {string} session_id
* @param {spv.vds.VdsPriceMode} price_mode
* @param {spv.vds.SendBopUpdateFlag} send_update
* @param {function(spv.ds.SessionStateUpdate, spv.ds.impl.AuxData)} on_state_update
* @param {function(Object)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionAttemptSetPriceMode = function(
session_id,
price_mode,
send_update,
on_state_update,
on_success,
on_failure)
{
var that = this;
/** @param {Object} data */
var on_backend_response = function(data)
{
var result_code = data.attempt_result_code;
if (result_code === spv.vds.ipprot_nova.pricemode.SetPriceModeResultCode.FAILED)
{
on_failure(new Error(result_code));
return;
}
that.updateStateFromBop(data.bop, on_state_update);
if (result_code === spv.vds.ipprot_nova.pricemode.SetPriceModeResultCode.SUCCESS)
{
on_success(data);
return;
}
// config changes required
if (data.required_changes && data.required_changes.multiple_resolvers)
{
// convert resolvers to the format VdsClient operates on.
data.required_changes.multiple_resolvers = data.required_changes.multiple_resolvers
.map(function(resolver) { return spv.ds.impl.IPPCommon.convertToGoalStateResolver(resolver); });
}
if (data.optional_changes && data.optional_changes.optional_active_items)
{
data.optional_changes.optional_active_items =
spv.ds.impl.IPPCommon.convertToMenuItems(data.optional_changes.optional_active_items);
}
on_success(data);
};
this._impl.attempt_set_price_mode(
session_id,
price_mode,
send_update,
on_backend_response,
on_failure);
}
/**
* @param {string} session_id
* @param {spv.vds.VdsPriceMode} price_mode
* @param {spv.vds.SendBopUpdateFlag} send_update
* @param {Array.<string>} optional_items
* @param {function(spv.ds.SessionStateUpdate, spv.ds.impl.AuxData)} on_state_update
* @param {function(string)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionSetPriceMode = function(
session_id,
price_mode,
send_update,
optional_items,
on_state_update,
on_success,
on_failure)
{
var that = this;
/** @param {spv.vds.ipprot_nova.pricemode.PriceModeResult} result */
var on_backend_response = function(result)
{
if (result.result_code != spv.vds.ipprot_nova.pricemode.SetPriceModeResultCode.SUCCESS)
{
on_failure(new Error(result.result_code));
return;
}
that.updateStateFromBop(result.bop, on_state_update);
on_success(result.current_price_mode);
};
var optional_input = optional_items && optional_items.length ? optional_items.join(';') : "";
this._impl.set_price_mode(
session_id,
price_mode,
send_update,
optional_input,
on_backend_response,
on_failure);
}
/** */
/**
* @param {string} session_id
* @param {string} config_name
* @param {function(spv.vds.ConfigQuickInfoResult)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.getConfigQuickInfo = function(
session_id,
config_name,
on_success,
on_failure)
{
/** @param {spv.vds.impl.RawConfigQuickInfoResult} qi_result */
var on_success_wrapper = function( qi_result )
{
on_success( spv.vds.impl.IPPCommon.convertToConfigQuickInfoResult( qi_result ) );
};
this._impl.get_config_quick_info(
session_id,
config_name,
on_success_wrapper,
on_failure);
}
/**
* @param {string} session_id
* @param {Function} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionEnablePrivateLeasing = function(
session_id,
on_success,
on_failure)
{
this._impl.enable_private_leasing(
session_id,
on_success,
on_failure);
}
/**
* @param {string} session_id
* @param {Function} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionDisablePrivateLeasing = function(
session_id,
on_success,
on_failure)
{
this._impl.disable_private_leasing(
session_id,
on_success,
on_failure);
}
/**
* @param {function(Array.<spv.vds.VolvoRetailer>)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.getRetailers = function(
on_success,
on_failure)
{
/** @param {Array.<spv.vds.impl.RawVolvoRetailer>} rets */
var on_protocol_success = function(rets)
{
var volvo_retailers = spv.vds.impl.IPPCommon.convertToVolvoRetailers(rets);
on_success(volvo_retailers);
};
this._impl.vret_get_retailers(on_protocol_success, on_failure);
};
/**
* @param {spv.ds.Config} config
* @param {string} localization_id
* @param {function(spv.vds.VolvoCarSpec)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.getSpecification = function(
config,
localization_id,
on_success,
on_failure)
{
/** @param {spv.vds.impl.RawCarSpecification} spec */
var proto_success = function(spec)
{
var volvo_car_spec = spv.vds.impl.IPPCommon.convertToVolvoCarSpec(spec);
on_success(volvo_car_spec);
};
this._impl.vspec_get_specification(
config.data,
config.encoding,
localization_id,
proto_success,
on_failure);
};
/**
* Disables company car pricing.
*
* @param {string} session_id
* @param {function()} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionDisableCCPrices = function(
session_id,
on_success,
on_failure )
{
this._impl.vcomp_disable_company_car_prices(
session_id,
on_success,
on_failure );
};
/**
* Enables company car pricing.
*
* @param {string} session_id
* @param {function()} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionEnableCCPrices = function(
session_id,
on_success,
on_failure )
{
this._impl.vcomp_enable_company_car_prices(
session_id,
on_success,
on_failure );
};
/**
* Updates the parameters for Company Cars pricing.
* @param {string} session_id
* @param {Object.<string,Object>} input_params
* @param {spv.vds.SendBopUpdateFlag} send_update
* @param {function(spv.ds.SessionStateUpdate, spv.ds.impl.AuxData)} on_state_update
* @param {function(Object.<string,spv.vds.CCInputParam>)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionUpdateCCInputParams = function(
session_id,
input_params,
send_update,
on_state_update,
on_success,
on_failure )
{
var that = this;
/** @param {Object} reply */
var on_success_wrapper = function (reply)
{
/** @type {Array.<Object>} */
var raw_params = reply['cc_input_param_list'];
var cc_params = spv.vds.impl.IPPCommon.convertObjectsToCCParams(raw_params);
that.updateStateFromBop(reply.bop, on_state_update);
on_success(cc_params);
};
var raw_params = input_params; // convertCCParamsToObjects( input_params );
//console.log( raw_params );
this._impl.vcomp_update_input_params_2(
session_id,
raw_params,
send_update,
on_success_wrapper,
on_failure );
};
/**
* @param {string} session_id
* @param {number} down_payment
* @param {number} interest_rate
* @param {number} number_of_months
* @param {spv.vds.SendBopUpdateFlag} send_update
* @param {function(spv.ds.SessionStateUpdate, spv.ds.impl.AuxData)} on_state_update
* @param {function(spv.ds.Loan)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionSetLoan = function(
session_id,
down_payment,
interest_rate,
number_of_months,
send_update,
on_state_update,
on_success,
on_failure)
{
var that = this;
/** @param {Object} loan_obj */
var on_protocol_success = function(loan_obj)
{
var loan = spv.ds.impl.IPPCommon.convertToLoan(loan_obj);
that.updateStateFromBop(loan_obj.bop, on_state_update);
on_success(loan);
};
this._impl.loan_set_loan_paramters(
session_id,
down_payment,
interest_rate,
number_of_months,
send_update,
on_protocol_success,
on_failure);
};
/**
* @param {string} session_id
* @param {number} driving_distance
* @param {number} duration
* @param {spv.vds.SendBopUpdateFlag} send_update
* @param {function(spv.ds.SessionStateUpdate, spv.ds.impl.AuxData)} on_state_update
* @param {function(Object)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionUpdateLeasingParams = function(
session_id,
driving_distance,
duration,
send_update,
on_state_update,
on_success,
on_failure)
{
var that = this;
/** @param {Object} result */
var on_protocol_success = function(result)
{
that.updateStateFromBop(result.bop, on_state_update);
// no convertation of the returned object is used in this case
on_success(result);
};
this._impl.update_leasing_params(
session_id,
driving_distance,
send_update,
duration,
on_protocol_success,
on_failure);
};
/**
* @param {string} session_id
* @param {function(Object)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionGetLeasingParams = function(
session_id,
on_success,
on_failure)
{
/** @param {Object} result */
var on_protocol_success = function(result)
{
on_success(result);
};
this._impl.get_leasing_params(
session_id,
on_protocol_success,
on_failure);
};
/**
* @param {function(spv.vds.LeasingParams)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.getAvailableLeasingParams = function(
on_success,
on_failure)
{
/** @param {Object} leasing_params_obj */
var on_protocol_success = function(leasing_params_obj)
{
var leasing_params = spv.vds.impl.IPPCommon.convertToLeasingParams(leasing_params_obj);
on_success(leasing_params);
};
this._impl.get_available_leasing_parameters(
on_protocol_success,
on_failure);
};
/**
* @param {string} session_id
* @param {function(spv.ds.Loan)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionGetLoan = function(
session_id,
on_success,
on_failure)
{
/** @param {Object} loan_obj */
var on_protocol_success = function(loan_obj)
{
var loan = spv.ds.impl.IPPCommon.convertToLoan(loan_obj);
on_success(loan);
};
this._impl.loan_get_current_loan(
session_id,
on_protocol_success,
on_failure);
};
/**
* @param {string} session_id
* @param {spv.vds.SendBopUpdateFlag} send_update
* @param {function(spv.ds.SessionStateUpdate, spv.ds.impl.AuxData)} on_state_update
* @param {function(spv.ds.Loan)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionResetLoan = function(
session_id,
send_update,
on_state_update,
on_success,
on_failure)
{
var that = this;
/** @param {Object} loan_obj */
var on_protocol_success = function(loan_obj)
{
var loan = spv.ds.impl.IPPCommon.convertToLoan(loan_obj);
that.updateStateFromBop(loan_obj.bop, on_state_update);
on_success(loan);
};
this._impl.loan_reset(
session_id,
send_update,
on_protocol_success,
on_failure);
};
/**
* @param {string} session_id
* @param {string} customer_first_name
* @param {string} customer_surname
* @param {string} customer_email
* @param {string} customer_phone
* @param {string} preferred_contact_time
* @param {string} preferred_contact_media
* @param {boolean} want_newsletter
* @param {boolean} want_summary_pdf
* @param {string} retailer_id
* @param {string} mail_link_url
* @param {function()} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionSendMailToCustomerAndRetailer = function(
session_id,
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 )
{
/** @type {function(spv.vds.impl.RawMailRequestResult)} */
var on_backend_response = function( mail_request_result )
{
var code = spv.ds.ipprot_nova.output.RESULT_CODE;
var mail_code = spv.vds.ipprot_nova.output.MAIL_REQUEST_CODE;
if( mail_request_result.result_code != code.SUCCESS )
{
on_failure( new Error( mail_request_result.result_code ) );
return;
}
if( mail_request_result.retailer_mail_status_code == mail_code.FAILURE )
{
on_failure( new Error( "RETAILER " +
mail_request_result.retailer_mail_status_code ) );
return
}
if( mail_request_result.customer_mail_status_code == mail_code.FAILURE )
{
on_failure( new Error( "CUSTOMER " +
mail_request_result.customer_mail_status_code ) );
return;
}
on_success()
}
this._impl.vret_send_customer_and_retailer_mail(
session_id,
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_backend_response,
on_failure );
};
/**
* @param {string} session_id
* @param {string} customer_first_name
* @param {string} customer_surname
* @param {string} customer_email
* @param {string} customer_phone
* @param {string} retailer_id
* @param {function()} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionSendToTacdis = function(
session_id,
customer_first_name,
customer_surname,
customer_email,
customer_phone,
retailer_id,
on_success,
on_failure)
{
var on_backend_response = function( tacdis_result )
{
if( !tacdis_result.success )
{
on_failure( new Error( "send_to_tacdis failed." ) );
return;
}
on_success()
}
this._impl.send_to_tacdis(
session_id,
customer_first_name,
customer_surname,
customer_email,
customer_phone,
retailer_id,
on_backend_response,
on_failure);
};
/**
* @param {string} session_id
* @param {string} customer_first_name
* @param {string} customer_surname
* @param {string} customer_email
* @param {string} customer_phone
* @param {string} preferred_contact_time
* @param {string} preferred_contact_media
* @param {boolean} want_quote
* @param {boolean} want_newsletter
* @param {string} mail_link_url
* @param {string} retailer_id
* @param {function()} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionSendCustomerMailAndTacdis = function(
session_id,
customer_first_name,
customer_surname,
customer_email,
customer_phone,
preferred_contact_time,
preferred_contact_media,
want_quote,
want_newsletter,
mail_link_url,
retailer_id,
on_success,
on_failure)
{
/** @type {function(spv.vds.impl.RawMailRequestResult)} */
var on_backend_response = function( mail_request_result )
{
var code = spv.ds.ipprot_nova.output.RESULT_CODE;
var mail_code = spv.vds.ipprot_nova.output.MAIL_REQUEST_CODE;
if( mail_request_result.result_code != code.SUCCESS )
{
on_failure( new Error( mail_request_result.result_code ) );
return;
}
if( mail_request_result.customer_mail_status_code == mail_code.FAILURE )
{
on_failure( new Error( "CUSTOMER " +
mail_request_result.customer_mail_status_code ) );
return;
}
on_success()
}
this._impl.send_customer_mail_and_tacdis(
session_id,
customer_first_name,
customer_surname,
customer_email,
customer_phone,
preferred_contact_time,
preferred_contact_media,
want_quote,
want_newsletter,
mail_link_url,
retailer_id,
on_backend_response,
on_failure);
};
/**
* @param {string} session_id
* @param {string} customer_email
* @param {boolean} want_newsletter
* @param {boolean} want_summary_pdf
* @param {string} mail_link_url
* @param {function()} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionSendMailToCustomer = function(
session_id,
customer_email,
want_newsletter,
want_summary_pdf,
mail_link_url,
on_success,
on_failure )
{
/** @type {function(spv.vds.impl.RawMailRequestResult)} */
var on_backend_response = function( mail_request_result )
{
var code = spv.ds.ipprot_nova.output.RESULT_CODE;
var mail_code = spv.vds.ipprot_nova.output.MAIL_REQUEST_CODE;
if( mail_request_result.result_code != code.SUCCESS )
{
on_failure( new Error( mail_request_result.result_code ) );
return;
}
if( mail_request_result.retailer_mail_status_code == mail_code.FAILURE )
{
on_failure( new Error( "RETAILER " +
mail_request_result.retailer_mail_status_code ) );
return
}
if( mail_request_result.customer_mail_status_code == mail_code.FAILURE )
{
on_failure( new Error( "CUSTOMER " +
mail_request_result.customer_mail_status_code ) );
return;
}
on_success()
}
this._impl.vret_send_customer_mail(
session_id,
customer_email,
want_newsletter,
want_summary_pdf,
mail_link_url,
on_backend_response,
on_failure);
};
/**
* @param {string} session_id
* @param {string} customer_first_name
* @param {string} customer_surname
* @param {string} customer_address
* @param {number} customer_zipcode
* @param {string} customer_city
* @param {string} customer_email
* @param {string} customer_phone
* @param {string} skype_name
* @param {string} preferred_contact_media
* @param {string} free_text
* @param {string} retailer_id
* @param {string} mail_link_url
* @param {function()} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionSendVolvoCareMailToRetailer = function(
session_id,
customer_first_name,
customer_surname,
customer_address,
customer_zipcode,
customer_city,
customer_email,
customer_phone,
skype_name,
preferred_contact_media,
free_text,
retailer_id,
mail_link_url,
on_success,
on_failure)
{
/** @type {function(spv.vds.impl.RawMailRequestResult)} */
var on_backend_response = function(mail_request_result)
{
var code = spv.ds.ipprot_nova.output.RESULT_CODE;
var mail_code = spv.vds.ipprot_nova.output.MAIL_REQUEST_CODE;
if (mail_request_result.result_code != code.SUCCESS)
{
on_failure(new Error(mail_request_result.result_code));
return;
}
if (mail_request_result.retailer_mail_status_code == mail_code.FAILURE)
{
on_failure(new Error("RETAILER " + mail_request_result.retailer_mail_status_code));
return;
}
on_success();
}
this._impl.vret_send_volvo_care_retailer_mail(
session_id,
customer_first_name,
customer_surname,
customer_address,
customer_zipcode,
customer_city,
customer_email,
customer_phone,
skype_name,
preferred_contact_media,
free_text,
retailer_id,
mail_link_url,
on_backend_response,
on_failure);
};
/**
* @param {string} session_id
* @param {string} feed_id
* @param {function(spv.vds.CampaignCollection)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionGetCampaigns = function(
session_id,
feed_id,
on_success,
on_failure )
{
this.getCampaigns( feed_id, on_success, on_failure );
}
/**
* @param {string} feed_id
* @param {function(spv.vds.CampaignCollection)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.getCampaigns = function(
feed_id,
on_success,
on_failure )
{
/** @param {spv.vds.impl.RawCampaignCollection} proto_cc */
var on_protocol_success = function(proto_cc)
{
var cc = spv.vds.impl.IPPCommon.convertToCampaignCollection(proto_cc);
on_success(cc);
};
this._impl.vcamp_get_campaigns(
feed_id,
on_protocol_success,
on_failure);
}
/**
* @param {string} session_id
* @param {string} business_group_retailer_id
* @param {function()} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionSetRetailerBusinessGroup = function (
session_id,
business_group_retailer_id,
on_success,
on_failure) {
/** @param {boolean} result_flag */
var handle_protocol = function (result_flag) {
if (true == result_flag) {
on_success();
}
else {
throw new Error('sessionSetRetailerBusinessGroup failed for retailer id: ' +
business_group_retailer_id);
}
};
this._impl.set_retailer_business_group(
session_id,
business_group_retailer_id,
handle_protocol,
on_failure);
};
/**
* @param {string} session_id
* @param {string} template_name
* @param {string} retailer_id
* @param {function(string)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionGenerateRetailerHtmlForPdf = function(
session_id,
template_name,
retailer_id,
on_success,
on_failure)
{
/** @param {spv.ds.ipprot_nova.output.PdfGenerationResult} pdf_result */
var handle_protocol = function(pdf_result)
{
var pdf_url = spv.ds.impl.IPPCommon.extractPdfUrl( pdf_result );
on_success(pdf_url);
};
this._impl.generate_retailer_html_for_pdf(
session_id,
template_name,
retailer_id,
handle_protocol,
on_failure );
};
/**
* @param {string} session_id
* @param {string} retid_delivery
* @param {string} retid_sales
* @param {string} customer_first_name
* @param {string} customer_last_name
* @param {string} customer_street_address
* @param {string} customer_city
* @param {string} customer_postal_code
* @param {string} customer_phone
* @param {string} customer_email
* @param {boolean} redirect
* @param {boolean} attachment
* @param {function(spv.vds.CareCustomerOrderResult)} on_success
* @param {function(Error)} on_failure
*/
spv.vds.impl.IPPNovaAdaptor.prototype.sessionCareSendCustomerOrder = function(
session_id,
retid_delivery,
retid_sales,
customer_first_name,
customer_last_name,
customer_street_address,
customer_city,
customer_postal_code,
customer_phone,
customer_email,
redirect,
attachment,
on_success,
on_failure
){
/**
* @param {spv.vds.ipprot_nova.output.CareCustomerOrderResult} raw
*/
function wrap_success(raw) {
return on_success(
new spv.vds.CareCustomerOrderResult(raw.pdf_url)
);
}
this._impl.volvo_care_send_customer_order(
session_id,
retid_delivery,
retid_sales,
customer_first_name,
customer_last_name,
customer_street_address,
customer_city,
customer_postal_code,
customer_phone,
customer_email,
redirect,
attachment,
wrap_success,
on_failure
);
};