def test_can_set_custom_base_uri(self): client = ZoomClient( "KEY", "SECRET", version=util.API_VERSION_1, base_uri="https://www.test.com" ) self.assertEqual(client.config["version"], util.API_VERSION_1) for key in client.components.keys(): self.assertEqual(client.components[key].base_uri, "https://www.test.com")
def test_can_set_api_version_to_1(self): client = ZoomClient("KEY", "SECRET", version=util.API_VERSION_1) self.assertEqual(client.config["version"], util.API_VERSION_1) for key in client.components.keys(): self.assertEqual( client.components[key].base_uri, API_BASE_URIS[util.API_VERSION_1] )
def test_can_set_api_version_to_1_and_set_custom_base_uri(self): client = ZoomClient("KEY", "SECRET", base_uri=API_BASE_URIS[util.API_GDPR]) self.assertEqual(client.config["version"], util.API_VERSION_2) for key in client.components.keys(): self.assertEqual( client.components[key].base_uri, API_BASE_URIS[util.API_GDPR] )
def test_api_version_defaults_to_2(self): client = ZoomClient("KEY", "SECRET") self.assertEqual(client.config["version"], util.API_VERSION_2) for key in client.components.keys(): self.assertEqual( client.components[key].base_uri, API_BASE_URIS[util.API_VERSION_2] )
def generic_zoom_request(request="report/daily", params=None, request_type='get', proxies=None): """Perform an unlisted request on zoom""" if proxies is None: proxies = PROXIES # noinspection PyUnresolvedReferences,PyUnresolvedReferences client = ZoomClient(API_KEY, API_SECRET) if params is None: params = {} headers = { "Authorization": "Bearer {}".format(client.config.get("token")), 'content-type': "application/json" } result = None if request_type == 'get': result = requests.get('https://api.zoom.us/v2/' + request, params, headers=headers, proxies=proxies) elif request_type == 'patch': result = requests.patch('https://api.zoom.us/v2/' + request, data=params, headers=headers, proxies=proxies) elif request_type == 'post': result = requests.post('https://api.zoom.us/v2/' + request, data=params, headers=headers, proxies=proxies) return result
def test_init_sets_config(self): client = ZoomClient('KEY', 'SECRET') self.assertEqual(client.config, { 'api_key': 'KEY', 'api_secret': 'SECRET', 'data_type': 'json' })
def zoom(request): try: client = ZoomClient('3NKu1UtkSpW1FiCCrFrykg', '5qq7tR3ZBS2lJth3FgAqUasKDxP5KiYPMVPF') user_list_response = client.user.list() user_list = json.loads(user_list_response.content) client_id = (user_list['users'][0]['id']) dtime = request.POST.get("datetime_field") date_time = dtime.split(" ") date = date_time[0].split("-") time = date_time[1].split(":") zoom_date = format_date(int(date[0]), int(date[1]), int(date[2]), int(time[0]), int(time[1]), int(time[2])) settings = {"host_video": True,"participant_video": True,"cn_meeting": False ,"in_meeting": False,"join_before_host": True, "mute_upon_entry": False,"watermark": False,"use_pmi": False,"approval_type": 2,"audio": "both","auto_recording": "none","alternative_hosts": "","close_registration": True,"waiting_room": False,"contact_name": "me","contact_email": "*****@*****.**","registrants_email_notification": True,"meeting_authentication": False,"authentication_option": "","authentication_domains": ""} meeting = client.meeting.create(user_id=client_id, start_time=zoom_date, topic="Study Buddy Meeting", settings=settings) content = json.loads(meeting.content) link = content["join_url"] buddy_pk = request.POST.getlist('zoom_item')[0] buddy_account = userAccount.objects.get(pk=buddy_pk) currentUser = userAccount.objects.get(user=request.user) buddyObject = currentUser.getBuddyObject(buddy_account) meeting_object = ZoomMeeting(buddies=buddyObject, meeting_link=link, start_time=dtime) meeting_object.save() messages.add_message(request, messages.SUCCESS, "Meeting created successfully") src_url = request.META.get('HTTP_REFERER') if src_url != None: return redirect(src_url) else: return HttpResponseRedirect(reverse('userAccount:view_buddies')) except: if(request.user.is_authenticated): messages.add_message(request, messages.ERROR, "Error creating zoom meeting") return HttpResponseRedirect(reverse('userAccount:view_buddies')) else: messages.add_message(request, messages.ERROR, "Login before attempting to view contact information") return HttpResponseRedirect(reverse('login:login'))
def zoom_grabby(): zoom_key = 'FILLMEIN' zoom_secret = 'FILLMEIN' zoom_token = 'FILLMEIN' def getz(path, raw=False, **params): res = requests.get("%s/%s" % (zoom_api, path), auth=(zoom_token, ""), params=params) return res.text if raw else res.json() custom_key = str(input('custom api key? (y/n): ')) if 'y' in custom_key: print('') zoom_key = input('plz input your api key!~') timeframe = input('daily/monthly/yearly: ') client = ZoomClient(zoom_key, zoom_secret) with open('zoom_%s_%s_data.csv' % (run_date,timeframe), mode='w', newline='') as data_file: data_writer = csv.writer(data_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) print('') print('--------------------') print('writing initial row~') print('--------------------') print('') data_writer.writerow(['Meeting Minutes','Participants','Total Meetings']) time.sleep(2) start_date zoom_users = getz(client.report.get_account_report())['total_meetings'] #zoom_users = str(zoom_users) for zoom_user in zoom_users: print('') print('--------------------') print('writing table to file~') print('--------------------') print('') data_writer.writerows([zoom_user])
def test_init_creates_all_components(self): client = ZoomClient("KEY", "SECRET") self.assertEqual( set(["meeting", "past_meeting", "report", "user", "webinar", "recording"]), set(client.components.keys()), ) self.assertIsInstance( client.components["meeting"], components.meeting.MeetingComponentV2 ) self.assertIsInstance( client.components["past_meeting"], components.past_meeting.PastMeetingComponentV2, ) self.assertIsInstance( client.components["report"], components.report.ReportComponentV2 ) self.assertIsInstance( client.components["user"], components.user.UserComponentV2 ) self.assertIsInstance( client.components["webinar"], components.webinar.WebinarComponentV2 ) self.assertIsInstance( client.components["recording"], components.recording.RecordingComponentV2 )
def main(): # Get zoom client zoom_client = ZoomClient(api_key=os.environ['ZOOM_API_KEY'], api_secret=os.environ['ZOOM_API_SECRET']) # Get current open zoom meetings response = zoom_client.meeting.list(user_id=os.environ['ZOOM_USER_ID']) open_meetings = json.loads(response.content) # Delete old zoom meetings now = datetime.utcnow().replace(tzinfo=timezone.utc) for meeting in open_meetings['meetings']: dt = datetime.strptime( meeting['start_time'], '%Y-%m-%dT%H:%M:%SZ').replace(tzinfo=timezone.utc) if dt < now - timedelta(hours=1): zoom_client.meeting.delete(id=meeting['id']) # Create new zoom meeting response = zoom_client.meeting.create( user_id=os.environ['ZOOM_USER_ID'], settings=dict(join_before_host=True, waiting_room=False), ) new_meeting = json.loads(response.content) # Create a telegram bot bot = telegram.Bot(token=os.environ['TELEGRAM_BOT_TOKEN']) # Send zoom join url through telegram bot bot.send_message(chat_id=os.environ['TELEGRAM_CHAT_ID'], text=new_meeting['join_url'])
def get_zoom_url(): import json from zoomus import ZoomClient from zoomus.components import meeting from app import app client = ZoomClient(app.config.get('ZOOM_API_KEY'), app.config.get('ZOOM_API_SECRET')) user_list_response = client.user.list() user_list = json.loads(user_list_response.content) for user in user_list['users']: user_id = user['id'] print(json.loads(client.meeting.list(user_id=user_id).content)) new_meeting = client.meeting.create(user_id=user_id).json() join_url = new_meeting['join_url'] id = request.args.get('appointment_id') appointment = Appointment.get_or_none(Appointment.id == id) appointment.zoom_url = join_url appointment.start_datetime = appointment.start_datetime.strftime( "%Y-%m-%d %H:%M:%S") appointment.end_datetime = appointment.end_datetime.strftime( "%Y-%m-%d %H:%M:%S") if appointment.save(): return join_url else: return "fail"
def form_valid(self, form): event = form.save() request = self.request event.main_recruiter = request.user # Check for scheduling conflicts if not recruiter_available(request, event): event.delete() messages.error(request, ( 'You have a scheduling conflict with another event that you have created previously.' )) return HttpResponseRedirect(request.META.get('HTTP_REFERER')) event.space_open = event.rsvp_capacity with ZoomClient('BLKlHrYJQE2Zfc5VN7YgmQ', 'X729m575QKEgWrymCCNjICxE13TJTfzf43sO') as client: date_str = str(event.date) time_str = str(event.start_time) year = int(date_str[:4]) month = int(date_str[5:7]) day = int(date_str[8:]) HH = int(time_str[:2]) MM = int(time_str[3:5]) SS = 00 startTime = datetime(year, month, day, HH, MM, SS) create_meeting_response = client.meeting.create( user_id='me', start_time=startTime) create_meeting_json = create_meeting_response.json() event.join_zoom_url = create_meeting_json['join_url'] event.start_zoom_url = create_meeting_json['start_url'] #print(create_meeting_json) form.save() messages.success(request, _('You have successfully created your event')) return HttpResponseRedirect('/event')
def run(zoom_api_key, zoom_api_secret, webhook_url, timezone): timezone = tz.gettz(timezone) client = ZoomClient(zoom_api_key, zoom_api_secret) user_list_response = client.user.list() user_list = json.loads(user_list_response.content) for user in user_list['users']: user_id = user['id'] meetings = json.loads(client.meeting.list(user_id=user_id, type='upcoming', page_size=300).content)['meetings'] conflicts = determine_conflicts(meetings) if conflicts: for conflict in conflicts: report = f'Conflict detected on account {user["email"]}\n' (meeting_1, meeting_2) = conflict time_format = "%m/%d/%Y, %I:%M:%S %p" meeting_1_start = meeting_1.start_time.astimezone(timezone).strftime(time_format) meeting_1_end = meeting_1.end_time.astimezone(timezone).strftime(time_format) meeting_2_start = meeting_2.start_time.astimezone(timezone).strftime(time_format) meeting_2_end = meeting_2.end_time.astimezone(timezone).strftime(time_format) report += f'{meeting_1.title}: {meeting_1_start} - {meeting_1_end}\n' report += f'{meeting_2.title}: {meeting_2_start} - {meeting_2_end}\n' report_conflict(webhook_url, report) else: logging.info('No upcoming conflicts detected')
def mock_zoom_client(self): client = ZoomClient(TestZoom.FAKE_SECRET, TestZoom.FAKE_SECRET) client.meeting.create = MagicMock(return_value=self.mock_response()) client.meeting.delete = MagicMock(return_value=self.mock_response()) client.meeting.get = MagicMock(return_value=self.mock_response()) client.meeting.list = MagicMock(return_value=self.mock_response()) return client
def test_init_sets_config(self): client = ZoomClient('KEY', 'SECRET') self.assertEqual( client.config, { 'api_key': 'KEY', 'api_secret': 'SECRET', 'data_type': 'json', 'token': util.generate_jwt('KEY', 'SECRET'), 'version': API_VERSION_2, })
def test_init_creates_all_components(self): client = ZoomClient("KEY", "SECRET") self.assertEqual( set( [ "contacts", "live_stream", "meeting", "metric", "past_meeting", "phone", "recording", "report", "user", "webinar", "group", ] ), set(client.components.keys()), ) self.assertIsInstance( client.components["contacts"], components.contacts.ContactsComponentV2 ) self.assertIsInstance( client.components["meeting"], components.meeting.MeetingComponentV2 ) self.assertIsInstance( client.components["metric"], components.metric.MetricComponentV2 ) self.assertIsInstance( client.components["past_meeting"], components.past_meeting.PastMeetingComponentV2, ) self.assertIsInstance( client.components["report"], components.report.ReportComponentV2 ) self.assertIsInstance( client.components["user"], components.user.UserComponentV2 ) self.assertIsInstance( client.components["webinar"], components.webinar.WebinarComponentV2 ) self.assertIsInstance( client.components["recording"], components.recording.RecordingComponentV2 ) self.assertIsInstance( client.components["phone"], components.phone.PhoneComponentV2 ) self.assertIsInstance( client.components["group"], components.group.GroupComponentV2 ) self.assertIsInstance( client.components["live_stream"], components.live_stream.LiveStreamComponentV2, )
def view_meeting_form(meeting_form_id): # Grab meeting form and the creator meeting_form = MeetingForm.query.get_or_404(meeting_form_id) creator = meeting_form.creator # Make zoom client using creator's credentials zoom_client = ZoomClient(creator.api_key, creator.api_secret) # If the form is not active if not meeting_form.active: flash("This form is not available to fill out anymore.", "info") return redirect(url_for("home")) # If form is still active form = MeetingRegistrationForm() if form.validate_on_submit(): # Check if the registrant already signed up for the meeting through any other form. registrant = Registrant.query\ .join(MeetingForm, Registrant.meeting_form_id == MeetingForm.id)\ .filter(MeetingForm.meeting_id==meeting_form.meeting_id).first() # If so, they can't sign up again on this form anymore if registrant: flash("You already signed up for this meeting through one of our forms.", "danger") return redirect(url_for("view_meeting_form", meeting_form_id=meeting_form.id)) # If not, then send a request to the server through the Zoom client request_body = { "email": form.email.data, "first_name": form.first_name.data, "last_name": form.last_name.data } response = zoom_client.meeting.post_request(f"/meetings/{meeting_form.meeting_id}/registrants", data=request_body) response_json = json.loads(response.content) # If the status code is 200, add the registrant's info to the DB print(response_json) if response_json["code"] == 200: registrant = Registrant( email=form.email.data, first_name=form.first_name.data, last_name=form.last_name.data, address=form.address.data, job_title=form.job_title.data, register_form=meeting_form ) db.session.add(registrant) db.session.commit() return render_template("meeting_register_complete.html") else: flash(f"Error: {response_json['message']}") return render_template("meeting_form_submittable.html", form=form, title="Meeting Form", legend=f"{meeting_form.meeting_form_name}")
def __init__(self): self.client = ZoomClient(settings.ZOOM_KEY, settings.ZOOM_SECRET) # Make sure we only do this once if (ZoomProxy.user_id == None): user_list_response = self.client.user.list() user_list = json.loads(user_list_response.content) ZoomProxy.user_id = user_list['users'][0]['id'] ZoomProxy.logger.info("Zoom User ID is %s", ZoomProxy.user_id)
def get_meeting_detail(self, request): """ Get meeting detail Params: id: int, host_id: text """ data = self.request.data client = ZoomClient(ZOOM_API_KEY, ZOOM_API_SECRET) meetings = json.loads(client.meeting.get(**data).content) return Response(status=status.HTTP_200_OK, data=meetings)
def setup(): client = ZoomClient("ughCBh93TRyPCf9Xzkoy3Q", "jgngXqwIQQw5gvYOEiEXLKAn4vP51byGIj1R", version=1) user_list_response = client.user.list() user_list = json.loads(user_list_response.content) user_id = '' for user in user_list['users']: user_id = user['id'] print(json.loads(client.meeting.list(host_id=user_id).content)) return user_id, client
def test_init_sets_config(self): client = ZoomClient("KEY", "SECRET") self.assertEqual( client.config, { "api_key": "KEY", "api_secret": "SECRET", "data_type": "json", "token": util.generate_jwt("KEY", "SECRET"), "version": API_VERSION_2, }, )
def create_zoom_calls(): while true: date = pd.Timestamp.now() hour = date.hour print("Hour: ", hour) response = table.query( KeyConditionExpression=Key('timeslots').eq(str(hour))) print(response) data = response['Items'][0]['zoomlink'] print(data) if (data == 'WAIT'): client = ZoomClient(ZOOM_KEY, ZOOM_SECRET) user_list_response = client.user.list() user_list = json.loads(user_list_response.content) zoom_meeting = None for user in user_list['users']: user_id = user['id'] zoom_meeting = client.meeting.create(topic="Meeting", type=2, duration=30, user_id=user_id, agenda="", host_id=user_id, settings={ 'host_video': False, 'participant_video': True, 'join_before_host': True, 'waiting_room': False, 'jbh_time': 0 }) t = ((zoom_meeting.json())) table.update_item( Key={'timeslots': str(hour)}, UpdateExpression="set zoomlink=:r", ExpressionAttributeValues={':r': str(t['join_url'])}, ReturnValues="UPDATED_NEW") print('Updated with zoomlink') for x in range(0, 24): if x != hour: table.update_item(Key={'timeslots': str(x)}, UpdateExpression="set zoomlink=:r", ExpressionAttributeValues={':r': 'WAIT'}, ReturnValues="UPDATED_NEW") print('Finished writing')
def test_init_creates_all_components(self): client = ZoomClient('KEY', 'SECRET') self.assertEqual( set(['meeting', 'report', 'user', 'webinar', 'recording']), set(client.components.keys())) self.assertIsInstance(client.components['meeting'], components.meeting.MeetingComponentV2) self.assertIsInstance(client.components['report'], components.report.ReportComponentV2) self.assertIsInstance(client.components['user'], components.user.UserComponentV2) self.assertIsInstance(client.components['webinar'], components.webinar.WebinarComponentV2) self.assertIsInstance(client.components['recording'], components.recording.RecordingComponentV2)
def __init__(self, api_key, api_secret, host_id, start_date, duration_min=10, filter_meeting_by_name=False, only_meeting_names=None): self.client = ZoomClient(api_key, api_secret) self.session_client = ZoomSessionClient(api_key, api_secret) self.host_id = host_id self.start_date = start_date self.duration_min = duration_min self.filter_meeting_by_name = filter_meeting_by_name self.only_meeting_names = only_meeting_names or []
def home(): if current_user.is_authenticated: zoom_client = ZoomClient(current_user.api_key, current_user.api_secret) meeting_list_response = zoom_client.meeting.list(user_id="me") # Grab all meetings associated with this API credentials meetings = json.loads(meeting_list_response.content)['meetings'] meetings_id = [meeting["id"] for meeting in meetings] # Get all forms that this user owns that are associated with this API client meeting_forms = MeetingForm.query\ .join(User, MeetingForm.user_id == current_user.id)\ .filter(MeetingForm.meeting_id.in_(meetings_id)).all() else: meetings = [] meeting_forms = [] return render_template('home.html', meetings=meetings, meeting_forms=meeting_forms)
def validate(self): """ Send a test request to see if this API credentials are valid """ rv = FlaskForm.validate(self) if not rv: return False client = ZoomClient(api_key=self.api_key.data, api_secret=self.api_secret.data) response = json.loads(client.user.list().content) # If invalid credentials, raise error to the form. if response.get("code") != 200: self.api_key.errors.append(response.get("message")) self.api_secret.errors.append(response.get("message")) return False return True
def get_meetings(self, request): """ Get all meetings of user params: no """ client = ZoomClient(ZOOM_API_KEY, ZOOM_API_SECRET) user_list_response = client.user.list() user_list = json.loads(user_list_response.content.decode('utf-8')) for user in user_list['users']: user_id = user['id'] meetings = json.loads( client.meeting.list(user_id=user_id).content.decode('utf-8')) return Response(status=status.HTTP_200_OK, data=meetings)
def construct_rabbit_msg(self, payload, token): now = time.asctime() logging.info("Constructing rabbit msg") zoom_client = ZoomClient(API_KEY, API_SECRET) user_list_response = zoom_client.user.get( id=payload["object"]["host_id"]) user_list = json.loads(user_list_response.content.decode("utf-8")) recording_files = [] rec_id = [] meeting_id = payload["object"]["uuid"] for file in payload["object"]["recording_files"]: if file["file_type"].lower() == "mp4": rec_id.append(file["id"]) recording_files.append({ "recording_id": file["id"], "recording_start": file["recording_start"], "recording_end": file["recording_end"], "download_url": file["download_url"], "file_type": file["file_type"], "recording_type": file["recording_type"] }) rabbit_msg = { "uuid": meeting_id, "zoom_series_id": payload["object"]["id"], "topic": payload["object"]["topic"], "start_time": payload["object"]["start_time"], "duration": payload["object"]["duration"], "host_id": payload["object"]["host_id"], "recording_files": recording_files, "token": token, "received_time": now, "creator": user_list["location"] } logging.info("Constructed Rabbit Msg") return rabbit_msg, rec_id, meeting_id
class MeetingDetailView(DetailView): model = Meeting nombre = Meeting.numero_de_meeting host_id = "7pCPQl2tSC-S9QoSbZ3RHA" client = ZoomClient('g7MZBr7GT3CdFn07F1F2Bw', 'jEJouAV2JgKAEHLHe0eQogUL7yvKHHaDXY3y', host_id) lista = client.meeting meeting = lista.get(id='268601917',host_id='7pCPQl2tSC-S9QoSbZ3RHA') print(meeting) context_object_name = 'meetings' # your own name for the list as a template variable # Get 5 books containing the title war template_name = 'videoclase/meeting_detail.html' # Specify your own template name/location def get_context_data(self, **kwargs): context = super(MeetingDetailView, self).get_context_data(**kwargs) context['meeting'] = self.meeting context['lista'] = self.lista return context
class Meeting(models.Model): pass client = ZoomClient('g7MZBr7GT3CdFn07F1F2Bw', 'jEJouAV2JgKAEHLHe0eQogUL7yvKHHaDXY3y') host_id = "7pCPQl2tSC-S9QoSbZ3RHA" lista = client.meeting.list numero_de_meeting = models.CharField(max_length=30) with open('static/datos.json') as f: data = json.load(f) meeting_lista = data slug = models.SlugField(max_length=100, default=numero_de_meeting) def __str__(self): return self.numero_de_meeting
def test_can_set_api_secret(self): client = ZoomClient('KEY', 'SECRET') client.api_secret = 'NEW-SECRET' self.assertEqual(client.api_secret, 'NEW-SECRET')
def test_can_set_api_key(self): client = ZoomClient('KEY', 'SECRET') client.api_key = 'NEW-KEY' self.assertEqual(client.api_key, 'NEW-KEY')