Пример #1
0
 def test_can_get_contacts_component(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertIsInstance(client.contacts,
                           components.contacts.ContactsComponentV2)
Пример #2
0
###
import json
import secrets
import sys

from zoomus import ZoomClient

# noinspection PyUnresolvedReferences
client = ZoomClient(secrets.API_KEY, secrets.API_SECRET)

output_file = open('output/zoom_users_features.csv', 'w', encoding="utf-8")
user_ids = set()

# 300 seems to be the maximum page size, less pages is faster
user_list_response = client.user.list(page_size=300)
page_count = json.loads(user_list_response.content)['page_count']
for page in range(page_count):
    user = 0
    user_list_response = client.user.list(page_number=page, page_size=300)
    user_list = json.loads(user_list_response.content)['users']
    for this_user in user_list:
        user += 1
        user_id = this_user['id']
        # This is cheating, the get function isn't meant to be a get settings function, but it works
        user_get_response = client.user.get(id=str(user_id) + "/settings")
        large_meeting_enabled = (json.loads(
            user_get_response.content)['feature']['large_meeting'])
        if large_meeting_enabled:
            output_file.write(str(user_id) + "\n")
        sys.stdout.write("\rPage: " + str(page + 1) + "/" + str(page_count) +
                         " User: " + str(user))
Пример #3
0
 def test_can_get_recording_component(self):
     client = ZoomClient('KEY', 'SECRET')
     self.assertIsInstance(client.recording,
                           components.recording.RecordingComponentV2)
Пример #4
0
 def test_can_get_webinar_component(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertIsInstance(client.webinar,
                           components.webinar.WebinarComponentV2)
from datetime import datetime
import json
import os
import requests
from subprocess import check_output
import tempfile
from urllib.parse import urlparse
from zoomus import ZoomClient

ZOOM_API_KEY = os.environ['EDGI_ZOOM_API_KEY']
ZOOM_API_SECRET = os.environ['EDGI_ZOOM_API_SECRET']

MEETINGS_TO_RECORD = ['EDGI Community Standup']
DEFAULT_YOUTUBE_PLAYLIST = 'Uploads from Zoom'

client = ZoomClient(ZOOM_API_KEY, ZOOM_API_SECRET)

# Assumes first id is main account
user_id = json.loads(client.user.list().text)['users'][0]['id']


def fix_date(date_string):
    date = date_string
    index = date.find('Z')
    date = date[:index] + '.0' + date[index:]

    return date


def pretty_date(date_string):
    return datetime.strptime(date_string,
Пример #6
0
 def test_can_set_api_secret(self):
     client = ZoomClient("KEY", "SECRET")
     client.api_secret = "NEW-SECRET"
     self.assertEqual(client.api_secret, "NEW-SECRET")
Пример #7
0
 def test_can_get_report_component(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertIsInstance(client.report,
                           components.report.ReportComponentV2)
Пример #8
0
def init_client(key, secret):
    client = ZoomClient(api_key, api_secret)
    return (client)
Пример #9
0
    def form_valid(self, form):
        booth = form.save()
        request = self.request
        booth.recruiter = request.user
        recruiter = Recruiter.objects.filter(user=request.user)[0]
        # Check for scheduling conflicts
        if not recruiter_available(request, booth):
            booth.delete()
            messages.error(request, (
                'You have a scheduling conflict with another event that you have created previously.'
            ))
            return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
        # Check for career fairs, if none exist, create one
        week_number = booth.date.strftime("%V")
        year = booth.date.year
        firstdate, lastdate = getDateRangeFromWeek(year, week_number)
        booth.company = recruiter.company
        existing_fairs = Career_Fair.objects.filter(
            firstdate=firstdate,
            lastdate=lastdate,
            university=booth.university)
        if (len(existing_fairs) == 0):
            fair = Career_Fair.objects.create(university=booth.university,
                                              firstdate=firstdate,
                                              lastdate=lastdate)
        else:
            fair = existing_fairs[0]
            existing_booths = Career_Booth.objects.filter(
                career_fair=fair, company=booth.company)
            if (len(existing_booths) > 0):
                booth.delete()
                messages.error(request, (
                    'You have a scheduling conflict with another event that you have created previously.'
                ))
                return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

        booth.career_fair = fair

        # Set up booth_name
        if booth.booth_name == None:
            booth.booth_name = booth.company + "Booth"
        """ code below will create dictionary for signup """

        dictionary = Dictionary_Booth.objects.create(career_booth=booth)

        signup_slots = list(
            time_slots(booth.time_start, booth.time_end,
                       booth.interview_duration, booth.rest_duration))
        """ Keyval values"""
        for time in signup_slots:
            t = datetime.datetime.strptime(time, '%H:%M')
            time_end = (t +
                        datetime.timedelta(minutes=booth.interview_duration))
            time_end = time_end.strftime('%H:%M')
            KeyVal.objects.create(container=dictionary,
                                  key=time,
                                  end=time_end,
                                  value=None)

        # for time in signup_slots:
        # 	KeyVal.objects.create(container=dictionary, key=time, value=None)
        """Here is the Zoom link creation"""
        with ZoomClient('BLKlHrYJQE2Zfc5VN7YgmQ',
                        'X729m575QKEgWrymCCNjICxE13TJTfzf43sO') as client:
            date_str = str(booth.date)
            time_str = str(booth.time_start)
            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.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()
            booth.join_zoom_url = create_meeting_json['join_url']
            booth.start_zoom_url = create_meeting_json['start_url']

        form.save()
        messages.success(
            request,
            ('You have successfully signed up for a booth at a career fair'))
        return HttpResponseRedirect('/career_fair')
Пример #10
0
 def test_can_get_room_component(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertIsInstance(client.room, components.room.RoomComponentV2)
Пример #11
0
 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])
Пример #12
0
 def test_can_get_group_component(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertIsInstance(client.group, components.group.GroupComponentV2)
Пример #13
0
 def test_can_get_phone_component(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertIsInstance(client.phone, components.phone.PhoneComponentV2)
Пример #14
0
 def test_can_get_live_stream_component(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertIsInstance(client.live_stream,
                           components.live_stream.LiveStreamComponentV2)
Пример #15
0
 def test_can_set_api_key(self):
     client = ZoomClient("KEY", "SECRET")
     client.api_key = "NEW-KEY"
     self.assertEqual(client.api_key, "NEW-KEY")
Пример #16
0
 def test_can_use_client_with_context(self):
     with ZoomClient("KEY", "SECRET") as client:
         self.assertIsInstance(client, ZoomClient)
Пример #17
0
 def test_can_get_api_secret(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertEqual(client.api_secret, "SECRET")
Пример #18
0
 def test_refresh_token_replaces_config_token_with_new_jwt(self, mock_jwt):
     client = ZoomClient("KEY", "SECRET")
     client.refresh_token()
     mock_jwt.assert_called_with("KEY", "SECRET")
     self.assertEqual(client.config["token"], (mock_jwt.return_value, ))
Пример #19
0
 def test_can_get_meeting_component(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertIsInstance(client.meeting,
                           components.meeting.MeetingComponentV2)
Пример #20
0
 def test_invalid_api_version_raises_error(self):
     with self.assertRaisesRegexp(RuntimeError,
                                  "API version not supported: 42"):
         ZoomClient("KEY", "SECRET", version=42)
Пример #21
0
 def test_can_get_user_component(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertIsInstance(client.user, components.user.UserComponentV2)
Пример #22
0
 def test_init_sets_config_with_timeout(self):
     client = ZoomClient("KEY", "SECRET", timeout=500)
     self.assertEqual(client.timeout, 500)
Пример #23
0
import pytz

# Import environmental variables
load_dotenv()

app = Flask(__name__)
app.secret_key = os.getenv("FLASK_SECRET")

API_KEY = os.getenv('API_KEY')
API_SECRET = os.getenv('API_SECRET')
EMAIL_ADDRESS = os.getenv('USER_EMAIL')

# regex pattern for validating the time
regex_start_time = r"[0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}"
# Create Zoom Client
client = ZoomClient(API_KEY, API_SECRET)


# define a route for the application that supports POST
# requests
@app.route("/meeting", methods=["POST"])
def meeting():

    # convert incoming message to lower case and remove
    # trailing whitespace
    in_msg = request.values.get("Body", "").strip().lower()
    resp = MessagingResponse()
    msg = resp.message()

    # List meetings
    if in_msg == "1" or "one" in in_msg:
Пример #24
0
 def test_cannot_init_with_non_int_timeout(self):
     with self.assertRaises(ValueError) as context:
         ZoomClient("KEY", "SECRET", timeout="bad")
         self.assertEqual(context.exception.message,
                          "timeout value must be an integer")
Пример #25
0
 def init_app(self, app):
     app.zoom_client = ZoomClient(app.config['ZOOM_API_KEY'],
                                  app.config['ZOOM_API_SECRET'])
Пример #26
0
 def test_api_version_defaults_to_2(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertEqual(client.config["version"], API_VERSION_2)
Пример #27
0
def get_call_logs(API_KEY: str,
                  API_SECRET: str,
                  from_date: datetime.datetime,
                  number_of_days: int = 1,
                  call_direction: str = 'all'):
    '''
    Script to access Zoom Phone Call Log via marketplace.zoom.us API

    --call_direction can be used to limit results to 'outbound' or 'inbound' calls
    '''

    client = ZoomClient(API_KEY, API_SECRET)

    # Create ZM User object
    user_list_response = client.user.list()
    user_list = json.loads(user_list_response.content)

    # Create ZP User object
    phone_user_list_response = client.phone.users()
    phone_user_list = json.loads(phone_user_list_response.content)

    # Set Call Log Query Parameters
    page_size = 300

    # Set end date based on from_date + number of days ( zoom Call log API is limited to max 30 days in a single query)
    end_date = from_date + datetime.timedelta(days=number_of_days)

    # Set headers for CSV file
    headers = [
        'email', 'dept', 'job_title', 'caller_number', 'caller_number_type',
        'caller_name', 'callee_number', 'callee_number_type', 'callee_name',
        'direction', 'duration', 'result', 'date_time'
    ]

    error_count = 0

    # Create CSV file, query Call Log API, and write data
    filename = datetime.datetime.now().strftime('call-logs-%Y-%m-%d-%H-%M.csv')
    with open(filename, 'w', newline='') as output_file:
        dict_writer = csv.DictWriter(output_file,
                                     extrasaction='ignore',
                                     fieldnames=headers)
        dict_writer.writeheader()

        # iterate phone users
        for user in phone_user_list['users']:
            time.sleep(
                1.25
            )  # delay due to Zoom Phone Call Log API rate limit ( 1 request per second )
            print(f" Getting Call Logs for user {user['email']}")
            try:
                # find the ZP users ZM user profile
                zm_user_info_temp = ''
                zm_user_info_temp = next(
                    item for item in user_list['users']
                    if item["email"].lower() == user['email'].lower())

                # Handle users that don't have a department specified. ( Set 'dept' to '' to prevent future error)
                if 'dept' not in zm_user_info_temp:
                    zm_user_info_temp['dept'] = ''

                # Get Title from user profile ( title is not provided in the list ZM users API call, so need to query each ZM user to get this. )
                user_get_response = client.user.get(id=user['email'])
                user_get = json.loads(user_get_response.content)
                user_title_temp = user_get['job_title']

                # Get Call Logs for this user
                next_page_token = ""
                first_run = True

                while next_page_token != "" or first_run:

                    phone_user_call_logs_response = client.phone.user_call_logs(
                        page_size=page_size,
                        email=user['email'],
                        start_date=from_date,
                        end_date=end_date,
                        next_page_token=next_page_token)
                    phone_user_call_logs = json.loads(
                        phone_user_call_logs_response.content)

                    if phone_user_call_logs['total_records'] > 0:

                        # filter call logs as needed
                        if call_direction == 'inbound':
                            # only keep inbound calls
                            phone_user_call_logs['call_logs'] = [
                                x for x in phone_user_call_logs['call_logs']
                                if x['direction'] == 'inbound'
                            ]
                        elif call_direction == 'outbound':
                            # only keep outbound calls
                            phone_user_call_logs['call_logs'] = [
                                x for x in phone_user_call_logs['call_logs']
                                if x['direction'] == 'outbound'
                            ]

                        # loop through all returned call logs & add data for additional columns as required
                        for user_call_log in phone_user_call_logs['call_logs']:
                            user_call_log.update({
                                'email':
                                zm_user_info_temp['email'],
                                'dept':
                                zm_user_info_temp['dept'],
                                'job_title':
                                user_title_temp
                            })

                        dict_writer.writerows(
                            phone_user_call_logs['call_logs'])

                    next_page_token = phone_user_call_logs['next_page_token']
                    first_run = False
            except:
                print(f" FAILED retrieving call Logs for user {user['email']}")
                error_count += 1

    # Print error count
    print(f"Errors encountered: {error_count}")
Пример #28
0
 def test_can_get_api_key(self):
     client = ZoomClient("KEY", "SECRET")
     self.assertEqual(client.api_key, "KEY")
Пример #29
0
 def test_can_use_client_with_context(self):
     with ZoomClient('KEY', 'SECRET') as client:
         self.assertIsInstance(client, ZoomClient)
Пример #30
0
 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])