copper@1.0.0
This adaptor exports the following from common:
- as()
- combine()
- cursor()
- dataPath()
- dataValue()
- dateFns
- each()
- field()
- fields()
- fn()
- fnIf()
- group()
- lastReferenceValue()
- map()
- merge()
- scrubEmojis()
- sourceValue()
- util
- combine()
Functions
request
request(method, path, body, options) ⇒ Operation
Make a general HTTP request to the Copper API
| Param | Type | Description |
|---|---|---|
| method | string | HTTP method to use |
| path | string | Path to resource, relative to https://api.copper.com/developer_api/v1 |
| body | object | Object which will be attached to the request body |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
Example
request('POST', 'leads/search', { page_size: 25 });
upsertLead
upsertLead(properties, [match]) ⇒ Operation
Create or update a Copper lead. If no lead matches, a new lead is created.
If exactly one lead matches, it is updated. If several leads match, an error is thrown.
By default leads are matched on properties.email.email.
Writes the created or updated lead to state.data.
| Param | Type | Description |
|---|---|---|
| properties | object | Lead fields to set, as described in the Copper lead schema |
| [match] | LeadMatch | Match criteria. Defaults to matching on email. |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
Example: Upsert a lead, matching on email
upsertLead({
name: 'Ada Lovelace',
email: { email: 'ada@example.com', category: 'work' },
company_name: 'Analytical Engines',
});
Example: Upsert a lead from a lemlist activity
upsertLead($ => ({
name: `${$.data.leadFirstName} ${$.data.leadLastName}`,
email: { email: $.data.leadEmail, category: 'work' },
company_name: $.data.leadCompanyName,
}));
Example: Upsert a lead, matching on name
upsertLead(
{ name: 'Ada Lovelace', title: 'Mathematician' },
{ field_name: 'name', field_value: 'Ada Lovelace' }
);
Interfaces
HttpState
State object
Properties
| Name | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
LeadMatch
Lead match criteria
Properties
| Name | Type | Description |
|---|---|---|
| field_name | string | The field to match on: email, name, or a custom field |
| field_value | string | The value to match |
RequestOptions
Options provided to the HTTP request
Properties
| Name | Type | Description |
|---|---|---|
| errors | object | Map of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code. |
| query | object | An object of query parameters to be encoded into the URL. |
| headers | object | An object of headers to append to the request. |
| parseAs | string | Parse the response body as json, text or stream. By default will use the response headers. |
| timeout | number | Request timeout in ms. Default: 300 seconds. |