@friggframework/api-module-pipedrive 0.8.6 → 0.8.9-canary.40.6738541.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Left Hook Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/api.js CHANGED
@@ -1,12 +1,13 @@
1
- const OAuth2Base = require('../../base/auth/OAuth2Base');
1
+ const { OAuth2Requester } = require('@friggframework/module-plugin');
2
+ const { get } = require('@friggframework/assertions');
2
3
 
3
- class Api extends OAuth2Base {
4
+ class Api extends OAuth2Requester {
4
5
  constructor(params) {
5
6
  super(params);
6
7
 
7
- this.access_token = this.getParam(params, 'access_token', null);
8
- this.refresh_token = this.getParam(params, 'refresh_token', null);
9
- this.companyDomain = this.getParam(params, 'companyDomain', null);
8
+ this.access_token = get(params, 'access_token', null);
9
+ this.refresh_token = get(params, 'refresh_token', null);
10
+ this.companyDomain = get(params, 'companyDomain', null);
10
11
  this.baseURL = () => `${this.companyDomain}/api`;
11
12
 
12
13
  this.client_id = process.env.PIPEDRIVE_CLIENT_ID;
@@ -84,9 +85,9 @@ class Api extends OAuth2Base {
84
85
  }
85
86
 
86
87
  async createActivity(params) {
87
- const dealId = this.getParam(params, 'dealId', null);
88
- const subject = this.getParam(params, 'subject');
89
- const type = this.getParam(params, 'type');
88
+ const dealId = get(params, 'dealId', null);
89
+ const subject = get(params, 'subject');
90
+ const type = get(params, 'type');
90
91
  const options = {
91
92
  url: this.baseURL() + this.URLs.activities,
92
93
  body: { ...params },
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "name": "pipedrive",
3
+ "label": "PipeDrive CRM",
3
4
  "productUrl": "https://pipedrive.com",
4
5
  "apiDocs": "https://developer.pipedrive.com",
5
6
  "logoUrl": "https://friggframework.org/assets/img/pipedrive.jpeg",
package/jest.config.js CHANGED
@@ -1,3 +1,21 @@
1
- module.exports = async () => {
2
- preset: '@friggframework/test-environment';
1
+ /*
2
+ * For a detailed explanation regarding each configuration property, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ module.exports = {
7
+ // preset: '@friggframework/test-environment',
8
+ coverageThreshold: {
9
+ global: {
10
+ statements: 13,
11
+ branches: 0,
12
+ functions: 1,
13
+ lines: 13,
14
+ },
15
+ },
16
+ // A path to a module which exports an async function that is triggered once before all test suites
17
+ globalSetup: '../../scripts/set-up-tests.js',
18
+
19
+ // A path to a module which exports an async function that is triggered once after all test suites
20
+ globalTeardown: '../../scripts/tear-down-tests.js',
3
21
  };
package/manager.js CHANGED
@@ -2,13 +2,14 @@ const _ = require('lodash');
2
2
  const { Api } = require('./api.js');
3
3
  const { Entity } = require('./models/entity');
4
4
  const { Credential } = require('./models/credential');
5
- const LHModuleManager = require('../../base/managers/LHModuleManager');
6
- const ModuleConstants = require('../ModuleConstants');
7
- const { update } = require('lodash');
8
- const { flushDebugLog, debug } = require('../../utils/logger');
5
+ const {
6
+ ModuleManager,
7
+ ModuleConstants,
8
+ } = require('@friggframework/module-plugin');
9
+ const { flushDebugLog, debug } = require('@friggframework/logs');
9
10
  const Config = require('./defaultConfig.json');
10
11
 
11
- class Manager extends LHModuleManager {
12
+ class Manager extends ModuleManager {
12
13
  static Entity = Entity;
13
14
 
14
15
  static Credential = Credential;
@@ -64,7 +65,7 @@ class Manager extends LHModuleManager {
64
65
  }
65
66
 
66
67
  async processAuthorizationCallback(params) {
67
- const code = this.getParam(params.data, 'code');
68
+ const code = get(params.data, 'code');
68
69
  await this.api.getTokenFromCode(code);
69
70
  await this.testAuth();
70
71
 
@@ -82,8 +83,8 @@ class Manager extends LHModuleManager {
82
83
  }
83
84
 
84
85
  async findOrCreateEntity(params) {
85
- const companyId = this.getParam(params, 'companyId');
86
- const companyName = this.getParam(params, 'companyName');
86
+ const companyId = get(params, 'companyId');
87
+ const companyName = get(params, 'companyName');
87
88
 
88
89
  const search = await this.entityMO.list({
89
90
  user: this.userId,
@@ -0,0 +1,26 @@
1
+ const Manager = require('./manager');
2
+ const mongoose = require('mongoose');
3
+ const config = require('./defaultConfig.json');
4
+
5
+ describe(`Should fully test the ${config.label} Manager`, () => {
6
+ let manager, userManager;
7
+
8
+ beforeAll(async () => {
9
+ await mongoose.connect(process.env.MONGO_URI);
10
+ manager = await Manager.getInstance({
11
+ userId: new mongoose.Types.ObjectId(),
12
+ });
13
+ });
14
+
15
+ afterAll(async () => {
16
+ await Manager.Credential.deleteMany();
17
+ await Manager.Entity.deleteMany();
18
+ await mongoose.disconnect();
19
+ });
20
+
21
+ it('should return auth requirements', async () => {
22
+ const requirements = await manager.getAuthorizationRequirements();
23
+ expect(requirements).exists;
24
+ expect(requirements.type).toEqual('oauth2');
25
+ });
26
+ });
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.8.6",
2
+ "version": "0.8.9-canary.40.6738541.0",
3
3
  "name": "@friggframework/api-module-pipedrive",
4
4
  "prettier": "@friggframework/prettier-config",
5
5
  "description": "",
@@ -11,15 +11,16 @@
11
11
  "author": "",
12
12
  "license": "MIT",
13
13
  "devDependencies": {
14
- "@friggframework/eslint-config": "^1.0.0",
15
- "@friggframework/test-environment": "^1.0.0",
16
- "eslint": "^7.32.0",
17
- "jest": "^27.4.7",
18
- "prettier": "^2.5.1",
19
- "sinon": "^12.0.1"
14
+ "@friggframework/eslint-config": "^1.0.7",
15
+ "@friggframework/test-environment": "^1.1.3",
16
+ "eslint": "^8.22.0",
17
+ "jest": "^28.1.3",
18
+ "prettier": "^2.7.1",
19
+ "sinon": "^14.0.0"
20
20
  },
21
21
  "dependencies": {
22
- "@friggframework/module-plugin": "^1.0.4",
23
- "@friggframework/assertions": "^1.0.1"
24
- }
22
+ "@friggframework/assertions": "^1.0.4",
23
+ "@friggframework/module-plugin": "^1.0.11"
24
+ },
25
+ "gitHead": "67385416143012a99d736edd0ffaace260721d92"
25
26
  }