Python SDK Samples - Organization Operations
Get Organization Details
Upload Organization Photo
from zcrmsdk.src.com.zoho.crm.api.org import *
from zcrmsdk.src.com.zoho.crm.api.util import StreamWrapper
class Organization(object):
@staticmethod
def upload_organization_photo(absolute_file_path):
"""
This method is used to upload the brand logo or image of the organization and print the response.
:param absolute_file_path: The absolute file path of the file to be attached
"""
"""
example
absolute_file_path = "/Users/user_name/Desktop/logo.png";
"""
# Get instance of OrgOperations Class
org_operations = OrgOperations()
# Get instance of FileBodyWrapper class that will contain the request file
request = FileBodyWrapper()
"""
StreamWrapper can be initialized in any of the following ways
* param 1 -> fileName
* param 2 -> Read Stream.
"""
# stream_wrapper = StreamWrapper(stream=open(absolute_file_path, 'rb'))
"""
* param 1 -> fileName
* param 2 -> Read Stream
* param 3 -> Absolute File Path of the file to be attached
"""
stream_wrapper = StreamWrapper(file_path=absolute_file_path)
# Set file to the FileBodyWrapper instance
request.set_file(stream_wrapper)
# Call upload_organization_photo method that takes FileBodyWrapper instance as parameter
response = org_operations.upload_organization_photo(request)
if response is not None:
# Get the status code from response
print('Status Code: ' + str(response.get_status_code()))
# Get object from response
response_object = response.get_object()
if response_object is not None:
# Check if expected ActionWrapper instance is received.
if isinstance(response_object, SuccessResponse):
# Get the Status
print("Status: " + response_object.get_status().get_value())
# Get the Code
print("Code: " + response_object.get_code().get_value())
print("Details")
# Get the details dict
details = response_object.get_details()
for key, value in details.items():
print(key + ' : ' + str(value))
# Get the Message
print("Message: " + response_object.get_message().get_value())
# Check if the request returned an exception
elif isinstance(response_object, APIException):
# Get the Status
print("Status: " + response_object.get_status().get_value())
# Get the Code
print("Code: " + response_object.get_code().get_value())
print("Details")
# Get the details dict
details = response_object.get_details()
for key, value in details.items():
print(key + ' : ' + str(value))
# Get the Message
print("Message: " + response_object.get_message().get_value())