getExtractRecordByDate static method

Future<String> getExtractRecordByDate(
  1. String userId,
  2. String deviceId,
  3. String? startDate,
  4. String? endDate,
  5. String? extractType,
)

按时间获取总统计数据 userId app用户id deviceId 绑定的设备id startDate 开始时间,yyyy-MM-dd,为空则是不限制起始时间 endDate 结束时间,yyyy-MM-dd,为空则是不限制结束时间 extractType 萃取模式

Implementation

static Future<String> getExtractRecordByDate(String userId,String deviceId,String? startDate,String? endDate, String? extractType) async {
  Map<String,String> headers = {
    'tenantId': '10002',
    'token': SpUtil().getString(SpUtil.SP_KEY_ACCESS_TOKEN) ?? '',
    'appSource': 'Maxims',
    'reqSource': '1',
  };
  int timestamp = DateTime.now().millisecondsSinceEpoch;
  String randomStr = CipherUtil.generateRandomString(6);
  Map<String,dynamic> params = {
    'userId': userId,
    'deviceId': deviceId,
    'startDate': startDate,
    'endDate': endDate,
    'extractType': extractType
  };
  if(startDate == null) {
    params.remove('startDate');
  }
  if(endDate == null) {
    params.remove('endDate');
  }
  Map<String,dynamic> data = {
    'timestamp': timestamp,
    'appKey': BaseHttpConstant.APP_BUSINESS_KEY,
    'nonceStr': randomStr,
    'signVersion': '1',
    'data': params,
  };
  String sign = CipherUtil.generateSignature2(data, ['data'], BaseHttpConstant.APP_BUSINESS_SECRET);
  data['sign'] = sign;
  Options options = Options(
    headers: headers,
    contentType: Headers.jsonContentType,
  );
  var result = await HttpUtils.post(true, Api.PATH_GET_EXTRACT_RECORD_BY_DATE,
      data: data,
      options: options);
  return formatResponse(result);
}