prepare method

  1. @override
Future<void> prepare()
override

Do some preparation work before using the platform.

Like modify dio, to set baseUrl, get access token & set to headers, etc.

Implementation

@override
Future<void> prepare() {
  dio.options.baseUrl = 'https://open.feishu.cn/open-apis';

  return dio.post(
    '/auth/v3/app_access_token/internal',
    data: {
      'app_id': appId,
      'app_secret': appSecret,
    },
  ).then(
    (response) {
      dio.options.headers['Authorization'] =
          'Bearer ${response.data['app_access_token'] as String}';
    },
  );
}