File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
2+ from dotenv import load_dotenv
3+ from sinch import SinchClient
4+
5+ load_dotenv ()
6+
7+ sinch_client = SinchClient (
8+ project_id = os .environ .get ("SINCH_PROJECT_ID" ) or "MY_PROJECT_ID" ,
9+ key_id = os .environ .get ("SINCH_KEY_ID" ) or "MY_KEY_ID" ,
10+ key_secret = os .environ .get ("SINCH_KEY_SECRET" ) or "MY_KEY_SECRET" ,
11+ sms_region = os .environ .get ("SINCH_SMS_REGION" ) or "MY_SMS_REGION"
12+ )
13+
14+ batch_id = "MY_BATCH_ID"
15+ response = sinch_client .sms .batches .cancel (batch_id = batch_id )
16+
17+ print (f"Cancelled batch:\n { response } " )
Original file line number Diff line number Diff line change 1+ import os
2+ from dotenv import load_dotenv
3+ from sinch import SinchClient
4+ from sinch .domains .sms .models .v1 .internal .dry_run_request import DryRunTextRequest
5+
6+ load_dotenv ()
7+
8+ sinch_client = SinchClient (
9+ project_id = os .environ .get ("SINCH_PROJECT_ID" ) or "MY_PROJECT_ID" ,
10+ key_id = os .environ .get ("SINCH_KEY_ID" ) or "MY_KEY_ID" ,
11+ key_secret = os .environ .get ("SINCH_KEY_SECRET" ) or "MY_KEY_SECRET" ,
12+ sms_region = os .environ .get ("SINCH_SMS_REGION" ) or "MY_SMS_REGION"
13+ )
14+
15+ request = DryRunTextRequest (
16+ to = ["+1234567890" ],
17+ from_ = "+2345678901" ,
18+ body = "Test message for dry run"
19+ )
20+
21+ response = sinch_client .sms .batches .dry_run (request = request )
22+
23+ print (f"Dry run result:\n { response } " )
Original file line number Diff line number Diff line change 1+ import os
2+ import base64
3+ from dotenv import load_dotenv
4+ from sinch import SinchClient
5+
6+ load_dotenv ()
7+
8+ sinch_client = SinchClient (
9+ project_id = os .environ .get ("SINCH_PROJECT_ID" ) or "MY_PROJECT_ID" ,
10+ key_id = os .environ .get ("SINCH_KEY_ID" ) or "MY_KEY_ID" ,
11+ key_secret = os .environ .get ("SINCH_KEY_SECRET" ) or "MY_KEY_SECRET" ,
12+ sms_region = os .environ .get ("SINCH_SMS_REGION" ) or "MY_SMS_REGION"
13+ )
14+
15+ # Example: Encode message body as Base64
16+ message = "Test message for dry run"
17+ body = base64 .b64encode (message .encode ('utf-8' )).decode ('utf-8' )
18+
19+ # Example: UDH header (HEX encoded)
20+ udh = "06050423F423F4"
21+
22+ response = sinch_client .sms .batches .dry_run_binary (
23+ to = ["+1234567890" ],
24+ from_ = "+2345678901" ,
25+ body = body ,
26+ udh = udh
27+ )
28+
29+ print (f"Dry run result:\n { response } " )
Original file line number Diff line number Diff line change 1+ import os
2+ from dotenv import load_dotenv
3+ from sinch import SinchClient
4+ from sinch .domains .sms .models .v1 .shared import MediaBody
5+
6+ load_dotenv ()
7+
8+ sinch_client = SinchClient (
9+ project_id = os .environ .get ("SINCH_PROJECT_ID" ) or "MY_PROJECT_ID" ,
10+ key_id = os .environ .get ("SINCH_KEY_ID" ) or "MY_KEY_ID" ,
11+ key_secret = os .environ .get ("SINCH_KEY_SECRET" ) or "MY_KEY_SECRET" ,
12+ sms_region = os .environ .get ("SINCH_SMS_REGION" ) or "MY_SMS_REGION"
13+ )
14+
15+ body = MediaBody (
16+ url = "https://example.com/image.jpg" ,
17+ message = "Test message for dry run"
18+ )
19+
20+ response = sinch_client .sms .batches .dry_run_mms (
21+ to = ["+1234567890" ],
22+ from_ = "+2345678901" ,
23+ body = body
24+ )
25+
26+ print (f"Dry run result:\n { response } " )
Original file line number Diff line number Diff line change 1+ import os
2+ from dotenv import load_dotenv
3+ from sinch import SinchClient
4+
5+ load_dotenv ()
6+
7+ sinch_client = SinchClient (
8+ project_id = os .environ .get ("SINCH_PROJECT_ID" ) or "MY_PROJECT_ID" ,
9+ key_id = os .environ .get ("SINCH_KEY_ID" ) or "MY_KEY_ID" ,
10+ key_secret = os .environ .get ("SINCH_KEY_SECRET" ) or "MY_KEY_SECRET" ,
11+ sms_region = os .environ .get ("SINCH_SMS_REGION" ) or "MY_SMS_REGION"
12+ )
13+
14+ batch_id = "MY_BATCH_ID"
15+ response = sinch_client .sms .batches .get (batch_id = batch_id )
16+
17+ print (f"Batch details:\n { response } " )
Original file line number Diff line number Diff line change 1+ import os
2+ from dotenv import load_dotenv
3+ from sinch import SinchClient
4+
5+ load_dotenv ()
6+
7+ sinch_client = SinchClient (
8+ project_id = os .environ .get ("SINCH_PROJECT_ID" ) or "MY_PROJECT_ID" ,
9+ key_id = os .environ .get ("SINCH_KEY_ID" ) or "MY_KEY_ID" ,
10+ key_secret = os .environ .get ("SINCH_KEY_SECRET" ) or "MY_KEY_SECRET" ,
11+ sms_region = os .environ .get ("SINCH_SMS_REGION" ) or "MY_SMS_REGION"
12+ )
13+
14+ batches = sinch_client .sms .batches .list (
15+ page = 0 ,
16+ page_size = 10
17+ )
18+
19+ page_counter = 1
20+ reached_last_page = False
21+
22+ while not reached_last_page :
23+ print (f"Page { page_counter } List of Batches: { batches } " )
24+
25+ if batches .has_next_page :
26+ batches = batches .next_page ()
27+ page_counter += 1
28+ else :
29+ reached_last_page = True
Original file line number Diff line number Diff line change 1+ import os
2+ from dotenv import load_dotenv
3+ from sinch import SinchClient
4+
5+ load_dotenv ()
6+
7+ sinch_client = SinchClient (
8+ project_id = os .environ .get ("SINCH_PROJECT_ID" ) or "MY_PROJECT_ID" ,
9+ key_id = os .environ .get ("SINCH_KEY_ID" ) or "MY_KEY_ID" ,
10+ key_secret = os .environ .get ("SINCH_KEY_SECRET" ) or "MY_KEY_SECRET" ,
11+ sms_region = os .environ .get ("SINCH_SMS_REGION" ) or "MY_SMS_REGION"
12+ )
13+
14+ batch_id = "MY_BATCH_ID"
15+ response = sinch_client .sms .batches .replace_sms (
16+ batch_id = batch_id ,
17+ to = ["+1234567890" ],
18+ from_ = "+12345678901" ,
19+ body = "Updated message content"
20+ )
21+
22+ print (f"Replaced batch:\n { response } " )
Original file line number Diff line number Diff line change 1+ import os
2+ import base64
3+ from dotenv import load_dotenv
4+ from sinch import SinchClient
5+
6+ load_dotenv ()
7+
8+ sinch_client = SinchClient (
9+ project_id = os .environ .get ("SINCH_PROJECT_ID" ) or "MY_PROJECT_ID" ,
10+ key_id = os .environ .get ("SINCH_KEY_ID" ) or "MY_KEY_ID" ,
11+ key_secret = os .environ .get ("SINCH_KEY_SECRET" ) or "MY_KEY_SECRET" ,
12+ sms_region = os .environ .get ("SINCH_SMS_REGION" ) or "MY_SMS_REGION"
13+ )
14+
15+ batch_id = "MY_BATCH_ID"
16+
17+ # Example: Encode message body as Base64
18+ message = "Updated binary message content"
19+ body = base64 .b64encode (message .encode ('utf-8' )).decode ('utf-8' )
20+
21+ # Example: UDH header (HEX encoded)
22+ udh = "06050423F423F4"
23+
24+ response = sinch_client .sms .batches .replace_binary (
25+ batch_id = batch_id ,
26+ to = ["+1234567890" ],
27+ from_ = "+2345678901" ,
28+ body = body ,
29+ udh = udh
30+ )
31+
32+ print (f"Replaced batch:\n { response } " )
Original file line number Diff line number Diff line change 1+ import os
2+ from dotenv import load_dotenv
3+ from sinch import SinchClient
4+ from sinch .domains .sms .models .v1 .shared import MediaBody
5+
6+ load_dotenv ()
7+
8+ sinch_client = SinchClient (
9+ project_id = os .environ .get ("SINCH_PROJECT_ID" ) or "MY_PROJECT_ID" ,
10+ key_id = os .environ .get ("SINCH_KEY_ID" ) or "MY_KEY_ID" ,
11+ key_secret = os .environ .get ("SINCH_KEY_SECRET" ) or "MY_KEY_SECRET" ,
12+ sms_region = os .environ .get ("SINCH_SMS_REGION" ) or "MY_SMS_REGION"
13+ )
14+
15+ batch_id = "MY_BATCH_ID"
16+
17+ body = MediaBody (
18+ url = "https://example.com/image.jpg" ,
19+ message = "Updated MMS message content"
20+ )
21+
22+ response = sinch_client .sms .batches .replace_mms (
23+ batch_id = batch_id ,
24+ to = ["+1234567890" ],
25+ from_ = "+2345678901" ,
26+ body = body
27+ )
28+
29+ print (f"Replaced batch:\n { response } " )
Original file line number Diff line number Diff line change 1+ import os
2+ from dotenv import load_dotenv
3+ from sinch import SinchClient
4+ from sinch .domains .sms .models .v1 .shared import TextRequest
5+
6+ load_dotenv ()
7+
8+ sinch_client = SinchClient (
9+ project_id = os .environ .get ("SINCH_PROJECT_ID" ) or "MY_PROJECT_ID" ,
10+ key_id = os .environ .get ("SINCH_KEY_ID" ) or "MY_KEY_ID" ,
11+ key_secret = os .environ .get ("SINCH_KEY_SECRET" ) or "MY_KEY_SECRET" ,
12+ sms_region = os .environ .get ("SINCH_SMS_REGION" ) or "MY_SMS_REGION"
13+ )
14+
15+ request = TextRequest (
16+ to = ["+1234567890" ],
17+ from_ = "+2345678901" ,
18+ body = "Hello, this is a test message!"
19+ )
20+
21+ response = sinch_client .sms .batches .send (request = request )
22+
23+ print (f"Batch sent:\n { response } " )
You can’t perform that action at this time.
0 commit comments