Skip to content
This repository has been archived by the owner on Jul 14, 2019. It is now read-only.

Releases: ask-utils/isp

Add new RequestInterceptor

01 Jul 10:36
Compare
Choose a tag to compare

The Alexa Blog says to cache the product data by using RequestInterceptor.
https://developer.amazon.com/ja/blogs/alexa/post/75ee61df-8365-44bb-b28f-e708000891ad/how-to-use-interceptors-to-simplify-handler-code-and-cache-product-and-purchase-information-in-monetized-alexa-skills

Today, we provides a new Interceptor to cache the data in your Skill.
You can cache the ISP Product data by the following code.

import { loadISPDataInterceptor } from '@ask-utils/isp'

// add interceptor
.addRequestInteceptor(loadISPDataInterceptor)

And you can get the products by the following code.

// get product from session attributes
import { getAllEntitledProducts } from '@ask-utils/isp'

const { inSkillProducts } = handlerInput.attributesManager.getSessionAttributes()
const entitledProducts = getAllEntitledProducts(inSkillProducts)

First release

29 May 08:49
Compare
Choose a tag to compare

Provide a simple helpers.

getBuyProductDirective('product_id')

Create BuyRequest directive.

getAllEntitledProducts(products)

filter entitled products.

getAllPurchasableProducts(products)

filter purchasable product.

getProductByName(products, 'product_1')

find a product by product name.