Ruby SDK Samples - Organization Operations
Get Organization Details
Upload Organization Photo
require 'ZOHOCRMSDK2_0'
class Organization
def self.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_operation = Org::OrgOperations.new
fbw = Org::FileBodyWrapper.new
# """
# StreamWrapper can be initialized in any of the following ways
# * param 1 -> fileName
# * param 2 -> Read Stream.
# * param 3 -> Absolute File Path of the file to be attached
# """
# stream_wrapper = StreamWrapper.new(name,stream,absolutefilepath)
sw = Util::StreamWrapper.new(nil, nil, absolute_file_path)
# Set file to the FileBodyWrapper instance
fbw.file = sw
response = org_operation.upload_organization_photo(fbw)
unless response.nil?
status_code = response.status_code
# Get the status code from response
print "\n Status Code :" + status_code.to_s
# Check if expected instance is received.
if response.is_expected
# Get object from response
action_handler = response.data_object
# Check if expected SuccessResponse instance is received
if action_handler.is_a? Org::SuccessResponse
success_response = action_handler
# Get the Code
print 'code:'
print success_response.code.value
# Get the status
print "\n status:"
print success_response.status.value
# Get the message
print "\n message:"
print success_response.message.value
# Get the details map
success_response.details.each do |k, v|
print "\n"
print k
print v
print "\n"
end
# Check if the request returned an exception
elsif action_handler.is_a? Org::APIException
exception = action_handler
# Get the Code
print 'code:'
print exception.code.value
# Get the Status
print "\n status:"
print exception.status.value
# Get the Message
print "\n message:"
print exception.message.value
# Get the details map
exception.details.each do |k, v|
print "\n"
print k
print v
print "\n"
end
print "\n"
end
else
response_object = response.data_object
response_object.instance_variables.each do |field|
print field
print "\n"
print response_object.instance_variable_get(field)
end
end
end
end
end