Ruby SDK Samples - Blueprint Operations
Get Blueprint Details
Update Blueprint
require 'ZOHOCRMSDK2_0'
class Blueprint
def self.update_blueprint(module_api_name, record_id, transition_id)
# """
# This method is used to update a single record's Blueprint details with ID and print the response.
# :param module_api_name: The API Name of the record's module
# :param record_id: The ID of the record to update Blueprint
# :param transition_id: The ID of the Blueprint transition Id
# """
# """
# example
# module_api_name = "Leads"
# record_id = "3409643000002469044"
# transition_id = '3409643000001172075'
# """
# Get instance of BluePrintOperations Class that takes module_api_name and record_id as parameter
bpo = BluePrint::BluePrintOperations.new(record_id, module_api_name)
# Get instance of BodyWrapper Class that will contain the request body
bw = BluePrint::BodyWrapper.new
# Get instance of BluePrint Class
blue_print = BluePrint::BluePrint.new
# Set transitionId to the BluePrint instance
blue_print.transition_id = transition_id
# Get instance of Record Class
data = Record::Record.new
data.add_key_value('Phone', '8940372937')
data.add_key_value('Notes', 'Updated via blueprint')
# Set data to the BluePrint instance
blue_print.data = data
# List to contain BluePrint instances
# Add BluePrint instance to the list
blue_print_list = [blue_print]
# Set the list to bluePrint in BodyWrapper instance
bw.blueprint = blue_print_list
# Call updateBluePrint method that takes BodyWrapper instance as parameter
response = bpo.update_blueprint(bw)
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_response = response.data_object
# Check if SuccessResponse instance is received.
if action_response.is_a? BluePrint::SuccessResponse
success_response = action_response
# 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 APIException instance is received.
elsif action_response.is_a? BluePrint::APIException
api_exception = action_response
# Get the Code
print 'code:'
print api_exception.code.value
# Get the Status
print "\n status:"
# Get the message
print api_exception.status.value
print "\n message:"
print api_exception.message.value
# Get the details map
api_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