pipedrive-api-client
v1.1.0
Published
PipeDrive API wrapper.
Downloads
8
Readme
PipeDrive API wrapper for JavaScript
PipeDrive API wrapper. api docs.
Installation
Node.js
npm i pipedrive-api-client -S
Usage with api token
import PipeDrive from 'pipedrive-api-client'
const pd = new PipeDrive({
apiToken: 'xxxxxx',
host: 'https://your-pipedrive-domain.pipedrive.com'
})
let r = await gc.get('/v1/users/me')
.then(d => d.data)
.catch(console.log)
expect(r.success).toBe(true)
Usage with oauth
import PipeDrive from 'pipedrive-api-client'
const pd = new PipeDrive({
redirectUri: 'https://xxxxxx.com/oauth',
clientId: 'xxxxxx',
clientSecret: 'yyyyyy'
})
const loginUrl = pd.authorizeUri('some_state_string')
app.get('/oauth', (req, res) {
const { code } = req.query
await pd.authorize(code)
let r = await pd.get('/v1/users/me')
.then(d => d.data)
.catch(console.log)
expect(r.success).toBe(true)
})
Check examples/server.js as basic example server side code.
APIs
// constructor
const pd = new PipeDrive({
host?: string,
apiToken?: string,
clientId?: string,
clientSecret?: string,
oauthServer?: string,
redirectUri?: string,
appName?: string,
appVersion?: string,
token?: Token,
logger?: Logger
})
// refresh token
pd.refresh()
// revoke token
pd.revoke()
// rest request
pg.get(url, options)
pg.delete(url, data, options)
pg.post(url, data, options)
pg.put(url, data, options)
// options: check https://axios-http.com/docs/req_config
Test
cp .sample.env .env
# edit .env fill required fields
npm run test
Credits
Based on Tyler's https://github.com/tylerlong/ringcentral-js-concise.
License
MIT