# coding=utf-8
r"""
This code was generated by
\ / _    _  _|   _  _
 | (_)\/(_)(_|\/| |(/_  v1.0.0
      /       /
"""

from twilio.base import deserialize
from twilio.base import values
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.page import Page


class PhoneCallList(ListResource):
    """ PLEASE NOTE that this class contains preview products that are subject
    to change. Use them with caution. If you currently do not have developer
    preview access, please contact help@twilio.com. """

    def __init__(self, version):
        """
        Initialize the PhoneCallList

        :param Version version: Version that contains the resource

        :returns: twilio.rest.preview.trusted_comms.phone_call.PhoneCallList
        :rtype: twilio.rest.preview.trusted_comms.phone_call.PhoneCallList
        """
        super(PhoneCallList, self).__init__(version)

        # Path Solution
        self._solution = {}
        self._uri = '/Business/PhoneCalls'.format(**self._solution)

    def create(self, from_, to, url, reason=values.unset):
        """
        Create a new PhoneCallInstance

        :param unicode from_: The originating Phone Number
        :param unicode to: The terminating Phone Number
        :param unicode url: The Twiml URL
        :param unicode reason: The business reason for this phone call

        :returns: Newly created PhoneCallInstance
        :rtype: twilio.rest.preview.trusted_comms.phone_call.PhoneCallInstance
        """
        data = values.of({'From': from_, 'To': to, 'Url': url, 'Reason': reason, })

        payload = self._version.create(
            'POST',
            self._uri,
            data=data,
        )

        return PhoneCallInstance(self._version, payload, )

    def __repr__(self):
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        """
        return '<Twilio.Preview.TrustedComms.PhoneCallList>'


class PhoneCallPage(Page):
    """ PLEASE NOTE that this class contains preview products that are subject
    to change. Use them with caution. If you currently do not have developer
    preview access, please contact help@twilio.com. """

    def __init__(self, version, response, solution):
        """
        Initialize the PhoneCallPage

        :param Version version: Version that contains the resource
        :param Response response: Response from the API

        :returns: twilio.rest.preview.trusted_comms.phone_call.PhoneCallPage
        :rtype: twilio.rest.preview.trusted_comms.phone_call.PhoneCallPage
        """
        super(PhoneCallPage, self).__init__(version, response)

        # Path Solution
        self._solution = solution

    def get_instance(self, payload):
        """
        Build an instance of PhoneCallInstance

        :param dict payload: Payload response from the API

        :returns: twilio.rest.preview.trusted_comms.phone_call.PhoneCallInstance
        :rtype: twilio.rest.preview.trusted_comms.phone_call.PhoneCallInstance
        """
        return PhoneCallInstance(self._version, payload, )

    def __repr__(self):
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        """
        return '<Twilio.Preview.TrustedComms.PhoneCallPage>'


class PhoneCallInstance(InstanceResource):
    """ PLEASE NOTE that this class contains preview products that are subject
    to change. Use them with caution. If you currently do not have developer
    preview access, please contact help@twilio.com. """

    def __init__(self, version, payload):
        """
        Initialize the PhoneCallInstance

        :returns: twilio.rest.preview.trusted_comms.phone_call.PhoneCallInstance
        :rtype: twilio.rest.preview.trusted_comms.phone_call.PhoneCallInstance
        """
        super(PhoneCallInstance, self).__init__(version)

        # Marshaled Properties
        self._properties = {
            'sid': payload['sid'],
            'account_sid': payload['account_sid'],
            'from_': payload['from'],
            'to': payload['to'],
            'reason': payload['reason'],
            'created_at': deserialize.iso8601_datetime(payload['created_at']),
            'url': payload['url'],
        }

        # Context
        self._context = None
        self._solution = {}

    @property
    def sid(self):
        """
        :returns: A string that uniquely identifies this Current Call.
        :rtype: unicode
        """
        return self._properties['sid']

    @property
    def account_sid(self):
        """
        :returns: Account Sid.
        :rtype: unicode
        """
        return self._properties['account_sid']

    @property
    def from_(self):
        """
        :returns: The originating Phone Number
        :rtype: unicode
        """
        return self._properties['from_']

    @property
    def to(self):
        """
        :returns: The terminating Phone Number
        :rtype: unicode
        """
        return self._properties['to']

    @property
    def reason(self):
        """
        :returns: The business reason for this phone call
        :rtype: unicode
        """
        return self._properties['reason']

    @property
    def created_at(self):
        """
        :returns: The date this Current Call was created
        :rtype: datetime
        """
        return self._properties['created_at']

    @property
    def url(self):
        """
        :returns: The URL of this resource.
        :rtype: unicode
        """
        return self._properties['url']

    def __repr__(self):
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        """
        return '<Twilio.Preview.TrustedComms.PhoneCallInstance>'
