11import os ,time ,ssl
22from dotenv import load_dotenv
3- from ringcentral import SDK
43import certifi
54import urllib .request
5+ import sys
6+ sys .path .append (os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' , '..' ))) # Add the project root to sys.path
7+ from ringcentral import SDK
68
79load_dotenv ()
810#env = dotenv_values(".env")
@@ -23,17 +25,14 @@ def send_fax():
2325 'coverPageText' : "This is a demo Fax page from Python"
2426 })
2527
26- with open ('test.txt' , "r" ) as f :
27- content = f .read ()
28- #attachment = ('test.jpg', content)
29- attachment = (
30- 'test.png' ,
31- urllib .request .urlopen ('https://www.ringcentral.com/content/dam/rc-2018/en_us/images/logo.jpg' ,
32- context = ssl .create_default_context (cafile = certifi .where ())).read (),
33- 'image/png'
34- )
35- builder .add (attachment )
36- request = builder .request ('/restapi/v1.0/account/~/extension/~/fax' )
28+ attachment = (
29+ 'test.png' ,
30+ urllib .request .urlopen ('https://www.ringcentral.com/content/dam/rc-2018/en_us/images/logo.jpg' ,
31+ context = ssl .create_default_context (cafile = certifi .where ())).read (),
32+ 'image/png'
33+ )
34+ builder .add (attachment )
35+ request = builder .request ('/restapi/v1.0/account/~/extension/~/fax' )
3736 resp = platform .send_request (request )
3837 jsonObj = resp .json ()
3938 print ("Fax sent. Message id: " + str (jsonObj .id ))
@@ -59,7 +58,7 @@ def check_fax_message_status(messageId):
5958# Authenticate a user using a personal JWT token
6059def login ():
6160 try :
62- platform .login ( jwt = os .environ .get ('RINGCENTRAL_JWT_TOKEN' ) )
61+ platform .login (jwt = os .environ .get ('RINGCENTRAL_JWT_TOKEN' ) )
6362 send_fax ()
6463 except Exception as e :
6564 print ("Unable to authenticate to platform. Check credentials." + str (e ))
0 commit comments