Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added boolean_to_string converter for python #554

Merged
merged 5 commits into from
Feb 22, 2024
Merged
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
8 changes: 4 additions & 4 deletions examples/python/tests/unit/credential_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_create_credentials(self, mock_request):
request_args = self.generic_request_args
request_args["data"] = {
"TestString": "abc",
"TestBoolean": True,
"TestBoolean": "true",
"TestAnyArray": ['{"any": "thing"}', '{"another": "thing"}'],
"TestAnyType": '{"type": "any"}',
}
Expand All @@ -48,7 +48,7 @@ def test_update_credentials(self, mock_request):
test_boolean=False, test_string="new string"
)
request_args = self.generic_request_args
request_args["data"] = {"TestString": "new string", "TestBoolean": False}
request_args["data"] = {"TestString": "new string", "TestBoolean": "false"}

mock_request.assert_called_once_with(
"POST", "http://flex-api.twilio.com/v1/Credentials/AWS/123", **request_args
Expand Down Expand Up @@ -113,7 +113,7 @@ async def test_async_create_credentials(self, mock_request):
request_args = self.generic_request_args
request_args["data"] = {
"TestString": "abc",
"TestBoolean": True,
"TestBoolean": "true",
"TestAnyArray": ['{"any": "thing"}', '{"another": "thing"}'],
"TestAnyType": '{"type": "any"}',
}
Expand All @@ -129,7 +129,7 @@ async def test_async_update_credentials(self, mock_request):
test_boolean=False, test_string="new string"
)
request_args = self.generic_request_args
request_args["data"] = {"TestString": "new string", "TestBoolean": False}
request_args["data"] = {"TestString": "new string", "TestBoolean": "false"}

mock_request.assert_called_once_with(
"POST", "http://flex-api.twilio.com/v1/Credentials/AWS/123", **request_args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
Expand Down Expand Up @@ -249,7 +249,7 @@ def update(
data = values.of(
{
"TestString": test_string,
"TestBoolean": test_boolean,
"TestBoolean": serialize.boolean_to_string(test_boolean),
}
)

Expand Down Expand Up @@ -277,7 +277,7 @@ async def update_async(
data = values.of(
{
"TestString": test_string,
"TestBoolean": test_boolean,
"TestBoolean": serialize.boolean_to_string(test_boolean),
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def create(
data = values.of(
{
"TestString": test_string,
"TestBoolean": test_boolean,
"TestBoolean": serialize.boolean_to_string(test_boolean),
"TestInteger": test_integer,
"TestNumber": test_number,
"TestNumberFloat": test_number_float,
Expand Down Expand Up @@ -195,7 +195,7 @@ async def create_async(
data = values.of(
{
"TestString": test_string,
"TestBoolean": test_boolean,
"TestBoolean": serialize.boolean_to_string(test_boolean),
"TestInteger": test_integer,
"TestNumber": test_number,
"TestNumberFloat": test_number_float,
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/config/python.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"date_time": "serialize.iso8601_datetime({value})",
"date_or_time": "serialize.iso8601_datetime({value})",
"date_time_inequality": "serialize.iso8601_datetime({value})",
"prefixed_collapsible_map": "serialize.prefixed_collapsible_map({value}, {trait})"
"prefixed_collapsible_map": "serialize.prefixed_collapsible_map({value}, {trait})",
"boolean": "serialize.boolean_to_string({value})"
},

"deserialize": {
Expand Down
Loading