Skip to content

Commit

Permalink
chore: adding contentType in put and post
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwarishubham635 committed Aug 2, 2024
1 parent ac01d83 commit 5eed26b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
53 changes: 38 additions & 15 deletions twilio/rest/content/v1/content/approval_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Do not edit the class manually.
"""

from typing import Any, Dict, Optional, Union
from typing import Any, Dict, Optional
from twilio.base import values

from twilio.base.instance_resource import InstanceResource
Expand All @@ -30,7 +30,7 @@ class ApprovalCreateInstance(InstanceResource):
:ivar allow_category_change:
"""

def __init__(self, version: Version, payload: Dict[str, Any], sid: str):
def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str):
super().__init__(version)

self.name: Optional[str] = payload.get("name")
Expand All @@ -43,7 +43,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], sid: str):
)

self._solution = {
"sid": sid,
"content_sid": content_sid,
}

def __repr__(self) -> str:
Expand All @@ -58,33 +58,52 @@ def __repr__(self) -> str:

class ApprovalCreateList(ListResource):

def __init__(self, version: Version, sid: str):
class ContentApprovalRequest(object):
"""
:ivar name: Name of the template.
:ivar category: A WhatsApp recognized template category.
"""

def __init__(self, payload: Dict[str, Any]):

self.name: Optional[str] = payload.get("name")
self.category: Optional[str] = payload.get("category")

def to_dict(self):
return {
"name": self.name,
"category": self.category,
}

def __init__(self, version: Version, content_sid: str):
"""
Initialize the ApprovalCreateList
:param version: Version that contains the resource
:param sid:
:param content_sid:
"""
super().__init__(version)

# Path Solution
self._solution = {
"sid": sid,
"content_sid": content_sid,
}
self._uri = "/Content/{sid}/ApprovalRequests/whatsapp".format(**self._solution)
self._uri = "/Content/{content_sid}/ApprovalRequests/whatsapp".format(
**self._solution
)

def create(
self, body: Union[object, object] = values.unset
self, content_approval_request: ContentApprovalRequest
) -> ApprovalCreateInstance:
"""
Create the ApprovalCreateInstance
:param body:
:param content_approval_request:
:returns: The created ApprovalCreateInstance
"""
data = body.to_dict()
data = content_approval_request.to_dict()

headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})
headers["Content-Type"] = "application/json"
Expand All @@ -93,19 +112,21 @@ def create(
method="POST", uri=self._uri, data=data, headers=headers
)

return ApprovalCreateInstance(self._version, payload, sid=self._solution["sid"])
return ApprovalCreateInstance(
self._version, payload, content_sid=self._solution["content_sid"]
)

async def create_async(
self, body: Union[object, object] = values.unset
self, content_approval_request: ContentApprovalRequest
) -> ApprovalCreateInstance:
"""
Asynchronously create the ApprovalCreateInstance
:param body:
:param content_approval_request:
:returns: The created ApprovalCreateInstance
"""
data = body.to_dict()
data = content_approval_request.to_dict()

headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})
headers["Content-Type"] = "application/json"
Expand All @@ -114,7 +135,9 @@ async def create_async(
method="POST", uri=self._uri, data=data, headers=headers
)

return ApprovalCreateInstance(self._version, payload, sid=self._solution["sid"])
return ApprovalCreateInstance(
self._version, payload, content_sid=self._solution["content_sid"]
)

def __repr__(self) -> str:
"""
Expand Down
2 changes: 1 addition & 1 deletion twilio/rest/content/v1/content_and_approvals.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ContentAndApprovalsInstance(InstanceResource):
:ivar friendly_name: A string name used to describe the Content resource. Not visible to the end recipient.
:ivar language: Two-letter (ISO 639-1) language code (e.g., en) identifying the language the Content resource is in.
:ivar variables: Defines the default placeholder values for variables included in the Content resource. e.g. {\"1\": \"Customer_Name\"}.
:ivar types: The [Content types](https://www.twilio.com/docs/content/content-types-overview) (e.g. twilio/text) for this Content resource.
:ivar types: The [Content types](https://www.twilio.com/docs/content-api/content-types-overview) (e.g. twilio/text) for this Content resource.
:ivar approval_requests: The submitted information and approval request status of the Content resource.
"""

Expand Down
2 changes: 1 addition & 1 deletion twilio/rest/content/v1/legacy_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LegacyContentInstance(InstanceResource):
:ivar friendly_name: A string name used to describe the Content resource. Not visible to the end recipient.
:ivar language: Two-letter (ISO 639-1) language code (e.g., en) identifying the language the Content resource is in.
:ivar variables: Defines the default placeholder values for variables included in the Content resource. e.g. {\"1\": \"Customer_Name\"}.
:ivar types: The [Content types](https://www.twilio.com/docs/content/content-types-overview) (e.g. twilio/text) for this Content resource.
:ivar types: The [Content types](https://www.twilio.com/docs/content-api/content-types-overview) (e.g. twilio/text) for this Content resource.
:ivar legacy_template_name: The string name of the legacy content template associated with this Content resource, unique across all template names for its account. Only lowercase letters, numbers and underscores are allowed
:ivar legacy_body: The string body field of the legacy content template associated with this Content resource
:ivar url: The URL of the resource, relative to `https://content.twilio.com`.
Expand Down

0 comments on commit 5eed26b

Please sign in to comment.