<?php

namespace App\Http\Controllers\Wechat\OfficialAccount;

use App\Http\Controllers\Channel\BaseController as ChannelBaseController;
use App\Http\Controllers\Wechat\OfficialAccount\Transformers\WechatPublicTemplatesTransformer;
use Illuminate\Http\Request;
use GuzzleHttp\Client;
use App\Libs\OSS;
use App\Modules\OfficialAccount\Services\WechatTemplateService;

class WechatPublicTemplatesController extends ChannelBaseController
{

    /**
     * @apiDefine OfficialAccount 公众号
     */

    /**
     * @apiVersion 1.0.0
     * @api {GET} OfficialAccount/wechatPublicTemplateList 获取模板消息基础列表
     * @apiGroup OfficialAccount
     * @apiName wechatPublicTemplateList
     * @apiSuccess {String}  title 标题.
     * @apiSuccess {String}  common_template_id 公共模版的ID.
     * @apiSuccess {String}  primary_industry 主类别.
     * @apiSuccess {String}  deputy_industry 副类别.
     * @apiSuccess {String}  content 模板消息内容.
     * @apiSuccess {String}  example 模板发送示例.
     * @apiSuccessExample {json} Success-Response:
     *
     *      {
     *          "code": 0,
     *          "msg": "",
     *          "data": [
     *              {
     *                  "common_template_id": "TM00202",
     *                  "title": "帐户资金变动提醒",
     *                  "primary_industry": "IT科技",
     *                  "deputy_industry": "IT软件与服务",
     *                  "content": "{{first.DATA}}\n\n变动时间：{{date.DATA}}\n变动金额：{{adCharge.DATA}}\n{{type.DATA}}帐户余额：{{cashBalance.DATA}}\n{{remark.DATA}}",
     *                  "example": "您好，您于2013\/10\/29  15:24 有一笔现金帐户充值到账：\n\n变动时间：2013\/11\/26 14：00\n变动金额：￥5618.63\n现金帐户余额：￥8454.74\n点击“查看详情“立即查阅您的帐户财务记录。"
     *              },
     *              {
     *                  "common_template_id": "TM00155",
     *                  "title": "会员充值通知",
     *                  "primary_industry": "文体娱乐",
     *                  "deputy_industry": "文化|传媒",
     *                  "content": "{{first.DATA}}\n\n{{accountType.DATA}}：{{account.DATA}}\n充值金额：{{amount.DATA}}\n充值状态：{{result.DATA}}\n{{remark.DATA}}",
     *                  "example": "您好，您已成功进行会员卡充值。\n\n会员卡号：11912345678\n充值金额：50元\n充值状态：充值成功\n如有疑问，请致电13912345678联系我们。"
     *              },
     *              {
     *                  "common_template_id": "OPENTM217772013",
     *                  "title": "任务到期通知",
     *                  "primary_industry": "IT科技",
     *                  "deputy_industry": "IT软件与服务",
     *                  "content": "{{first.DATA}}\n到期任务：{{keyword1.DATA}}\n到期时间：{{keyword2.DATA}}\n{{remark.DATA}}",
     *                  "example": "早上好，你有任务已延误\n到期任务：触屏版点击添加附件无效（9-9）\n到期时间：9月12日\n点击处理"
     *              },
     *              {
     *                  "common_template_id": "TM405959659",
     *                  "title": "会员卡升级通知",
     *                  "primary_industry": "IT科技",
     *                  "deputy_industry": " IT软件与服务",
     *                  "content": "{{first.DATA}}\n\n会员卡号：{{keynote1.DATA}}\n有效期：{{keynote2.DATA}}\n{{remark.DATA}}",
     *                  "example": "恭喜你，你的会员卡可以升级为微信会员卡，使用会员卡更加方便，查询 积分更加快捷\n\n会员卡号：光明顶工作坊 \n有效期：222 \n点击详情，立刻升级会员卡。"
     *              },
     *              {
     *                  "common_template_id": "OPENTM410178244",
     *                  "title": "图书送达通知",
     *                  "primary_industry": "IT科技",
     *                  "deputy_industry": "互联网|电子商务",
     *                  "content": "{{first.DATA}}\r书名：{{keyword1.DATA}}\r送达时间：{{keyword2.DATA}}\r还书日期：{{keyword3.DATA}}\r{{remark.DATA}}",
     *                  "example": "您的图书已经送达\r书名：三体\r送达时间：2016-09-07\r还书日期：2017-09-08\r祝您阅读愉快！"
     *              }
     *          ]
     *      }   
     */

    function wechatPublicTemplateList(Request $request)
    {

        $wechatPublicTemplatesService = WechatTemplateService::wechatPublicTemplateList();

        return response()->collection(new WechatPublicTemplatesTransformer(), $wechatPublicTemplatesService);
    }

    
}