1.1.3 • Published 6 years ago

salesforce-rest-api v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

salesforce-rest-api

Node.js library for salesforce rest api

Known Vulnerabilities

Supports 'query records' and the following record methods:

  • Create
  • Update
  • Delete
  • Get

In order to set oauth credentials prior to executing the methods there are 2 options:

  • Using the setOauth function - then each method execution will use this predfined oauth
  • Passing an oauth credentials as an argument in the relevant method (optional)

Install

npm i salesforce-rest-api

Usage

let rest = require('salesforce-rest-api');

rest.setOauth({
  accessToken: 'access token value', 
  instanceUrl: 'instance url value'
});

Create

try {
  const response = await rest.createRecord({
    type: 'Account',
    recordData: {name: 'Gilad'}
  });
  const newRecordId = response.body.id;
}
catch (err) {
  body = err.response.body[0];
  //handle error
}
    

Update

try {
  const response = await rest.updateRecord({
    type: 'Account',
    recordData: {Name: 'Gilad'},
    recordId: newRecordId
  });
}
catch (err) {
  //handle error
}

Delete

try {
  const response = await rest.deleteRecord({
    type: 'Account',
    recordId
  });
}
catch (err) {
  //handle error
}

Get

Gets a record data

try {
  const response = await rest.getRecord({
    type: 'AccountInvalid',
    recordId
  });
  const recordId = response.body.Id;
}
catch (err) {
  //handle error
}

Query records

Query records using the soql syntax

try {
  const response = await rest.queryRecords({soqlQuery: 'SELECT name from Account where name=\'Account1\''});
  const records = response.body.records;
}
catch (err) {
  //handle error
}
1.1.3

6 years ago

1.1.1

6 years ago

1.1.2

6 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago