var util = require('./util');
var wrapper = util.wrapper;
var postJSON = util.postJSON;

/**
 * 设置所属行业
 * Examples:
 * ```
 * var industryIds = {
 *  "industry_id1":'1',
 *  "industry_id2":"4"
 * };
 * api.setIndustry(industryIds, callback);
 * ```
 * Callback:
 *
 * - `err`, 调用失败时得到的异常
 * - `result`, 调用正常时得到的对象
 *
 * @param {Object} industryIds 公众号模板消息所属行业编号
 */
exports.setIndustry = function(industryIds, callback){
  this.preRequest(this._setIndustry, arguments);
}

exports._setIndustry = function (industryIds, callback) {
  var apiUrl = this.prefix + 'template/api_set_industry?access_token=' + this.token.accessToken;
  this.request(apiUrl, postJSON(industryIds), wrapper(callback));
};

/**
 * 获得模板ID
 * Examples:
 * ```
 * var templateIdShort = 'TM00015';
 * api.addTemplate(templateIdShort, callback);
 * ```
 * Callback:
 *
 * - `err`, 调用失败时得到的异常
 * - `result`, 调用正常时得到的对象
 *
 * @param {String} templateIdShort 模板库中模板的编号，有“TM**”和“OPENTMTM**”等形式
 */
exports.addTemplate = function(templateIdShort, callback){
  this.preRequest(this._addTemplate, arguments);
}

exports._addTemplate = function (templateIdShort, callback) {
  var apiUrl = this.prefix + 'template/api_add_template?access_token=' + this.token.accessToken;
  var templateId = {
    template_id_short: templateIdShort
  };
  this.request(apiUrl, postJSON(templateId), wrapper(callback));
};

/**
 * 发送模板消息
 * Examples:
 * ```
 * var templateId: '模板id';
 * // URL置空，则在发送后,点击模板消息会进入一个空白页面（ios）, 或无法点击（android）
 * var url: 'http://weixin.qq.com/download';
 * var topcolor = '#FF0000'; // 顶部颜色
 * var data = {
 *  user:{
 *    "value":'黄先生',
 *    "color":"#173177"
 *  }
 * };
 * api.sendTemplate('openid', templateId, url, topColor, data, callback);
 * ```
 * Callback:
 *
 * - `err`, 调用失败时得到的异常
 * - `result`, 调用正常时得到的对象
 *
 * @param {String} openid 用户的openid
 * @param {String} templateId 模板ID
 * @param {String} url URL置空，则在发送后，点击模板消息会进入一个空白页面（ios），或无法点击（android）
 * @param {String} topColor 顶部颜色
 * @param {Object} data 渲染模板的数据
 * @param {Function} callback 回调函数
 */
exports.sendTemplate = function (openid, templateId, url, topColor, data, callback) {
  this.preRequest(this._sendTemplate, arguments);
};

exports._sendTemplate = function (openid, templateId, url, topColor, data, callback) {
  var apiUrl = this.prefix + 'message/template/send?access_token=' + this.token.accessToken;
  var template = {
    touser: openid,
    template_id: templateId,
    url: url,
    topcolor: topColor,
    data: data
  };
  this.request(apiUrl, postJSON(template), wrapper(callback));
};
@@ -1532,67 +1532,360 @@
 var 
-topcolor = '#FF0000'; // %E9%A1%B6%E9%83%A8%E9%A2%9C%E8%89%B2%0A * var data =
+data = %7B%0A *    %22first%22: %7B%0A *      %22value%22:%22%E6%81%AD%E5%96%9C%E4%BD%A0%E8%B4%AD%E4%B9%B0%E6%88%90%E5%8A%9F%EF%BC%81%22,%0A *      %22color%22:%22#173177%22%0A *    %7D,%0A *    %22keyword1%22:%7B%0A *      %22value%22:%22%E5%B7%A7%E5%85%8B%E5%8A%9B%22,%0A *      %22color%22:%22#173177%22%0A *    %7D,%0A *    %22keyword2%22: %7B%0A *      %22value%22:%2239.8%E5%85%83%22,%0A *      %22color%22:%22#173177%22%0A *    %7D,%0A *    %22keyword3%22:
  %7B%0A *  
+ 
-user
+   %22value%22:%222014%E5%B9%B49%E6%9C%8822%E6%97%A5%22,%0A *      %22color%22:%22#173177%22%0A *    %7D,%0A *    %22remark%22
 :%7B%0A *
+  
     
@@ -1896,17 +1896,23 @@
 ue%22:
-'%E9%BB%84%E5%85%88%E7%94%9F'
+%22%E6%AC%A2%E8%BF%8E%E5%86%8D%E6%AC%A1%E8%B4%AD%E4%B9%B0%EF%BC%81%22
 ,%0A *
+  
     
@@ -1931,16 +1931,18 @@
 3177%22%0A *
+  
   %7D%0A * %7D
@@ -1985,34 +1985,24 @@
 lateId, url,
- topColor,
  data, callb
@@ -2228,41 +2228,8 @@
 id%EF%BC%89%0A
- * @param %7BString%7D topColor %E9%A1%B6%E9%83%A8%E9%A2%9C%E8%89%B2%0A
  * @
@@ -2348,34 +2348,24 @@
 lateId, url,
- topColor,
  data, callb
@@ -2483,26 +2483,16 @@
 Id, url,
- topColor,
  data, c
@@ -2681,32 +2681,8 @@
 rl,%0A
-    topcolor: topColor,%0A
     

update addTemplate api related docs vs code