Skip to content

Commit

Permalink
chore: generate python examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwarishubham635 committed Dec 12, 2024
1 parent 2fb73b4 commit 81fba7f
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 74 deletions.
64 changes: 44 additions & 20 deletions examples/python/twilio/rest/api/v2010/account/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ def delete(self) -> bool:
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)

headers = values.of({})

return self._version.delete(method="DELETE", uri=self._uri, headers=headers)

async def delete_async(self) -> bool:
"""
Expand All @@ -243,9 +243,11 @@ async def delete_async(self) -> bool:
:returns: True if delete succeeds, False otherwise
"""

headers = values.of({})

return await self._version.delete_async(
method="DELETE",
uri=self._uri,
method="DELETE", uri=self._uri, headers=headers
)

def fetch(self) -> AccountInstance:
Expand All @@ -256,10 +258,11 @@ def fetch(self) -> AccountInstance:
:returns: The fetched AccountInstance
"""

payload = self._version.fetch(
method="GET",
uri=self._uri,
)
headers = values.of({})

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

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

return AccountInstance(
self._version,
Expand All @@ -275,9 +278,12 @@ async def fetch_async(self) -> AccountInstance:
:returns: The fetched AccountInstance
"""

headers = values.of({})

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

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

return AccountInstance(
Expand All @@ -299,17 +305,21 @@ def update(
:returns: The updated AccountInstance
"""

data = values.of(
{
"Status": status,
"PauseBehavior": pause_behavior,
}
)
headers = values.of({})

headers["Content-Type"] = "application/x-www-form-urlencoded"

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

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

return AccountInstance(self._version, payload, sid=self._solution["sid"])
Expand All @@ -327,17 +337,21 @@ async def update_async(
:returns: The updated AccountInstance
"""

data = values.of(
{
"Status": status,
"PauseBehavior": pause_behavior,
}
)
headers = values.of({})

headers["Content-Type"] = "application/x-www-form-urlencoded"

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

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

return AccountInstance(self._version, payload, sid=self._solution["sid"])
Expand Down Expand Up @@ -677,7 +691,13 @@ def page(
}
)

response = self._version.page(method="GET", uri=self._uri, params=data)
headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

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

response = self._version.page(
method="GET", uri=self._uri, params=data, headers=headers
)
return AccountPage(self._version, response)

async def page_async(
Expand Down Expand Up @@ -716,8 +736,12 @@ async def page_async(
}
)

headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

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

response = await self._version.page_async(
method="GET", uri=self._uri, params=data
method="GET", uri=self._uri, params=data, headers=headers
)
return AccountPage(self._version, response)

Expand Down
30 changes: 18 additions & 12 deletions examples/python/twilio/rest/api/v2010/account/call/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ def delete(self) -> bool:
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)

headers = values.of({})

return self._version.delete(method="DELETE", uri=self._uri, headers=headers)

async def delete_async(self) -> bool:
"""
Expand All @@ -206,9 +206,11 @@ async def delete_async(self) -> bool:
:returns: True if delete succeeds, False otherwise
"""

headers = values.of({})

return await self._version.delete_async(
method="DELETE",
uri=self._uri,
method="DELETE", uri=self._uri, headers=headers
)

def fetch(self) -> CallInstance:
Expand All @@ -219,10 +221,11 @@ def fetch(self) -> CallInstance:
:returns: The fetched CallInstance
"""

payload = self._version.fetch(
method="GET",
uri=self._uri,
)
headers = values.of({})

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

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

return CallInstance(
self._version,
Expand All @@ -239,9 +242,12 @@ async def fetch_async(self) -> CallInstance:
:returns: The fetched CallInstance
"""

headers = values.of({})

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

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

return CallInstance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,22 @@ def update(
:returns: The updated FeedbackCallSummaryInstance
"""

data = values.of(
{
"EndDate": serialize.iso8601_date(end_date),
"StartDate": serialize.iso8601_date(start_date),
"AccountSid": account_sid,
}
)
headers = values.of({})

headers["Content-Type"] = "application/x-www-form-urlencoded"

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

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

return FeedbackCallSummaryInstance(
Expand All @@ -242,18 +246,22 @@ async def update_async(
:returns: The updated FeedbackCallSummaryInstance
"""

data = values.of(
{
"EndDate": serialize.iso8601_date(end_date),
"StartDate": serialize.iso8601_date(start_date),
"AccountSid": account_sid,
}
)
headers = values.of({})

headers["Content-Type"] = "application/x-www-form-urlencoded"

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

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

return FeedbackCallSummaryInstance(
Expand Down
16 changes: 10 additions & 6 deletions examples/python/twilio/rest/flex_api/v1/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,14 @@ def update(self) -> CallInstance:
:returns: The updated CallInstance
"""

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

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

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

return CallInstance(self._version, payload, sid=self._solution["sid"])
Expand All @@ -122,12 +124,14 @@ async def update_async(self) -> CallInstance:
:returns: The updated CallInstance
"""

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

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

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

return CallInstance(self._version, payload, sid=self._solution["sid"])
Expand Down
Loading

0 comments on commit 81fba7f

Please sign in to comment.