// angular
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
// libs
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { Observable } from 'rxjs/Observable';
import { Store } from '@ngrx/store';
// app
import { APIDispatcher } from '../utils/index';

@Injectable()
export class MediaService extends APIDispatcher {

    constructor(public http: Http, public store: Store<any>) {
        super(http, store);
    }

    signUrl(fileLocation: string): Observable<any> {
        return this.http.get('ma_core/api/v2/mediaservice/sign_url?url=' + fileLocation)
            .catch(this.handleError)
            .map(res => (<Response>res).json());
    }

    signForm(): Observable<any> {
        return this.http.get('ma_core/api/v2/mediaservice/sign_form')
            .catch(this.handleError)
            .map(res => (<Response>res).json());
    }

}

