Skip to content

Instantly share code, notes, and snippets.

@wmathes
Created October 20, 2016 09:19
Show Gist options
  • Save wmathes/215c5cb17793867c24a24d538876a897 to your computer and use it in GitHub Desktop.
Save wmathes/215c5cb17793867c24a24d538876a897 to your computer and use it in GitHub Desktop.
// Imports from the http-client package
import {ServiceClient} from "@crazy-factory/service-client";
import {ServiceRequestOptions} from "@crazy-factory/service-client";
import {ServiceResponse} from "@crazy-factory/service-client";
// shop-api-client
import {IProductData} from "@crazy-factory/shop-service-data";
// Nodes
class ProductsNode extends ServiceNode {
get(id: number, options?: ServiceRequestOptions): Promise<ServiceResponse<IProductData>> {
let url = `products/${id}`;
return this.client.get(url, options);
}
}
// Service
export class ShopService extends Service {
get products() {
return new ProductsNode(this.client);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment