Skip to content

Instantly share code, notes, and snippets.

@justlev
justlev / stw-integrate.ts
Last active February 6, 2022 11:40
Integrate once & forget
import {StatewizeClient} from "statewize-client-sdk";
const sdk = new StatewizeClient(process.env.STW_TOKEN);
// Report an action, along with its state (start/finished/failed):
await sdk.reportEvent({ slug: `checkout-express`, type: 'finished',
// Optionally, add data attachments that will help you debug
attachments: [{
type: 'object', // can be any object, file or text you like
@justlev
justlev / index.js
Created May 6, 2021 16:11
STATEWIZE Integration
const res = await sdk.executions.startExecutionSync({
token: process.env.MY_FLOW_TOKEN,
entryPayload: {user: {id: 123, data: 'whatever-you-need'}}
});
@justlev
justlev / Stwspec.json
Created April 14, 2021 17:58
Stwspec.json file for CI/CD
{
"stw-v1": {
"deployment": {
"bundles": [
{
"bundleDir": "./build/functions",
"runtime": "nodejs12.x",
"token": "TUP5vJCp7aRvdwBPuqR1HSpZMYZ9kHh27kt35emNa8uk2WPJaDfgEXXBe33HyhhU",
"layout": [
{
@justlev
justlev / stwspec.json
Created April 11, 2021 14:17
stwspec.json
{
"stw-v1": {
"deployment": {
"bundles": [
{
"bundleDir": "./toDeploy",
"runtime": "nodejs12.x",
"token": "PzaJq1Vwzb1MDGeRrCFjdtZFvy3BwAyaqEjNbFthxGth4kE7wNeJ82Bq2JQ6YFYe",
"layout": [
{
@justlev
justlev / statewize.js
Created January 31, 2021 13:40
Integrating STATEWIZE
const sdk = require('statewize-client-sdk');
const execution = await sdk.executions.startExecutionSync({
token: process.env.PROJECT_TOKEN,
entryPayload: {user: {id: 1234, otherParams: 'whatever-you-need'}}
});
@justlev
justlev / usage.json
Last active October 20, 2020 14:12
GetCurrentUsage.json
{
"data": {
"id": "447890025715",
"type": "get_usage_currents",
"attributes": {
"plan": {
"code": "SM_SMALL",
"description": "2GB",
"autoRenew": true,
"start": "2020-10-06T01:00:02+01:00",
{
"data": [
{
"id": "NEW_10GB_RETAIL",
"type": "package",
"attributes": {
"id": "NEW_10GB_RETAIL",
"description": "10GB Data add-on (Retail)",
"renewalPrice": 1500,
"name": "10GB Data add-on (Retail)",
{
"plans": [
{
"currency": "GB",
"description": "5GB Data, Unlimited Text, Unlimited Voice",
"description_pre": "4GB of data",
"id": "NEW_RETAIL",
"name": "Retail Plan 2",
"price": 1000,
"type": "data",
config.middleware.use FayeRails::Middleware, mount: '/faye', engine: { type: Faye::Redis, host: ENV['REDIS_HOST'] }, :timeout => 25
EM.run {
client = Faye::Client.new('http://localhost:3000/faye')
publication = client.publish('/foo', 'text' => 'Hello world')
publication.callback do
puts 'SUCCESS!'
EM.stop
end
publication.errback do |error|
puts "[PUBLISH FAILED]"
EM.stop