limit Zoom meetings with max participants - api

Is there a way to create a zoom meeting for a specific max number of participants?
For example,
If a player books a "Small" package, which is up to 6 players, is it possible to create a zoom link for 7 players max (1 host + 6 players)?
If a player books a "Mid" package, which is up to 8 players, is it possible to create a zoom link for 9 players max (1 host + 8 players)?
If a player books a "Large" package, which is up to 10 players, is it possible to create a zoom link for 11 players max (1 host + 10 players)?
If a player books a "XL" package, which is for a custom number of players, is it possible to create a zoom link for that specific amount of players + 1 host?
then how can i limit number of participants who join zoom meeting
Is it can be done using Zoom API
let createZoomMeeting = (req, res, next, meetingoption) => {
return new Promise(async resolve => {
if (meetingoption) {
const jwt = require('jsonwebtoken');
const payload = {
iss: ZOOM_API_KEY,
exp: ((new Date()).getTime() + 5000)
};
const token = jwt.sign(payload, ZOOM_API_SECRET);
let optionsForHost = {
conditions: {
user_role_id: FRONT_USER_ROLE_ID,
active: ACTIVE,
is_deleted: NOT_DELETED,
is_verified: VERIFIED,
},
fields: {
_id: 1, full_name: 1, email: 1,
}
};
/**Condition for player Slug*/
optionsForHost.conditions._id = meetingoption.host_id;
/** Get host details **/
let hostResponse = await getUserData(req, res, next, optionsForHost);
/** get global zoom url and set email for particular host **/
let HOST_ZOOM_URL = MEETING_ZOOM_URL;
const host_email = hostResponse.result.email ? hostResponse.result.email : "hello#gamenitesocial.com";
HOST_ZOOM_URL = HOST_ZOOM_URL.replace("me", host_email);
if (hostResponse.status != STATUS_SUCCESS) return next(hostResponse.message);
if (!hostResponse.result) return resolve({ status: STATUS_ERROR, message: res.__("admin.system.invalid_access") });
const options = {
method: 'POST',
url: HOST_ZOOM_URL,
headers: { 'content-type': 'application/json', authorization: `Bearer ${token}` },
body: {
topic: meetingoption.game_type + ' (' + meetingoption.game_name + '-' + meetingoption.game_category_name + ')',
type: 2,
start_time: meetingoption.game_date + 'T' + meetingoption.start_time + ":00:00",
timezone: 'America/New_York',
agenda: meetingoption.game_type + ' (' + meetingoption.game_name + '-' + meetingoption.game_category_name + ')',
settings: {
host_video: true,
participant_video: true,
join_before_host: false,
mute_upon_entry: true,
use_pmi: false,
approval_type: 2,
alternative_hosts: hostResponse.result.email
}
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
return resolve({ status: STATUS_SUCCESS, result: body });
});
} else {
return resolve({ status: STATUS_ERROR, result: {} });
}
});
};// End createZoomMeeting().

You can not do this by zoom/SDK zoom SDK does not provide such type of parameter in its documentation
Reference Link: Create Zoom meeting Docs Link

Related

Google Sheets integrate with Mailerlite using API - to add multiple subscribers from Google Sheet to Mailerlite

I would like help with a google apps script. I would like to connect a Google sheet to the Mailerlite API in order to add multiple subscribers.
I would like to post each individual row from the google sheet as a subscriber in Mailerlite.
I would like a google sheet updated with the log of API responses with each trigger.
Here is the code I am using but can't get it to work. Thanks for your help!
function postUsersData() {
function getDataFromSpreadsheet() {
var usersSheetId = 11111111 // // Put your SHEET ID here
var usersSheet = getSheetById(usersSheetId)
// Users data
var values = usersSheet.getDataRange().getValues()
return values.map(function(value) {
return makePayload(values[0], value)
})
}
function postDataToMailerlite(payload) {
// API data
var url = 'https://api.mailerlite.com/api/v2/groups/'
var token = 'xxxxxxxxxxxxxxxxx' // // Put your TOKEN here
var groupId = 11111111 // // Put your GROUP ID here
var groupUrl = url + groupId + '/subscribers/import'
var params = {
'method': 'POST',
'muteHttpExceptions': true,
'headers': {
'Authorization': 'apikey ' + token,
'Content-Type': 'application/json'
},
'payload': JSON.stringify({'subscribers': payload, 'resubscribe': false, 'autoresponders': true})
};
var response = UrlFetchApp.fetch(groupUrl, params)
return JSON.parse(response.getContentText())
}
function logAction(json) {
var logsSheetId = 11111111 // // Put your SHEET ID here
var logsSheet = getSheetById(logsSheetId)
var logsSheetValues = logsSheet.getDataRange().getValues()
var payload = {
'datetime': Date(),
'imported': json.imported.length,
'unchanged': json.unchanged.length,
'updated': json.updated.length,
'errors': json.errors.length,
'errors log': json.errors
}
Object.keys(payload).forEach(function(key) {
logsSheet.getRange(logsSheetValues.length + 1, logsSheetValues[0].indexOf(key) + 1).setValue(payload[key])
})
Logger.log('Done ' + Date())
}
function getSheetById(id) {
// Get sheet by ID
return SpreadsheetApp.getActive().getSheets().filter(
function(s) {return s.getSheetId() === id;})[0];
}
function makePayload(headers, value) {
// Make single user data JSON from data based on row number
return {
'email': value[headers.indexOf('email')],
'fields': {
'full_name': value[headers.indexOf('name')],
'job': value[headers.indexOf('job')],
'trigger': value[headers.indexOf('trigger')]
}
}
}
// Perform
const data = getDataFromSpreadsheet()
const response = postDataToMailerlite(data)
logAction(response)
}

React Native - How to access variable between two buttons

Trying to learn react native here and want to reuse a variable between two "buttons" to perform tasks.
Take for example a simple workflow:
When the user presses Start a random number is generated and a
message is displayed
When the user presses Check I do some checking and display a
message according to the results.
This is my approach:
state = {
statusText: "Press Start to begin",
randNum: 0,
};
generateRandNum = () => {
var rand = Math.floor(Math.random() * 100);
return rand;
};
pressStart = () => {
this.setState({
randNum: this.generateRandNum(),
statusText: "started; " + randNum, //display randnum for simple check-debug
});
};
pressCheck = () => {
this.setState({
statusText: "checked; ",
});
};
Above, when pressStart is pressed, returns an error saying randNum is not found.
This, however, does work, but now can't access the variable elsewhere
pressStart = () => {
this.setState({
statusText: "started; " + this.generateRandNum(), //display randnum for simple check-debug
});
};
How can I properly update randNum to the generated number so that I can access it globally?
==== While the answer below works this is what I ended up using, which seems to work just the same.
pressCheck = () => {
this.setState({
statusText: "checked; " + this.state.randNum,
});
};
You never initialize randNum anywhere, so in order to use it in both places, you should give it a value before the setState.
Try this :
pressStart = () => {
const randNum = this.generateRandNum()
this.setState({
randNum: randNum,
statusText: "started; " + randNum, //display randnum for simple check-debug
});
};
pressCheck = () => {
this.setState(oldState => ({
...oldState,
statusText: "checked; " + oldState.randNum,
}));
};

Perform a POST request in the background using React Native (expo)

I am relatively new to React Native but I have a functional codebase. My app sends orders from the waiter to the kitchen. I have tested it in stores. What I need is to somehow post the order to my web app without waiting for the server to respond (assuming that all is ok) and navigate directly to the list of tables some sort of async/background job. Do I implement this using some background tasks? if yes could you point in the right direction? Also if possible no redux answers I don't know how to use it yet.
Sorry for the messy code I'm getting better.
onSendOrder = () => {
//console.log('Sending Order');
//console.log("table_id", this.props.navigation.getParam("table_id"));
// trim the contents.
let order_items = this.state.order;
// //console.log(order_items);
// const myArray = this.state.data.filter(function( obj ) {
// return obj.checked !== false;
// });
var i;
// let total_cost = 0;
let contents = []
// //console.log('total_cost: ', total_cost);
// let items = order.items;
for (i = 0; i < order_items.length; i++) {
contents = order_items[i].contents.filter(function( obj ) {
return obj.checked !== false;
});
// //console.log(contents);
order_items[i].contents = contents;
// total_cost += this.compute_item_cost(order[i]);
}
this.setState({loading:true});
//console.log('Trimed order items: ',order_items);
let order = {
"items": {
"credentials": this.state.credentials,
"personnel_id": 1,
"store_id": 1,
"order_comment": "",
"order_id": "",
"timestamp": "None",
"table_id": this.props.navigation.getParam("table_id"),
"order_items": order_items
}
};
var host = this.props.navigation.getParam('url', 'something.com');
// //console.log('SENDING ORDER TO HOST: ', host)
//console.log('ORDER OBJECT', order);
fetch("http://" + host + "/api/v1/mobile/order?store_id=1", {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(order)
})
.then(response => {
// //console.log(response.status)
// this.props.navigation.navigate('Table', { order: this.state.order });
const statusCode = response.status;
const data = response.json();
return Promise.all([statusCode, data]);
})
.then((server_response) => {
//console.log("RESULTS HERE:", server_response[0])
this.setState({
order: [],
}, function () {
if (server_response[0] == 201) {
//console.log('Success Going to Table')
this.props.navigation.navigate('Table', { order: this.state.order });
} else {
//console.log('Failed going to table')
this.props.navigation.navigate('Table', { order: this.state.order });
}
});
})
.catch((error) => {
//console.error(error);
})
};
}
import * as Notifications from 'expo-notifications';

How to optionally choose the filter from url filtering vuejs

I'm using vuejs and vuex for creating my project and I want to optionally choose filter out of this url filters. For ex: when i want to choose only city and car filter, there will be only city and car url's (...?city_id=2&car__car_model=11), but now, when I'm send id's to this action, I should send id's I want and others as blank ('') and then output is ...?city_id=2&sub_category=&sub_category=&car__car_model=&limit=&offset=.
That's my javascript code:
async filteredServices ({ commit, dispatch }, cityId = '', subCat = '', car = '', limit = '', offset = '') {
const url = 'test/service/' + '?city_id=' + cityId + '&sub_category=' + subCat + '&car__car_model=' + car + '&limit=' + limit + '&offset=' + offset
console.log('url', url)
const response = await dispatch('api/test/get', { url }, { root: true })
if (response.status === 200) {
commit('setCompanyService', response.data.results)
console.log('setCompanyService', response.data.results)
}
},
That's my html script code:
applyFilter () {
this.filteredServices(this.selectedCityId)
}
And I also try to use like this:
async filteredServices ({ commit, dispatch }, form) {
const url = 'test/service/' + '?city_id=' + form.cityId + '&sub_category=' + form.subCat + '&car__car_model=' + form.car + '&limit=' + form.limit + '&offset=' + form.offset
const response = await dispatch('api/test/get', { url }, { root: true })
if (response.status === 200) {
commit('setCompanyService', response.data.results)
console.log('setCompanyService', response.data.results)
}
},
and html code script:
applyFilter () {
this.filteredServices({
cityId: this.selectedCityId,
car: '',
subCat: 3360,
limit: '',
offset: ''
})
}
And the main question is, How to clear write url filtering with optionally choosing the filter what I want in vuejs vuex actions.

Testing CouchDB views, filters, lists, shows etc

What testing frameworks are available to test views and it's map and reduce functions, filters, lists, shows etc. of my CouchDB?
Ideally the framework allows to unit test each function, as well as provide support to test a given set of views, filters etc. against a dataset on a CouchDB instance.
I have found a blog post on writing a test suite for the CouchDB API but it's from 2010 and I was wondering what has happened since.
I would use the Expresso TDD framework for Node.js. The overhead of writing a Node.js application will not be a wasted effort.
Install Node.js from the download page: nodejs.org/download
Make sure you also get the npm (node.js package manager).
With the expresso framework you can easily test any of the RESTful functions in CouchDB.
Here is a sample node.js test that communicates with CouchDB:
var http = require('http');
var url = require('url');
var log_level = 5;
var base_url = 'http://localhost:5984/';
var delete_db_at_end = false;
/**
* This test fetches all the data from a database and verifies that the data is
* returned as it should.
*/
exports.testCouchDBCartoonsAllDocs = function(beforeExit, assert) {
curl('GET', base_url + 'cartoons/_all_docs', null, function(response) {
assert.equal(7, response.total_rows);
assert.equal('Donald Duck', response.rows[1].id);
});
}
/**
* This test creates a database for this test only and deletes it at the end if the
* global parameter delete_db_at_end is set to true, otherwise it is left as is for
* human inspection.
*
*/
exports.testCreateDatabaseTestAddAndDestroy = function(beforeExit, assert) {
var dbname = 'test_db_cartoon';
deleteExistingDatabase(dbname, assert, function(response) {
/* Create the database */
curl('PUT', base_url + dbname, null, function(response) {
assert.equal(true, response.ok);
curl('PUT', base_url + dbname + '/Donald+Duck', '{"publisher":"Walt Disney"}', function(response){
assert.equal(true, response.ok);
assert.equal('Donald Duck', response.id);
curl('GET', base_url + dbname + '/Donald+Duck', null, function(response) {
assert.equal('Donald Duck', response._id);
assert.equal('Walt Disney', response.publisher);
/* Finally we delete the database from CouchDB */
if (delete_db_at_end) {
deleteExistingDatabase(dbname, assert, function(response) {
assert.equal(true, response.ok);
});
}
});
});
});
});
}
/**
* This is a helper function that deletes the database if it exists so
* that the tests can run even if they where interrupted.
*/
function deleteExistingDatabase(dbname, assert, callback) {
curl('GET', base_url + dbname, null, function(response) {
if (response.db_name === dbname) {
log(1, 'About to delete the database ' + dbname);
curl('DELETE', base_url + '/' + dbname, null, function(response) {
callback(response);
});
} else {
callback(response);
}
});
}
/**
* This is a helper method to manage the RESTful sending to the database
*/
function curl(method, urlString, payload, callback) {
log(1, method + ' ' + urlString);
var auth = 'Basic ' + new Buffer('username:password').toString('base64');
log(7, auth);
var options = url.parse(urlString);
options.method = method;
options.headers = {
'Content-Encoding': 'UTF8',
'Content-Type': 'application/json',
'Authorization' : auth
};
log(7, options);
var req = http.request(options, function (res) {
var data = "";
res.setEncoding('UTF8');
res.on('data', function (chunk) {
data += chunk;
});
res.on('end', function (chunk) {
var response = JSON.parse(data);
log(5, response);
callback(response);
});
});
if (payload) {
req.write(payload);
}
req.end();
}
/**
* This simple logger logs message depending on the log_level set at
* the top of this file.
*/
function log(level, message) {
if (level<=log_level) {
console.log(message);
}
}
In the same folder as you have this file stored execute this command:
npm install expresso
Run the test by issuing this command:
node_modules/expresso/bin/expresso test.js
This is the console output from the command above:
GET http://localhost:5984/cartoons/_all_docs
GET http://localhost:5984/test_db_cartoon
{ error: 'not_found', reason: 'no_db_file' }
PUT http://localhost:5984/test_db_cartoon
{ total_rows: 7,
offset: 0,
rows:
[ { id: 'Batman', key: 'Batman', value: [Object] },
{ id: 'Donald Duck', key: 'Donald Duck', value: [Object] },
{ id: 'Iron Man', key: 'Iron Man', value: [Object] },
{ id: 'Mickey Mouse', key: 'Mickey Mouse', value: [Object] },
{ id: 'Spider-Man', key: 'Spider-Man', value: [Object] },
{ id: 'Superman', key: 'Superman', value: [Object] },
{ id: '_design/select', key: '_design/select', value: [Object] } ] }
{ ok: true }
PUT http://localhost:5984/test_db_cartoon/Donald+Duck
{ ok: true,
id: 'Donald Duck',
rev: '1-1c431dfb2c46991ec999743830a5363b' }
GET http://localhost:5984/test_db_cartoon/Donald+Duck
{ _id: 'Donald Duck',
_rev: '1-1c431dfb2c46991ec999743830a5363b',
publisher: 'Walt Disney' }
100% 2 tests
You can easily expand the test with additional
exports.testname = function(beforeExit, assert) {
}