Skip to content
Draft
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/unit/http/test_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_str_excludes_authorization_header(self):
data={"FriendlyName": "My New Account"},
headers={
"Authorization": "Bearer secret-token",
"X-Custom-Header": "Value"
"X-Custom-Header": "Value",
},
)
expected = (
Expand Down
6 changes: 5 additions & 1 deletion twilio/http/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def __str__(self) -> str:
headers = ""
if self.headers and self.headers != Match.ANY:
headers = "\n{}".format(
"\n".join(' -H "{}: {}"'.format(k, v) for k, v in self.headers.items() if k.lower() != "authorization")
"\n".join(
' -H "{}: {}"'.format(k, v)
for k, v in self.headers.items()
if k.lower() != "authorization"
)
)

return "{method} {url}{params}{data}{headers}".format(
Expand Down
14 changes: 12 additions & 2 deletions twilio/rest/accounts/v1/secondary_auth_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,15 @@ def create(self) -> SecondaryAuthTokenInstance:

:returns: The created SecondaryAuthTokenInstance
"""

data = values.of({})
headers = values.of({})

payload = self._version.create(method="POST", uri=self._uri, data=data)
headers["Accept"] = "application/json"

payload = self._version.create(
method="POST", uri=self._uri, data=data, headers=headers
)

return SecondaryAuthTokenInstance(self._version, payload)

Expand All @@ -137,10 +143,14 @@ async def create_async(self) -> SecondaryAuthTokenInstance:

:returns: The created SecondaryAuthTokenInstance
"""

data = values.of({})
headers = values.of({})

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

payload = await self._version.create_async(
method="POST", uri=self._uri, data=data
method="POST", uri=self._uri, data=data, headers=headers
)

return SecondaryAuthTokenInstance(self._version, payload)
Expand Down
8 changes: 4 additions & 4 deletions twilio/rest/api/v2010/account/recording/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def fetch(
:returns: The fetched RecordingInstance
"""

data = values.of(
params = values.of(
{
"IncludeSoftDeleted": serialize.boolean_to_string(include_soft_deleted),
}
Expand All @@ -269,7 +269,7 @@ def fetch(
headers["Accept"] = "application/json"

payload = self._version.fetch(
method="GET", uri=self._uri, params=data, headers=headers
method="GET", uri=self._uri, params=params, headers=headers
)

return RecordingInstance(
Expand All @@ -290,7 +290,7 @@ async def fetch_async(
:returns: The fetched RecordingInstance
"""

data = values.of(
params = values.of(
{
"IncludeSoftDeleted": serialize.boolean_to_string(include_soft_deleted),
}
Expand All @@ -301,7 +301,7 @@ async def fetch_async(
headers["Accept"] = "application/json"

payload = await self._version.fetch_async(
method="GET", uri=self._uri, params=data, headers=headers
method="GET", uri=self._uri, params=params, headers=headers
)

return RecordingInstance(
Expand Down
10 changes: 8 additions & 2 deletions twilio/rest/assistants/v1/assistant/assistants_knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,13 @@ def create(self) -> AssistantsKnowledgeInstance:

:returns: The created AssistantsKnowledgeInstance
"""

data = values.of({})
headers = values.of({})

payload = self._version.create(method="POST", uri=self._uri, data=data)
payload = self._version.create(
method="POST", uri=self._uri, data=data, headers=headers
)

return AssistantsKnowledgeInstance(
self._version,
Expand All @@ -176,10 +180,12 @@ async def create_async(self) -> AssistantsKnowledgeInstance:

:returns: The created AssistantsKnowledgeInstance
"""

data = values.of({})
headers = values.of({})

payload = await self._version.create_async(
method="POST", uri=self._uri, data=data
method="POST", uri=self._uri, data=data, headers=headers
)

return AssistantsKnowledgeInstance(
Expand Down
10 changes: 8 additions & 2 deletions twilio/rest/assistants/v1/assistant/assistants_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,13 @@ def create(self) -> AssistantsToolInstance:

:returns: The created AssistantsToolInstance
"""

data = values.of({})
headers = values.of({})

payload = self._version.create(method="POST", uri=self._uri, data=data)
payload = self._version.create(
method="POST", uri=self._uri, data=data, headers=headers
)

return AssistantsToolInstance(
self._version,
Expand All @@ -174,10 +178,12 @@ async def create_async(self) -> AssistantsToolInstance:

:returns: The created AssistantsToolInstance
"""

data = values.of({})
headers = values.of({})

payload = await self._version.create_async(
method="POST", uri=self._uri, data=data
method="POST", uri=self._uri, data=data, headers=headers
)

return AssistantsToolInstance(
Expand Down
8 changes: 4 additions & 4 deletions twilio/rest/flex_api/v1/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def fetch(
:returns: The fetched ConfigurationInstance
"""

data = values.of(
params = values.of(
{
"UiVersion": ui_version,
}
Expand All @@ -309,7 +309,7 @@ def fetch(
headers["Accept"] = "application/json"

payload = self._version.fetch(
method="GET", uri=self._uri, params=data, headers=headers
method="GET", uri=self._uri, params=params, headers=headers
)

return ConfigurationInstance(
Expand All @@ -328,7 +328,7 @@ async def fetch_async(
:returns: The fetched ConfigurationInstance
"""

data = values.of(
params = values.of(
{
"UiVersion": ui_version,
}
Expand All @@ -339,7 +339,7 @@ async def fetch_async(
headers["Accept"] = "application/json"

payload = await self._version.fetch_async(
method="GET", uri=self._uri, params=data, headers=headers
method="GET", uri=self._uri, params=params, headers=headers
)

return ConfigurationInstance(
Expand Down
30 changes: 14 additions & 16 deletions twilio/rest/flex_api/v1/insights_questionnaires.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,17 @@ def fetch(
:returns: The fetched InsightsQuestionnairesInstance
"""

data = values.of(
{
"Authorization": authorization,
}
)

headers = values.of({})

if not (
authorization is values.unset
or (isinstance(authorization, str) and not authorization)
):
headers["Authorization"] = authorization

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

payload = self._version.fetch(
method="GET", uri=self._uri, params=data, headers=headers
)
payload = self._version.fetch(method="GET", uri=self._uri, headers=headers)

return InsightsQuestionnairesInstance(
self._version,
Expand All @@ -289,18 +287,18 @@ async def fetch_async(
:returns: The fetched InsightsQuestionnairesInstance
"""

data = values.of(
{
"Authorization": authorization,
}
)

headers = values.of({})

if not (
authorization is values.unset
or (isinstance(authorization, str) and not authorization)
):
headers["Authorization"] = authorization

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

payload = await self._version.fetch_async(
method="GET", uri=self._uri, params=data, headers=headers
method="GET", uri=self._uri, headers=headers
)

return InsightsQuestionnairesInstance(
Expand Down
38 changes: 26 additions & 12 deletions twilio/rest/flex_api/v1/insights_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,21 @@ def create(

:returns: The created InsightsSessionInstance
"""
data = values.of(
{
"Authorization": authorization,
}
)

payload = self._version.create(method="POST", uri=self._uri, data=data)
data = values.of({})
headers = values.of({})

if not (
authorization is values.unset
or (isinstance(authorization, str) and not authorization)
):
headers["Authorization"] = authorization

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

payload = self._version.create(
method="POST", uri=self._uri, data=data, headers=headers
)

return InsightsSessionInstance(self._version, payload)

Expand All @@ -134,14 +142,20 @@ async def create_async(

:returns: The created InsightsSessionInstance
"""
data = values.of(
{
"Authorization": authorization,
}
)

data = values.of({})
headers = values.of({})

if not (
authorization is values.unset
or (isinstance(authorization, str) and not authorization)
):
headers["Authorization"] = authorization

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

payload = await self._version.create_async(
method="POST", uri=self._uri, data=data
method="POST", uri=self._uri, data=data, headers=headers
)

return InsightsSessionInstance(self._version, payload)
Expand Down
30 changes: 14 additions & 16 deletions twilio/rest/flex_api/v1/insights_user_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,17 @@ def fetch(
:returns: The fetched InsightsUserRolesInstance
"""

data = values.of(
{
"Authorization": authorization,
}
)

headers = values.of({})

if not (
authorization is values.unset
or (isinstance(authorization, str) and not authorization)
):
headers["Authorization"] = authorization

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

payload = self._version.fetch(
method="GET", uri=self._uri, params=data, headers=headers
)
payload = self._version.fetch(method="GET", uri=self._uri, headers=headers)

return InsightsUserRolesInstance(
self._version,
Expand All @@ -139,18 +137,18 @@ async def fetch_async(
:returns: The fetched InsightsUserRolesInstance
"""

data = values.of(
{
"Authorization": authorization,
}
)

headers = values.of({})

if not (
authorization is values.unset
or (isinstance(authorization, str) and not authorization)
):
headers["Authorization"] = authorization

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

payload = await self._version.fetch_async(
method="GET", uri=self._uri, params=data, headers=headers
method="GET", uri=self._uri, headers=headers
)

return InsightsUserRolesInstance(
Expand Down
30 changes: 14 additions & 16 deletions twilio/rest/flex_api/v1/plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,17 @@ def fetch(self, flex_metadata: Union[str, object] = values.unset) -> PluginInsta
:returns: The fetched PluginInstance
"""

data = values.of(
{
"Flex-Metadata": flex_metadata,
}
)

headers = values.of({})

if not (
flex_metadata is values.unset
or (isinstance(flex_metadata, str) and not flex_metadata)
):
headers["Flex-Metadata"] = flex_metadata

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

payload = self._version.fetch(
method="GET", uri=self._uri, params=data, headers=headers
)
payload = self._version.fetch(method="GET", uri=self._uri, headers=headers)

return PluginInstance(
self._version,
Expand All @@ -223,18 +221,18 @@ async def fetch_async(
:returns: The fetched PluginInstance
"""

data = values.of(
{
"Flex-Metadata": flex_metadata,
}
)

headers = values.of({})

if not (
flex_metadata is values.unset
or (isinstance(flex_metadata, str) and not flex_metadata)
):
headers["Flex-Metadata"] = flex_metadata

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

payload = await self._version.fetch_async(
method="GET", uri=self._uri, params=data, headers=headers
method="GET", uri=self._uri, headers=headers
)

return PluginInstance(
Expand Down
Loading
Loading