Manages products within the VFS Product Library.
Edit me

RPC.ProductService

Manages products within the VFS Product Library.

Quick Start

To run the service locally:

npm install
npm start -- --debug

For automatic code reloading in development:

npm install -g nodemon
nodemon -- --debug

To run on AMQP, omit the --debug option from either command.

Note: You will need a running RabbitMQ and ETCD2 environment.

Interface

This section outlines the details you will need to use this service.

Methods

Get Products (v1)

Gets a list of products.

API Request
GET /dev-product/products
Host: api.vfs.velma.com
Authorization: 
x-api-key: 
Cache-Control: no-cache
RPC Execution
var args = { ... }
seneca.act('role:productService.Pub,cmd:getProductList.v1', args, (err, dat) => {
    /* Handle result */
});
HTTP Execution
POST /amqp/exec/productService/getProductList?version=v1 HTTP/1.1
Host: devel.rpc.velma.com
Content-Type: application/json
x-repr-format: RPC
Cache-Control: no-cache
Request

API Requests should be made with these parameters in the Query String. RPC requests accept these parameters in the POST body.

Field Type Default Description
filterBy String (none) String of filter parameters as described in the FilterBy Parameter (v1).
sortBy String id Field name for sorting results
sortDir String asc Sort order as ascending (asc) or descending (desc)
pageSize Integer 20 Page size is the maximum number of results in each set
pageIndex Integer 1 Page number of the requested results (one-based index). Ex. pageIndex=1, pageSize=20 will return records 1-20, pageIndex=2 will return 21-40.
{
	"token": "jwt XXX",
    "filterBy": "title:BEGINSWITH:Buyer",
    "sortBy": "id",
    "sortDir": "asc",
    "pageSize": 20,
    "pageIndex": 1
}
Response

This method responds with an array of Product Entities (v1).

{
  "items": [
    {
      "id": "0000",
      "title": "Your Product Title",
      "description": "Your Product Description",
      "preview": "https://vfs.url/preview.jpg",
      "template": "https://vfs.url/template.html?versionId=XXX",
      "thumb": "https://vfs.url/thumb.jpg?versionId=XXX"
    }
  ],
  "totalCount": 1,
  "pageIndex": 1,
  "itemPerPage": 20
}
Get Product (v1)

Gets product by ID.

API Request
GET /dev-product/products/:id
Host: api.vfs.velma.com
Authorization: 
x-api-key: 
Cache-Control: no-cache
RPC Execution
var args = { ... }
seneca.act('role:productService.Pub,cmd:getProduct.v1', args, (err, dat) => {
    /* Handle result */
});
HTTP Execution
POST /amqp/exec/productService/getProduct?version=v1 HTTP/1.1
Host: devel.rpc.velma.com
Content-Type: application/json
x-repr-format: RPC
Cache-Control: no-cache
Request

API Requests should include the product’s ID on the URL. RPC Requests should include the id value in the POST body.

{
	"token": "jwt XXX",
    "id": "0000"
}
Response

This method responds with a single Product Entity (v1).

{
	"id": "0000",
	"title": "Your Product Title",
	"description": "Your Product Description",
	"template": "https://vfs.url/template.html?versionId=XXX",
	"thumb": "https://vfs.url/thumb.jpg?versionId=XXX",
	"preview": "https://vfs.url/preview.jpg"
}

Create Product (v1)

Creates a new product.

API Request
POST /dev-product/products
Host: api.vfs.velma.com
Authorization: 
x-api-key: 
Cache-Control: no-cache
RPC Execution
var args = { ... }
seneca.act('role:productService.Pub,cmd:createProduct.v1', args, (err, dat) => {
    /* Handle result */
});
HTTP Execution
POST /amqp/exec/productService/createProduct?version=v1 HTTP/1.1
Host: devel.rpc.velma.com
Content-Type: application/json
x-repr-format: RPC
Cache-Control: no-cache
Request
Field Type Description
id String Unique identifier for the entity. The requester is required to find a unique identifier for their own library.
productId String (Deprecated) Legacy identifier. Can still be used for GetProduct requests.
title String Name of the product
description String Description of the product
templateData String Template data to store as the HTML content for this product.
{
	"token": "jwt XXX",
	"id": "0000",
    "title": "Your Product Title",
    "description": "Your Product Description",
    "templateData": "XXX"
}
Response

This method responds with the newly created Product Entity (v1).

{
	"id": "0000",
	"title": "Your Product Title",
	"description": "Your Product Description",
	"template": "https://vfs.url/template.html?versionId=XXX",
	"thumb": "https://vfs.url/thumb.jpg?versionId=XXX",
	"preview": "https://vfs.url/preview.jpg"
}
Copy Product (v1)

Create a new product using another product’s template.

API Request
POST /dev-product/products/:fromProductId/copy
Host: api.vfs.velma.com
Authorization: 
x-api-key: 
Cache-Control: no-cache

{
  "id": "0000",
  "productId": "0000",
  "title": "New Product Title",
  "description": "New Product Description."
}
RPC Execution
var args = { ... }
seneca.act('role:productService.Pub,cmd:copyProduct.v1', args, (err, dat) => {
    /* Handle result */
});
HTTP Execution
POST /amqp/exec/productService/copyProduct?version=v1 HTTP/1.1
Host: devel.rpc.velma.com
Content-Type: application/json
x-repr-format: RPC
Cache-Control: no-cache
Request
Field Type Description
id String Unique identifier for the entity. The requester is required to find a unique identifier for their own library.
productId String (Deprecated) Legacy identifier. Can still be used for GetProduct requests.
title String Name of the product
description String Description of the product
fromId String The product ID of an existing product who’s template will be copied.
{
	"token": "jwt XXX",
	"id": "0000",
    "title": "Your Product Title",
    "description": "Your Product Description",
    "fromId": "0000"
}
Response

This method responds with the newly created Product Entity (v1).

{
	"id": "0000",
	"title": "Your Product Title",
	"description": "Your Product Description",
	"template": "https://vfs.url/template.html?versionId=XXX",
	"thumb": "https://vfs.url/thumb.jpg?versionId=XXX",
	"preview": "https://vfs.url/preview.jpg"
}
Update Product (v1)

Updates an existing product.

API Request
POST /dev-product/products/:id
Host: api.vfs.velma.com
Authorization: 
x-api-key: 
Cache-Control: no-cache
RPC Execution
var args = { ... }
seneca.act('role:productService.Pub,cmd:updateProduct.v1', args, (err, dat) => {
    /* Handle result */
});
HTTP Execution
POST /amqp/exec/productService/updateProduct?version=v1 HTTP/1.1
Host: devel.rpc.velma.com
Content-Type: application/json
x-repr-format: RPC
Cache-Control: no-cache
Request
Field Type Description
id String Unique identifier for the entity.
title String Name of the product
description String Description of the product
templateData String Template data to store as the HTML content for this product.
{
	"token": "jwt XXX",
	"id": "0000",
    "title": "Your Product Title",
    "description": "Your Product Description",
    "templateData": "XXX"
}
Response

This method responds with the updated Product Entity (v1).

{
	"id": "0000",
	"title": "Your Product Title",
	"description": "Your Product Description",
	"template": "https://vfs.url/template.html?versionId=XXX",
	"thumb": "https://vfs.url/thumb.jpg?versionId=XXX",
	"preview": "https://vfs.url/preview.jpg"
}

Publish Template (v1)

Publishes version of the product’s template.

API Request

POST /dev-product/products/:id/publish
Host: api.vfs.velma.com
Authorization: 
x-api-key: 
Cache-Control: no-cache

RPC Execution

var args = { ... }
seneca.act('role:productService.Pub,cmd:publishTemplate.v1', args, (err, dat) => {
    /* Handle result */
});

HTTP Execution

POST /amqp/exec/productService/publishTemplate?version=v1 HTTP/1.1
Host: devel.rpc.velma.com
Content-Type: application/json
x-repr-format: RPC
Cache-Control: no-cache

Request

Field Type Description
id String Unique identifier for the entity. For now, the requester is required to find their own unique identifier.
versionId String AWS-assigned version identifier. If not specified, the “latest” version will be published.
{
	"token": "jwt XXX",
	"id": "0000",
    "versionId": "latest"
}

Response

This method responds with the updated asset URL’s for the newly published template.

{
	"id": "0000",
	"template": "https://vfs.url/template.html?versionId=XXX",
	"thumb": "https://vfs.url/thumb.jpg?versionId=XXX",
	"preview": "https://vfs.url/preview.jpg"
}

Get Token Manifest (v1)

Retrieve the token manifest for a specific product.

API Request

GET /dev-product/products/:id/manifest
Host: api.vfs.velma.com
Authorization: 
x-api-key: 
Cache-Control: no-cache

RPC Execution

var args = { ... }
seneca.act('role:productService.Pub,cmd:getTokenManifest.v1', args, (err, dat) => {
    /* Handle result */
});

HTTP Execution

POST /amqp/exec/productService/getTokenManifest?version=v1 HTTP/1.1
Host: devel.rpc.velma.com
Content-Type: application/json
x-repr-format: RPC
Cache-Control: no-cache

Request

Field Type Description
id String Unique identifier for the entity. For now, the requester is required to find their own unique identifier.
{
	"token": "jwt XXX",
	"id": "0000"
}

Response

Get Product Tags (v1)

Retrieve a list of tags associated with this product.

API Request

GET /dev-product/products/:id/tags
Host: api.vfs.velma.com
Authorization: 
x-api-key: 
Cache-Control: no-cache

RPC Execution

var args = { ... }
seneca.act('role:productService.Pub,cmd:getProductTags.v1', args, (err, dat) => {
    /* Handle result */
});

HTTP Execution

POST /amqp/exec/productService/getProductTags?version=v1 HTTP/1.1
Host: devel.rpc.velma.com
Content-Type: application/json
x-repr-format: RPC
Cache-Control: no-cache

Request

Field Type Description
id String Unique identifier for the entity. For now, the requester is required to find their own unique identifier.
{
	"token": "jwt XXX",
	"id": "0000"
}

Response

Representations

A description of the various entities

Product Entity (v1)

Field Type Description
id String Unique identifier for the entity
title String Name of the product
description String Description of the product
template String URL to the HTML content of this product
thumb String URL to the thumbnail image for this product
preview String URL to the preview image(s) for this product. If a multi-page product, this will be a reference to an image of the first page.
{
	"id": "0000",
	"title": "Your Product Title",
	"description": "Your Product Description",
	"template": "https://vfs.url/template.html?versionId=XXX",
	"thumb": "https://vfs.url/thumb.jpg?versionId=XXX",
	"preview": "https://vfs.url/preview.jpg"
}

Tag List (v1)

Returns a list of strings that represent the tags asoociated with a product.

[
    "Tag1",
    "Tag2",
    "Tag3"
]

Token Manifest (v1)

This is a passthrough from the token service. Please see documentation

Error Response

{
	"code": 000,
    "message": "Description of error"
}

Local Development

Initial Setup:

  1. Configure RabbitMQ and ETCD2 environment
  2. Install Prince www.princexml.com
  3. Run “npm install -g nodemon” to globally install Nodemon code monitoring utility
  4. Repeat the following steps for RPC.Interface, RPC.AccountService, RPC.AssetService, RPC.Render, RPC.ProductService:
git clone git@github.com:nsnsolutions/[ProjectName].git
cd [ProjectName]
npm install

Steps for Running:

Start Docker

term 1 - Run RabbitMQ:
cd rpcfw.env
docker-compose --file local/docker-compose.yml up

term 2 - Run RPC Interface:
cd RPC.Interface
npm start

term 3 - Run RPC.AccountService:
cd RPC.AccountService
npm start

term 4 - Run RPC.AssetService:
cd RPC.AssetService
npm start

term 5 - Run RPC.Render:
cd RPC.Render
npm start

term 6 - Run Product Service:
cd RPC.ProductService
nodemon
Tags: vfs service rpc