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
9 changes: 5 additions & 4 deletions docs/jobs/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ password from your `state.configuration` (or "credential" if using the app) into
http request body.

```js
post('/api/v1/auth/login', {
body: {
post(
'/api/v1/auth/login',
{
username: $.configuration.username, //map the UN from credential
password: $.configuration.password, //map the PW from credential
},
headers: { 'content-type': 'application/json' },
});
{ headers: { 'content-type': 'application/json' } }
);
```

> **Note:** While most adaptors handles authentication automatically, The
Expand Down
12 changes: 6 additions & 6 deletions docs/jobs/data-transformation.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn(state => {
// Read the data we fetched
const obj = state.data;

// convert it by mapping properties from one object to the o ther
// convert it by mapping properties from one object to the other
state.uploadData = {
id: obj.id,
name: `${obj.first_name} ${obj.last_name}`,
Expand Down Expand Up @@ -106,7 +106,7 @@ fn((state) => {
state.transformed = []
return state;
})
each("$.items[*]", fn(state) => {
each("$.items[*]", fn(state => {
// Pull the next item off the state
const next = state.data;

Expand All @@ -118,7 +118,7 @@ each("$.items[*]", fn(state) => {

// Always return state
return state;
})
}))
```

Or we can pass in another operation, like this Salesforce example:
Expand All @@ -127,9 +127,9 @@ Or we can pass in another operation, like this Salesforce example:
each(
'$.form.participants[*]',
upsert('Person__c', 'Participant_PID__c', state => ({
Participant_PID__c: state.pid,
First_Name__c: state.participant_first_name,
Surname__c: state.participant_surname,
Participant_PID__c: state.data.pid,
First_Name__c: state.data.participant_first_name,
Surname__c: state.data.participant_surname,
}))
);
```
Expand Down
11 changes: 5 additions & 6 deletions docs/jobs/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ declare more properties:

```js
const newState = {
...state
...state,
data: {} // create a new data object but keep all other keys of state
}
```
Expand All @@ -243,7 +243,7 @@ finally overwrites the data key.
```js
const newState = {
...defaults,
...state
...state,
data: {} // create a new data object but keep all other keys of state
}
```
Expand Down Expand Up @@ -275,7 +275,7 @@ const b = {

b.x = 2; // a.x is unchanged
b.y.values = []; // a.y.values is changed
b.y = 20' // a.y is unchanged
b.y = 20; // a.y is unchanged
```

A deep clone means that all properties in the whole object tree are cloned.
Expand Down Expand Up @@ -305,7 +305,7 @@ fn(state => {
// Here we build the payload of our http request body...
// We assume the input is an array of records
const payload = state.data.map(record => ({
location: locationMap[record.location_id] //translate location_id to the mapped value
location: locationMap[record.location_id], //translate location_id to the mapped value
external_id: record.case_id
}));

Expand All @@ -314,11 +314,10 @@ fn(state => {

//Workflow step 2
//Then we post the payload built in the prior operation to create a record
post('/api/myEndpoint', {
post('/api/myEndpoint', state => state.payload, {
headers: {
'Content-Type': 'application/json',
},
body: (state) => state.payload
});
```

Expand Down
Loading