Skip to content

Commit f9160ea

Browse files
authored
Merge pull request #3 from sinch/DEVEXP-963-Numbers_Snippets
DEVEXP-963: Numbers Snippets
2 parents 3c1f783 + 6d1bd21 commit f9160ea

File tree

14 files changed

+161
-39
lines changed

14 files changed

+161
-39
lines changed

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SINCH_PROJECT_ID=
2+
SINCH_KEY_ID=
3+
SINCH_KEY_SECRET=

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ celerybeat.pid
9393
*.sage.py
9494

9595
# Environments
96-
.env
9796
.venv
9897
env/
9998
venv/
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python-snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
19
from sinch import SinchClient
210

11+
load_dotenv()
12+
313
sinch_client = SinchClient(
4-
project_id="YOUR_PROJECT_ID",
5-
key_id="KEY_ID",
6-
key_secret="KEY_SECRET"
14+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
15+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
16+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET"
717
)
818

9-
phone_number = "YOUR_RENTED_PHONE_NUMBER"
19+
phone_number = "MY_SINCH_PHONE_NUMBER"
1020
response = sinch_client.numbers.get(phone_number=phone_number)
1121

1222
print(f"Rented number details:\n{response}")

snippets/numbers/active_numbers/list/snippet.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python-snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
19
from sinch import SinchClient
210

11+
load_dotenv()
12+
313
sinch_client = SinchClient(
4-
project_id="YOUR_PROJECT_ID",
5-
key_id="KEY_ID",
6-
key_secret="KEY_SECRET"
14+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
15+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
16+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET"
717
)
818

919
active_numbers = sinch_client.numbers.list(

snippets/numbers/active_numbers/list_auto/snippet.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python-snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
19
from sinch import SinchClient
210

11+
load_dotenv()
12+
313
sinch_client = SinchClient(
4-
project_id="YOUR_PROJECT_ID",
5-
key_id="KEY_ID",
6-
key_secret="KEY_SECRET"
14+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
15+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
16+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET"
717
)
818

919
active_numbers = sinch_client.numbers.list(

snippets/numbers/active_numbers/release/snippet.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python-snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
19
from sinch import SinchClient
210

11+
load_dotenv()
12+
313
sinch_client = SinchClient(
4-
project_id="YOUR_PROJECT_ID",
5-
key_id="KEY_ID",
6-
key_secret="KEY_SECRET"
14+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
15+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
16+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET"
717
)
818

919
phone_number = "PHONE_NUMBER_TO_BE_RELEASED"

snippets/numbers/active_numbers/update/snippet.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python-snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
19
from sinch import SinchClient
210
from sinch.domains.numbers.models.v1.types import VoiceConfigurationDictType
311

12+
load_dotenv()
13+
414
sinch_client = SinchClient(
5-
project_id="YOUR_PROJECT_ID",
6-
key_id="KEY_ID",
7-
key_secret="KEY_SECRET"
15+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
16+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
17+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET"
818
)
919

1020
phone_number = "PHONE_NUMBER"

snippets/numbers/available_numbers/check_availability/snippet.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python-snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
19
from sinch import SinchClient
210

11+
load_dotenv()
12+
313
sinch_client = SinchClient(
4-
project_id="YOUR_PROJECT_ID",
5-
key_id="KEY_ID",
6-
key_secret="KEY_SECRET"
14+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
15+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
16+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET"
717
)
818

919
phone_number = "PHONE_NUMBER"

snippets/numbers/available_numbers/rent/snippet.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
from sinch.domains.numbers.models.v1.types import SmsConfigurationDict
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python-snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
29
from sinch import SinchClient
10+
from sinch.domains.numbers.models.v1.types import SmsConfigurationDict
11+
12+
load_dotenv()
313

414
sinch_client = SinchClient(
5-
project_id="YOUR_PROJECT_ID",
6-
key_id="KEY_ID",
7-
key_secret="KEY_SECRET"
15+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
16+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
17+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET"
818
)
919

1020
phone_number = "AVAILABLE_PHONE_NUMBER_TO_BE_RENTED"

snippets/numbers/available_numbers/rent_any/snippet.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python-snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
19
from sinch import SinchClient
210
from sinch.domains.numbers.models.v1.types import (
311
NumberPatternDict, SmsConfigurationDict, VoiceConfigurationDictType
412
)
513

14+
load_dotenv()
15+
616
sinch_client = SinchClient(
7-
project_id="YOUR_PROJECT_ID",
8-
key_id="KEY_ID",
9-
key_secret="KEY_SECRET"
17+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
18+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
19+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET"
1020
)
1121

1222
sms_configuration: SmsConfigurationDict = {

0 commit comments

Comments
 (0)