1# coding=utf-8
2r"""
3This code was generated by
4\ / _    _  _|   _  _
5 | (_)\/(_)(_|\/| |(/_  v1.0.0
6      /       /
7"""
8
9from twilio.base import deserialize
10from twilio.base import values
11from twilio.base.instance_context import InstanceContext
12from twilio.base.instance_resource import InstanceResource
13from twilio.base.list_resource import ListResource
14from twilio.base.page import Page
15from twilio.rest.messaging.v1.service.alpha_sender import AlphaSenderList
16from twilio.rest.messaging.v1.service.phone_number import PhoneNumberList
17from twilio.rest.messaging.v1.service.short_code import ShortCodeList
18from twilio.rest.messaging.v1.service.us_app_to_person import UsAppToPersonList
19from twilio.rest.messaging.v1.service.us_app_to_person_usecase import UsAppToPersonUsecaseList
20
21
22class ServiceList(ListResource):
23    """ PLEASE NOTE that this class contains beta products that are subject to
24    change. Use them with caution. """
25
26    def __init__(self, version):
27        """
28        Initialize the ServiceList
29
30        :param Version version: Version that contains the resource
31
32        :returns: twilio.rest.messaging.v1.service.ServiceList
33        :rtype: twilio.rest.messaging.v1.service.ServiceList
34        """
35        super(ServiceList, self).__init__(version)
36
37        # Path Solution
38        self._solution = {}
39        self._uri = '/Services'.format(**self._solution)
40
41    def create(self, friendly_name, inbound_request_url=values.unset,
42               inbound_method=values.unset, fallback_url=values.unset,
43               fallback_method=values.unset, status_callback=values.unset,
44               sticky_sender=values.unset, mms_converter=values.unset,
45               smart_encoding=values.unset, scan_message_content=values.unset,
46               fallback_to_long_code=values.unset, area_code_geomatch=values.unset,
47               validity_period=values.unset, synchronous_validation=values.unset,
48               usecase=values.unset, use_inbound_webhook_on_number=values.unset):
49        """
50        Create the ServiceInstance
51
52        :param unicode friendly_name: A string to describe the resource
53        :param unicode inbound_request_url: The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled.
54        :param unicode inbound_method: The HTTP method we should use to call inbound_request_url
55        :param unicode fallback_url: The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled.
56        :param unicode fallback_method: The HTTP method we should use to call fallback_url
57        :param unicode status_callback: The URL we should call to pass status updates about message delivery
58        :param bool sticky_sender: Whether to enable Sticky Sender on the Service instance
59        :param bool mms_converter: Whether to enable the MMS Converter for messages sent through the Service instance
60        :param bool smart_encoding: Whether to enable Encoding for messages sent through the Service instance
61        :param ServiceInstance.ScanMessageContent scan_message_content: Reserved
62        :param bool fallback_to_long_code: Whether to enable Fallback to Long Code for messages sent through the Service instance
63        :param bool area_code_geomatch: Whether to enable Area Code Geomatch on the Service Instance
64        :param unicode validity_period: How long, in seconds, messages sent from the Service are valid
65        :param bool synchronous_validation: Reserved
66        :param unicode usecase: A string describing the scenario in which the Messaging Service will be used
67        :param bool use_inbound_webhook_on_number: If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received.
68
69        :returns: The created ServiceInstance
70        :rtype: twilio.rest.messaging.v1.service.ServiceInstance
71        """
72        data = values.of({
73            'FriendlyName': friendly_name,
74            'InboundRequestUrl': inbound_request_url,
75            'InboundMethod': inbound_method,
76            'FallbackUrl': fallback_url,
77            'FallbackMethod': fallback_method,
78            'StatusCallback': status_callback,
79            'StickySender': sticky_sender,
80            'MmsConverter': mms_converter,
81            'SmartEncoding': smart_encoding,
82            'ScanMessageContent': scan_message_content,
83            'FallbackToLongCode': fallback_to_long_code,
84            'AreaCodeGeomatch': area_code_geomatch,
85            'ValidityPeriod': validity_period,
86            'SynchronousValidation': synchronous_validation,
87            'Usecase': usecase,
88            'UseInboundWebhookOnNumber': use_inbound_webhook_on_number,
89        })
90
91        payload = self._version.create(method='POST', uri=self._uri, data=data, )
92
93        return ServiceInstance(self._version, payload, )
94
95    def stream(self, limit=None, page_size=None):
96        """
97        Streams ServiceInstance records from the API as a generator stream.
98        This operation lazily loads records as efficiently as possible until the limit
99        is reached.
100        The results are returned as a generator, so this operation is memory efficient.
101
102        :param int limit: Upper limit for the number of records to return. stream()
103                          guarantees to never return more than limit.  Default is no limit
104        :param int page_size: Number of records to fetch per request, when not set will use
105                              the default value of 50 records.  If no page_size is defined
106                              but a limit is defined, stream() will attempt to read the
107                              limit with the most efficient page size, i.e. min(limit, 1000)
108
109        :returns: Generator that will yield up to limit results
110        :rtype: list[twilio.rest.messaging.v1.service.ServiceInstance]
111        """
112        limits = self._version.read_limits(limit, page_size)
113
114        page = self.page(page_size=limits['page_size'], )
115
116        return self._version.stream(page, limits['limit'])
117
118    def list(self, limit=None, page_size=None):
119        """
120        Lists ServiceInstance records from the API as a list.
121        Unlike stream(), this operation is eager and will load `limit` records into
122        memory before returning.
123
124        :param int limit: Upper limit for the number of records to return. list() guarantees
125                          never to return more than limit.  Default is no limit
126        :param int page_size: Number of records to fetch per request, when not set will use
127                              the default value of 50 records.  If no page_size is defined
128                              but a limit is defined, list() will attempt to read the limit
129                              with the most efficient page size, i.e. min(limit, 1000)
130
131        :returns: Generator that will yield up to limit results
132        :rtype: list[twilio.rest.messaging.v1.service.ServiceInstance]
133        """
134        return list(self.stream(limit=limit, page_size=page_size, ))
135
136    def page(self, page_token=values.unset, page_number=values.unset,
137             page_size=values.unset):
138        """
139        Retrieve a single page of ServiceInstance records from the API.
140        Request is executed immediately
141
142        :param str page_token: PageToken provided by the API
143        :param int page_number: Page Number, this value is simply for client state
144        :param int page_size: Number of records to return, defaults to 50
145
146        :returns: Page of ServiceInstance
147        :rtype: twilio.rest.messaging.v1.service.ServicePage
148        """
149        data = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, })
150
151        response = self._version.page(method='GET', uri=self._uri, params=data, )
152
153        return ServicePage(self._version, response, self._solution)
154
155    def get_page(self, target_url):
156        """
157        Retrieve a specific page of ServiceInstance records from the API.
158        Request is executed immediately
159
160        :param str target_url: API-generated URL for the requested results page
161
162        :returns: Page of ServiceInstance
163        :rtype: twilio.rest.messaging.v1.service.ServicePage
164        """
165        response = self._version.domain.twilio.request(
166            'GET',
167            target_url,
168        )
169
170        return ServicePage(self._version, response, self._solution)
171
172    def get(self, sid):
173        """
174        Constructs a ServiceContext
175
176        :param sid: The SID that identifies the resource to fetch
177
178        :returns: twilio.rest.messaging.v1.service.ServiceContext
179        :rtype: twilio.rest.messaging.v1.service.ServiceContext
180        """
181        return ServiceContext(self._version, sid=sid, )
182
183    def __call__(self, sid):
184        """
185        Constructs a ServiceContext
186
187        :param sid: The SID that identifies the resource to fetch
188
189        :returns: twilio.rest.messaging.v1.service.ServiceContext
190        :rtype: twilio.rest.messaging.v1.service.ServiceContext
191        """
192        return ServiceContext(self._version, sid=sid, )
193
194    def __repr__(self):
195        """
196        Provide a friendly representation
197
198        :returns: Machine friendly representation
199        :rtype: str
200        """
201        return '<Twilio.Messaging.V1.ServiceList>'
202
203
204class ServicePage(Page):
205    """ PLEASE NOTE that this class contains beta products that are subject to
206    change. Use them with caution. """
207
208    def __init__(self, version, response, solution):
209        """
210        Initialize the ServicePage
211
212        :param Version version: Version that contains the resource
213        :param Response response: Response from the API
214
215        :returns: twilio.rest.messaging.v1.service.ServicePage
216        :rtype: twilio.rest.messaging.v1.service.ServicePage
217        """
218        super(ServicePage, self).__init__(version, response)
219
220        # Path Solution
221        self._solution = solution
222
223    def get_instance(self, payload):
224        """
225        Build an instance of ServiceInstance
226
227        :param dict payload: Payload response from the API
228
229        :returns: twilio.rest.messaging.v1.service.ServiceInstance
230        :rtype: twilio.rest.messaging.v1.service.ServiceInstance
231        """
232        return ServiceInstance(self._version, payload, )
233
234    def __repr__(self):
235        """
236        Provide a friendly representation
237
238        :returns: Machine friendly representation
239        :rtype: str
240        """
241        return '<Twilio.Messaging.V1.ServicePage>'
242
243
244class ServiceContext(InstanceContext):
245    """ PLEASE NOTE that this class contains beta products that are subject to
246    change. Use them with caution. """
247
248    def __init__(self, version, sid):
249        """
250        Initialize the ServiceContext
251
252        :param Version version: Version that contains the resource
253        :param sid: The SID that identifies the resource to fetch
254
255        :returns: twilio.rest.messaging.v1.service.ServiceContext
256        :rtype: twilio.rest.messaging.v1.service.ServiceContext
257        """
258        super(ServiceContext, self).__init__(version)
259
260        # Path Solution
261        self._solution = {'sid': sid, }
262        self._uri = '/Services/{sid}'.format(**self._solution)
263
264        # Dependents
265        self._phone_numbers = None
266        self._short_codes = None
267        self._alpha_senders = None
268        self._us_app_to_person = None
269        self._us_app_to_person_usecases = None
270
271    def update(self, friendly_name=values.unset, inbound_request_url=values.unset,
272               inbound_method=values.unset, fallback_url=values.unset,
273               fallback_method=values.unset, status_callback=values.unset,
274               sticky_sender=values.unset, mms_converter=values.unset,
275               smart_encoding=values.unset, scan_message_content=values.unset,
276               fallback_to_long_code=values.unset, area_code_geomatch=values.unset,
277               validity_period=values.unset, synchronous_validation=values.unset,
278               usecase=values.unset, use_inbound_webhook_on_number=values.unset):
279        """
280        Update the ServiceInstance
281
282        :param unicode friendly_name: A string to describe the resource
283        :param unicode inbound_request_url: The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled.
284        :param unicode inbound_method: The HTTP method we should use to call inbound_request_url
285        :param unicode fallback_url: The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled.
286        :param unicode fallback_method: The HTTP method we should use to call fallback_url
287        :param unicode status_callback: The URL we should call to pass status updates about message delivery
288        :param bool sticky_sender: Whether to enable Sticky Sender on the Service instance
289        :param bool mms_converter: Whether to enable the MMS Converter for messages sent through the Service instance
290        :param bool smart_encoding: Whether to enable Encoding for messages sent through the Service instance
291        :param ServiceInstance.ScanMessageContent scan_message_content: Reserved
292        :param bool fallback_to_long_code: Whether to enable Fallback to Long Code for messages sent through the Service instance
293        :param bool area_code_geomatch: Whether to enable Area Code Geomatch on the Service Instance
294        :param unicode validity_period: How long, in seconds, messages sent from the Service are valid
295        :param bool synchronous_validation: Reserved
296        :param unicode usecase: A string describing the scenario in which the Messaging Service will be used
297        :param bool use_inbound_webhook_on_number: If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received.
298
299        :returns: The updated ServiceInstance
300        :rtype: twilio.rest.messaging.v1.service.ServiceInstance
301        """
302        data = values.of({
303            'FriendlyName': friendly_name,
304            'InboundRequestUrl': inbound_request_url,
305            'InboundMethod': inbound_method,
306            'FallbackUrl': fallback_url,
307            'FallbackMethod': fallback_method,
308            'StatusCallback': status_callback,
309            'StickySender': sticky_sender,
310            'MmsConverter': mms_converter,
311            'SmartEncoding': smart_encoding,
312            'ScanMessageContent': scan_message_content,
313            'FallbackToLongCode': fallback_to_long_code,
314            'AreaCodeGeomatch': area_code_geomatch,
315            'ValidityPeriod': validity_period,
316            'SynchronousValidation': synchronous_validation,
317            'Usecase': usecase,
318            'UseInboundWebhookOnNumber': use_inbound_webhook_on_number,
319        })
320
321        payload = self._version.update(method='POST', uri=self._uri, data=data, )
322
323        return ServiceInstance(self._version, payload, sid=self._solution['sid'], )
324
325    def fetch(self):
326        """
327        Fetch the ServiceInstance
328
329        :returns: The fetched ServiceInstance
330        :rtype: twilio.rest.messaging.v1.service.ServiceInstance
331        """
332        payload = self._version.fetch(method='GET', uri=self._uri, )
333
334        return ServiceInstance(self._version, payload, sid=self._solution['sid'], )
335
336    def delete(self):
337        """
338        Deletes the ServiceInstance
339
340        :returns: True if delete succeeds, False otherwise
341        :rtype: bool
342        """
343        return self._version.delete(method='DELETE', uri=self._uri, )
344
345    @property
346    def phone_numbers(self):
347        """
348        Access the phone_numbers
349
350        :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberList
351        :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberList
352        """
353        if self._phone_numbers is None:
354            self._phone_numbers = PhoneNumberList(self._version, service_sid=self._solution['sid'], )
355        return self._phone_numbers
356
357    @property
358    def short_codes(self):
359        """
360        Access the short_codes
361
362        :returns: twilio.rest.messaging.v1.service.short_code.ShortCodeList
363        :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeList
364        """
365        if self._short_codes is None:
366            self._short_codes = ShortCodeList(self._version, service_sid=self._solution['sid'], )
367        return self._short_codes
368
369    @property
370    def alpha_senders(self):
371        """
372        Access the alpha_senders
373
374        :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderList
375        :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderList
376        """
377        if self._alpha_senders is None:
378            self._alpha_senders = AlphaSenderList(self._version, service_sid=self._solution['sid'], )
379        return self._alpha_senders
380
381    @property
382    def us_app_to_person(self):
383        """
384        Access the us_app_to_person
385
386        :returns: twilio.rest.messaging.v1.service.us_app_to_person.UsAppToPersonList
387        :rtype: twilio.rest.messaging.v1.service.us_app_to_person.UsAppToPersonList
388        """
389        if self._us_app_to_person is None:
390            self._us_app_to_person = UsAppToPersonList(
391                self._version,
392                messaging_service_sid=self._solution['sid'],
393            )
394        return self._us_app_to_person
395
396    @property
397    def us_app_to_person_usecases(self):
398        """
399        Access the us_app_to_person_usecases
400
401        :returns: twilio.rest.messaging.v1.service.us_app_to_person_usecase.UsAppToPersonUsecaseList
402        :rtype: twilio.rest.messaging.v1.service.us_app_to_person_usecase.UsAppToPersonUsecaseList
403        """
404        if self._us_app_to_person_usecases is None:
405            self._us_app_to_person_usecases = UsAppToPersonUsecaseList(
406                self._version,
407                messaging_service_sid=self._solution['sid'],
408            )
409        return self._us_app_to_person_usecases
410
411    def __repr__(self):
412        """
413        Provide a friendly representation
414
415        :returns: Machine friendly representation
416        :rtype: str
417        """
418        context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items())
419        return '<Twilio.Messaging.V1.ServiceContext {}>'.format(context)
420
421
422class ServiceInstance(InstanceResource):
423    """ PLEASE NOTE that this class contains beta products that are subject to
424    change. Use them with caution. """
425
426    class ScanMessageContent(object):
427        INHERIT = "inherit"
428        ENABLE = "enable"
429        DISABLE = "disable"
430
431    def __init__(self, version, payload, sid=None):
432        """
433        Initialize the ServiceInstance
434
435        :returns: twilio.rest.messaging.v1.service.ServiceInstance
436        :rtype: twilio.rest.messaging.v1.service.ServiceInstance
437        """
438        super(ServiceInstance, self).__init__(version)
439
440        # Marshaled Properties
441        self._properties = {
442            'sid': payload.get('sid'),
443            'account_sid': payload.get('account_sid'),
444            'friendly_name': payload.get('friendly_name'),
445            'date_created': deserialize.iso8601_datetime(payload.get('date_created')),
446            'date_updated': deserialize.iso8601_datetime(payload.get('date_updated')),
447            'inbound_request_url': payload.get('inbound_request_url'),
448            'inbound_method': payload.get('inbound_method'),
449            'fallback_url': payload.get('fallback_url'),
450            'fallback_method': payload.get('fallback_method'),
451            'status_callback': payload.get('status_callback'),
452            'sticky_sender': payload.get('sticky_sender'),
453            'mms_converter': payload.get('mms_converter'),
454            'smart_encoding': payload.get('smart_encoding'),
455            'scan_message_content': payload.get('scan_message_content'),
456            'fallback_to_long_code': payload.get('fallback_to_long_code'),
457            'area_code_geomatch': payload.get('area_code_geomatch'),
458            'synchronous_validation': payload.get('synchronous_validation'),
459            'validity_period': deserialize.integer(payload.get('validity_period')),
460            'url': payload.get('url'),
461            'links': payload.get('links'),
462            'usecase': payload.get('usecase'),
463            'us_app_to_person_registered': payload.get('us_app_to_person_registered'),
464            'use_inbound_webhook_on_number': payload.get('use_inbound_webhook_on_number'),
465        }
466
467        # Context
468        self._context = None
469        self._solution = {'sid': sid or self._properties['sid'], }
470
471    @property
472    def _proxy(self):
473        """
474        Generate an instance context for the instance, the context is capable of
475        performing various actions.  All instance actions are proxied to the context
476
477        :returns: ServiceContext for this ServiceInstance
478        :rtype: twilio.rest.messaging.v1.service.ServiceContext
479        """
480        if self._context is None:
481            self._context = ServiceContext(self._version, sid=self._solution['sid'], )
482        return self._context
483
484    @property
485    def sid(self):
486        """
487        :returns: The unique string that identifies the resource
488        :rtype: unicode
489        """
490        return self._properties['sid']
491
492    @property
493    def account_sid(self):
494        """
495        :returns: The SID of the Account that created the resource
496        :rtype: unicode
497        """
498        return self._properties['account_sid']
499
500    @property
501    def friendly_name(self):
502        """
503        :returns: The string that you assigned to describe the resource
504        :rtype: unicode
505        """
506        return self._properties['friendly_name']
507
508    @property
509    def date_created(self):
510        """
511        :returns: The ISO 8601 date and time in GMT when the resource was created
512        :rtype: datetime
513        """
514        return self._properties['date_created']
515
516    @property
517    def date_updated(self):
518        """
519        :returns: The ISO 8601 date and time in GMT when the resource was last updated
520        :rtype: datetime
521        """
522        return self._properties['date_updated']
523
524    @property
525    def inbound_request_url(self):
526        """
527        :returns: The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled.
528        :rtype: unicode
529        """
530        return self._properties['inbound_request_url']
531
532    @property
533    def inbound_method(self):
534        """
535        :returns: The HTTP method we use to call inbound_request_url
536        :rtype: unicode
537        """
538        return self._properties['inbound_method']
539
540    @property
541    def fallback_url(self):
542        """
543        :returns: The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled.
544        :rtype: unicode
545        """
546        return self._properties['fallback_url']
547
548    @property
549    def fallback_method(self):
550        """
551        :returns: The HTTP method we use to call fallback_url
552        :rtype: unicode
553        """
554        return self._properties['fallback_method']
555
556    @property
557    def status_callback(self):
558        """
559        :returns: The URL we call to pass status updates about message delivery
560        :rtype: unicode
561        """
562        return self._properties['status_callback']
563
564    @property
565    def sticky_sender(self):
566        """
567        :returns: Whether to enable Sticky Sender on the Service instance
568        :rtype: bool
569        """
570        return self._properties['sticky_sender']
571
572    @property
573    def mms_converter(self):
574        """
575        :returns: Whether to enable the MMS Converter for messages sent through the Service instance
576        :rtype: bool
577        """
578        return self._properties['mms_converter']
579
580    @property
581    def smart_encoding(self):
582        """
583        :returns: Whether to enable Encoding for messages sent through the Service instance
584        :rtype: bool
585        """
586        return self._properties['smart_encoding']
587
588    @property
589    def scan_message_content(self):
590        """
591        :returns: Reserved
592        :rtype: ServiceInstance.ScanMessageContent
593        """
594        return self._properties['scan_message_content']
595
596    @property
597    def fallback_to_long_code(self):
598        """
599        :returns: Whether to enable Fallback to Long Code for messages sent through the Service instance
600        :rtype: bool
601        """
602        return self._properties['fallback_to_long_code']
603
604    @property
605    def area_code_geomatch(self):
606        """
607        :returns: Whether to enable Area Code Geomatch on the Service Instance
608        :rtype: bool
609        """
610        return self._properties['area_code_geomatch']
611
612    @property
613    def synchronous_validation(self):
614        """
615        :returns: Reserved
616        :rtype: bool
617        """
618        return self._properties['synchronous_validation']
619
620    @property
621    def validity_period(self):
622        """
623        :returns: How long, in seconds, messages sent from the Service are valid
624        :rtype: unicode
625        """
626        return self._properties['validity_period']
627
628    @property
629    def url(self):
630        """
631        :returns: The absolute URL of the Service resource
632        :rtype: unicode
633        """
634        return self._properties['url']
635
636    @property
637    def links(self):
638        """
639        :returns: The absolute URLs of related resources
640        :rtype: unicode
641        """
642        return self._properties['links']
643
644    @property
645    def usecase(self):
646        """
647        :returns: A string describing the scenario in which the Messaging Service will be used
648        :rtype: unicode
649        """
650        return self._properties['usecase']
651
652    @property
653    def us_app_to_person_registered(self):
654        """
655        :returns: Whether US A2P campaign is registered for this Service.
656        :rtype: bool
657        """
658        return self._properties['us_app_to_person_registered']
659
660    @property
661    def use_inbound_webhook_on_number(self):
662        """
663        :returns: If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received.
664        :rtype: bool
665        """
666        return self._properties['use_inbound_webhook_on_number']
667
668    def update(self, friendly_name=values.unset, inbound_request_url=values.unset,
669               inbound_method=values.unset, fallback_url=values.unset,
670               fallback_method=values.unset, status_callback=values.unset,
671               sticky_sender=values.unset, mms_converter=values.unset,
672               smart_encoding=values.unset, scan_message_content=values.unset,
673               fallback_to_long_code=values.unset, area_code_geomatch=values.unset,
674               validity_period=values.unset, synchronous_validation=values.unset,
675               usecase=values.unset, use_inbound_webhook_on_number=values.unset):
676        """
677        Update the ServiceInstance
678
679        :param unicode friendly_name: A string to describe the resource
680        :param unicode inbound_request_url: The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled.
681        :param unicode inbound_method: The HTTP method we should use to call inbound_request_url
682        :param unicode fallback_url: The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled.
683        :param unicode fallback_method: The HTTP method we should use to call fallback_url
684        :param unicode status_callback: The URL we should call to pass status updates about message delivery
685        :param bool sticky_sender: Whether to enable Sticky Sender on the Service instance
686        :param bool mms_converter: Whether to enable the MMS Converter for messages sent through the Service instance
687        :param bool smart_encoding: Whether to enable Encoding for messages sent through the Service instance
688        :param ServiceInstance.ScanMessageContent scan_message_content: Reserved
689        :param bool fallback_to_long_code: Whether to enable Fallback to Long Code for messages sent through the Service instance
690        :param bool area_code_geomatch: Whether to enable Area Code Geomatch on the Service Instance
691        :param unicode validity_period: How long, in seconds, messages sent from the Service are valid
692        :param bool synchronous_validation: Reserved
693        :param unicode usecase: A string describing the scenario in which the Messaging Service will be used
694        :param bool use_inbound_webhook_on_number: If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received.
695
696        :returns: The updated ServiceInstance
697        :rtype: twilio.rest.messaging.v1.service.ServiceInstance
698        """
699        return self._proxy.update(
700            friendly_name=friendly_name,
701            inbound_request_url=inbound_request_url,
702            inbound_method=inbound_method,
703            fallback_url=fallback_url,
704            fallback_method=fallback_method,
705            status_callback=status_callback,
706            sticky_sender=sticky_sender,
707            mms_converter=mms_converter,
708            smart_encoding=smart_encoding,
709            scan_message_content=scan_message_content,
710            fallback_to_long_code=fallback_to_long_code,
711            area_code_geomatch=area_code_geomatch,
712            validity_period=validity_period,
713            synchronous_validation=synchronous_validation,
714            usecase=usecase,
715            use_inbound_webhook_on_number=use_inbound_webhook_on_number,
716        )
717
718    def fetch(self):
719        """
720        Fetch the ServiceInstance
721
722        :returns: The fetched ServiceInstance
723        :rtype: twilio.rest.messaging.v1.service.ServiceInstance
724        """
725        return self._proxy.fetch()
726
727    def delete(self):
728        """
729        Deletes the ServiceInstance
730
731        :returns: True if delete succeeds, False otherwise
732        :rtype: bool
733        """
734        return self._proxy.delete()
735
736    @property
737    def phone_numbers(self):
738        """
739        Access the phone_numbers
740
741        :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberList
742        :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberList
743        """
744        return self._proxy.phone_numbers
745
746    @property
747    def short_codes(self):
748        """
749        Access the short_codes
750
751        :returns: twilio.rest.messaging.v1.service.short_code.ShortCodeList
752        :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeList
753        """
754        return self._proxy.short_codes
755
756    @property
757    def alpha_senders(self):
758        """
759        Access the alpha_senders
760
761        :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderList
762        :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderList
763        """
764        return self._proxy.alpha_senders
765
766    @property
767    def us_app_to_person(self):
768        """
769        Access the us_app_to_person
770
771        :returns: twilio.rest.messaging.v1.service.us_app_to_person.UsAppToPersonList
772        :rtype: twilio.rest.messaging.v1.service.us_app_to_person.UsAppToPersonList
773        """
774        return self._proxy.us_app_to_person
775
776    @property
777    def us_app_to_person_usecases(self):
778        """
779        Access the us_app_to_person_usecases
780
781        :returns: twilio.rest.messaging.v1.service.us_app_to_person_usecase.UsAppToPersonUsecaseList
782        :rtype: twilio.rest.messaging.v1.service.us_app_to_person_usecase.UsAppToPersonUsecaseList
783        """
784        return self._proxy.us_app_to_person_usecases
785
786    def __repr__(self):
787        """
788        Provide a friendly representation
789
790        :returns: Machine friendly representation
791        :rtype: str
792        """
793        context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items())
794        return '<Twilio.Messaging.V1.ServiceInstance {}>'.format(context)
795