Copiedcurl -X POST \
https://api.office-integrator.com/writer/officeapi/v1/documents \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F apikey=423s***** \
-F document=@/Users/username/Documents/Sample.docx \
-F 'document_defaults={"track_changes":"disabled","language":"en-US","date_format":"MM/DD/YY"}' \
-F 'editor_settings={'\''unit'\'':'\''in'\'','\''language'\'':'\''en'\'','\''view'\'':'\''webview'\''}' \
-F 'permissions={'\''document.export'\'':true,'\''document.print'\'':true,'\''document.edit'\'':true,'\''review.changes.resolve'\'':false,'\''review.comment'\'':true,'\''collab.chat'\'':true,'\''document.pausecollaboration'\'':false,'\''document.fill'\'':true }' \
-F 'callback_settings={'\''save_format'\'':'\''zdoc'\'','\''save_url'\'':'\''https://domain.com/save.php/'\'}' \
-F 'document_info={'\''document_name'\'':'\''New'\'', '\''document_id'\'':1349}' \
-F 'user_info={'\''user_id'\'':'\''1973'\'','\''display_name'\'':'\''Ken'\''}' \
-F 'ui_options={"save_button":"show","chat_panel":"show","dark_mode":"hide","file_menu":"show"}'
Copiedimport * as SDK from "@zoho-corp/office-integrator-sdk";
import { readFileSync } from 'fs';
const __dirname = import.meta.dirname;
class EditDocument {
static async execute() {
//Initializing SDK once is enough. Calling here since code sample will be tested standalone.
//You can place SDK initializer code in you application and call once while your application start-up.
await this.initializeSdk();
try {
var sdkOperations = new SDK.V1.V1Operations();
var createDocumentParameters = new SDK.V1.CreateDocumentParameters();
//Either use url as document source or attach the document in request body use below methods
createDocumentParameters.setUrl("https://demo.office-integrator.com/zdocs/Graphic-Design-Proposal.docx");
// var fileName = "Graphic-Design-Proposal.docx";
// var filePath = __dirname + "/sample_documents/Graphic-Design-Proposal.docx";
// var fileStream = readFileSync(filePath);
// var streamWrapper = new SDK.StreamWrapper(fileName, fileStream, filePath);
// createDocumentParameters.setDocument(streamWrapper);
var documentInfo = new SDK.V1.DocumentInfo();
//Time value used to generate unique document everytime. You can replace based on your application.
documentInfo.setDocumentId("" + new Date().getTime());
documentInfo.setDocumentName("Graphic-Design-Proposal.docx");
createDocumentParameters.setDocumentInfo(documentInfo);
var userInfo = new SDK.V1.UserInfo();
userInfo.setUserId("1000");
userInfo.setDisplayName("Amelia");
createDocumentParameters.setUserInfo(userInfo);
var margin = new SDK.V1.Margin();
margin.setTop("2in");
margin.setBottom("2in");
margin.setLeft("2in");
margin.setRight("2in");
var documentDefaults = new SDK.V1.DocumentDefaults();
documentDefaults.setLanguage("ta");
documentDefaults.setTrackChanges("enabled");
createDocumentParameters.setDocumentDefaults(documentDefaults);
var editorSettings = new SDK.V1.EditorSettings();
editorSettings.setUnit("mm");
editorSettings.setLanguage("en");
editorSettings.setView("pageview");
createDocumentParameters.setEditorSettings(editorSettings);
var uiOptions = new SDK.V1.UiOptions();
uiOptions.setDarkMode("show");
uiOptions.setFileMenu("show");
uiOptions.setSaveButton("show");
uiOptions.setChatPanel("show");
createDocumentParameters.setUiOptions(uiOptions);
var permissions = new Map();
permissions.set("document.export", true);
permissions.set("document.print", false);
permissions.set("document.edit", true);
permissions.set("review.comment", false);
permissions.set("review.changes.resolve", false);
permissions.set("collab.chat", false);
permissions.set("document.pausecollaboration", false);
permissions.set("document.fill", false);
createDocumentParameters.setPermissions(permissions);
var callbackSettings = new SDK.V1.CallbackSettings();
var saveUrlParams = new Map();
saveUrlParams.set("auth_token", "1234");
saveUrlParams.set("id", "123131");
var saveUrlHeaders = new Map();
saveUrlHeaders.set("header1", "value1");
saveUrlHeaders.set("header2", "value2");
callbackSettings.setSaveUrlParams(saveUrlParams);
callbackSettings.setSaveUrlHeaders(saveUrlHeaders);
callbackSettings.setRetries(1);
callbackSettings.setTimeout(10000);
callbackSettings.setSaveFormat("zdoc");
callbackSettings.setHttpMethodType("post");
callbackSettings.setSaveUrl("https://officeintegrator.zoho.com/v1/api/webhook/savecallback/601e12157123434d4e6e00cc3da2406df2b9a1d84a903c6cfccf92c8286");
createDocumentParameters.setCallbackSettings(callbackSettings);
var responseObject = await sdkOperations.createDocument(createDocumentParameters);
if(responseObject != null) {
//Get the status code from response
console.log("Status Code: " + responseObject.statusCode);
//Get the api response object from responseObject
let writerResponseObject = responseObject.object;
if(writerResponseObject != null){
//Check if expected CreateDocumentResponse instance is received
if(writerResponseObject instanceof SDK.V1.CreateDocumentResponse){
console.log("\nDocument ID - " + writerResponseObject.getDocumentId());
console.log("\nDocument session ID - " + writerResponseObject.getSessionId());
console.log("\nDocument session URL - " + writerResponseObject.getDocumentUrl());
console.log("\nDocument save URL - " + writerResponseObject.getSaveUrl());
console.log("\nDocument delete URL - " + writerResponseObject.getDocumentDeleteUrl());
console.log("\nDocument session delete URL - " + writerResponseObject.getSessionDeleteUrl());
} else if (writerResponseObject instanceof SDK.V1.InvalidConfigurationException) {
console.log("\nInvalid configuration exception. Exception json - ", writerResponseObject);
} else {
console.log("\nRequest not completed successfullly");
}
}
}
} catch (error) {
console.log("\nException while running sample code", error);
}
}
//Include office-integrator-sdk package in your package json and the execute this code.
static async initializeSdk() {
// Refer this help page for api end point domain details - https://www.zoho.com/officeintegrator/api/v1/getting-started.html
let environment = await new SDK.DataCenter.Production("https://api.office-integrator.com");
let auth = new SDK.AuthBuilder()
.addParam("apikey", "2ae438cf864488657c********") //Update this apikey with your own apikey signed up in office integrator service
.authenticationSchema(await new SDK.V1.Authentication().getTokenFlow())
.build();
let tokens = [ auth ];
//Sdk application log configuration
let logger = new SDK.LogBuilder()
.level(SDK.Levels.INFO)
//.filePath("<file absolute path where logs would be written>") //No I18N
.build();
let initialize = await new SDK.InitializeBuilder();
await initialize.environment(environment).tokens(tokens).logger(logger).initialize();
console.log("SDK initialized successfully.");
}
}
EditDocument.execute();
Copied
package com.zoho.officeintegrator.v1.examples.writer;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import com.zoho.Initializer;
import com.zoho.UserSignature;
import com.zoho.api.authenticator.APIKey;
import com.zoho.api.logger.Logger;
import com.zoho.api.logger.Logger.Levels;
import com.zoho.dc.ZOIEnvironment;
import com.zoho.officeintegrator.v1.CallbackSettings;
import com.zoho.officeintegrator.v1.CreateDocumentParameters;
import com.zoho.officeintegrator.v1.CreateDocumentResponse;
import com.zoho.officeintegrator.v1.DocumentDefaults;
import com.zoho.officeintegrator.v1.DocumentInfo;
import com.zoho.officeintegrator.v1.EditorSettings;
import com.zoho.officeintegrator.v1.InvaildConfigurationException;
import com.zoho.officeintegrator.v1.UiOptions;
import com.zoho.officeintegrator.v1.UserInfo;
import com.zoho.officeintegrator.v1.V1Operations;
import com.zoho.officeintegrator.v1.WriterResponseHandler;
import com.zoho.util.APIResponse;
public class EditDocument {
private static final java.util.logging.Logger LOGGER = java.util.logging.Logger.getLogger(EditDocument.class.getName());
public static void main(String args[]) {
try {
initializeSdk();
V1Operations sdkOperations = new V1Operations();
CreateDocumentParameters editDocumentParams = new CreateDocumentParameters();
editDocumentParams.setUrl("https://demo.office-integrator.com/zdocs/Graphic-Design-Proposal.docx");
DocumentInfo documentInfo = new DocumentInfo();
documentInfo.setDocumentName("Untilted Document");
documentInfo.setDocumentId("" + System.currentTimeMillis());
editDocumentParams.setDocumentInfo(documentInfo);
UserInfo userInfo = new UserInfo();
userInfo.setUserId("1000");
userInfo.setDisplayName("John");
editDocumentParams.setUserInfo(userInfo);
DocumentDefaults documentDefault = new DocumentDefaults();
documentDefault.setTrackChanges("disabled");
editDocumentParams.setDocumentDefaults(documentDefault);
EditorSettings editorSettings = new EditorSettings();
editorSettings.setUnit("in");
editorSettings.setLanguage("en");
editorSettings.setView("pageview");
editDocumentParams.setEditorSettings(editorSettings);
UiOptions uiOptions = new UiOptions();
uiOptions.setChatPanel("show");
uiOptions.setDarkMode("show");
uiOptions.setFileMenu("show");
uiOptions.setSaveButton("show");
editDocumentParams.setUiOptions(uiOptions);
Map<String, Object> permissions = new HashMap<String, Object>();
permissions.put("collab.chat", false);
permissions.put("document.edit", true);
permissions.put("review.comment", false);
permissions.put("document.export", true);
permissions.put("document.print", false);
permissions.put("document.fill", false);
permissions.put("review.changes.resolve", false);
permissions.put("document.pausecollaboration", false);
editDocumentParams.setPermissions(permissions);
Map<String, Object> saveUrlParams = new HashMap<String, Object>();
saveUrlParams.put("id", 123456789);
saveUrlParams.put("auth_token", "oswedf32rk");
CallbackSettings callbackSettings = new CallbackSettings();
callbackSettings.setRetries(2);
callbackSettings.setTimeout(10000);
callbackSettings.setSaveFormat("docx");
callbackSettings.setHttpMethodType("post");
callbackSettings.setSaveUrlParams(saveUrlParams);
callbackSettings.setSaveUrl("https://domain.com/save.php");
editDocumentParams.setCallbackSettings(callbackSettings);
APIResponse<WriterResponseHandler> response = sdkOperations.createDocument(editDocumentParams);
int responseStatusCode = response.getStatusCode();
if ( responseStatusCode >= 200 && responseStatusCode <= 299 ) {
CreateDocumentResponse documentResponse = (CreateDocumentResponse) response.getObject();
LOGGER.log(Level.INFO, "Document id - {0}", new Object[] { documentResponse.getDocumentId() });
LOGGER.log(Level.INFO, "Document session id - {0}", new Object[] { documentResponse.getSessionId() });
LOGGER.log(Level.INFO, "Document session url - {0}", new Object[] { documentResponse.getDocumentUrl() });
} else {
InvaildConfigurationException invalidConfiguration = (InvaildConfigurationException) response.getObject();
String errorMessage = invalidConfiguration.getMessage();
LOGGER.log(Level.INFO, "Document configuration error - {0}", new Object[] { errorMessage });
}
} catch (Exception e) {
LOGGER.log(Level.INFO, "Exception in creating document session url - ", e);
}
}
public static boolean initializeSdk() {
boolean status = false;
try {
APIKey apikey = new APIKey("2ae438cf864488657cc9754a2*****”);
UserSignature user = new UserSignature("john@zylker.com");
Logger logger = new Logger.Builder()
.level(Levels.INFO)
.build();
ZOIEnvironment.setProductionUrl("https://api.office-integrator.com/");
new Initializer.Builder()
.user(user)
.environment(ZOIEnvironment.PRODUCTION)
.token(apikey)
.logger(logger)
.initialize();
status = true;
} catch (Exception e) {
LOGGER.log(Level.INFO, "Exception in creating document session url - ", e);
}
return status;
}
}
Copied#Reference on how to run the below sample code: http://zco.to/run-php
<?php
namespace com\zoho\officeintegrator\v1\writer;
require_once dirname(__FILE__) . '/../vendor/autoload.php';
use com\zoho\api\authenticator\APIKey;
use com\zoho\api\logger\Levels;
use com\zoho\api\logger\LogBuilder;
use com\zoho\dc\DataCenter;
use com\zoho\InitializeBuilder;
use com\zoho\officeintegrator\v1\CallbackSettings;
use com\zoho\officeintegrator\v1\CreateDocumentParameters;
use com\zoho\officeintegrator\v1\CreateDocumentResponse;
use com\zoho\officeintegrator\v1\DocumentDefaults;
use com\zoho\officeintegrator\v1\DocumentInfo;
use com\zoho\officeintegrator\v1\EditorSettings;
use com\zoho\officeintegrator\v1\UiOptions;
use com\zoho\officeintegrator\v1\UserInfo;
use com\zoho\officeintegrator\v1\V1Operations;
use com\zoho\UserSignature;
use com\zoho\util\Constants;
use com\zoho\util\StreamWrapper;
class EditDocument {
//Refer API documentation - https://www.zoho.com/officeintegrator/api/v1/zoho-writer-edit-document.html
public static function execute() {
self::initializeSdk();
$v1Operations = new V1Operations();
$createDocumentParameters = new CreateDocumentParameters();
$url = "https://demo.office-integrator.com/zdocs/Graphic-Design-Proposal.docx";
$createDocumentParameters->setUrl($url);
// Either you can give the document as publicly downloadable url as above or add the file in request body itself using below code.
// $filePath = getcwd() . DIRECTORY_SEPARATOR . "sample_documents" . DIRECTORY_SEPARATOR . "Graphic-Design-Proposal.docx";
// $createDocumentParameters->setDocument(new StreamWrapper(null, null, $filePath));
# Optional Configuration - Add document meta in request to identify the file in Zoho Server
$documentInfo = new DocumentInfo();
$currentTime = time();
$documentInfo->setDocumentName("New Document");
$documentInfo->setDocumentId($currentTime);
$createDocumentParameters->setDocumentInfo($documentInfo);
# Optional Configuration - Add User meta in request to identify the user in document session
$userInfo = new UserInfo();
$userInfo->setUserId(100);
$userInfo->setDisplayName("John");
$createDocumentParameters->setUserInfo($userInfo);
# Optional Configuration - Set default settings for document while creating document itself.
# It's applicable only for new documents.
$documentDefaults = new DocumentDefaults();
$documentDefaults->getTrackChanges("enabled");
$documentDefaults->setLanguage("ta");
$createDocumentParameters->setDocumentDefaults($documentDefaults);
# Optional Configuration
$editorSettings = new EditorSettings();
$editorSettings->setUnit("in");
$editorSettings->setLanguage("en");
$editorSettings->setView("pageview");
$createDocumentParameters->setEditorSettings($editorSettings);
# Optional Configuration
$uiOptions = new UiOptions();
$uiOptions->setDarkMode("show");
$uiOptions->setFileMenu("show");
$uiOptions->setSaveButton("show");
$uiOptions->setChatPanel("show");
$createDocumentParameters->setUiOptions($uiOptions);
# Optional Configuration
$permissions = array();
$permissions["document.export"] = true;
$permissions["document.print"] = false;
$permissions["document.edit"] = true;
$permissions["review.comment"] = false;
$permissions["review.changes.resolve"] = false;
$permissions["collab.chat"] = false;
$permissions["document.pausecollaboration"] = false;
$permissions["document.fill"] = false;
$createDocumentParameters->setPermissions($permissions);
# Optional Configuration - Add callback settings to configure.
# how file needs to be received while saving the document
$callbackSettings = new CallbackSettings();
$saveUrlParams = array();
$saveUrlHeaders["param1"] = "value1";
$saveUrlHeaders["param2"] = "value2";
$callbackSettings->setSaveUrlParams($saveUrlParams);
$saveUrlHeaders = array();
$saveUrlHeaders["header1"] = "value1";
$saveUrlHeaders["header2"] = "value2";
$callbackSettings->setSaveUrlHeaders($saveUrlHeaders);
$callbackSettings->setRetries(1);
$callbackSettings->setSaveFormat("zdoc");
$callbackSettings->setHttpMethodType("post");
$callbackSettings->setTimeout(100000);
$callbackSettings->setSaveUrl("https://domain.com/save.php");
// To implement your save callback url, refer here: https://github.com/iampraba/zoi-php-sdk-examples/tree/eeb5994f70125d264aa98091c1efdd547219b615/save_callback_implementation
$createDocumentParameters->setCallbackSettings($callbackSettings);
$response = $v1Operations->createDocument($createDocumentParameters);
if($response != null)
{
//Get the status code from response
echo("Status code " . $response->getStatusCode() . "\n");
//Get object from response
$responseHandler = $response->getObject();
if($responseHandler instanceof CreateDocumentResponse)
{
echo("\nDocument ID - " . $responseHandler->getDocumentId() . "\n");
echo("Document Session ID - " . $responseHandler->getSessionId() . "\n");
echo("Document Session URL - " . $responseHandler->getDocumentUrl() . "\n");
echo("Document Session Delete URL - " . $responseHandler->getSessionDeleteUrl() . "\n");
echo("Document Save URL - " . $responseHandler->getSaveUrl() . "\n");
echo("Document Delete URL - " . $responseHandler->getDocumentDeleteUrl() . "\n");
}
}
}
public static function initializeSdk() {
// Replace email address associated with your apikey below
$user = new UserSignature("john@zylker.com");
# Update the api domain based on in which data center user register your apikey
# To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html
$environment = DataCenter::setEnvironment("https://api.office-integrator.com", null, null, null);
# User your apikey that you have in office integrator dashboard
$apikey = new APIKey("2ae438cf864488657cc9754a2&******, Constants::PARAMS);
# Configure a proper file path to write the sdk logs
$logger = (new LogBuilder())
->level(Levels::INFO)
->filePath("./app.log")
->build();
(new InitializeBuilder())
->user($user)
->environment($environment)
->token($apikey)
->logger($logger)
->initialize();
echo "SDK initialized successfully.\n";
}
}
EditDocument::execute();
?>
Copied
using System;
using Com.Zoho.Util;
using Com.Zoho.Officeintegrator.V1;
using Com.Zoho;
using Com.Zoho.Dc;
using Com.Zoho.API.Authenticator;
using Com.Zoho.API.Logger;
using static Com.Zoho.API.Logger.Logger;
using System.Collections.Generic;
namespace Documents
{
class EditDocument
{
static void execute(String[] args)
{
try
{
initializeSdk();
V1Operations sdkOperations = new V1Operations();
CreateDocumentParameters createDocumentParams = new CreateDocumentParameters();
createDocumentParams.Url = "https://demo.office-integrator.com/zdocs/Graphic-Design-Proposal.docx";
DocumentInfo documentInfo = new DocumentInfo();
documentInfo.DocumentName = "Untilted Document";
documentInfo.DocumentId = $"{DateTimeOffset.Now.ToUnixTimeMilliseconds()}";
createDocumentParams.DocumentInfo = documentInfo;
UserInfo userInfo = new UserInfo();
userInfo.UserId = "1000";
userInfo.DisplayName = "John";
createDocumentParams.UserInfo = userInfo;
Margin margin = new Margin();
margin.Top = "2in";
margin.Bottom = "2in";
margin.Left = "2in";
margin.Right = "2in";
DocumentDefaults documentDefault = new DocumentDefaults();
documentDefault.FontSize = 14;
documentDefault.FontName = "Arial";
documentDefault.PaperSize = "Letter";
documentDefault.Orientation = "portrait";
documentDefault.TrackChanges = "disabled";
documentDefault.Margin = margin;
createDocumentParams.DocumentDefaults = documentDefault;
EditorSettings editorSettings = new EditorSettings();
editorSettings.Unit = "in";
editorSettings.Language = "en";
editorSettings.View = "pageview";
createDocumentParams.EditorSettings = editorSettings;
UiOptions uiOptions = new UiOptions();
uiOptions.ChatPanel = "show";
uiOptions.DarkMode = "show";
uiOptions.FileMenu = "show";
uiOptions.SaveButton = "show";
createDocumentParams.UiOptions = uiOptions;
Dictionary<string, object> permissions = new Dictionary<string, object>();
permissions.Add("collab.chat", false);
permissions.Add("document.edit", true);
permissions.Add("review.comment", false);
permissions.Add("document.export", true);
permissions.Add("document.print", false);
permissions.Add("document.fill", false);
permissions.Add("review.changes.resolve", false);
permissions.Add("document.pausecollaboration", false);
createDocumentParams.Permissions = permissions;
Dictionary<string, object> saveUrlParams = new Dictionary<string, object>();
saveUrlParams.Add("id", 123456789);
saveUrlParams.Add("auth_token", "oswedf32rk");
Dictionary<string, object> saveUrlHeaders = new Dictionary<string, object>();
saveUrlHeaders.Add("header1", "value1");
saveUrlHeaders.Add("header2", "value2");
CallbackSettings callbackSettings = new CallbackSettings();
callbackSettings.Retries = 2;
callbackSettings.Timeout = 10000;
callbackSettings.SaveFormat = "docx";
callbackSettings.HttpMethodType = "post";
callbackSettings.SaveUrlParams = saveUrlParams;
callbackSettings.SaveUrlHeaders = saveUrlHeaders;
callbackSettings.SaveUrl = "https://domain.com/save.php";
createDocumentParams.CallbackSettings = callbackSettings;
APIResponse<WriterResponseHandler> response = sdkOperations.CreateDocument(createDocumentParams);
int responseStatusCode = response.StatusCode;
if (responseStatusCode >= 200 && responseStatusCode <= 299)
{
CreateDocumentResponse documentResponse = (CreateDocumentResponse)response.Object;
Console.WriteLine("Document id - {0}", documentResponse.DocumentId);
Console.WriteLine("Document session id - {0}", documentResponse.SessionId);
Console.WriteLine("Document session url - {0}", documentResponse.DocumentUrl);
}
else
{
InvalidConfigurationException invalidConfiguration = (InvalidConfigurationException)response.Object;
string errorMessage = invalidConfiguration.Message;
Console.WriteLine("Document configuration error - {0}", errorMessage);
}
}
catch (System.Exception e)
{
Console.WriteLine("Exception in creating document session url - ", e);
}
}
static Boolean initializeSdk()
{
Boolean status = false;
try
{
Apikey apikey = new Apikey("2ae438cf864488657cc9754a27d*****”, Com.Zoho.Util.Constants.PARAMS);
UserSignature user = new UserSignature("john@zylker.com");
Logger logger = new Logger.Builder()
.Level(Levels.INFO)
.FilePath("./log.txt")
.Build();
Com.Zoho.Dc.DataCenter.Environment environment = new DataCenter.Environment("", "https://api.office-integrator.com", "", "");
new Initializer.Builder()
.User(user)
.Environment(environment)
.Token(apikey)
.Logger(logger)
.Initialize();
status = true;
}
catch (System.Exception e)
{
Console.WriteLine("Exception in Init SDK", e);
}
return status;
}
}
}
Copied
from zohosdk.src.com.zoho.exception.sdk_exception import SDKException
from zohosdk.src.com.zoho.user_signature import UserSignature
from zohosdk.src.com.zoho.dc.data_center import DataCenter
from zohosdk.src.com.zoho.api.authenticator.api_key import APIKey
from zohosdk.src.com.zoho.util.constants import Constants
from zohosdk.src.com.zoho.api.logger import Logger
from zohosdk.src.com.zoho import Initializer
from zohosdk.src.com.zoho.officeintegrator.v1 import DocumentInfo, UserInfo, CallbackSettings, DocumentDefaults, \
EditorSettings, UiOptions, InvalidConfigurationException
from zohosdk.src.com.zoho.officeintegrator.v1.create_document_parameters import CreateDocumentParameters
from zohosdk.src.com.zoho.officeintegrator.v1.create_document_response import CreateDocumentResponse
from zohosdk.src.com.zoho.officeintegrator.v1.v1_operations import V1Operations
import time
import os
from zohosdk.src.com.zoho.util import StreamWrapper
class EditDocument:
@staticmethod
def execute():
EditDocument.init_sdk()
createDocumentParams = CreateDocumentParameters()
createDocumentParams.set_url('https://demo.office-integrator.com/zdocs/Graphic-Design-Proposal.docx')
documentInfo = DocumentInfo()
documentInfo.set_document_name("New Document")
documentInfo.set_document_id((round(time.time() * 1000)).__str__())
createDocumentParams.set_document_info(documentInfo)
userInfo = UserInfo()
userInfo.set_user_id("1000")
userInfo.set_display_name("User 1")
createDocumentParams.set_user_info(userInfo)
callbackSettings = CallbackSettings()
saveUrlParams = {}
saveUrlParams['id'] = '123131'
saveUrlParams['auth_token'] = '1234'
saveUrlParams['extension'] = '$format'
saveUrlParams['document_name'] = '$filename'
saveUrlParams['session_id'] = '$session_id'
callbackSettings.set_save_url_params(saveUrlParams)
saveUrlHeaders = {}
saveUrlHeaders['access_token'] = '12dweds32r42wwds34'
saveUrlHeaders['client_id'] = '12313111'
callbackSettings.set_save_url_headers(saveUrlHeaders)
callbackSettings.set_retries(1)
callbackSettings.set_timeout(10000)
callbackSettings.set_save_format("zdoc")
callbackSettings.set_http_method_type("post")
callbackSettings.set_save_url("https://domain.com/save.php")
// To implement your save callback url, refer here: https://github.com/iampraba/zoi-python-sdk-examples/tree/b74e1f5f08ca6841dc5bbf31f2049b66bf2a7d72/save-callback-implementation/Flask
createDocumentParams.set_callback_settings(callbackSettings)
documentDefaults = DocumentDefaults()
documentDefaults.set_track_changes("enabled")
documentDefaults.set_language("ta")
createDocumentParams.set_document_defaults(documentDefaults)
editorSettings = EditorSettings()
editorSettings.set_unit("in")
editorSettings.set_language("en")
editorSettings.set_view("pageview")
createDocumentParams.set_editor_settings(editorSettings)
uiOptions = UiOptions()
uiOptions.set_dark_mode("show")
uiOptions.set_file_menu("show")
uiOptions.set_save_button("show")
uiOptions.set_chat_panel("show")
createDocumentParams.set_ui_options(uiOptions)
permissions = {}
permissions["document.export"] = True
permissions["document.print"] = True
permissions["document.edit"] = True
permissions["review.comment"] = True
permissions["review.changes.resolve"] = True
permissions["document.pausecollaboration"] = True
permissions["document.fill"] = False
createDocumentParams.set_permissions(permissions)
v1Operations = V1Operations()
response = v1Operations.create_document(createDocumentParams)
if response is not None:
print('Status Code: ' + str(response.get_status_code()))
responseObject = response.get_object()
if responseObject is not None:
if isinstance(responseObject, CreateDocumentResponse):
print('Document Id : ' + str(responseObject.get_document_id()))
print('Document Session ID : ' + str(responseObject.get_session_id()))
print('Document Session URL : ' + str(responseObject.get_document_url()))
print('Document Session Delete URL : ' + str(responseObject.get_session_delete_url()))
print('Document Delete URL : ' + str(responseObject.get_document_delete_url()))
elif isinstance(responseObject, InvalidConfigurationException):
print('Invalid configuration exception.')
print('Error Code : ' + str(responseObject.get_code()))
print("Error Message : " + str(responseObject.get_message()))
if responseObject.get_parameter_name() is not None:
print("Error Parameter Name : " + str(responseObject.get_parameter_name()))
if responseObject.get_key_name() is not None:
print("Error Key Name : " + str(responseObject.get_key_name()))
else:
print('Edit Document Request Failed')
@staticmethod
def init_sdk():
try:
user = UserSignature("john@zylker.com")
environment = DataCenter.Environment("https://api.office-integrator.com", None, None, None)
apikey = APIKey("2ae438cf864488657cc9754a27d*****”, Constants.PARAMS)
logger = Logger.get_instance(Logger.Levels.INFO, "./logs.txt")
Initializer.initialize(user, environment, apikey, None, None, logger, None)
except SDKException as ex:
print(ex.code)
EditDocument.execute()