
var RPCClient = require('@alicloud/pop-core').RPCClient;

class AliApiClient {
    constructor() {
        this.client = new RPCClient({
            accessKeyId: 'LTAI4FvNyYTUtvfUsuoMzy7D',
            accessKeySecret: '1B4YqlWxNUtMpifbtmExQwY7m3Caj4',
            endpoint: 'https://trademark.aliyuncs.com',
            apiVersion: '2018-07-24'
        });
    }

    async reqbyget(obj,cbk) {
        var self = this;
        var action = obj.action;
        var reqbody = obj.reqbody;
        return self.client.request(action, reqbody, {
            timeout: 3000, // default 3000 ms
            formatAction: true, // default true, format the action to Action
            formatParams: true, // default true, format the parameter name to first letter upper case
            method: 'GET', // set the http method, default is GET
            headers: {}, // set the http request headers
        });
    }
    async reqbypost(obj,cbk) {
        var self = this;
        var action = obj.action;
        var reqbody = obj.reqbody;
     
        return self.client.request(action, reqbody, {
            timeout: 3000, // default 3000 ms
            formatAction: true, // default true, format the action to Action
            formatParams: true, // default true, format the parameter name to first letter upper case
            method: 'POST', // set the http method, default is GET
            headers: {}, // set the http request headers
        });
    }

}

module.exports = AliApiClient;