salesforce-service
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

salesforce-service

Maintainability Rating Security Rating Reliability Rating Duplicated Lines (%) Bugs Code Smells Technical Debt

Introduction

salesforce-service is a wrapper that helps interacting with Salesforce REST and SOAP API easier. This can be very helpful while testing Salesforce application.

Installation

npm install --save-dev salesforce-service

Usages

Configuration file

Configuration file is a json file in which you can store all relevant information for your Salesforce application. Here is a example:

{
  "urls":{
    "testUrl": "https://test.salesforce.com",
    "baseUrl": "https://test.salesforce.com",
    "domain": "your-domain.my.salesforce.com"
  },
  "paths": {
    "soap": "/services/Soap/u/51.0",
    "data": "/services/data/v51.0",
    "query": "/services/data/v51.0/query/?q="
  }
}

Get session information

const SfService = require('salesforce-service').SfService;

const service = new SfService({
  configFile: 'config.json'
})

service.getSessionId({
  username: 'youruser',
  password: 'yourpass',
  token:'yourtoken'
}).then((res) => {
  console.log(res)
})

Run a query

await service.query('your query command');

Deal with records

it('get record successfully', async () => {
    const response = await service.getRecord('123');
    expect(response.data).toEqual('got record');
  });

  it('create record successfully', async () => {
    const data: JSON = JSON.parse('{"field1": "value1"}');
    const response = await service.createRecord('name', data);
    expect(response.data).toEqual('created record');
  });

  it('update record successfully', async () => {
    const data: JSON = JSON.parse('{"field1": "value1"}');
    const response = await service.updateRecord('123', data);
    expect(response.data).toEqual('updated record');
  });

  it('delete record successfully', async () => {
    const response = await service.deleteRecord('123');
    expect(response.data).toEqual('deleted record');
  });

Readme

Keywords

Package Sidebar

Install

npm i salesforce-service

Weekly Downloads

152

Version

0.0.5

License

ISC

Unpacked Size

33.4 kB

Total Files

16

Last publish

Collaborators

  • thanhlenov