Skip to content

Commit

Permalink
fix(ts): remove most of use of any in generated code (box/box-codegen…
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build committed Apr 26, 2024
1 parent 7bb02ca commit 08b1767
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "9443573", "specHash": "1698c95", "version": "0.6.4" }
{ "engineHash": "cb5120c", "specHash": "1698c95", "version": "0.6.4" }
2 changes: 1 addition & 1 deletion docs/collaboration_allowlist_entries.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ See the endpoint docs at
<!-- sample post_collaboration_whitelist_entries -->

```python
client.collaboration_allowlist_entries.create_collaboration_whitelist_entry(domain, direction)
client.collaboration_allowlist_entries.create_collaboration_whitelist_entry(domain, CreateCollaborationWhitelistEntryDirection.INBOUND.value)
```

### Arguments
Expand Down
2 changes: 1 addition & 1 deletion docs/web_links.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ See the endpoint docs at
<!-- sample put_web_links_id -->

```python
client.web_links.update_web_link_by_id(weblink.id, name=updated_name, shared_link=UpdateWebLinkByIdSharedLink(access=shared_access, password=password))
client.web_links.update_web_link_by_id(weblink.id, name=updated_name, shared_link=UpdateWebLinkByIdSharedLink(access=UpdateWebLinkByIdSharedLinkAccessField.OPEN.value, password=password))
```

### Arguments
Expand Down
15 changes: 10 additions & 5 deletions test/collaboration_allowlist_entries.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from box_sdk_gen.internal.utils import to_string

import pytest

from box_sdk_gen.client import BoxClient
Expand All @@ -6,6 +8,10 @@

from box_sdk_gen.schemas import CollaborationAllowlistEntry

from box_sdk_gen.managers.collaboration_allowlist_entries import (
CreateCollaborationWhitelistEntryDirection,
)

from test.commons import get_default_client

client: BoxClient = get_default_client()
Expand All @@ -16,23 +22,22 @@ def collaborationAllowlistEntries():
client.collaboration_allowlist_entries.get_collaboration_whitelist_entries()
)
assert len(allowlist.entries) >= 0
direction: str = 'inbound'
domain: str = 'example.com'
new_entry: CollaborationAllowlistEntry = (
client.collaboration_allowlist_entries.create_collaboration_whitelist_entry(
domain, direction
domain, CreateCollaborationWhitelistEntryDirection.INBOUND.value
)
)
assert new_entry.type == 'collaboration_whitelist_entry'
assert new_entry.direction == direction
assert to_string(new_entry.type) == 'collaboration_whitelist_entry'
assert to_string(new_entry.direction) == 'inbound'
assert new_entry.domain == domain
entry: CollaborationAllowlistEntry = (
client.collaboration_allowlist_entries.get_collaboration_whitelist_entry_by_id(
new_entry.id
)
)
assert entry.id == new_entry.id
assert entry.direction == direction
assert to_string(entry.direction) == to_string(new_entry.direction)
assert entry.domain == domain
client.collaboration_allowlist_entries.delete_collaboration_whitelist_entry_by_id(
entry.id
Expand Down
6 changes: 2 additions & 4 deletions test/file_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

from box_sdk_gen.managers.file_metadata import DeleteFileMetadataByIdScope

from box_sdk_gen.schemas import MetadataTemplate

from box_sdk_gen.managers.metadata_templates import CreateMetadataTemplateFields

from box_sdk_gen.managers.metadata_templates import (
Expand Down Expand Up @@ -64,7 +62,7 @@ def testGlobalFileMetadata():
)
assert received_metadata.extra_data['abc'] == 'xyz'
new_value: str = 'bar'
updated_metadata: MetadataFull = client.file_metadata.update_file_metadata_by_id(
client.file_metadata.update_file_metadata_by_id(
file.id,
UpdateFileMetadataByIdScope.GLOBAL.value,
'properties',
Expand Down Expand Up @@ -95,7 +93,7 @@ def testGlobalFileMetadata():
def testEnterpriseFileMetadata():
file: FileFull = upload_new_file()
template_key: str = ''.join(['key', get_uuid()])
template: MetadataTemplate = client.metadata_templates.create_metadata_template(
client.metadata_templates.create_metadata_template(
'enterprise',
template_key,
template_key=template_key,
Expand Down
24 changes: 11 additions & 13 deletions test/folder_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,17 @@ def testGlobalFolderMetadata():
)
assert received_metadata.extra_data['abc'] == 'xyz'
new_value: str = 'bar'
updated_metadata: MetadataFull = (
client.folder_metadata.update_folder_metadata_by_id(
folder.id,
UpdateFolderMetadataByIdScope.GLOBAL.value,
'properties',
[
UpdateFolderMetadataByIdRequestBody(
op=UpdateFolderMetadataByIdRequestBodyOpField.REPLACE.value,
path='/abc',
value=new_value,
)
],
)
client.folder_metadata.update_folder_metadata_by_id(
folder.id,
UpdateFolderMetadataByIdScope.GLOBAL.value,
'properties',
[
UpdateFolderMetadataByIdRequestBody(
op=UpdateFolderMetadataByIdRequestBodyOpField.REPLACE.value,
path='/abc',
value=new_value,
)
],
)
received_updated_metadata: MetadataFull = (
client.folder_metadata.get_folder_metadata_by_id(
Expand Down
13 changes: 8 additions & 5 deletions test/weblinks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from box_sdk_gen.internal.utils import to_string

from box_sdk_gen.client import BoxClient

from box_sdk_gen.schemas import FolderFull
Expand All @@ -8,19 +10,20 @@

from box_sdk_gen.managers.web_links import UpdateWebLinkByIdSharedLink

from box_sdk_gen.managers.web_links import UpdateWebLinkByIdSharedLinkAccessField

from box_sdk_gen.internal.utils import get_uuid

from test.commons import get_default_client

client: BoxClient = get_default_client()


def test_create_get_delete_weblink():
def test_createGetDeleteWeblink():
url: str = 'https://www.box.com'
parent: FolderFull = client.folders.get_folder_by_id('0')
name: str = get_uuid()
description: str = 'Weblink description'
shared_access: str = 'open'
password: str = 'super-secret-password'
weblink: WebLink = client.web_links.create_web_link(
url, CreateWebLinkParent(id=parent.id), name=name, description=description
Expand All @@ -37,11 +40,11 @@ def test_create_get_delete_weblink():
weblink.id,
name=updated_name,
shared_link=UpdateWebLinkByIdSharedLink(
access=shared_access, password=password
access=UpdateWebLinkByIdSharedLinkAccessField.OPEN.value, password=password
),
)
assert updated_weblink.name == updated_name
assert updated_weblink.shared_link.access == shared_access
assert to_string(updated_weblink.shared_link.access) == 'open'
client.web_links.delete_web_link_by_id(weblink.id)
deleted_weblink: WebLink = client.web_links.get_web_link_by_id(weblink.id)
assert deleted_weblink.item_status == 'trashed'
assert to_string(deleted_weblink.item_status) == 'trashed'

0 comments on commit 08b1767

Please sign in to comment.