1.1.3 • Published 4 years ago

salesforce-rest-api v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 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

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago