Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'zapier-platform-core' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
/**
* This file is part of the Ingram Micro Cloud Blue Connect SDK.
*
* @copyright (c) 2019. Ingram Micro. All Rights Reserved.
*/
/* globals describe it */
const should = require('should');
const sinon = require('sinon');
const zapier = require('zapier-platform-core');
const { HubResource } = require('@cloudblueconnect/connect-javascript-sdk/lib/connect/api');
// Use this to make test calls into your app:
const App = require('../../index');
const appTester = zapier.createAppTester(App);
zapier.tools.env.inject();
const responses = require('../responses');
describe('Connect Fulfillment Zapier App - List hubs', () => {
let sandbox;
before(() => { sandbox = sinon.createSandbox(); });
afterEach(done => { sandbox.restore(); done(); });
it('should return a list of hubs', done => {
const bundle = {
authData: {
api_key: process.env.CONNECT_API_KEY,
endpoint: process.env.CONNECT_ENDPOINT
},
inputData: {}
};
require('should');
const zapier = require('zapier-platform-core');
const App = require('../index');
const nock = require('nock');
const {
CLIENT_ID,
BASE_URL,
OAUTH_AUTHORIZE_ENDPOINT,
OAUTH_TOKEN_ENDPOINT,
OAUTH_TEST_ENDPOINT,
} = require('../constants');
const appTester = zapier.createAppTester(App);
zapier.tools.env.inject();
describe('oAuth', () => {
before(() => {
// Run `source test/.env` before running `zapier test`.
// It's a good idea to store your Client ID and Secret in the environment rather than in code.
// This works locally via the `export` shell command and in production by using `zapier env`
});
it('generates an authorize URL', () => {
const bundle = {
// In production, these will be generated by Zapier and set automatically
inputData: {
state: '4444',
redirect_uri: process.env.REDIRECT_URI,
},
};
/**
* This file is part of the Ingram Micro Cloud Blue Connect SDK.
*
* @copyright (c) 2019. Ingram Micro. All Rights Reserved.
*/
const should = require('should');
const { Fulfillment } = require('@cloudblueconnect/connect-javascript-sdk');
const sinon = require('sinon');
const zapier = require('zapier-platform-core');
const responses = require('../responses');
// Use this to make test calls into your app:
const App = require('../../index');
const appTester = zapier.createAppTester(App);
zapier.tools.env.inject();
describe('Connect Fulfillment Zapier App - Fill Fulfillment Parameters', () => {
let sandbox;
before(() => { sandbox = sinon.createSandbox(); });
afterEach(done => { sandbox.restore(); done(); });
it('should return a request with fulfillment parameter filled', done => {
const bundle = {
authData: {
api_key: process.env.CONNECT_API_KEY,
endpoint: process.env.CONNECT_ENDPOINT
},
inputData: {
request_id: 'PR-0000-0000-0000-000',
params: [
{
id: 'param_a',
/**
* This file is part of the Ingram Micro Cloud Blue Connect SDK.
*
* @copyright (c) 2019. Ingram Micro. All Rights Reserved.
*/
const should = require('should');
const { Fulfillment } = require('@cloudblueconnect/connect-javascript-sdk');
const sinon = require('sinon');
const zapier = require('zapier-platform-core');
const responses = require('../responses');
// Use this to make test calls into your app:
const App = require('../../index');
const appTester = zapier.createAppTester(App);
zapier.tools.env.inject();
describe('Connect Fulfillment Zapier App - Create Asset Request (purchase)', () => {
let sandbox;
before(() => { sandbox = sinon.createSandbox(); });
afterEach(done => { sandbox.restore(); done(); });
it('should create a new purchase request', done => {
const bundle = {
authData: {
api_key: process.env.CONNECT_API_KEY,
endpoint: process.env.CONNECT_ENDPOINT
},
inputData: {
request_type: 'purchase',
reseller_tiers: 't1',
hub_id: 'HB-0000-0000',
// connection_id: 'CT-0000-0000-0000',
it('should delete the email open hook', (done) => {
zapier.tools.env.inject();
const bundle = {
targetUrl: 'http://provided.by?zapier',
subscribeData: subscribeData,
authData: {
baseUrl: process.env.TEST_BASE_URL,
username: process.env.TEST_BASIC_AUTH_USERNAME,
password: process.env.TEST_BASIC_AUTH_PASSWORD
}
};
// Delete the created hook to clean up after previous test and to test delete too
appTester(App.triggers.emailOpened.operation.performUnsubscribe, bundle)
.then(response => {
should.exist(response.hook);
response.hook.webhookUrl.should.eql(bundle.targetUrl);
response.hook.name.should.eql('Trigger Zapier about email open events');
*
* @copyright (c) 2019. Ingram Micro. All Rights Reserved.
*/
/* globals describe it */
const should = require('should');
const sinon = require('sinon');
const zapier = require('zapier-platform-core');
const { Fulfillment } = require('@cloudblueconnect/connect-javascript-sdk');
const BaseResource = require('@cloudblueconnect/connect-javascript-sdk/lib/connect/api/base');
const { RequestResource } = require('@cloudblueconnect/connect-javascript-sdk/lib/connect/api');
// Use this to make test calls into your app:
const App = require('../../index');
const appTester = zapier.createAppTester(App);
zapier.tools.env.inject();
const responses = require('../responses');
describe('Connect Fulfillment Zapier App - Search Requests', () => {
let sandbox;
before(() => { sandbox = sinon.createSandbox(); });
afterEach(done => { sandbox.restore(); done(); });
it('should return a list of requests filtered by status', done => {
const bundle = {
authData: {
api_key: process.env.CONNECT_API_KEY,
endpoint: process.env.CONNECT_ENDPOINT
},
inputData: {
status: ['pending', 'inquiring']
it('should delete the page hit hook', (done) => {
zapier.tools.env.inject();
const bundle = {
targetUrl: 'http://provided.by?zapier',
subscribeData: subscribeData,
authData: {
baseUrl: process.env.TEST_BASE_URL,
username: process.env.TEST_BASIC_AUTH_USERNAME,
password: process.env.TEST_BASIC_AUTH_PASSWORD
}
};
// Delete the created hook to clean up after previous test and to test delete too
appTester(App.triggers.pageHit.operation.performUnsubscribe, bundle)
.then(response => {
should.exist(response.hook);
response.hook.webhookUrl.should.eql(bundle.targetUrl);
response.hook.name.should.eql('Trigger Zapier about page hit events');
'use strict';
const should = require('should');
const zapier = require('zapier-platform-core');
const App = require('../index');
const appTester = zapier.createAppTester(App);
describe('basic authentication', () => {
// Put your test TEST_USERNAME and TEST_PASSWORD in a .env file.
// The inject method will load them and make them available to use in your
// tests.
zapier.tools.env.inject();
it('should authenticate', (done) => {
const bundle = {
authData: {
username: process.env.TEST_USERNAME,
password: process.env.TEST_PASSWORD
}
};
/* globals describe it */
const should = require('should');
const sinon = require('sinon');
const zapier = require('zapier-platform-core');
const { ProductService } = require('@cloudblueconnect/connect-javascript-sdk/lib/connect/api');
// Use this to make test calls into your app:
const App = require('../../index');
const appTester = zapier.createAppTester(App);
zapier.tools.env.inject();
const responses = require('../responses');
describe('Connect Fulfillment Zapier App - Fulfillment parameters', () => {
let sandbox;
before(() => { sandbox = sinon.createSandbox(); });
afterEach(done => { sandbox.restore(); done(); });
it('should return a list of parameters with scope=asset and phase=fulfillment', done => {
const bundle = {
authData: {
api_key: process.env.CONNECT_API_KEY,
endpoint: process.env.CONNECT_ENDPOINT
},
inputData: {
id: 'PRD-000-000-000'
/**
* This file is part of the Ingram Micro Cloud Blue Connect SDK.
*
* @copyright (c) 2019. Ingram Micro. All Rights Reserved.
*/
const should = require('should');
const { Fulfillment } = require('@cloudblueconnect/connect-javascript-sdk');
const sinon = require('sinon');
const zapier = require('zapier-platform-core');
const responses = require('../responses');
// Use this to make test calls into your app:
const App = require('../../index');
const appTester = zapier.createAppTester(App);
zapier.tools.env.inject();
describe('Connect Fulfillment Zapier App - Reject Request', () => {
let sandbox;
before(() => { sandbox = sinon.createSandbox(); });
afterEach(done => { sandbox.restore(); done(); });
it('should return a payload of the rejected request', done => {
const bundle = {
authData: {
api_key: process.env.CONNECT_API_KEY,
endpoint: process.env.CONNECT_ENDPOINT
},
inputData: {
request_id: 'PR-5426-PR-5426-9883-2189-001',
reason: 'Not available'
}