Skip to content

Commit

Permalink
Merge pull request #2 from zoho/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
raja-7453 authored Aug 6, 2024
2 parents 83d820c + 2e08c4e commit 75bef14
Show file tree
Hide file tree
Showing 1,598 changed files with 176,864 additions and 24 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ License

## Latest Version

- [2.0.0](/versions/2.0.0/README.md)

- Handled Error Structure in MassDeleteTags API.

- [1.0.0](/versions/1.0.0/README.md)

- C# SDK upgraded to support v7 APIs.
Expand Down Expand Up @@ -59,15 +63,15 @@ You can include the SDK to your project using:
- Package Manager

```sh
Install-Package ZOHOCRMSDK-7.0 -Version 1.0.0
Install-Package ZOHOCRMSDK-7.0 -Version 2.0.0
Install-Package MySql.Data -Version 6.9.12
Install-Package Newtonsoft.Json -Version 13.0.1
```

- .NET CLI

```sh
dotnet add package ZOHOCRMSDK-7.0 --version 1.0.0
dotnet add package ZOHOCRMSDK-7.0 --version 2.0.0
dotnet add package Newtonsoft.Json --version 13.0.1
dotnet add package MySql.Data --version 6.9.12
```
Expand All @@ -78,7 +82,7 @@ You can include the SDK to your project using:

```sh
<ItemGroup>
<PackageReference Include="ZOHOCRMSDK-7.0" Version="1.0.0" />
<PackageReference Include="ZOHOCRMSDK-7.0" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="MySql.Data" Version="6.9.12" />
</ItemGroup>
Expand All @@ -98,4 +102,4 @@ For example, if you generate the tokens for your Sandbox environment in the CN d

---

For more details, kindly refer [here](/versions/1.0.0/ZohoCRM/README.md).
For more details, kindly refer [here](/versions/2.0.0/ZohoCRM/README.md).
134 changes: 134 additions & 0 deletions Samples/DuplicateCheckPreference1/CreateDuplicateCheckPreference.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
using System;
using Initializer = Com.Zoho.Crm.API.Initializer;
using Environment = Com.Zoho.Crm.API.Dc.DataCenter.Environment;
using Com.Zoho.Crm.API.DuplicateCheckPreference;
using Com.Zoho.Crm.API.Util;
using System.Collections.Generic;
using System.Reflection;
using Newtonsoft.Json;
using Com.Zoho.Crm.API.Dc;
using Com.Zoho.API.Authenticator;

namespace Samples.DuplicateCheckPreference1
{
public class CreateDuplicateCheckPreference
{
public static void CreateDuplicateCheckPreference_1(string moduleAPIName)
{
DuplicateCheckPreferenceOperations duplicateCheckPreferenceOperations = new DuplicateCheckPreferenceOperations(moduleAPIName);
BodyWrapper request = new BodyWrapper();
DuplicateCheckPreference duplicateCheckPreference = new DuplicateCheckPreference();
duplicateCheckPreference.Type = new Choice<String>("mapped_module_records");

List<TypeConfiguration> typeConfigurations = new List<TypeConfiguration>();
TypeConfiguration typeConfiguration = new TypeConfiguration();
MappedModule mappedModule = new MappedModule();
mappedModule.Id = "34770612175";
mappedModule.APIName = "Leads";
typeConfiguration.MappedModule = mappedModule;
List<FieldMappings> fieldMappings = new List<FieldMappings>();
FieldMappings fieldMapping = new FieldMappings();
CurrentField currentField = new CurrentField();
currentField.Id = "34770616570001";
currentField.APIName = "Email_1";
fieldMapping.CurrentField = currentField;

MappedField mappedField = new MappedField();
mappedField.Id = "347706123537018";
mappedField.APIName = "Email_2";
fieldMapping.MappedField = mappedField;

fieldMappings.Add(fieldMapping);
typeConfiguration.FieldMappings = fieldMappings;
typeConfigurations.Add(typeConfiguration);
duplicateCheckPreference.TypeConfigurations = typeConfigurations;
request.DuplicateCheckPreference = duplicateCheckPreference;
APIResponse<ActionHandler> response = duplicateCheckPreferenceOperations.CreateDuplicateCheckPreference(request);
if (response != null)
{
Console.WriteLine("Status Code: " + response.StatusCode);
if (response.IsExpected)
{
ActionHandler actionHandler = response.Object;
if (actionHandler is ActionWrapper)
{
ActionWrapper actionWrapper = (ActionWrapper) actionHandler;
ActionResponse actionresponse = actionWrapper.DuplicateCheckPreference;
if (actionresponse is SuccessResponse)
{
SuccessResponse successresponse = (SuccessResponse) actionresponse;
Console.WriteLine("Status: " + successresponse.Status.Value);
Console.WriteLine("Code: " + successresponse.Code.Value);
Console.WriteLine("Details: ");
foreach (KeyValuePair<string, object> entry in successresponse.Details)
{
Console.WriteLine(entry.Key + ": " + entry.Value);
}
Console.WriteLine("Message: " + successresponse.Message);
}
else if (actionresponse is APIException)
{
APIException exception = (APIException) actionresponse;
Console.WriteLine("Status: " + exception.Status.Value);
Console.WriteLine("Code: " + exception.Code.Value);
Console.WriteLine("Details: ");
foreach (KeyValuePair<string, object> entry in exception.Details)
{
Console.WriteLine(entry.Key + ": " + entry.Value);
}
Console.WriteLine("Message: " + exception.Message.Value);
}
}
else if (actionHandler is APIException)
{
APIException exception = (APIException) actionHandler;
Console.WriteLine("Status: " + exception.Status.Value);
Console.WriteLine("Code: " + exception.Code.Value);
Console.WriteLine("Details: ");
foreach (KeyValuePair<string, object> entry in exception.Details)
{
Console.WriteLine(entry.Key + ": " + entry.Value);
}
Console.WriteLine("Message: " + exception.Message.Value);
}
}
else
{
Model responseObject = response.Model;
Type type = responseObject.GetType();
Console.WriteLine("Type is : {0}", type.Name);
PropertyInfo[] props = type.GetProperties();
Console.WriteLine("Properties (N = {0}) :", props.Length);
foreach (var prop in props)
{
if (prop.GetIndexParameters().Length == 0)
{
Console.WriteLine("{0} ({1}) in {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
}
else
{
Console.WriteLine("{0} ({1}) in <Indexed>", prop.Name, prop.PropertyType.Name);
}
}
}
}
}

public static void Call()
{
try
{
Environment environment = USDataCenter.PRODUCTION;
IToken token = new OAuthToken.Builder().ClientId("Client_Id").ClientSecret("Client_Secret").RefreshToken("Refresh_Token").RedirectURL("Redirect_URL" ).Build();
new Initializer.Builder().Environment(environment).Token(token).Initialize();
string moduleAPIName = "Contacts";
CreateDuplicateCheckPreference_1(moduleAPIName);
}
catch (Exception e)
{
Console.WriteLine(JsonConvert.SerializeObject(e));
}
}
}
}

107 changes: 107 additions & 0 deletions Samples/DuplicateCheckPreference1/DeleteDuplicateCheckPreference.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using System;
using Initializer = Com.Zoho.Crm.API.Initializer;
using Environment = Com.Zoho.Crm.API.Dc.DataCenter.Environment;
using Com.Zoho.Crm.API.DuplicateCheckPreference;
using Com.Zoho.Crm.API.Util;
using System.Collections.Generic;
using System.Reflection;
using Newtonsoft.Json;
using Com.Zoho.Crm.API.Dc;
using Com.Zoho.API.Authenticator;

namespace Samples.DuplicateCheckPreference1
{
public class DeleteDuplicateCheckPreference
{
public static void DeleteDuplicateCheckPreference_1(string moduleAPIName)
{
DuplicateCheckPreferenceOperations duplicateCheckPreferenceOperations = new DuplicateCheckPreferenceOperations(moduleAPIName);
APIResponse<ActionHandler> response = duplicateCheckPreferenceOperations.DeleteDuplicateCheckPreference();
if (response != null)
{
Console.WriteLine("Status Code: " + response.StatusCode);
if (response.IsExpected)
{
ActionHandler actionHandler = response.Object;
if (actionHandler is ActionWrapper)
{
ActionWrapper actionWrapper = (ActionWrapper)actionHandler;
ActionResponse actionresponse = actionWrapper.DuplicateCheckPreference;
if (actionresponse is SuccessResponse)
{
SuccessResponse successresponse = (SuccessResponse)actionresponse;
Console.WriteLine("Status: " + successresponse.Status.Value);
Console.WriteLine("Code: " + successresponse.Code.Value);
Console.WriteLine("Details: ");
foreach (KeyValuePair<string, object> entry in successresponse.Details)
{
Console.WriteLine(entry.Key + ": " + entry.Value);
}
Console.WriteLine("Message: " + successresponse.Message);
}
else if (actionresponse is APIException)
{
APIException exception = (APIException)actionresponse;
Console.WriteLine("Status: " + exception.Status.Value);
Console.WriteLine("Code: " + exception.Code.Value);
Console.WriteLine("Details: ");
foreach (KeyValuePair<string, object> entry in exception.Details)
{
Console.WriteLine(entry.Key + ": " + entry.Value);
}
Console.WriteLine("Message: " + exception.Message.Value);
}
}
else if (actionHandler is APIException)
{
APIException exception = (APIException)actionHandler;
Console.WriteLine("Status: " + exception.Status.Value);
Console.WriteLine("Code: " + exception.Code.Value);
Console.WriteLine("Details: ");
foreach (KeyValuePair<string, object> entry in exception.Details)
{
Console.WriteLine(entry.Key + ": " + entry.Value);
}
Console.WriteLine("Message: " + exception.Message.Value);
}
}
else
{
Model responseObject = response.Model;
Type type = responseObject.GetType();
Console.WriteLine("Type is : {0}", type.Name);
PropertyInfo[] props = type.GetProperties();
Console.WriteLine("Properties (N = {0}) :", props.Length);
foreach (var prop in props)
{
if (prop.GetIndexParameters().Length == 0)
{
Console.WriteLine("{0} ({1}) in {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
}
else
{
Console.WriteLine("{0} ({1}) in <Indexed>", prop.Name, prop.PropertyType.Name);
}
}
}
}
}

public static void Call()
{
try
{
Environment environment = USDataCenter.PRODUCTION;
IToken token = new OAuthToken.Builder().ClientId("Client_Id").ClientSecret("Client_Secret").RefreshToken("Refresh_Token").RedirectURL("Redirect_URL").Build();
new Initializer.Builder().Environment(environment).Token(token).Initialize();
string moduleAPIName = "Contacts";
DeleteDuplicateCheckPreference_1(moduleAPIName);
}
catch (Exception e)
{
Console.WriteLine(JsonConvert.SerializeObject(e));
}
}
}
}

Loading

0 comments on commit 75bef14

Please sign in to comment.