Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Following actions are supported by this connector:
2. `getRecordById`: To fetch a record by id from an object. Objects supported are Addresses, Customers, Countries, Currencies, Devices, Locations, Products, Purchase Orders, Purchase Order Items, Sales Orders, Sales Order Items and Service Requests.
3. `createPurchaseOrder`: To create a new purchase order.
4. `createSalesOrder`: To create a new sales order.
5. `createAddress`: To create a new address.

------------------------------

Expand Down
116 changes: 116 additions & 0 deletions action/v1/create_address.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
const services = require("../../services");

module.exports = {

name: "create_address",

title: "Create Address",

description: "",
version: "v1",

input: {
title: "createSalesOrder",
type: "object",
properties: {
"addressLine1": {
"title": "addressLine1",
"displayTitle": "Address Line 1",
"type": "string",
"description": "",
"required": true,
"minLength": 1
},
"addressLine2": {
"title": "addressLine2",
"displayTitle": "Address Line 2",
"type": "string",
"description": "",
"required": true,
"minLength": 1
},
"cityTown": {
"title": "cityTown",
"displayTitle": "City Town",
"type": "string",
"description": "",
"required": true,
"minLength": 1
},
"postcodeZip": {
"title": "postcodeZip",
"displayTitle": "Postcode Zip",
"type": "string",
"description": "",
"required": true,
"minLength": 1
},
"countyStateProvince": {
"title": "countyStateProvince",
"displayTitle": "County/State/Province",
"type": "string",
"description": "",
"required": true,
"minLength": 1
},
"countryId": {
"title": "countryId",
"displayTitle": "Country Id",
"type": "string",
"description": "",
"required": true,
"minLength": 1
}
}
},

output: {
title: "output",
type: "object",
properties: {
"output": {
"title": "Output",
"type": "object",
"properties": {
"id": {
"title": "id",
"displayTitle": "Id",
"type": "string",
"description": ""
}
}
}
}
},

mock_input: {
"addressLine1": "Software AG",
"addressLine2": "Darmstadt",
"cityTown": "Darmstadt",
"postcodeZip": "64297",
"countyStateProvince": "Germany",
"countryId": "REFCOUN-003"
},

execute: function (input, output) {
// to access auth info use input.auth , eg: input.auth.username
// and to return output use output callback like this output(null, { 'notice' : 'successful'})
// var rootURL = input.auth.tenant + "addresses";
var rootURL = input.auth.tenant;
var credentials = input.auth.username + ":" + input.auth.password;
var requestBody =
{
"input": {
"addressLine1": input.addressLine1,
"addressLine2": input.addressLine2,
"cityTown": input.cityTown,
"postcodeZip": input.postcodeZip,
"countyStateProvince": input.countyStateProvince,
"countryId": input.countryId
}
};
var option = services.getOptionsForCreateRequest(rootURL, 'addresses', credentials, requestBody); //reusable function in services.js
services.makeHttpRequest(option, output); //reusable function in services.js
}

}
7 changes: 4 additions & 3 deletions action/v1/create_purchase_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {

name: "create_purchase_order",

title: "createPurchaseOrder",
title: "Create Purchase Order",

description: "",
version: "v1",
Expand Down Expand Up @@ -77,7 +77,8 @@ module.exports = {
execute: function (input, output) {
// to access auth info use input.auth , eg: input.auth.username
// and to return output use output callback like this output(null, { 'notice' : 'successful'})
var rootURL = input.auth.tenant + "purchaseorders";
// var rootURL = input.auth.tenant + "purchaseorders";
var rootURL = input.auth.tenant;
var credentials = input.auth.username + ":" + input.auth.password;
var requestBody =
{
Expand All @@ -87,7 +88,7 @@ module.exports = {
"products": input.products
}
};
var option = services.getOptionsForCreateRequest(rootURL, credentials, requestBody); //reusable function in services.js
var option = services.getOptionsForCreateRequest(rootURL, 'purchaseorders', credentials, requestBody); //reusable function in services.js
services.makeHttpRequest(option, output); //reusable function in services.js
}

Expand Down
7 changes: 4 additions & 3 deletions action/v1/create_sales_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {

name: "create_sales_order",

title: "createSalesOrder",
title: "Create Sales Order",

description: "",
version: "v1",
Expand Down Expand Up @@ -90,7 +90,8 @@ module.exports = {
execute: function (input, output) {
// to access auth info use input.auth , eg: input.auth.username
// and to return output use output callback like this output(null, { 'notice' : 'successful'})
var rootURL = input.auth.tenant + "salesorders";
// var rootURL = input.auth.tenant + "salesorders";
var rootURL = input.auth.tenant;
var credentials = input.auth.username + ":" + input.auth.password;
var requestBody =
{
Expand All @@ -103,7 +104,7 @@ module.exports = {
"products": input.products
}
};
var option = services.getOptionsForCreateRequest(rootURL, credentials, requestBody); //reusable function in services.js
var option = services.getOptionsForCreateRequest(rootURL, 'salesorders', credentials, requestBody); //reusable function in services.js
services.makeHttpRequest(option, output); //reusable function in services.js
}

Expand Down
7 changes: 3 additions & 4 deletions action/v1/get_record_by_id.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ module.exports = {

name: "get_record_by_id",

title: "getRecordById",
title: "Get Record By Id",

description: "",
version: "v1",

input: {
title: "getRecordById",
title: "Get Record By Id",
type: "object",
properties: {
object: {
Expand Down Expand Up @@ -46,9 +46,8 @@ module.exports = {
execute: function (input, output) {
var objectString = utils.removeSpacesAndLowerCase(input.object); //reusable function in utils.js
var resource = utils.pluralizeNoun(objectString); //reusable function in utils.js
var rootURL = input.auth.tenant + resource + "/" + input.id;
var credentials = input.auth.username + ":" + input.auth.password;
var option = services.getOptionsForGetRequest(rootURL, credentials); //reusable function in services.js
var option = services.getOptionsForGetRequest(input.auth.tenant, `${resource}/${input.id}`, credentials); //reusable function in services.js
services.makeHttpRequest(option, output); //reusable function in services.js
}

Expand Down
8 changes: 4 additions & 4 deletions action/v1/get_records.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ module.exports = {

name: "get_records",

title: "getRecords",
title: "Get Records",

description: "",
version: "v1",

input: {
title: "getRecords",
title: "Get Records",
type: "object",
properties: {
object: {
Expand Down Expand Up @@ -53,9 +53,9 @@ module.exports = {
// and to return output use output callback like this output(null, { 'notice' : 'successful'})
var objectString = utils.removeSpacesAndLowerCase(input.object); //reusable function in utils.js
var resource = utils.pluralizeNoun(objectString); //reusable function in utils.js
var rootURL = input.auth.tenant + resource;
var credentials = input.auth.username + ":" + input.auth.password;
var option = services.getOptionsForGetRequest(rootURL, credentials); //reusable function in services.js
var option = services.getOptionsForGetRequest(input.auth.tenant, resource, credentials); //reusable function in services.js
// var option = services.getOptionsForGetRequest(rootURL, credentials); //reusable function in services.js
services.makeHttpRequest(option, output); //reusable function in services.js
}

Expand Down
8 changes: 5 additions & 3 deletions authentication.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
var request = require('request');

module.exports = {
label: 'Connect to Basic',
mock_input: {},
mock_input: {
"tenant": "",
"username": "",
"password": ""
},
input: {
type: "object",
properties: {
Expand Down
5 changes: 3 additions & 2 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"/v1/get_records",
"/v1/get_record_by_id",
"/v1/create_purchase_order",
"/v1/create_sales_order"
"/v1/create_sales_order",
"/v1/create_address"
],
"version": 1,
"auth_type": "custom",
"doc_link": ""
}
}
Loading