Skip to content

Commit

Permalink
fix: create resources with environments
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-scherzinger committed Feb 9, 2017
1 parent 51d3b01 commit e75614b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/DataManager.js
Expand Up @@ -51,7 +51,7 @@ export default class DataManager extends Core {
.withTemplateParameters(optionsToQuery(options));
return get(this.environment, request);
})
.then(([res, traversal]) => new DataManagerList(res, traversal));
.then(([res, traversal]) => new DataManagerList(res, this.environment, traversal));
}

/**
Expand All @@ -71,6 +71,6 @@ export default class DataManager extends Core {
.withTemplateParameters({ dataManagerID });
return get(this.environment, request);
})
.then(([res, traversal]) => new DataManagerResource(res, traversal));
.then(([res, traversal]) => new DataManagerResource(res, this.environment, traversal));
}
}
4 changes: 2 additions & 2 deletions src/resources/ListResource.js
Expand Up @@ -52,7 +52,7 @@ export default class ListResource extends Resource {
*/
getAllItems() {
const array = this.resource.embeddedArray(this.name) || [];
return array.map(resource => new this.ItemClass(resource));
return array.map(resource => new this.ItemClass(resource, this.environment));
}

/**
Expand All @@ -70,7 +70,7 @@ export default class ListResource extends Resource {
if (!array || array.length === 0) {
throw new Error('Cannot get n\'th item of empty list.');
}
return new this.ItemClass(array[n]);
return new this.ItemClass(array[n], this.environment);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/resources/ModelList.js
Expand Up @@ -15,7 +15,7 @@ export default class ModelList extends ListResource {
* @param {?object} traversal traversal from which traverson can continue.
*/
constructor(resource, environment, traversal) {
super(resource, environment, 'ec:account', traversal);
super(resource, environment, 'ec:model', traversal);
this.ListClass = ModelList;
this.ItemClass = ModelResource;
}
Expand Down
4 changes: 2 additions & 2 deletions src/resources/Resource.js
Expand Up @@ -161,9 +161,9 @@ export default class Resource {
return get(this.environment, this.newRequest().follow(link))
.then(([res, traversal]) => {
if (ResourceClass) {
return new ResourceClass(res, null, traversal);
return new ResourceClass(res, this.environment, traversal);
}
return new Resource(res, traversal);
return new Resource(res, this.environment, traversal);
});
}

Expand Down
2 changes: 1 addition & 1 deletion typings/resources/DataManagerResource.d.ts
Expand Up @@ -6,7 +6,7 @@ import { ModelResource } from './ModelResource';
export declare class DataManagerResource extends Resource {
constructor(resource: any, environment: string, traversal?: any);

modelList(options: filterOptions): ModelList
modelList(options?: filterOptions): ModelList

model(modelID: string): ModelResource;

Expand Down

0 comments on commit e75614b

Please sign in to comment.