8000 initial work on call feedback · LilyAcorn/twilio-python@d8b28bb · GitHub
[go: up one dir, main page]

Skip to content

Commit d8b28bb

Browse files
author
Doug Black
committed
initial work on call feedback
1 parent 26f6707 commit d8b28bb

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

twilio/rest/resources/applications.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Applications(ListResource):
2525
def list(self, **kwargs):
2626
"""
2727
Returns a page of :class:`Application` resources as a list. For paging
28-
informtion see :class:`ListResource`
28+
information see :class:`ListResource`
2929
3030
:param date friendly_name: List applications with this friendly name
3131
"""
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from twilio.rest.resources import ListResource, InstanceResource, transform_params
2+
3+
4+
class CallFeedbackFactory(ListResource):
5+
6+
"""
7+
CallFeedback is a unique endpoint in the API in that it only
8+
has an instance representation, and that instance representation
9+
lives at the same URL you POST to to create it. Here, our
10+
ListResource class acts as a Factory resource.
11+
"""
12+
13+
name = "Feedback"
14+
instance = CallFeedback
15+
16+
def create(self, **kwargs):
17+
"""
18+
Create a :class:`CallFeedback` object for the parent call.
19+
20+
:param int quality: The score quality. Must be an
21+
int between 1 and 5.
22+
:param list issue: A list of issues. The issue types are
23+
found at the CallFeedback rest docs.
24+
"""
25+
return self.create_instance(kwargs)
26+
27+
def get(self, **kwargs):
28+
""" Get the feedback for this call
29+
30+
Usage:
31+
32+
.. code-block:: python
33+
feedback = client.calls.get("CA123").feedback
34+
print feedback.issues
35+
36+
:rtype: :class:`~twilio.rest.resources.InstanceResource`
37+
:raises: a :exc:`~twilio.TwilioRestException` if the request fails
38+
"""
39+
params = transform_params(kwargs)
40+
resp, _ = self.request("GET", self.uri, params=params)
41+
return self.load_instance(resp)
42+
43+
def load_instance(self, data):
44+
# Overridden because CallFeedback instances
45+
# don't contain sids :(
46+
BEC8 instance = self.instance(self)
47+
instance.load(data)
48+
return instance
49+
50+
51+
class CallFeedback(InstanceResource):
52+
pass

twilio/rest/resources/calls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .notifications import Notifications
22
from .recordings import Recordings
3+
from twilio.rest.resources.call_feedback import CallFeedbackFactory
34
from .util import normalize_dates, parse_date
45
from . import InstanceResource, ListResource
56

@@ -19,6 +20,7 @@ class Call(InstanceResource):
1920
subresources = [
2021
Notifications,
2122
Recordings,
23+
CallFeedbackFactory,
2224
]
2325

2426
def hangup(self):

0 commit comments

Comments
 (0)
0