//import the Darwin API classes
import API from '../API.js';
const chalk = require("chalk");

exports.command = 'info'
exports.desc = 'Return information about the logged in client.'
exports.builder = {}
exports.handler = function (argv) {
  //1) Logout so we can refresh our credentials.
  API.logout(false, false, false)

  //2) Authenticate & get the profile for this client.
  API.clientCallDarwinAPI("GET", "profile", {}, [], (result, data) => {
    if (!result) {
      return
    }
    console.log(chalk("You are authenticated with the client:"))
    console.log(chalk.bold(data.name))
    console.log(chalk.bold(data.note))
  }, process.env.DARWIN_CLIENT_ID, process.env.DARWIN_CLIENT_SECRET)
}
