import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';

class CoursesServices {
  static String baseUrl = 'https://houshan.ai';
  static String getCourses = '/wp-json/wc/v3/products?per_page=50';
  static String getPosts = '/wp-json/wp/v2/posts?per_page=8';
  static const String _usernameAuth =
      'ck_4fdd186edb30c06f1c786473ec4d8bd216c9f4d6';
  static const String _passAuth = 'cs_e41e031f44197ecfef23bd685580d4b2650a9478';
  static const _canLog = kDebugMode && !kIsWeb;

  static getAuth() {
    return {
      'Authorization':
          'Basic ${base64Encode(utf8.encode('$_usernameAuth:$_passAuth'))}',
    };
  }

  static final Dio dio = Dio(BaseOptions(
    baseUrl: baseUrl,
    connectTimeout: const Duration(minutes: 1),
    responseType: ResponseType.json,
  ))
    ..interceptors.add(PrettyDioLogger(enabled: _canLog));
}
