Skip to content

Commit

Permalink
Merge pull request MadKudu#100 from MadKudu/feat/upgrade-deps
Browse files Browse the repository at this point in the history
Upgrade dependencies (replace restler by axios) to fix vulnerabilities + fix tests + install Prettier
  • Loading branch information
mdarcemont committed Jan 16, 2023
2 parents cf07f19 + 516c928 commit 4a9102f
Show file tree
Hide file tree
Showing 79 changed files with 4,427 additions and 1,806 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.nyc_output
/coverage
/dist
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
150 changes: 71 additions & 79 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,92 +6,88 @@

Implements [Get Lead by Id](http://developers.marketo.com/documentation/rest/get-lead-by-id/)

param | type | description
------|------|------------
`id` | int | the lead id to query for
`options` | object | `fields`: a comma separated list or array of fields to retrieve
| param | type | description |
| --------- | ------ | --------------------------------------------------------------- |
| `id` | int | the lead id to query for |
| `options` | object | `fields`: a comma separated list or array of fields to retrieve |

```js
marketo.lead.byId(3)
.then(function(data) {
console.log(data);
})
marketo.lead.byId(3).then(function (data) {
console.log(data);
});

// Using the field attribute
marketo.lead.byId(3, {fields: ['email', 'lastName']})
.then(function(data) {
// data.result[0]
//
// {
// email: "some@email.com",
// lastName: "LastName"
// }
});
marketo.lead.byId(3, { fields: ['email', 'lastName'] }).then(function (data) {
// data.result[0]
//
// {
// email: "some@email.com",
// lastName: "LastName"
// }
});
```


#### lead.find(filterType, filterValues, options)

Implements [Get Multiple Leads by Filter Type](http://developers.marketo.com/documentation/rest/get-multiple-leads-by-filter-type/)

param | type | description
------|------|------------
`filterType` | string | the field that we will filter on
`filterValues` | Array<string>/string | the values that we will filter for
`options` | object | `fields`: a comma separated list or array of fields to retrieve
| | `batchSize`: the number of lead records to be returned (max is 300)
| | `nextPageToken`: used to paginate through large result sets
| param | type | description |
| -------------- | ------------------------------------------------------------------- | --------------------------------------------------------------- |
| `filterType` | string | the field that we will filter on |
| `filterValues` | Array<string>/string | the values that we will filter for |
| `options` | object | `fields`: a comma separated list or array of fields to retrieve |
| | `batchSize`: the number of lead records to be returned (max is 300) |
| | `nextPageToken`: used to paginate through large result sets |

```js
marketo.lead.find('email', ['email@one.com', 'email@two.com'])
marketo.lead.find('email', ['email@one.com', 'email@two.com']);

// or
marketo.lead.find('email', 'email@one.com,email@two.com')
marketo.lead.find('email', 'email@one.com,email@two.com');
```


#### lead.createOrUpdate(input, options)

Implements [Create/Update Leads](http://developers.marketo.com/documentation/rest/createupdate-leads/)

param | type | description
------|------|------------
`input` | Array<Object> | An array of lead records to create or update
`options` | object | `action`: one of 4 valid actions (createOnly, updateOnly, ...)
| | `lookupField`: the field used to dedup on
| | `partitionName`: not sure what this does yet, :)
| param | type | description |
| --------- | ------------------------------------------------ | -------------------------------------------------------------- |
| `input` | Array<Object> | An array of lead records to create or update |
| `options` | object | `action`: one of 4 valid actions (createOnly, updateOnly, ...) |
| | `lookupField`: the field used to dedup on |
| | `partitionName`: not sure what this does yet, :) |

```js
// Since the action is not passed in, the default action is 'createOrUpdate'
marketo.lead.createOrUpdate(
[{'email': 'email@one.com'}, {'email': 'email@two.com'}],
{lookupField: 'email'}
)
[{ email: 'email@one.com' }, { email: 'email@two.com' }],
{ lookupField: 'email' }
);

// The same query without creating new leads
marketo.lead.createOrUpdate(
[{'email': 'email@one.com'}, {'email': 'email@two.com'}],
{lookupField: 'email', action: 'updateOnly'}
)
[{ email: 'email@one.com' }, { email: 'email@two.com' }],
{ lookupField: 'email', action: 'updateOnly' }
);
```

#### lead.push(input, options)

Implements [Push Leads](http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Leads/pushToMarketoUsingPOST)

param | type | description
------|------|------------
`input` | Array<Object> | An array of lead records to push
`options` | object |
| | `lookupField`: the field used to dedup on
| | `programName `: the program name in Marketo
| param | type | description |
| --------- | ------------------------------------------- | -------------------------------- |
| `input` | Array<Object> | An array of lead records to push |
| `options` | object |
| | `lookupField`: the field used to dedup on |
| | `programName `: the program name in Marketo |

```js
// Push a lead to Marketo program name
marketo.lead.push(
[{'email': 'email@one.com'}, {'email': 'email@two.com'}],
{lookupField: 'email', programName: 'Test program name'}
)
marketo.lead.push([{ email: 'email@one.com' }, { email: 'email@two.com' }], {
lookupField: 'email',
programName: 'Test program name',
});
```

### List
Expand All @@ -100,64 +96,60 @@ marketo.lead.push(

Implements [Get Multiple Lists](http://developers.marketo.com/documentation/rest/get-multiple-lists/)

param | type | description
------|------|------------
`options` | object | `id`: array of ids to filter by
| | `name`: array of names to filter by
| | `programName`: array of program names to filter by
| | `workspaceName`: array of workspaces to filter by
| param | type | description |
| --------- | -------------------------------------------------- | ------------------------------- |
| `options` | object | `id`: array of ids to filter by |
| | `name`: array of names to filter by |
| | `programName`: array of program names to filter by |
| | `workspaceName`: array of workspaces to filter by |

```js
// Retrieve all lists
marketo.list.find()
marketo.list.find();

// Find lists with specific ids
marketo.list.find({id: [1, 2, 3]})
marketo.list.find({ id: [1, 2, 3] });

// The same query using CSV instead
marketo.list.find({id: '1,2,3'})
marketo.list.find({ id: '1,2,3' });

// Name in a specific program
marketo.list.find({
name: ['some name'],
workspaceName: ['Default']
})
workspaceName: ['Default'],
});
```


#### list.addLeadsToList(listId, input)

Implements [Add Leads To List](http://developers.marketo.com/documentation/rest/add-leads-to-list/)

param | type | description
------|------|------------
`listId` | int | the id of the list you want to add leads to
`input` | Array<int> | an array of lead ids to be added to the list, not CSV
| param | type | description |
| -------- | ---------- | ----------------------------------------------------- |
| `listId` | int | the id of the list you want to add leads to |
| `input` | Array<int> | an array of lead ids to be added to the list, not CSV |

```js
// Add leads 1, 2, and 3 to list id 1
marketo.list.addLeadsToList(1, [1, 2, 3])

marketo.list.addLeadsToList(1, [1, 2, 3]);

// Same thing, in object form
marketo.list.addLeadsToList(1, [{id: 1}, {id: 2}, {id: 3}])
marketo.list.addLeadsToList(1, [{ id: 1 }, { id: 2 }, { id: 3 }]);
```

#### list.getLeads(options)

Implements [Get Multiple Leads by List Id](http://developers.marketo.com/documentation/rest/get-multiple-leads-by-list-id)

param | type | description
------|------|------------
`listId` | int | the id of the list you want to get leads
`options` | object | `fields`: a comma separated list or array of fields to retrieve
| | `batchSize`: the number of lead records to be returned (max is 300)
| | `nextPageToken`: used to paginate through large result sets
| | `fields`: a comma separated list or array of fields to retrieve
| param | type | description |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------- |
| `listId` | int | the id of the list you want to get leads |
| `options` | object | `fields`: a comma separated list or array of fields to retrieve |
| | `batchSize`: the number of lead records to be returned (max is 300) |
| | `nextPageToken`: used to paginate through large result sets |
| | `fields`: a comma separated list or array of fields to retrieve |

```js
// Get leads from list id 1
marketo.list.getLeads(1)
marketo.list.getLeads(1);
```


0 comments on commit 4a9102f

Please sign in to comment.