Skip to content

Commit 67911ed

Browse files
Ihor BilousIhor Bilous
authored andcommitted
Fix issue #53: Fix order of calling functions in example
1 parent 593ea1c commit 67911ed

File tree

6 files changed

+26
-27
lines changed

6 files changed

+26
-27
lines changed

examples/contacts/contact_fields.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ def delete_contact_field(contact_field_id: int) -> DeletedObject:
5454
fields = list_contact_fields()
5555
print(fields)
5656

57-
field_id = fields[0].id
58-
field = get_contact_field(contact_field_id=field_id)
57+
field = get_contact_field(contact_field_id=created.id)
5958
print(field)
6059

6160
updated = update_contact_field(
62-
contact_field_id=field_id, name=f"{field.name}-updated"
61+
contact_field_id=created.id, name=f"{field.name}-updated"
6362
)
6463
print(updated)
6564

66-
deleted = delete_contact_field(contact_field_id=field_id)
65+
deleted = delete_contact_field(contact_field_id=created.id)
6766
print(deleted)

examples/contacts/contact_lists.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ def delete_contact_list(contact_list_id: int) -> DeletedObject:
3838
lists = list_contact_lists()
3939
print(lists)
4040

41-
list_id = lists[0].id
42-
contact_list = get_contact_list(contact_list_id=list_id)
41+
contact_list = get_contact_list(contact_list_id=created.id)
4342
print(contact_list)
4443

4544
updated = update_contact_list(
46-
contact_list_id=list_id,
45+
contact_list_id=created.id,
4746
name=f"{contact_list.name}-updated",
4847
)
4948
print(updated)
5049

51-
deleted = delete_contact_list(contact_list_id=list_id)
50+
deleted = delete_contact_list(contact_list_id=created.id)
5251
print(deleted)

examples/email_templates/templates.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ def create_template(
3232
return templates_api.create(params)
3333

3434

35-
def get_template(template_id: str) -> EmailTemplate:
35+
def get_template(template_id: int) -> EmailTemplate:
3636
return templates_api.get_by_id(template_id)
3737

3838

3939
def update_template(
40-
template_id: str,
40+
template_id: int,
4141
name: Optional[str] = None,
4242
subject: Optional[str] = None,
4343
category: Optional[str] = None,
@@ -54,7 +54,7 @@ def update_template(
5454
return templates_api.update(template_id, params)
5555

5656

57-
def delete_template(template_id: str) -> DeletedObject:
57+
def delete_template(template_id: int) -> DeletedObject:
5858
return templates_api.delete(template_id)
5959

6060

@@ -70,17 +70,16 @@ def delete_template(template_id: str) -> DeletedObject:
7070
templates = list_templates()
7171
print(templates)
7272

73-
template_id = templates[0].id
74-
template = get_template(template_id=template_id)
73+
template = get_template(template_id=created.id)
7574
print(template)
7675

7776
updated = update_template(
78-
template_id=template_id,
77+
template_id=created.id,
7978
name=f"{template.name}-updated",
8079
subject=f"{template.subject}-updated",
8180
body_text=f"{template.body_text}\nUpdated content.",
8281
)
8382
print(updated)
8483

85-
deleted = delete_template(template_id=template_id)
84+
deleted = delete_template(template_id=created.id)
8685
print(deleted)

examples/general/permissions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ def bulk_permissions_update(
3030
print(resources)
3131
if resources:
3232
account_access_id = resources[0].id
33-
payload = [
34-
mt.PermissionResourceParams(resource_name=resources[0].name, permissions=[])
33+
permissions = [
34+
mt.PermissionResourceParams(
35+
resource_id=resources[0].id,
36+
resource_type=resources[0].type,
37+
access_level="viewer",
38+
)
3539
]
3640
updated = bulk_permissions_update(
3741
ACCOUNT_ID,
3842
account_access_id,
39-
payload,
43+
permissions,
4044
)
4145
print(updated)

examples/testing/inboxes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ def delete_inbox(inbox_id: int):
5959

6060

6161
if __name__ == "__main__":
62-
created = create_inbox(project_id=1, inbox_name="example-created-inbox")
63-
print(created)
64-
6562
inboxes = list_inboxes()
6663
print(inboxes)
6764

68-
inbox_id = inboxes[0].id
65+
created = create_inbox(project_id=1, inbox_name="example-created-inbox")
66+
print(created)
67+
68+
inbox_id = created.id
6969
inbox = get_inbox_by_id(inbox_id=inbox_id)
7070
print(inbox)
7171

examples/testing/projects.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ def delete_project(project_id: int):
2929

3030

3131
if __name__ == "__main__":
32-
created = create_project(name="example-created-project")
33-
print(created)
34-
3532
projects = list_projects()
3633
print(projects)
3734

38-
project_id = projects[0].id
35+
created = create_project(name="example-created-project")
36+
print(created)
3937

40-
project = get_project(project_id=project_id)
38+
project = get_project(project_id=created.id)
4139
print(project)
4240

4341
updated = update_project(project_id=created.id, new_name=f"{project.name}-updated")

0 commit comments

Comments
 (0)