2017-12-24 04:02:57 -05:00
|
|
|
import { Injectable } from "@angular/core";
|
2018-03-24 19:16:52 -04:00
|
|
|
import { AuthedApi } from "../authed-api";
|
2017-12-24 04:02:57 -05:00
|
|
|
import { FE_Widget } from "../../models/integration";
|
|
|
|
import { IntegrationsApiService } from "./integrations-api.service";
|
2019-06-29 02:21:56 -04:00
|
|
|
import { HttpClient } from "@angular/common/http";
|
2019-07-06 17:40:32 -04:00
|
|
|
import { FE_MinimalTerms } from "../../models/terms";
|
2017-12-24 04:02:57 -05:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class WidgetApiService extends AuthedApi {
|
2019-06-29 02:21:56 -04:00
|
|
|
constructor(http: HttpClient, private integrationsApi: IntegrationsApiService) {
|
2017-12-24 04:02:57 -05:00
|
|
|
super(http);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getWidget(type: string): Promise<FE_Widget> {
|
|
|
|
return this.integrationsApi.getIntegration("widget", type).then(i => <FE_Widget>i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public isEmbeddable(url: string): Promise<any> { // 200 = success, anything else = error
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.http.get("/api/v1/dimension/widgets/embeddable", {params: {url: url}}).toPromise();
|
2017-12-24 04:02:57 -05:00
|
|
|
}
|
2019-07-06 17:40:32 -04:00
|
|
|
|
|
|
|
public getTerms(shortcode: string, language: string, version: string): Promise<FE_MinimalTerms> {
|
|
|
|
return this.http.get<FE_MinimalTerms>(`/api/v1/dimension/widgets/terms/${shortcode}/${language}/${version}`).toPromise();
|
|
|
|
}
|
2017-12-24 04:02:57 -05:00
|
|
|
}
|