当我创建Data Studio连接器时,它需要函数doGet(),为什么

时间:2018-10-23 14:14:26

标签: google-data-studio

我尝试创建连接器yandex直接在Google Data Studio中发送数据。我创建了4个函数(),但我不明白为什么它需要函数doGet()。第一次使用script.google.com,创建简单的模板连接器需要什么?

function getAuthType() {
  var response = { type: 'NONE' };
  return response;
}


function getConfig(request) {
  var config = {

  return config;
}

var npmSchema = [];

function getSchema(request) {
  return { schema: npmSchema };
}

function getConfig(request) {
   var cc = DataStudioApp.createCommunityConnector();
  var config = cc.getConfig();


  return config.build();
}

function getData(request) {
  // Create schema for requested fields
  var requestedSchema = request.fields.map(function (field) {
    for (var i = 0; i < dataSchema.length; i++) {
      if (dataSchema[i].name == field.name) {
        return dataSchema[i];
      }
    }
  });

    var url = [
    'https://api-metrika.yandex.ru/stat/v1/data?ids=',
    request.configParams.apiKey,
    '&start_date=',
    request.dateRange.startDate,
    '&end_date=',
    request.dateRange.endDate,
    '&campaign_id=',
    request.configParams.campaignId,
    '&domain=',
//    request.configParams.domain,
//    '&output=json'
  ];

  var response = UrlFetchApp.fetch(url.join(''));
  var parsedResponse = JSON.parse(response.getContentText());


  // Prepare the tabular data.
  var requestedData = parsedResponse.map(function(rankings) {
    var values = [];

    return {
    schema: requestedSchema,
    rows: requestedData
  };
}

我剪了一些细节

0 个答案:

没有答案