Skip to content

Commit

Permalink
Bugfixes + updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Jan 18, 2019
1 parent 7ca9810 commit 666654a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ JavaScript client for the openEO API.

[![Build Status](https://travis-ci.org/Open-EO/openeo-js-client.svg?branch=master)](https://travis-ci.org/Open-EO/openeo-js-client)

This client is in **version 0.3.0** and supports **openEO API versions 0.3.0 and 0.3.1**. Legacy versions are available as releases.
This client is in **version 0.3.1** and supports **openEO API versions 0.3.0 and 0.3.1**. Legacy versions are available as releases.

## Usage
This library can run in a recent browser supporting ECMAScript 2015 or node.js.
Expand Down
26 changes: 12 additions & 14 deletions openeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class Connection {
constructor(baseUrl) {
this.baseUrl = baseUrl;
this.userId = null;
this.bearerToken = null;
this.subscriptionsObject = new Subscriptions(this);
this.accessToken = null;
this.capabilitiesObject = null;
this.subscriptionsObject = new Subscriptions(this);
}

getBaseUrl() {
Expand Down Expand Up @@ -122,7 +122,7 @@ class Connection {
throw new Error("No access_token returned.");
}
this.userId = response.data.user_id;
this.bearerToken = response.data.access_token;
this.accessToken = response.data.access_token;
return response.data;
}).catch(error => {
this._resetAuth();
Expand Down Expand Up @@ -312,7 +312,7 @@ class Connection {
if (!options.headers) {
options.headers = {};
}
options.headers['Authorization'] = 'Bearer ' + this.bearerToken;
options.headers['Authorization'] = 'Bearer ' + this.accessToken;
}
if (options.responseType == 'stream' && !isNode) {
options.responseType = 'blob';
Expand All @@ -333,11 +333,11 @@ class Connection {

_resetAuth() {
this.userId = null;
this.bearerToken = null;
this.accessToken = null;
}

isLoggedIn() {
return (this.bearerToken !== null);
return (this.accessToken !== null);
}

subscribe(topic, parameters, callback) {
Expand Down Expand Up @@ -444,7 +444,7 @@ class Subscriptions {
_createWebSocket() {
if (this.socket === null || this.socket.readyState === this.socket.CLOSING || this.socket.readyState === this.socket.CLOSED) {
this.messageQueue = [];
var url = this.httpConnection._baseUrl.replace('http', 'ws') + '/subscription';
var url = this.httpConnection.getBaseUrl().replace('http', 'ws') + '/subscription';

if (isNode) {
const WebSocket = require('ws');
Expand Down Expand Up @@ -508,7 +508,7 @@ class Subscriptions {

_sendMessage(topic, payload = null, priority = false) {
var obj = {
authorization: "Bearer " + this.httpConnection._token,
authorization: "Bearer " + this.httpConnection.accessToken,
message: {
topic: "openeo." + topic,
issued: (new Date()).toISOString()
Expand Down Expand Up @@ -686,6 +686,7 @@ class File extends BaseEntity {
constructor(connection, userId, name) {
super(connection, ["name", "size", "modified"]);
this.userId = userId;
this.name = name;
}

// If target is null, returns promise with data as stream in node environment, blob in browser.
Expand Down Expand Up @@ -717,9 +718,6 @@ class File extends BaseEntity {
return fs.createReadStream(path);
}

_uploadFile(source, statusCallback) {
}

// source for node must be a path to a file as string
// source for browsers must be an object from a file upload form
uploadFile(source, statusCallback = null) {
Expand Down Expand Up @@ -758,7 +756,7 @@ class File extends BaseEntity {

class Job extends BaseEntity {
constructor(connection, jobId) {
super(connection, [["job_id", "jobId"], "title", "description", "status", "submitted", "updated", "plan", "costs", "budget"]);
super(connection, [["job_id", "jobId"], "title", "description", ["process_graph", "processGraph"], "output", "status", "submitted", "updated", "plan", "costs", "budget"]);
this.jobId = jobId;
}

Expand Down Expand Up @@ -861,7 +859,7 @@ class Job extends BaseEntity {

class ProcessGraph extends BaseEntity {
constructor(connection, processGraphId) {
super(connection, [["process_graph_id", "processGraphId"], "title", "description", "process_graph"]);
super(connection, [["process_graph_id", "processGraphId"], "title", "description", ["process_graph", "processGraph"]]);
this.connection = connection;
this.processGraphId = processGraphId;
}
Expand Down Expand Up @@ -892,7 +890,7 @@ class ProcessGraph extends BaseEntity {

class Service extends BaseEntity {
constructor(connection, serviceId) {
super(connection, [["service_id", "serviceId"], "title", "description", "url", "type", "enabled", "submitted", "plan", "costs", "budget"]);
super(connection, [["service_id", "serviceId"], "title", "description", ["process_graph", "processGraph"], "url", "type", "enabled", "parameters", "attributes", "submitted", "plan", "costs", "budget"]);
this.serviceId = serviceId;
}

Expand Down

0 comments on commit 666654a

Please sign in to comment.