Skip to content
Closed
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
5 changes: 5 additions & 0 deletions api-module-library/clubworx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# v0.0.1 (Nov 4 2022)

#### Generated

- Initialized from template
9 changes: 9 additions & 0 deletions api-module-library/clubworx/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2022 Left Hook Inc.

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:

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

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.
5 changes: 5 additions & 0 deletions api-module-library/clubworx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# clubworx

This is the API Module for clubworx that allows the [Frigg](https://friggframework.org) code to talk to the clubworx API.

Read more on the [Frigg documentation site](https://docs.friggframework.org/api-modules/list/clubworx
311 changes: 311 additions & 0 deletions api-module-library/clubworx/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
const { ApiKeyRequester } = require('@friggframework/module-plugin');
const { get } = require('@friggframework/assertions');

class Api extends ApiKeyRequester {
constructor(params) {
super(params);

this.ACCOUNT_KEY = get(params, 'accountKey', null);

// Keep as function going forward?
this.baseUrl = () => {
// return 'https://app.cwx-staging.com';
return 'https://app.clubworx.com/api/v2';
};

this.URLs = {
webhooks: '/hooks',
webhookByID: (webhookId) => `/hooks/${webhookId}`,
members: '/members',
memberByID: (memberId) => `/members/${memberId}`,
memberships: '/memberships',
membershipPlans: '/membership_plans',
prospects: '/prospects',
prospectByID: (prospectId) => `/prospects/${prospectId}`,
prospectStatuses: '/prospect_statuses',
nonAttendingContacts: '/non_attending_contacts',
nonAttendingContactByID: (nonAttendingContactId) =>
`/non_attending_contacts/${nonAttendingContactId}`,
};
}

async createWebhook(event, targetURL) {
const options = {
url: this.baseUrl() + this.URLs.webhooks,
headers: {
'content-type': 'application/json',
},
query: {
account_key: this.ACCOUNT_KEY,
},
body: {
target_url: targetURL,
event,
},
};
const response = await this._post(options);
return response;
}

async deleteWebhook(webhookId) {
const options = {
url:
this.baseUrl() +
this.URLs.webhookByID(webhookId) +
'/unsubscribe',
headers: {
'content-type': 'application/json',
},
query: {
account_key: this.ACCOUNT_KEY,
},
};
const response = await this._delete(options);
return response;
}

async listAllMembershipPlans(query) {
const options = {
url: this.baseUrl() + this.URLs.membershipPlans,
headers: {
'content-type': 'application/json',
},
query: {
account_key: this.ACCOUNT_KEY,
},
};
if (query) {
for (const [key, value] of Object.entries(query)) {
options.query[key] = value;
}
}

const response = await this._get(options);
return response;
}

async listAllMembers(query) {
const options = {
url: this.baseUrl() + this.URLs.members,
headers: {
'content-type': 'application/json',
},
query: {
account_key: this.ACCOUNT_KEY,
},
};
if (query) {
for (const [key, value] of Object.entries(query)) {
options.query[key] = value;
}
}

const response = await this._get(options);
return response;
}

async retrieveMember(contactKey) {
const options = {
url: this.baseUrl() + this.URLs.memberByID(contactKey),
headers: {
'content-type': 'application/json',
},
query: {
account_key: this.ACCOUNT_KEY,
},
};

const response = await this._get(options);
return response;
}

async createMember(params) {
const options = {
url: this.baseUrl() + this.URLs.members,
headers: {
'content-type': 'application/json',
},
query: params,
};
options.query.account_key = this.ACCOUNT_KEY;

const response = await this._post(options);
return response;
}

async updateMember(contactKey, params) {
const options = {
url: this.baseUrl() + this.URLs.memberByID(contactKey),
headers: {
'content-type': 'application/json',
},
query: params,
};
options.query.account_key = this.ACCOUNT_KEY;

const response = await this._put(options);
return response;
}

async addMembership(params) {
const options = {
url: this.baseUrl() + this.URLs.memberships,
headers: {
'content-type': 'application/json',
},
query: params,
};
options.query.account_key = this.ACCOUNT_KEY;

const response = await this._post(options);
return response;
}

async listAllProspectStatuses(query) {
const options = {
url: this.baseUrl() + this.URLs.prospectStatuses,
headers: {
'content-type': 'application/json',
},
query: {
account_key: this.ACCOUNT_KEY,
},
};
if (query) {
for (const [key, value] of Object.entries(query)) {
options.query[key] = value;
}
}

const response = await this._get(options);
return response;
}

async listAllProspects(query) {
const options = {
url: this.baseUrl() + this.URLs.prospects,
headers: {
'content-type': 'application/json',
},
query: {
account_key: this.ACCOUNT_KEY,
},
};
if (query) {
for (const [key, value] of Object.entries(query)) {
options.query[key] = value;
}
}

const response = await this._get(options);
return response;
}

async retrieveProspect(contactKey) {
const options = {
url: this.baseUrl() + this.URLs.prospectByID(contactKey),
headers: {
'content-type': 'application/json',
},
query: {
account_key: this.ACCOUNT_KEY,
},
};

const response = await this._get(options);
return response;
}

async createProspect(params) {
const options = {
url: this.baseUrl() + this.URLs.prospects,
headers: {
'content-type': 'application/json',
},
query: params,
};
options.query.account_key = this.ACCOUNT_KEY;

const response = await this._post(options);
return response;
}

async updateProspect(contactKey, params) {
const options = {
url: this.baseUrl() + this.URLs.prospectByID(contactKey),
headers: {
'content-type': 'application/json',
},
query: params,
};
options.query.account_key = this.ACCOUNT_KEY;

const response = await this._put(options);
return response;
}

async listAllNonAttendingContacts(query) {
const options = {
url: this.baseUrl() + this.URLs.nonAttendingContacts,
headers: {
'content-type': 'application/json',
},
query: {
account_key: this.ACCOUNT_KEY,
},
};
if (query) {
for (const [key, value] of Object.entries(query)) {
options.query[key] = value;
}
}

const response = await this._get(options);
return response;
}

async retrieveNonAttendingContact(contactKey) {
const options = {
url: this.baseUrl() + this.URLs.nonAttendingContactByID(contactKey),
headers: {
'content-type': 'application/json',
},
query: {
account_key: this.ACCOUNT_KEY,
},
};

const response = await this._get(options);
return response;
}

async createNonAttendingContact(params) {
const options = {
url: this.baseUrl() + this.URLs.nonAttendingContacts,
headers: {
'content-type': 'application/json',
},
query: params,
};
options.query.account_key = this.ACCOUNT_KEY;

const response = await this._post(options);
return response;
}

async updateNonAttendingContact(contactKey, params) {
const options = {
url: this.baseUrl() + this.URLs.nonAttendingContactByID(contactKey),
headers: {
'content-type': 'application/json',
},
query: params,
};
options.query.account_key = this.ACCOUNT_KEY;

const response = await this._put(options);
return response;
}
}

module.exports = { Api };
20 changes: 20 additions & 0 deletions api-module-library/clubworx/authFields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const AuthFields = {
jsonSchema: {
type: 'object',
required: ['accountKey'],
properties: {
accountKey: {
type: 'string',
title: 'Account Key',
},
},
},
uiSchema: {
apiKey: {
'ui:help': 'Your Clubworx Account Key.',
'ui:placeholder': 'Your Clubworx Access Token...',
},
},
};

module.exports = AuthFields;
9 changes: 9 additions & 0 deletions api-module-library/clubworx/defaultConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "clubworx",
"label": "clubworx",
"productUrl": "",
"apiDocs": "",
"logoUrl": "https://friggframework.org/assets/img/clubworx.jpeg",
"categories": [],
"description": "clubworx"
}
13 changes: 13 additions & 0 deletions api-module-library/clubworx/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { Api } = require('./api');
const { Credential } = require('./models/credential');
const { Entity } = require('./models/entity');
const ModuleManager = require('./manager');
const Config = require('./defaultConfig');

module.exports = {
Api,
Credential,
Entity,
ModuleManager,
Config,
};
2 changes: 2 additions & 0 deletions api-module-library/clubworx/jest-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const { globalSetup } = require('@friggframework/test-environment');
module.exports = globalSetup;
2 changes: 2 additions & 0 deletions api-module-library/clubworx/jest-teardown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const { globalTeardown } = require('@friggframework/test-environment');
module.exports = globalTeardown;
Loading