|
| 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 | + instance = self.instance(self) |
| 47 | + instance.load(data) |
| 48 | + return instance |
| 49 | + |
| 50 | + |
| 51 | +class CallFeedback(InstanceResource): |
| 52 | + pass |
0 commit comments