diff --git a/.github/workflows/run_linter.yml b/.github/workflows/run_linter.yml index 265fdfd..28ff5cc 100644 --- a/.github/workflows/run_linter.yml +++ b/.github/workflows/run_linter.yml @@ -23,4 +23,4 @@ jobs: pip install flake8 - name: Lint with flake8 run: | - flake8 */ --count --max-complexity=10 --max-line-length=120 --statistics \ No newline at end of file + flake8 */ --count --ignore=F821 --max-complexity=10 --max-line-length=120 --statistics \ No newline at end of file diff --git a/common/client.py b/common/client.py index c581d17..9130797 100644 --- a/common/client.py +++ b/common/client.py @@ -1,6 +1,7 @@ from sinch import SinchClient sinch_client = SinchClient( - application_key="YOUR_application_key", - application_secret="YOUR_application_secret" + key_id="YOUR_KEY_ID", + key_secret="YOUR_KEY_SECRET", + project_id="YOUR_PROJECT_ID" ) diff --git a/common/client_with_environment_variables.py b/common/client_with_environment_variables.py index 95dd118..9348eb2 100644 --- a/common/client_with_environment_variables.py +++ b/common/client_with_environment_variables.py @@ -2,6 +2,7 @@ from sinch import SinchClient sinch_client = SinchClient( - application_key=os.getenv("APPLICATION_KEY"), - application_secret=os.getenv("APPLICATION_SECRET") + key_id=os.getenv("KEY_ID"), + key_secret=os.getenv("KEY_SECRET"), + project_id=os.getenv("PROJECT_ID") ) diff --git a/common/voice_and_verification_client.py b/common/voice_and_verification_client.py new file mode 100644 index 0000000..2ee7168 --- /dev/null +++ b/common/voice_and_verification_client.py @@ -0,0 +1,6 @@ +from sinch import SinchClient + +sinch_client = SinchClient( + application_key="YOUR_APPLICATION_KEY", + application_secret="YOUR_APPLICATION_SECRET" +) diff --git a/common/voice_and_verification_client_with_environment_variables.py b/common/voice_and_verification_client_with_environment_variables.py new file mode 100644 index 0000000..95dd118 --- /dev/null +++ b/common/voice_and_verification_client_with_environment_variables.py @@ -0,0 +1,7 @@ +import os +from sinch import SinchClient + +sinch_client = SinchClient( + application_key=os.getenv("APPLICATION_KEY"), + application_secret=os.getenv("APPLICATION_SECRET") +) diff --git a/numbers/rent_and_configure_a_virtual_number.py b/numbers/rent_and_configure_a_virtual_number.py index 4721931..6e33bba 100644 --- a/numbers/rent_and_configure_a_virtual_number.py +++ b/numbers/rent_and_configure_a_virtual_number.py @@ -1,11 +1,3 @@ -from sinch import SinchClient - -sinch_client = SinchClient( - key_id="YOUR_key_id", - key_secret="YOUR_key_secret", - project_id="YOUR_project_id" -) - activate_number_response = sinch_client.numbers.available.activate( phone_number="YOUR_phone_number", sms_configuration={ diff --git a/numbers/rent_and_configure_a_virtual_number_using_rest.py b/numbers/rent_and_configure_a_virtual_number_using_rest.py deleted file mode 100644 index 7e0958d..0000000 --- a/numbers/rent_and_configure_a_virtual_number_using_rest.py +++ /dev/null @@ -1,31 +0,0 @@ -import requests - -project_id = "YOUR_projectId" -phone_number = "YOUR_phoneNumber" -url = "https://numbers.api.sinch.com/v1/projects/" + project_id + "/availableNumbers/" + phone_number + ":rent" - -payload = { - "smsConfiguration": { - "servicePlanId": "YOUR_servicePlanId", - "scheduledProvisioning": { - "status": "WAITING", - "errorCodes": [ - "INTERNAL_ERROR" - ] - }, - "campaignId": "YOUR_10DLC_campaignId" - }, - "voiceConfiguration": { - "appId": "YOUR_appId", - "scheduledProvisioning": { - "status": "WAITING" - } - } -} - -headers = {"Content-Type": "application/json"} - -response = requests.post(url, json=payload, headers=headers, auth=('YOUR_username', 'YOUR_password')) - -data = response.json() -print(data) diff --git a/numbers/rent_any_number.py b/numbers/rent_any_number.py index 8e8c373..a49fe43 100644 --- a/numbers/rent_any_number.py +++ b/numbers/rent_any_number.py @@ -1,11 +1,3 @@ -from sinch import SinchClient - -sinch_client = SinchClient( - key_id="YOUR_key_id", - key_secret="YOUR_key_secret", - project_id="YOUR_project_id" -) - activate_number_response = sinch_client.numbers.available.rent_any( region_code="YOUR_region_code", type_="YOUR_number_type", diff --git a/numbers/search_for_a_virtual_number_using_rest.py b/numbers/search_for_a_virtual_number_using_rest.py deleted file mode 100644 index 5ec6d86..0000000 --- a/numbers/search_for_a_virtual_number_using_rest.py +++ /dev/null @@ -1,13 +0,0 @@ -import requests - -project_id = "YOUR_projectId" -url = "https://numbers.api.sinch.com/v1/projects/" + project_id + "/availableNumbers" - -query = { - "regionCode": "US", - "type": "LOCAL" -} -response = requests.get(url, params=query, auth=('YOUR_username', 'YOUR_password')) - -data = response.json() -print(data) diff --git a/numbers/search_for_virtual_number.py b/numbers/search_for_virtual_number.py index bbebfbd..8d8d2bb 100644 --- a/numbers/search_for_virtual_number.py +++ b/numbers/search_for_virtual_number.py @@ -1,11 +1,3 @@ -from sinch import SinchClient - -sinch_client = SinchClient( - key_id="YOUR_key_id", - key_secret="YOUR_key_secret", - project_id="YOUR_project_id" -) - available_numbers_response = sinch_client.numbers.available.list( region_code="YOUR_region_code", number_type="YOUR_number_type" diff --git a/sms/send_sms_message.py b/sms/send_sms_message.py index da3ee3c..5d991b2 100644 --- a/sms/send_sms_message.py +++ b/sms/send_sms_message.py @@ -1,11 +1,3 @@ -from sinch import SinchClient - -sinch_client = SinchClient( - key_id="YOUR_key_id", - key_secret="YOUR_key_secret", - project_id="YOUR_project_id" -) - send_batch_response = sinch_client.sms.batches.send( body="Hello from Sinch!", to=["YOUR_to_number"], diff --git a/sms/send_sms_using_rest.py b/sms/send_sms_using_rest.py deleted file mode 100644 index 9c43fd2..0000000 --- a/sms/send_sms_using_rest.py +++ /dev/null @@ -1,25 +0,0 @@ -import requests - -service_plan_id = "" -api_token = "" -sinch_number = "" -to_number = "" -url = "https://us.sms.api.sinch.com/xms/v1/" + service_plan_id + "/batches" - -payload = { - "from": sinch_number, - "to": [ - to_number - ], - "body": "Hello how are you" -} - -headers = { - "Content-Type": "application/json", - "Authorization": "Bearer " + api_token -} - -response = requests.post(url, json=payload, headers=headers) - -data = response.json() -print(data) diff --git a/verification/initiate_sms_verification.py b/verification/initiate_sms_verification.py index 303822c..fd67e2c 100644 --- a/verification/initiate_sms_verification.py +++ b/verification/initiate_sms_verification.py @@ -1,11 +1,5 @@ -from sinch import SinchClient from sinch.domains.verification.models import VerificationIdentity -sinch_client = SinchClient( - application_key="YOUR_application_key", - application_secret="YOUR_application_secret" -) - response = sinch_client.verification.verifications.start_sms( identity=VerificationIdentity( type="number", diff --git a/verification/verification_domain.py b/verification/verification_domain.py index 1c0cb5e..c999c58 100644 --- a/verification/verification_domain.py +++ b/verification/verification_domain.py @@ -1,9 +1,3 @@ -from sinch import SinchClient from sinch.domains.verification import Verification -sinch_client = SinchClient( - application_key="YOUR_application_key", - application_secret="YOUR_application_secret" -) - verification_client = Verification(sinch_client) diff --git a/voice/text_to_speech.py b/voice/text_to_speech.py index a61bd56..b117adc 100644 --- a/voice/text_to_speech.py +++ b/voice/text_to_speech.py @@ -1,10 +1,3 @@ -from sinch import SinchClient - -sinch_client = SinchClient( - application_key="YOUR_application_key", - application_secret="YOUR_application_secret" -) - response = sinch_client.voice.callouts.text_to_speech( destination={ "type": "number", diff --git a/voice/text_to_speech_using_rest.py b/voice/text_to_speech_using_rest.py deleted file mode 100644 index 7b818b2..0000000 --- a/voice/text_to_speech_using_rest.py +++ /dev/null @@ -1,28 +0,0 @@ -import requests - -key = "" -secret = "" -from_number = "" -to = "" -locale = "" -url = "https://calling.api.sinch.com/calling/v1/callouts" - -payload = { - "method": "ttsCallout", - "ttsCallout": { - "cli": from_number, - "destination": { - "type": "number", - "endpoint": to - }, - "locale": locale, - "text": "Hello, this is a call from Sinch. Congratulations! You made your first call." - } -} - -headers = {"Content-Type": "application/json"} - -response = requests.post(url, json=payload, headers=headers, auth=(key, secret)) - -data = response.json() -print(data) diff --git a/voice/voice_domain.py b/voice/voice_domain.py index 24588fa..a4c46fd 100644 --- a/voice/voice_domain.py +++ b/voice/voice_domain.py @@ -1,9 +1,3 @@ -from sinch import Client from sinch.domains.voice import Voice -sinch_client = Client( - application_key="YOUR_application_key", - application_secret="YOUR_application_secret" -) - voice_client = Voice(sinch_client)