Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PinBasedSessionSupport #262

Merged
merged 9 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unitTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: UnitTests
strategy:
matrix:
python-version: [ 3.5, 3.6, 3.7, 3.8, 3.9, 3.11]
python-version: [ 3.8, 3.9, 3.11]
os: [macos-latest]
runs-on: ${{ matrix.os }}

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [4.51.0](https://github.com/plivo/plivo-python/tree/v4.51.0) (2024-05-02)
**Feature - Added SubAccount and GeoMatch for Create Masking Session API of Number Masking.**
- Added sub_account and geo_match support in MaskingSession APIs

## [4.50.0](https://github.com/plivo/plivo-python/tree/v4.50.0) (2024-04-22)
**Feature - Support for dynamic button components when sending a templated WhatsApp message**
- Added new param `payload` in templates to support dynamic payload in templates
Expand Down
26 changes: 23 additions & 3 deletions plivo/resources/maskingsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
from plivo.utils import to_param_dict
from plivo.utils.validators import *


class MaskingSession(PlivoResource):
_name = 'MaskingSession'
_identifier_string = 'session_uuid'

def create_masking_session(self):
return self.client.calls.create_masking_session(self.id,
**to_param_dict(self.create_masking_session(), locals()))
Expand Down Expand Up @@ -35,6 +37,9 @@ class MaskingSessions(PlivoResourceInterface):
recording_callback_url=[optional(is_url())],
first_party_play_url=[optional(is_url())],
second_party_play_url=[optional(is_url())],
pin_prompt_play=[optional(is_url())],
incorrect_pin_play=[optional(is_url())],
unknown_caller_play=[optional(is_url())],
)
def create_masking_session(self,
first_party=None,
Expand All @@ -50,7 +55,19 @@ def create_masking_session(self,
ring_timeout=None,
first_party_play_url=None,
second_party_play_url=None,
recording_callback_method=None
recording_callback_method=None,
is_pin_authentication_required=None,
generate_pin=None,
generate_pin_length=None,
first_party_pin=None,
second_party_pin=None,
pin_prompt_play=None,
pin_retry=None,
pin_retry_wait=None,
incorrect_pin_play=None,
unknown_caller_play=None,
subaccount=None,
geomatch=None
):
return self.client.request('POST', ('Masking', 'Session',),
to_param_dict(self.create_masking_session, locals()), is_voice_request=True)
Expand Down Expand Up @@ -78,7 +95,9 @@ def update_masking_session(self,
ring_timeout=None,
first_party_play_url=None,
second_party_play_url=None,
recording_callback_method=None
recording_callback_method=None,
subaccount=None,
geomatch=None
):
return self.client.request('POST', ('Masking', 'Session', session_uuid),
to_param_dict(self.update_masking_session, locals()), is_voice_request=True)
Expand All @@ -104,7 +123,8 @@ def list_masking_session(self,
duration__gt=None,
duration__gte=None,
limit=None,
offset=None
offset=None,
subaccount=None
):
return self.client.request('GET', ('Masking', 'Session'), to_param_dict(self.list_masking_session, locals()),
is_voice_request=True)
2 changes: 1 addition & 1 deletion plivo/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '4.50.0'
__version__ = '4.51.0'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='plivo',
version='4.50.0',
version='4.51.0',
description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML',
long_description=long_description,
url='https://github.com/plivo/plivo-python',
Expand Down
12 changes: 11 additions & 1 deletion tests/resources/fixtures/maskingSessionCreateResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
"total_call_count": 0,
"total_call_billed_duration": 0,
"total_session_amount": 0,
"last_interaction_time": ""
"last_interaction_time": "",
"is_pin_authentication_required": true,
"generate_pin": false,
"generate_pin_length": 4,
"first_party_pin": "1234",
"second_party_pin": "1235",
"pin_prompt_play": "https://s3.amazonaws.com/plivosamplexml/pin_prompt_play_url.xml",
"pin_retry": 2,
"pin_retry_wait": 5,
"incorrect_pin_play": "https://s3.amazonaws.com/plivosamplexml/incorrect_play_url.xml",
"unknown_caller_play": "https://s3.amazonaws.com/plivosamplexml/unknown_play_url.xml"
}
}
36 changes: 35 additions & 1 deletion tests/resources/test_maskingsessions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tests.base import PlivoResourceTestCase
from tests.decorators import with_response


class MaskingSessionTest(PlivoResourceTestCase):
@with_response(201)
def test_create(self):
Expand All @@ -11,6 +12,39 @@ def test_create(self):
self.assertUrlEqual(
self.get_voice_url('Masking', 'Session'), self.client.current_request.url)

@with_response(201)
# geomatch = false
def test_create(self):
self.client.masking_sessions.create_masking_session(
first_party='917708772011',
second_party='918220568648',
geomatch=False)
self.assertEqual(self.client.current_request.method, 'POST')
self.assertUrlEqual(
self.get_voice_url('Masking', 'Session'), self.client.current_request.url)

@with_response(201)
# geomatch = true
def test_create(self):
self.client.masking_sessions.create_masking_session(
first_party='917708772011',
second_party='918220568648',
geomatch=True)
self.assertEqual(self.client.current_request.method, 'POST')
self.assertUrlEqual(
self.get_voice_url('Masking', 'Session'), self.client.current_request.url)

@with_response(201)
# subaccount is passed
def test_create(self):
self.client.masking_sessions.create_masking_session(
first_party='917708772011',
second_party='918220568648',
subaccount='SAZTA0ZJJHMDETOWQ4YI')
self.assertEqual(self.client.current_request.method, 'POST')
self.assertUrlEqual(
self.get_voice_url('Masking', 'Session'), self.client.current_request.url)

@with_response(200)
def test_delete(self):
session_uuid = "9fe6cba9-62b2-4de0-98a4-6b878fb906de"
Expand Down Expand Up @@ -47,4 +81,4 @@ def test_list(self):
self.assertEqual(self.client.current_request.method, 'GET')
self.assertUrlEqual(
self.get_voice_url('Masking', 'Session', duration__gte=50,
status="expired"), self.client.current_request.url)
status="expired"), self.client.current_request.url)
Loading