'use strict';

const apiService = require('app-service');

class CsIdentifyService {
    constructor(){
        this.options = {
            paramOption:{}
        }
    }
    getReturnParamOption(){
        return this.options.paramOption;
    }

    /***
     * 获取用户登录信息
     * param {String} openid
     * */
    getUserInfo (token) {
        return apiService.user_info(token)
    }

    /***
     * 获取用户身份验证请求头
     * param {String} username
     * param {String} password
     * */
    getAuthorization (username ,password) {
        let buf = Buffer.from(username + ":" + password, 'ascii');
        let authorization = buf.toString('base64');

        return authorization;
    }

}

function Q(caller) {
    let promise = new Promise(function (resolve, reject) {
        caller(resolve, reject);
    });
    return promise;
}

module.exports = new CsIdentifyService();