|
| 1 | +r""" |
| 2 | + This code was generated by |
| 3 | + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ |
| 4 | + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ |
| 5 | + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ |
| 6 | +
|
| 7 | + Twilio - Accounts |
| 8 | + This is the public Twilio REST API. |
| 9 | +
|
| 10 | + NOTE: This class is auto generated by OpenAPI Generator. |
| 11 | + https://openapi-generator.tech |
| 12 | + Do not edit the class manually. |
| 13 | +""" |
| 14 | + |
| 15 | +from typing import Any, Dict, List, Optional, Union |
| 16 | +from twilio.base import serialize, values |
| 17 | + |
| 18 | +from twilio.base.instance_resource import InstanceResource |
| 19 | +from twilio.base.list_resource import ListResource |
| 20 | +from twilio.base.version import Version |
| 21 | + |
| 22 | + |
| 23 | +class MessagingGeopermissionsInstance(InstanceResource): |
| 24 | + """ |
| 25 | + :ivar permissions: A list of objects where each object represents the result of processing a messaging Geo Permission. Each object contains the following fields: `country_code`, the country code of the country for which the permission was updated; `type`, the type of the permission i.e. country; `enabled`, true if the permission is enabled else false; `error_code`, an integer where 0 indicates success and any non-zero value represents an error; and `error_messages`, an array of strings describing specific validation errors encountered. If the request is successful, the error_messages array will be empty. |
| 26 | + """ |
| 27 | + |
| 28 | + def __init__(self, version: Version, payload: Dict[str, Any]): |
| 29 | + super().__init__(version) |
| 30 | + |
| 31 | + self.permissions: Optional[Dict[str, object]] = payload.get("permissions") |
| 32 | + |
| 33 | + def __repr__(self) -> str: |
| 34 | + """ |
| 35 | + Provide a friendly representation |
| 36 | +
|
| 37 | + :returns: Machine friendly representation |
| 38 | + """ |
| 39 | + |
| 40 | + return "<Twilio.Accounts.V1.MessagingGeopermissionsInstance>" |
| 41 | + |
| 42 | + |
| 43 | +class MessagingGeopermissionsList(ListResource): |
| 44 | + |
| 45 | + def __init__(self, version: Version): |
| 46 | + """ |
| 47 | + Initialize the MessagingGeopermissionsList |
| 48 | +
|
| 49 | + :param version: Version that contains the resource |
| 50 | +
|
| 51 | + """ |
| 52 | + super().__init__(version) |
| 53 | + |
| 54 | + self._uri = "/Messaging/GeoPermissions" |
| 55 | + |
| 56 | + def fetch( |
| 57 | + self, country_code: Union[str, object] = values.unset |
| 58 | + ) -> MessagingGeopermissionsInstance: |
| 59 | + """ |
| 60 | + Asynchronously fetch the MessagingGeopermissionsInstance |
| 61 | +
|
| 62 | + :param country_code: The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned. |
| 63 | + :returns: The fetched MessagingGeopermissionsInstance |
| 64 | + """ |
| 65 | + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) |
| 66 | + |
| 67 | + headers["Accept"] = "application/json" |
| 68 | + |
| 69 | + params = values.of( |
| 70 | + { |
| 71 | + "CountryCode": country_code, |
| 72 | + } |
| 73 | + ) |
| 74 | + |
| 75 | + payload = self._version.fetch( |
| 76 | + method="GET", uri=self._uri, headers=headers, params=params |
| 77 | + ) |
| 78 | + |
| 79 | + return MessagingGeopermissionsInstance(self._version, payload) |
| 80 | + |
| 81 | + async def fetch_async( |
| 82 | + self, country_code: Union[str, object] = values.unset |
| 83 | + ) -> MessagingGeopermissionsInstance: |
| 84 | + """ |
| 85 | + Asynchronously fetch the MessagingGeopermissionsInstance |
| 86 | +
|
| 87 | + :param country_code: The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned. |
| 88 | + :returns: The fetched MessagingGeopermissionsInstance |
| 89 | + """ |
| 90 | + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) |
| 91 | + |
| 92 | + headers["Accept"] = "application/json" |
| 93 | + |
| 94 | + params = values.of( |
| 95 | + { |
| 96 | + "CountryCode": country_code, |
| 97 | + } |
| 98 | + ) |
| 99 | + |
| 100 | + payload = await self._version.fetch_async( |
| 101 | + method="GET", uri=self._uri, headers=headers, params=params |
| 102 | + ) |
| 103 | + |
| 104 | + return MessagingGeopermissionsInstance(self._version, payload) |
| 105 | + |
| 106 | + def update(self, permissions: List[object]) -> MessagingGeopermissionsInstance: |
| 107 | + """ |
| 108 | + Update the MessagingGeopermissionsInstance |
| 109 | +
|
| 110 | + :param permissions: A list of objects where each object represents the Geo Permission to be updated. Each object contains the following fields: `country_code`, unique code for each country of Geo Permission; `type`, permission type of the Geo Permission i.e. country; `enabled`, configure true for enabling the Geo Permission, false for disabling the Geo Permission. |
| 111 | +
|
| 112 | + :returns: The created MessagingGeopermissionsInstance |
| 113 | + """ |
| 114 | + |
| 115 | + data = values.of( |
| 116 | + { |
| 117 | + "Permissions": serialize.map( |
| 118 | + permissions, lambda e: serialize.object(e) |
| 119 | + ), |
| 120 | + } |
| 121 | + ) |
| 122 | + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) |
| 123 | + |
| 124 | + headers["Content-Type"] = "application/x-www-form-urlencoded" |
| 125 | + |
| 126 | + headers["Accept"] = "application/json" |
| 127 | + |
| 128 | + payload = self._version.update( |
| 129 | + method="PATCH", uri=self._uri, data=data, headers=headers |
| 130 | + ) |
| 131 | + |
| 132 | + return MessagingGeopermissionsInstance(self._version, payload) |
| 133 | + |
| 134 | + async def update_async( |
| 135 | + self, permissions: List[object] |
| 136 | + ) -> MessagingGeopermissionsInstance: |
| 137 | + """ |
| 138 | + Asynchronously update the MessagingGeopermissionsInstance |
| 139 | +
|
| 140 | + :param permissions: A list of objects where each object represents the Geo Permission to be updated. Each object contains the following fields: `country_code`, unique code for each country of Geo Permission; `type`, permission type of the Geo Permission i.e. country; `enabled`, configure true for enabling the Geo Permission, false for disabling the Geo Permission. |
| 141 | +
|
| 142 | + :returns: The created MessagingGeopermissionsInstance |
| 143 | + """ |
| 144 | + |
| 145 | + data = values.of( |
| 146 | + { |
| 147 | + "Permissions": serialize.map( |
| 148 | + permissions, lambda e: serialize.object(e) |
| 149 | + ), |
| 150 | + } |
| 151 | + ) |
| 152 | + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) |
| 153 | + |
| 154 | + headers["Content-Type"] = "application/x-www-form-urlencoded" |
| 155 | + |
| 156 | + headers["Accept"] = "application/json" |
| 157 | + |
| 158 | + payload = await self._version.update_async( |
| 159 | + method="PATCH", uri=self._uri, data=data, headers=headers |
| 160 | + ) |
| 161 | + |
| 162 | + return MessagingGeopermissionsInstance(self._version, payload) |
| 163 | + |
| 164 | + def __repr__(self) -> str: |
| 165 | + """ |
| 166 | + Provide a friendly representation |
| 167 | +
|
| 168 | + :returns: Machine friendly representation |
| 169 | + """ |
| 170 | + return "<Twilio.Accounts.V1.MessagingGeopermissionsList>" |
0 commit comments