Skip to content

Commit

Permalink
Merge pull request #247 from plivo/SMS-6099
Browse files Browse the repository at this point in the history
Meta data added to message list
  • Loading branch information
narayana-plivo authored Oct 19, 2023
2 parents b11ce35 + b2e27b1 commit 489edb8
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
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.44.0](https://github.com/plivo/plivo-python/tree/v4.44.0) (2023-10-18)
**Feature - Fixes for Campaign services list API meta data**
- Fixed Meta data response for campaign, brand and profile list

## [4.43.0](https://github.com/plivo/plivo-python/tree/v4.43.0) (2023-10-18)
**Feature - Verify CallerID**
- Added Initiate and Verify VerifyCallerID API
Expand Down
38 changes: 38 additions & 0 deletions plivo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,44 @@ def has_error(self):
return self.error is not None


class ListMessagesResponseObject(ResponseObject):
def __init__(self, client, dct):
super(ListMessagesResponseObject, self).__init__(dct)
self.error = dct.get('error', None)
self.objects = dct.get('objects', None)
self.meta = dct.get('meta', None)
self.apiID = dct.get('api_id', None)

def __iter__(self):
if self.objects is not None:
return self.objects.__iter__()
else:
return iter([])

def __len__(self):
if self.objects is not None:
return len(self.objects)
else:
return 0 # Return 0 for error case

def __str__(self):
if self.objects is not None:
response_dict = {'api_id': self.apiID, 'meta': self.meta, 'objects': self.objects}
return pprint.pformat(response_dict)
else:
return str(self.error) # Display error message for error case

def __repr__(self):
if self.objects is not None:
response_dict = {'api_id': self.apiID, 'meta': self.meta, 'objects': [session for session in self.objects]}
return str(response_dict)
else:
return str(self.error) # Display error message for error case

def has_error(self):
return self.error is not None


class ListResponseObject(ResponseObject):
def __init__(self, client, dct):
super(ListResponseObject, self).__init__(dct)
Expand Down
4 changes: 2 additions & 2 deletions plivo/resources/messages.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from plivo.utils.validators import *

from ..base import ListResponseObject, PlivoResource, PlivoResourceInterface
from ..base import ListMessagesResponseObject, PlivoResource, PlivoResourceInterface
from ..exceptions import *
from ..utils import *

Expand Down Expand Up @@ -150,5 +150,5 @@ def list(self,
return self.client.request(
'GET', ('Message', ),
to_param_dict(self.list, locals()),
response_type=ListResponseObject,
response_type=ListMessagesResponseObject,
objects_type=Message)
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.43.0'
__version__ = '4.44.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.43.0',
version='4.44.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

0 comments on commit 489edb8

Please sign in to comment.