import axios from 'axios';
import {IAppCommands} from '../interfaces/commands/IAppCommands';
import {TSettings} from '../types/TSettings';

declare let settings:TSettings;

export class AppCommands implements IAppCommands {

    public login(email:string, password:string):Promise<any>
    {
        let token = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
        return axios.post(
            settings.requestUrl,
            {
                _token:token,
                email:email,
                password:password,
            }
        )
        .then((resp:any)=>{
            return Promise.resolve(resp.data);
        })
        .catch((error:any)=>{
            return Promise.reject(error.response.data);
        });
    }

}