-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from zoho/beta
2.0.0
- Loading branch information
Showing
1,532 changed files
with
85,261 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package apis | ||
|
||
import com.zoho.api.authenticator.OAuthToken | ||
import com.zoho.api.authenticator.Token | ||
import com.zoho.crm.api.Initializer | ||
import com.zoho.crm.api.apis.{APIException, APIsOperations, OperationTypes, ResponseHandler, ResponseWrapper, SupportedAPI} | ||
import com.zoho.crm.api.dc.USDataCenter | ||
import com.zoho.crm.api.util.APIResponse | ||
import com.zoho.crm.api.util.Model | ||
import com.zoho.crm.api.dc.DataCenter.Environment | ||
|
||
|
||
object GetSupportedAPI { | ||
|
||
@throws[Exception] | ||
def getSupportedAPI(): Unit = { | ||
val filters: Option[String] = Option(null) | ||
val apisOperations = new APIsOperations(filters) | ||
val response: Option[APIResponse[ResponseHandler]] = apisOperations.getSupportedAPI() | ||
|
||
if (response != null) { | ||
response match { | ||
case Some(apiResponse) => | ||
println(s"Status Code: ${apiResponse.getStatusCode}") | ||
if (apiResponse.getStatusCode == 204) { | ||
println("No Content") | ||
return | ||
} | ||
if (apiResponse.isExpected) { | ||
val responseHandler: ResponseHandler = apiResponse.getObject | ||
responseHandler match { | ||
case responseWrapper: ResponseWrapper => | ||
val apis: List[SupportedAPI] = responseWrapper.getApis.toList | ||
if (apis != null) { | ||
apis.foreach { api => | ||
println(s"API Path: ${api.getPath}") | ||
val operationTypes: List[OperationTypes] = api.getOperationTypes.toList | ||
operationTypes.foreach { operationType => | ||
println(s"API Operation Method: ${operationType.getMethod}") | ||
println(s"API Operation OAuthScope: ${operationType.getOauthScope}") | ||
println(s"API Operation MaxCredits: ${operationType.getMaxCredits}") | ||
println(s"API Operation MinCredits: ${operationType.getMinCredits}") | ||
} | ||
} | ||
} | ||
case exception: APIException => | ||
println(s"Status: ${exception.getStatus.getValue}") | ||
println(s"Code: ${exception.getCode.getValue}") | ||
println("Details: ") | ||
exception.getDetails.foreach { | ||
case (key, value) => println(s"$key: $value") | ||
} | ||
println(s"Message: ${exception.getMessage}") | ||
case _ => | ||
val responseObject: Any = apiResponse.getModel | ||
val fields = responseObject.getClass.getDeclaredFields | ||
fields.foreach { field => | ||
field.setAccessible(true) | ||
println(s"${field.getName}: ${field.get(responseObject)}") | ||
} | ||
} | ||
} else if (apiResponse.getStatusCode != 204) { | ||
val responseObject: Any = apiResponse.getModel | ||
val fields = responseObject.getClass.getDeclaredFields | ||
fields.foreach { field => | ||
field.setAccessible(true) | ||
println(s"${field.getName}: ${field.get(responseObject)}") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@throws[Exception] | ||
def main(args: Array[String]): Unit = { | ||
try { | ||
val environment: Environment = USDataCenter.PRODUCTION | ||
val token: Token = new OAuthToken.Builder() | ||
.clientID("client_id") | ||
.clientSecret("client_secret") | ||
.grantToken("grant_token") | ||
.build() | ||
new Initializer.Builder() | ||
.environment(environment) | ||
.token(token) | ||
.initialize() | ||
|
||
getSupportedAPI() | ||
} catch { | ||
case e: Exception => | ||
e.printStackTrace() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package auditlogexport | ||
|
||
import java.time.{OffsetDateTime, ZoneOffset} | ||
import java.util.{ArrayList, HashMap, List, Map} | ||
import com.zoho.api.authenticator.{OAuthToken, Token} | ||
import com.zoho.crm.api.Initializer | ||
import com.zoho.crm.api.auditlogexport.* | ||
import com.zoho.crm.api.dc.{INDataCenter, USDataCenter} | ||
import com.zoho.crm.api.dc.DataCenter.Environment | ||
import com.zoho.crm.api.util.APIResponse | ||
|
||
import scala.collection.mutable.ArrayBuffer | ||
|
||
object CreateAuditLogExport { | ||
|
||
def createAuditLogExport(): Unit = { | ||
val auditLogExportOperations = new AuditLogExportOperations() | ||
val request = new BodyWrapper() | ||
val auditLogExports = new ArrayBuffer[AuditLogExport]() | ||
val auditLogExport = new AuditLogExport() | ||
|
||
val criteria = new Criteria() | ||
criteria.setComparator(Option("between")) | ||
|
||
val field = new Field() | ||
field.setAPIName(Option("audited_time")) | ||
criteria.setField(Option(field)) | ||
|
||
val values = new ArrayBuffer[OffsetDateTime]() | ||
values.addOne(OffsetDateTime.of(2024, 1, 2, 10, 0, 0, 0, ZoneOffset.of("+05:30"))) | ||
values.addOne(OffsetDateTime.of(2024, 1, 3, 10, 0, 0, 0, ZoneOffset.of("+05:30"))) | ||
criteria.setValue(values) | ||
|
||
auditLogExport.setCriteria(Option(criteria)) | ||
auditLogExports.addOne(auditLogExport) | ||
request.setAuditLogExport(auditLogExports) | ||
|
||
val response: Option[APIResponse[ActionHandler]] = auditLogExportOperations.createAuditlogExport(request) | ||
|
||
if (response != null) { | ||
response match { | ||
case Some(apiResponse) => | ||
println(s"Status Code: ${apiResponse.getStatusCode}") | ||
|
||
if (apiResponse.isExpected) { | ||
apiResponse.getObject match { | ||
case actionWrapper: ActionWrapper => | ||
val actionResponses = actionWrapper.getAuditLogExport | ||
for (actionResponse <- actionResponses) { | ||
actionResponse match { | ||
case successResponse: SuccessResponse => | ||
println(s"Status: ${successResponse.getStatus.getValue}") | ||
println(s"Code: ${successResponse.getCode.getValue}") | ||
println("Details: ") | ||
if (successResponse.getDetails != null) { | ||
successResponse.getDetails.foreach(entry => { | ||
println(entry._1 + ": " + entry._2) | ||
}) | ||
} | ||
println(s"Message: ${successResponse.getMessage}") | ||
|
||
case exception: APIException => | ||
println(s"Status: ${exception.getStatus.getValue}") | ||
println(s"Code: ${exception.getCode.getValue}") | ||
println("Details: ") | ||
if (exception.getDetails != null) { | ||
exception.getDetails.foreach(entry => { | ||
println(entry._1 + ": " + entry._2) | ||
}) | ||
} | ||
println(s"Message: ${exception.getMessage}") | ||
} | ||
} | ||
|
||
case exception: APIException => | ||
println(s"Status: ${exception.getStatus.getValue}") | ||
println(s"Code: ${exception.getCode.getValue}") | ||
println("Details: ") | ||
if (exception.getDetails != null) { | ||
exception.getDetails.foreach(entry => { | ||
println(entry._1 + ": " + entry._2) | ||
}) | ||
} | ||
println(s"Message: ${exception.getMessage}") | ||
} | ||
} else { | ||
val responseObject = apiResponse.getModel | ||
val fields = responseObject.getClass.getDeclaredFields | ||
for (field <- fields) { | ||
field.setAccessible(true) | ||
println(s"${field.getName}: ${field.get(responseObject)}") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@throws[Exception] | ||
def main(args: Array[String]): Unit = { | ||
try { | ||
val environment: Environment = USDataCenter.PRODUCTION | ||
val token: Token = new OAuthToken.Builder() | ||
.clientID("client_id") | ||
.clientSecret("client_secret") | ||
.grantToken("grant_token") | ||
.build() | ||
new Initializer.Builder() | ||
.environment(environment) | ||
.token(token) | ||
.initialize() | ||
|
||
createAuditLogExport() | ||
} catch { | ||
case e: Exception => | ||
e.printStackTrace() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package auditlogexport | ||
|
||
import com.zoho.crm.api.Initializer | ||
import com.zoho.api.authenticator.{OAuthToken, Token} | ||
import com.zoho.crm.api.auditlogexport.* | ||
import com.zoho.crm.api.dc.DataCenter.Environment | ||
import com.zoho.crm.api.dc.{INDataCenter, USDataCenter} | ||
import com.zoho.crm.api.util.APIResponse | ||
|
||
import scala.jdk.CollectionConverters.* | ||
|
||
object GetExportedAuditlog { | ||
|
||
def getExportedAuditlog(id: Long): Unit = { | ||
val auditLogExportOperations = new AuditLogExportOperations() | ||
val response: Option[APIResponse[ResponseHandler]] = auditLogExportOperations.getExportedAuditlog(id) | ||
|
||
if (response != null) { | ||
response match { | ||
case Some(apiResponse) => | ||
println(s"Status Code: ${apiResponse.getStatusCode}") | ||
if (apiResponse.getStatusCode == 204) { | ||
println("No Content") | ||
return | ||
} | ||
|
||
if (apiResponse.isExpected) { | ||
apiResponse.getObject match { | ||
case responseWrapper: ResponseWrapper => | ||
val auditLogExports = responseWrapper.getAuditLogExport | ||
auditLogExports.foreach { auditLogExport => | ||
val criteria = auditLogExport.getCriteria | ||
if (criteria != null) printCriteria(criteria) | ||
|
||
println(s"AuditLogExport Id : ${auditLogExport.getId}") | ||
println(s"AuditLogExport Status : ${auditLogExport.getStatus}") | ||
val createdBy = auditLogExport.getCreatedBy | ||
if (createdBy != null) { | ||
createdBy match { | ||
case Some(created_by)=> | ||
println(s"AuditLogExport User Id : ${created_by.getId}") | ||
println(s"AuditLogExport User Name : ${created_by.getName}") | ||
} | ||
} | ||
val downloadLinks = auditLogExport.getDownloadLinks | ||
if (downloadLinks != null) { | ||
downloadLinks.foreach(link => println(s"AuditLogExport DownloadLink : $link")) | ||
println(s"AuditLogExport JobStartTime : ${auditLogExport.getJobStartTime}") | ||
println(s"AuditLogExport JobEndTime : ${auditLogExport.getJobEndTime}") | ||
println(s"AuditLogExport ExpiryDate : ${auditLogExport.getExpiryDate}") | ||
} | ||
} | ||
|
||
case exception: APIException => | ||
println(s"Status: ${exception.getStatus.getValue}") | ||
println(s"Code: ${exception.getCode.getValue}") | ||
println("Details: ") | ||
if (exception.getDetails != null) { | ||
exception.getDetails.foreach(entry => { | ||
println(entry._1 + ": " + entry._2) | ||
}) | ||
} | ||
println(s"Message: ${exception.getMessage}") | ||
|
||
case _ => | ||
val responseObject = apiResponse.getModel | ||
responseObject.getClass.getDeclaredFields.foreach { field => | ||
field.setAccessible(true) | ||
println(s"${field.getName}: ${field.get(responseObject)}") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private def printCriteria(criteria: Option[Criteria]): Unit = { | ||
criteria match { | ||
case Some(criteria_1) => | ||
if (criteria_1.getComparator != null) { | ||
println(s"ExportedAuditlogs Criteria Comparator: ${criteria_1.getComparator}") | ||
} | ||
if (criteria_1.getValue != null) { | ||
println(s"ExportedAuditlogs Criteria Value: ${criteria_1.getValue}") | ||
} | ||
if (criteria_1.getField != null) { | ||
criteria_1.getField() match { | ||
case Some(field) => | ||
println(s"ExportedAuditlogs Criteria Field Name: ${field.getAPIName}") | ||
} | ||
} | ||
val criteriaGroup = criteria_1.getGroup | ||
if (criteriaGroup != null) | ||
{ | ||
criteriaGroup.foreach { criteria_group => | ||
printCriteria(Option(criteria_group)) | ||
} | ||
} | ||
if (criteria_1.getGroupOperator != null) { | ||
println(s"ExportedAuditlogs Criteria Group Operator: ${criteria_1.getGroupOperator}") | ||
} | ||
} | ||
} | ||
|
||
@throws[Exception] | ||
def main(args: Array[String]): Unit = { | ||
try { | ||
val environment: Environment = USDataCenter.PRODUCTION | ||
val token: Token = new OAuthToken.Builder() | ||
.clientID("client_id") | ||
.clientSecret("client_secret") | ||
.grantToken("grant_token") | ||
.build() | ||
new Initializer.Builder() | ||
.environment(environment) | ||
.token(token) | ||
.initialize() | ||
|
||
val id: Long = 7534000347001L | ||
getExportedAuditlog(id) | ||
} catch { | ||
case e: Exception => e.printStackTrace() | ||
} | ||
} | ||
} |
Oops, something went wrong.