import fetch from 'isomorphic-fetch';

const API_PREFIX = "/api/v0";

export default class OutriggerHttp {
    constructor(outriggerUrl) {
        if (!outriggerUrl.startsWith('http')) {
            throw new Error('Url scheme must be \'http\' or \'https\'');
        }

        this.outriggerUrl = outriggerUrl;
    }

    getInputs(bundle, inputs) {
        return fetch(`${this.outriggerUrl}${API_PREFIX}/prepare`, {
            method: "post",
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                bundle,
                inputs
            })
        })
        .then(res => res.json());
    }

    runJob(bundle, inputs) {
        return fetch(`${this.outriggerUrl}${API_PREFIX}/jobs`, {
            method: 'post',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                bundle,
                inputs
            })
        })
        .then(res => res.json());
    };

    getJob(jobId) {
        return fetch(`${this.outriggerUrl}${API_PREFIX}/jobs/${jobId}`)
        .then(res => res.json());
    };

    getBundle(path) {
        return fetch(`${this.outriggerUrl}${API_PREFIX}/paths${path}`)
        .then(res => res.json());
    };
}

@@ -281,23 +281,17 @@
 his.
-outriggerU
+u
 rl = 
+%60$%7B
 outr
@@ -298,16 +298,32 @@
 iggerUrl
+%7D$%7BAPI_PREFIX%7D/%60
 ;%0A    %7D%0A
@@ -388,35 +388,12 @@
 his.
-outriggerUrl%7D$%7BAPI_PREFIX%7D/
+url%7D
 prep
@@ -728,35 +728,12 @@
 his.
-outriggerUrl%7D$%7BAPI_PREFIX%7D/
+url%7D
 jobs
@@ -1103,35 +1103,12 @@
 his.
-outriggerUrl%7D$%7BAPI_PREFIX%7D/
+url%7D
 jobs
@@ -1216,35 +1216,12 @@
 his.
-outriggerUrl%7D$%7BAPI_PREFIX%7D/
+url%7D
 path

Simplify api string concatenation