Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
78 changes: 46 additions & 32 deletions tests/unit/base/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,10 +811,12 @@ async def test_fetch_with_response_info_async(self):
),
Request(url="https://api.twilio.com/2010-04-01/Accounts/AC123.json"),
)
payload, status_code, headers = (
await self.client.api.v2010.fetch_with_response_info_async(
method="GET", uri="/Accounts/AC123.json"
)
(
payload,
status_code,
headers,
) = await self.client.api.v2010.fetch_with_response_info_async(
method="GET", uri="/Accounts/AC123.json"
)

self.assertEqual(payload["sid"], "AC123")
Expand All @@ -836,12 +838,14 @@ async def test_update_with_response_info_async(self):
url="https://api.twilio.com/2010-04-01/Accounts/AC123.json",
),
)
payload, status_code, headers = (
await self.client.api.v2010.update_with_response_info_async(
method="POST",
uri="/Accounts/AC123.json",
data={"name": "Updated Account"},
)
(
payload,
status_code,
headers,
) = await self.client.api.v2010.update_with_response_info_async(
method="POST",
uri="/Accounts/AC123.json",
data={"name": "Updated Account"},
)

self.assertEqual(payload["sid"], "AC123")
Expand All @@ -858,10 +862,12 @@ async def test_delete_with_response_info_async(self):
url="https://api.twilio.com/2010-04-01/Accounts/AC123/Messages/MM123.json",
),
)
success, status_code, headers = (
await self.client.api.v2010.delete_with_response_info_async(
method="DELETE", uri="/Accounts/AC123/Messages/MM123.json"
)
(
success,
status_code,
headers,
) = await self.client.api.v2010.delete_with_response_info_async(
method="DELETE", uri="/Accounts/AC123/Messages/MM123.json"
)

self.assertTrue(success)
Expand All @@ -881,12 +887,14 @@ async def test_create_with_response_info_async(self):
url="https://api.twilio.com/2010-04-01/Accounts/AC123/Messages.json",
),
)
payload, status_code, headers = (
await self.client.api.v2010.create_with_response_info_async(
method="POST",
uri="/Accounts/AC123/Messages.json",
data={"body": "Hello World"},
)
(
payload,
status_code,
headers,
) = await self.client.api.v2010.create_with_response_info_async(
method="POST",
uri="/Accounts/AC123/Messages.json",
data={"body": "Hello World"},
)

self.assertEqual(payload["sid"], "MM123")
Expand All @@ -906,10 +914,12 @@ async def test_page_with_response_info_async(self):
url="https://api.twilio.com/2010-04-01/Accounts/AC123/Messages.json"
),
)
response, status_code, headers = (
await self.client.api.v2010.page_with_response_info_async(
method="GET", uri="/Accounts/AC123/Messages.json"
)
(
response,
status_code,
headers,
) = await self.client.api.v2010.page_with_response_info_async(
method="GET", uri="/Accounts/AC123/Messages.json"
)

self.assertIsNotNone(response)
Expand Down Expand Up @@ -989,10 +999,12 @@ async def test_fetch_with_response_info_async_empty_headers(self):
Response(200, '{"sid": "AC123", "name": "Test Account"}', None),
Request(url="https://api.twilio.com/2010-04-01/Accounts/AC123.json"),
)
payload, status_code, headers = (
await self.client.api.v2010.fetch_with_response_info_async(
method="GET", uri="/Accounts/AC123.json"
)
(
payload,
status_code,
headers,
) = await self.client.api.v2010.fetch_with_response_info_async(
method="GET", uri="/Accounts/AC123.json"
)

self.assertEqual(payload["sid"], "AC123")
Expand All @@ -1014,10 +1026,12 @@ async def test_fetch_with_response_info_async_multiple_headers(self):
),
Request(url="https://api.twilio.com/2010-04-01/Accounts/AC123.json"),
)
payload, status_code, headers = (
await self.client.api.v2010.fetch_with_response_info_async(
method="GET", uri="/Accounts/AC123.json"
)
(
payload,
status_code,
headers,
) = await self.client.api.v2010.fetch_with_response_info_async(
method="GET", uri="/Accounts/AC123.json"
)

self.assertEqual(status_code, 200)
Expand Down
1 change: 0 additions & 1 deletion tests/unit/http/test_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ def test_session_not_preserved(self):

class TestTwilioRequest(unittest.TestCase):
def test_str(self):

req = Request(
method="POST",
url="https://api.twilio.com/2010-04-01/Accounts.json",
Expand Down
1 change: 0 additions & 1 deletion twilio/base/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def request(
headers = self.get_headers(method, headers)

if self.credential_provider:

auth_strategy = self.credential_provider.to_auth_strategy()
headers["Authorization"] = auth_strategy.get_auth_string()
elif self.username is not None and self.password is not None:
Expand Down
1 change: 0 additions & 1 deletion twilio/http/token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@


class TokenManager:

def fetch_access_token(self, version: Version):
pass
15 changes: 15 additions & 0 deletions twilio/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from twilio.rest.knowledge import Knowledge
from twilio.rest.lookups import Lookups
from twilio.rest.marketplace import Marketplace
from twilio.rest.memory import Memory
from twilio.rest.messaging import Messaging
from twilio.rest.monitor import Monitor
from twilio.rest.notify import Notify
Expand Down Expand Up @@ -147,6 +148,7 @@ def __init__(
self._knowledge: Optional["Knowledge"] = None
self._lookups: Optional["Lookups"] = None
self._marketplace: Optional["Marketplace"] = None
self._memory: Optional["Memory"] = None
self._messaging: Optional["Messaging"] = None
self._monitor: Optional["Monitor"] = None
self._notify: Optional["Notify"] = None
Expand Down Expand Up @@ -428,6 +430,19 @@ def messaging(self) -> "Messaging":
self._messaging = Messaging(self)
return self._messaging

@property
def memory(self) -> "Memory":
"""
Access the Messaging Twilio Domain

:returns: Messaging Twilio Domain
"""
if self._memory is None:
from twilio.rest.memory import Memory

self._memory = Memory(self)
return self._memory

@property
def monitor(self) -> "Monitor":
"""
Expand Down
1 change: 0 additions & 1 deletion twilio/rest/accounts/AccountsBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


class AccountsBase(Domain):

def __init__(self, twilio: Client):
"""
Initialize the Accounts Domain
Expand Down
1 change: 0 additions & 1 deletion twilio/rest/accounts/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


class V1(Version):

def __init__(self, domain: Domain):
"""
Initialize the V1 version of Accounts
Expand Down
4 changes: 2 additions & 2 deletions twilio/rest/accounts/v1/auth_token_promotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Do not edit the class manually.
"""


from datetime import datetime
from typing import Any, Dict, Optional
from twilio.base import deserialize, values
Expand All @@ -23,6 +24,7 @@


class AuthTokenPromotionInstance(InstanceResource):

"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the secondary Auth Token was created for.
:ivar auth_token: The promoted Auth Token that must be used to authenticate future API requests.
Expand Down Expand Up @@ -107,7 +109,6 @@ def __repr__(self) -> str:


class AuthTokenPromotionContext(InstanceContext):

def __init__(self, version: Version):
"""
Initialize the AuthTokenPromotionContext
Expand Down Expand Up @@ -205,7 +206,6 @@ def __repr__(self) -> str:


class AuthTokenPromotionList(ListResource):

def __init__(self, version: Version):
"""
Initialize the AuthTokenPromotionList
Expand Down
3 changes: 2 additions & 1 deletion twilio/rest/accounts/v1/bulk_consents.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Do not edit the class manually.
"""


from typing import Any, Dict, List, Optional
from twilio.base import serialize, values
from twilio.base.api_response import ApiResponse
Expand All @@ -22,6 +23,7 @@


class BulkConsentsInstance(InstanceResource):

"""
:ivar items: A list of objects where each object represents the result of processing a `correlation_id`. Each object contains the following fields: `correlation_id`, a unique 32-character UUID that maps the response to the original request; `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.
"""
Expand All @@ -42,7 +44,6 @@ def __repr__(self) -> str:


class BulkConsentsList(ListResource):

def __init__(self, version: Version):
"""
Initialize the BulkConsentsList
Expand Down
3 changes: 2 additions & 1 deletion twilio/rest/accounts/v1/bulk_contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Do not edit the class manually.
"""


from typing import Any, Dict, List, Optional
from twilio.base import serialize, values
from twilio.base.api_response import ApiResponse
Expand All @@ -22,6 +23,7 @@


class BulkContactsInstance(InstanceResource):

"""
:ivar items: A list of objects where each object represents the result of processing a `correlation_id`. Each object contains the following fields: `correlation_id`, a unique 32-character UUID that maps the response to the original request; `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.
"""
Expand All @@ -42,7 +44,6 @@ def __repr__(self) -> str:


class BulkContactsList(ListResource):

def __init__(self, version: Version):
"""
Initialize the BulkContactsList
Expand Down
2 changes: 1 addition & 1 deletion twilio/rest/accounts/v1/credential/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Do not edit the class manually.
"""


from typing import Optional


Expand All @@ -23,7 +24,6 @@


class CredentialList(ListResource):

def __init__(self, version: Version):
"""
Initialize the CredentialList
Expand Down
15 changes: 8 additions & 7 deletions twilio/rest/accounts/v1/credential/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Do not edit the class manually.
"""


from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
Expand All @@ -24,6 +25,7 @@


class AwsInstance(InstanceResource):

"""
:ivar sid: The unique string that we created to identify the AWS resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AWS resource.
Expand Down Expand Up @@ -206,7 +208,6 @@ def __repr__(self) -> str:


class AwsContext(InstanceContext):

def __init__(self, version: Version, sid: str):
"""
Initialize the AwsContext
Expand Down Expand Up @@ -493,7 +494,6 @@ def __repr__(self) -> str:


class AwsPage(Page):

def get_instance(self, payload: Dict[str, Any]) -> AwsInstance:
"""
Build an instance of AwsInstance
Expand All @@ -512,7 +512,6 @@ def __repr__(self) -> str:


class AwsList(ListResource):

def __init__(self, version: Version):
"""
Initialize the AwsList
Expand Down Expand Up @@ -1005,10 +1004,12 @@ async def page_with_http_info_async(

headers["Accept"] = "application/json"

response, status_code, response_headers = (
await self._version.page_with_response_info_async(
method="GET", uri=self._uri, params=data, headers=headers
)
(
response,
status_code,
response_headers,
) = await self._version.page_with_response_info_async(
method="GET", uri=self._uri, params=data, headers=headers
)
page = AwsPage(self._version, response)
return ApiResponse(data=page, status_code=status_code, headers=response_headers)
Expand Down
Loading
Loading