testcompanyname_productname
v1.0.0-a4
Published
TypeScript/JavaScript client for Test Company - Product Name
Downloads
2
Readme
Test Company - Product Name
TypeScript Node SDK
Documentation
Getting Started
Run the command below to install the testcompanyname_productname NPM package.
npm i testcompanyname_productname
Now you can use the typescript integration.
TypeScript integration
'use strict';
import { TestCompanyNameProductName } from 'testcompanyname_productname';
let macVersion: number = 1;
let spaceId: number = 405;
let userId: number = 512;
let apiSecret: string = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';
function getTransactionService(): TestCompanyNameProductName.api.TransactionService {
let transactionService: TestCompanyNameProductName.api.TransactionService = new TestCompanyNameProductName.api.TransactionService({
mac_version: macVersion,
space_id: spaceId,
user_id: userId,
api_secret: apiSecret
});
return transactionService;
}
function getTransaction(): TestCompanyNameProductName.model.TransactionCreate {
let lineItem: TestCompanyNameProductName.model.LineItemCreate = new TestCompanyNameProductName.model.LineItemCreate();
lineItem.name='Red T-Shirt';
lineItem.uniqueId='5412';
lineItem.sku='red-t-shirt-123';
lineItem.quantity=1;
lineItem.amountIncludingTax=3.50;
lineItem.type=TestCompanyNameProductName.model.LineItemType.PRODUCT;
let transaction: TestCompanyNameProductName.model.TransactionCreate = new TestCompanyNameProductName.model.TransactionCreate();
transaction.lineItems=[lineItem];
transaction.autoConfirmationEnabled=true;
transaction.currency='EUR';
return transaction;
}
let transactionService: TestCompanyNameProductName.api.TransactionService = getTransactionService();
transactionService.transactionServiceCreate(spaceId, getTransaction()).then(function (response) {
let transactionCreate: TestCompanyNameProductName.model.Transaction = response.body;
let entityQueryFilter: TestCompanyNameProductName.model.EntityQueryFilter = new TestCompanyNameProductName.model.EntityQueryFilter();
entityQueryFilter.fieldName = 'id';
entityQueryFilter.value = transactionCreate.id;
entityQueryFilter.type = TestCompanyNameProductName.model.EntityQueryFilterType.LEAF;
entityQueryFilter.operator = TestCompanyNameProductName.model.CriteriaOperator.EQUALS;
transactionService.transactionServiceCount(spaceId, entityQueryFilter).then(function (response) {
let transactionCount: number = response.body;
// expect transactionCount to equal 1
});
});
let transactionService: TestCompanyNameProductName.api.TransactionService = getTransactionService();
transactionService.transactionServiceCreate(spaceId, getTransaction()).then(function (response) {
let transactionCreate: TestCompanyNameProductName.model.Transaction = response.body;
// expect transactionCreate.state to equal TestCompanyNameProductName.model.TransactionState.PENDING
});
let transactionService: TestCompanyNameProductName.api.TransactionService = getTransactionService();
transactionService.transactionServiceCreate(spaceId, getTransaction()).then(function (response) {
let transactionCreate: TestCompanyNameProductName.model.Transaction = response.body;
transactionService.transactionServiceRead(spaceId, <number>transactionCreate.id).then(function (response) {
let transactionRead = response.body;
// expect transactionRead.state to equal TestCompanyNameProductName.model.TransactionState.PENDING
});
});
let transactionService: TestCompanyNameProductName.api.TransactionService = getTransactionService();
transactionService.transactionServiceCreate(spaceId, getTransaction()).then(function (response) {
let transactionCreate: TestCompanyNameProductName.model.Transaction = response.body;
let entityQueryFilter: TestCompanyNameProductName.model.EntityQueryFilter = new TestCompanyNameProductName.model.EntityQueryFilter();
entityQueryFilter.fieldName = 'id';
entityQueryFilter.value = transactionCreate.id;
entityQueryFilter.type = TestCompanyNameProductName.model.EntityQueryFilterType.LEAF;
entityQueryFilter.operator = TestCompanyNameProductName.model.CriteriaOperator.EQUALS;
let entityQuery = new TestCompanyNameProductName.model.EntityQuery();
entityQuery.filter = entityQueryFilter;
transactionService.transactionServiceSearch(spaceId, entityQuery).then(function (response) {
let transactionSearch = response.body;
transactionSearch.forEach(function (entry) {
// expect entry state to equal TestCompanyNameProductName.model.TransactionState.PENDING
});
});
});
let transactionService: TestCompanyNameProductName.api.TransactionService = getTransactionService();
transactionService.transactionServiceCreate(spaceId, getTransaction()).then(function (response) {
let transactionCreate: TestCompanyNameProductName.model.Transaction = response.body;
transactionCreate.language = 'en-US';
transactionService.transactionServiceUpdate(spaceId, <TestCompanyNameProductName.model.TransactionPending> transactionCreate).then(function (response) {
let transactionUpdate: TestCompanyNameProductName.model.Transaction = response.body;
// expect transactionUpdate.language to equal 'en-US'
});
});