|
| 1 | +from sendsafely import SendSafely, Package, utilities |
| 2 | + |
| 3 | +# Edit these variables |
| 4 | +api_key = "" |
| 5 | +api_secret = "" |
| 6 | +base_url = "https://companyabc.sendsafely.com" |
| 7 | + |
| 8 | + |
| 9 | +def rest_get_example_user_information(sendsafely): |
| 10 | + get_endpoint = "/user/" |
| 11 | + response = utilities.get_request(sendsafely, get_endpoint) |
| 12 | + print(response) |
| 13 | + |
| 14 | + |
| 15 | +def rest_post_example_update_package_life(sendsafely): |
| 16 | + package = Package(sendsafely) |
| 17 | + post_endpoint = "/package/" + package.package_id |
| 18 | + body = {"life": 10} |
| 19 | + response = utilities.post_request(sendsafely, post_endpoint, body) |
| 20 | + print(response) |
| 21 | + |
| 22 | + |
| 23 | +def rest_delete_example_delete_package(sendsafely): |
| 24 | + package = Package(sendsafely) |
| 25 | + delete_endpoint = "/package/" + package.package_id |
| 26 | + response = utilities.delete_request(sendsafely, delete_endpoint) |
| 27 | + print(response) |
| 28 | + |
| 29 | + |
| 30 | +def rest_put_example_add_recipients(sendsafely): |
| 31 | + package = Package(sendsafely) |
| 32 | + put_endpoint = "/package/" + package.package_id + "/recipients/" |
| 33 | + response = utilities.put_request(sendsafely, put_endpoint, |
| 34 | + {'emails': ['user@foobar.com', 'user2@foobar.com']}) |
| 35 | + print(response) |
| 36 | + |
| 37 | + |
| 38 | +def rest_patch_example_update_file(sendsafely): |
| 39 | + # Edit |
| 40 | + package_id = 'packageId of Dropzone package' |
| 41 | + file_id = 'fileId of Dropzone package' |
| 42 | + body = {'fileName': 'new file name'} |
| 43 | + |
| 44 | + patch_endpoint = "/package/" + package_id + "/file/" + file_id |
| 45 | + response = utilities.patch_request(sendsafely, patch_endpoint, body) |
| 46 | + print(response) |
| 47 | + |
| 48 | + |
| 49 | +def main(): |
| 50 | + sendsafely = SendSafely(base_url, api_key, api_secret) |
| 51 | + print("GET: User Information") |
| 52 | + rest_get_example_user_information(sendsafely) |
| 53 | + print("POST: Update Package Life") |
| 54 | + rest_post_example_update_package_life(sendsafely) |
| 55 | + print("PUT: Add Recipients") |
| 56 | + rest_put_example_add_recipients(sendsafely) |
| 57 | + print("DELETE: Delete Package") |
| 58 | + rest_delete_example_delete_package(sendsafely) |
| 59 | + # print("PATCH: Update Dropzone File") |
| 60 | + # rest_patch_example_update_file(sendsafely) |
| 61 | + |
| 62 | + |
| 63 | +if __name__ == '__main__': |
| 64 | + main() |
0 commit comments