Beispiel #1
0
        /// <summary>
        /// Created a {@link Checksum} of {@link Checksum.Type} with amount in the given currency.
        /// </summary>
        /// <param name="amount">
        ///          Amount (in cents) which will be charged.</param>
        /// <param name="currency">
        ///          ISO 4217 formatted currency code.</param>
        /// <param name="returnUrl">
        ///          URL to redirect customers to after checkout has completed.</param>
        /// <param name="cancelUrl">
        ///          URL to redirect customers to after they have canceled the checkout. As a result, there will be no transaction.</param>
        /// <param name="fee">
        ///          A {@link Fee}.
        /// <param name="description">
        ///          A short description for the transaction or <code>null</code>.</param>
        /// <param name="items">
        ///          {@link List} of {@link ShoppingCartItem}s</param>
        /// <param name="billing">
        ///          Billing {@link Address} for this transaction.</param>
        /// <param name="shipping">
        ///          Shipping {@link Address} for this transaction.</param>
        /// <param name="appId">
        ///          App (ID) that created this refund or null if created by yourself.</param>
        /// <returns>
        /// Checksum object.
        /// </returns>
        private async Task <Checksum> CreateChecksumForPaypalWithFeeAndItemsAndAddressAsync(int amount, String currency, String returnUrl,
                                                                                            String cancelUrl, Fee fee, String description, List <ShoppingCartItem> items, Address shipping, Address billing, String appId)
        {
            ValidationUtils.ValidatesAmount(amount);
            ValidationUtils.ValidatesCurrency(currency);
            ValidationUtils.ValidatesUrl(cancelUrl);
            ValidationUtils.ValidatesUrl(returnUrl);
            ValidationUtils.ValidatesFee(fee);

            ParameterMap <String, String> paramsMap = new ParameterMap <String, String>();

            paramsMap.Add("checksum_type", "paypal");
            paramsMap.Add("amount", amount.ToString());
            paramsMap.Add("currency", currency);
            paramsMap.Add("cancel_url", cancelUrl);
            paramsMap.Add("return_url", returnUrl);

            if (String.IsNullOrWhiteSpace(description) == false)
            {
                paramsMap.Add("description", description);
            }
            if (fee != null && fee.Amount != null)
            {
                paramsMap.Add("fee_amount", fee.Amount.ToString());
            }

            if (fee != null && String.IsNullOrWhiteSpace(fee.Payment) == false)
            {
                paramsMap.Add("fee_payment", fee.Payment);
            }
            if (fee != null && String.IsNullOrWhiteSpace(fee.Currency) == false)
            {
                paramsMap.Add("fee_currency", fee.Currency);
            }
            if (String.IsNullOrWhiteSpace(appId) == false)
            {
                paramsMap.Add("app_id", appId);
            }

            this.parametrizeItems(items, paramsMap);
            this.parametrizeAddress(billing, paramsMap, "billing_address");
            this.parametrizeAddress(shipping, paramsMap, "shipping_address");

            return(await createAsync(null,
                                     new UrlEncoder().EncodeParamsMap <string, string>(paramsMap)));
        }
Beispiel #2
0
 /// <summary>Create a set of parameters covering all known effects, with default values across the board.</summary>
 public static ParameterMap CreateParameterMap()
 {
     ParameterMap set = new ParameterMap();
     foreach (ParameterDescription desc in s_parameters) {
         set.Add(new ConstantParameter(desc));
     }
     return set;
 }
Beispiel #3
0
 private void parametrizeItems(List <ShoppingCartItem> items, ParameterMap <String, String> paramsMap)
 {
     if (items != null)
     {
         for (int i = 0; i < items.Count(); i++)
         {
             if (String.IsNullOrWhiteSpace(items[i].Name) == false)
             {
                 paramsMap.Add("items[" + i + "][name]", items[i].Name);
             }
             if (String.IsNullOrWhiteSpace(items[i].Description) == false)
             {
                 paramsMap.Add("items[" + i + "][description]", items[i].Description);
             }
             if (items[i].Amount != 0)
             {
                 paramsMap.Add("items[" + i + "][amount]", items[i].Amount.ToString());
             }
             if (items[i].Quantity != 0)
             {
                 paramsMap.Add("items[" + i + "][quantity]", items[i].Quantity.ToString());
             }
             if (String.IsNullOrWhiteSpace(items[i].ItemNumber) == false)
             {
                 paramsMap.Add("items[" + i + "][item_number]", items[i].ItemNumber);
             }
             if (String.IsNullOrWhiteSpace(items[i].Url) == false)
             {
                 paramsMap.Add("items[" + i + "][url]", items[i].Url);
             }
         }
     }
 }
Beispiel #4
0
        /// <summary>
        /// This method is to add an API request parameter.
        /// </summary>
        /// <typeparam name="T">A T containing the specified method type.</typeparam>
        /// <param name="paramInstance">A Param instance containing the API request parameter.</param>
        /// <param name="paramValue">A T containing the API request parameter value.</param>
        public void AddParam <T>(Param <T> paramInstance, T paramValue)
        {
            if (paramValue == null)
            {
                return;
            }

            if (param == null)
            {
                param = new ParameterMap();
            }

            param.Add(paramInstance, paramValue);
        }
Beispiel #5
0
 private void parametrizeAddress(Address address, ParameterMap <String, String> paramsMap, String prefix)
 {
     if (address != null)
     {
         if (String.IsNullOrWhiteSpace(address.Name) == false)
         {
             paramsMap.Add(prefix + "[name]", address.Name);
         }
         if (String.IsNullOrWhiteSpace(address.StreetAddress) == false)
         {
             paramsMap.Add(prefix + "[street_address]", address.StreetAddress);
         }
         if (String.IsNullOrWhiteSpace(address.StreetAddressAddition) == false)
         {
             paramsMap.Add(prefix + "[street_address_addition]", address.StreetAddressAddition);
         }
         if (String.IsNullOrWhiteSpace(address.City) == false)
         {
             paramsMap.Add(prefix + "[city]", address.City);
         }
         if (String.IsNullOrWhiteSpace(address.State) == false)
         {
             paramsMap.Add(prefix + "[state]", address.State);
         }
         if (String.IsNullOrWhiteSpace(address.PostalCode) == false)
         {
             paramsMap.Add(prefix + "[postal_code]", address.PostalCode);
         }
         if (String.IsNullOrWhiteSpace(address.Country) == false)
         {
             paramsMap.Add(prefix + "[country]", address.Country);
         }
         if (String.IsNullOrWhiteSpace(address.Phone) == false)
         {
             paramsMap.Add(prefix + "[phone]", address.Phone);
         }
     }
 }
Beispiel #6
0
        /// <summary>
        /// This method is used to get the custom views data of a particular module.
        /// Specify the module name in your API request whose custom view data you want to retrieve.
        /// </summary>
        /// <param name="moduleAPIName">Specify the API name of the required module.</param>
        public static void GetCustomViews(string moduleAPIName)
        {
            //example
            //string moduleAPIName = "Leads";

            //Get instance of CustomViewOperations Class that takes moduleAPIName as parameter
            CustomViewsOperations customViewsOperations = new CustomViewsOperations(moduleAPIName);

            //Get instance of ParameterMap Class
            ParameterMap paramInstance = new ParameterMap();

            paramInstance.Add(GetCustomViewsParam.PAGE, 1);

            paramInstance.Add(GetCustomViewsParam.PER_PAGE, 2);

            paramInstance.Add(new Param <string>("module", null), "Accounts");

            //Call GetCustomViews method
            APIResponse <ResponseHandler> response = customViewsOperations.GetCustomViews(paramInstance);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                if (new List <int>()
                {
                    204, 304
                }.Contains(response.StatusCode))
                {
                    Console.WriteLine(response.StatusCode == 204? "No Content" : "Not Modified");

                    return;
                }

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ResponseHandler responseHandler = response.Object;

                    if (responseHandler is ResponseWrapper)
                    {
                        //Get the received ResponseWrapper instance
                        ResponseWrapper responseWrapper = (ResponseWrapper)responseHandler;

                        //Get the list of obtained CustomView instances
                        List <Com.Zoho.Crm.API.CustomViews.CustomView> customViews = responseWrapper.CustomViews;

                        foreach (Com.Zoho.Crm.API.CustomViews.CustomView customView in customViews)
                        {
                            //Get the DisplayValue of each CustomView
                            Console.WriteLine("CustomView DisplayValue: " + customView.DisplayValue);

                            //Get the Offline of the each CustomView
                            Console.WriteLine("CustomView Offline: " + customView.Offline);

                            //Get the Default of each CustomView
                            Console.WriteLine("CustomView Default: " + customView.Default);

                            //Get the SystemName of each CustomView
                            Console.WriteLine("CustomView SystemName: " + customView.SystemName);

                            //Get the SystemDefined of each CustomView
                            Console.WriteLine("CustomView SystemDefined: " + customView.SystemDefined);

                            //Get the Name of each CustomView
                            Console.WriteLine("CustomView Name: " + customView.Name);

                            //Get the ID of each CustomView
                            Console.WriteLine("CustomView ID: " + customView.Id);

                            //Get the Category of each CustomView
                            Console.WriteLine("CustomView Category: " + customView.Category);

                            if (customView.Favorite != null)
                            {
                                //Get the Favorite of each CustomView
                                Console.WriteLine("CustomView Favorite: " + customView.Favorite);
                            }
                        }

                        //Get the object obtained Info instance
                        Info info = responseWrapper.Info;

                        //Check if info is not null
                        if (info != null)
                        {
                            if (info.PerPage != null)
                            {
                                //Get the PerPage of the Info
                                Console.WriteLine("CustomView Info PerPage: " + info.PerPage);
                            }

                            if (info.Default != null)
                            {
                                //Get the Default of the Info
                                Console.WriteLine("CustomView Info Default: " + info.Default);
                            }

                            if (info.Count != null)
                            {
                                //Get the Count of the Info
                                Console.WriteLine("CustomView Info Count: " + info.Count);
                            }

                            //Get the Translation instance of CustomView
                            Translation translation = info.Translation;

                            if (translation != null)
                            {
                                //Get the PublicViews of the Translation
                                Console.WriteLine("CustomView Info Translation PublicViews: " + translation.PublicViews);

                                //Get the OtherUsersViews of the Translation
                                Console.WriteLine("CustomView Info Translation OtherUsersViews: " + translation.OtherUsersViews);

                                //Get the SharedWithMe of the Translation
                                Console.WriteLine("CustomView Info Translation SharedWithMe: " + translation.SharedWithMe);

                                //Get the CreatedByMe of the Translation
                                Console.WriteLine("CustomView Info Translation CreatedByMe: " + translation.CreatedByMe);
                            }

                            if (info.Page != null)
                            {
                                //Get the Page of the Info
                                Console.WriteLine("CustomView Info Page: " + info.Page);
                            }

                            if (info.MoreRecords != null)
                            {
                                //Get the MoreRecords of the Info
                                Console.WriteLine("CustomView Info MoreRecords: " + info.MoreRecords);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (responseHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)responseHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    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}) : {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) : <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// This method is used to download a file.
        /// </summary>
        /// <param name="id">The ID of the uploaded File.</param>
        /// <param name="destinationFolder">The absolute path of the destination folder to store the File</param>
        public static void GetFile(string id, string destinationFolder)
        {
            //example
            //string id = "ae9c7cefa418aec1d6a5cc2d7d5e00a54b7563c0dd42b";
            //string destinationFolder = "/Users/user_name/Desktop"

            //Get instance of FileOperations Class
            FileOperations fileOperations = new FileOperations();

            //Get instance of ParameterMap Class
            ParameterMap paramInstance = new ParameterMap();

            paramInstance.Add(GetFileParam.ID, id);

            //Call getFile method that takes paramInstance as parameters
            APIResponse <ResponseHandler> response = fileOperations.GetFile(paramInstance);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                if (new List <int>()
                {
                    204, 304
                }.Contains(response.StatusCode))
                {
                    Console.WriteLine(response.StatusCode == 204? "No Content" : "Not Modified");

                    return;
                }

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ResponseHandler responseHandler = response.Object;

                    if (responseHandler is FileBodyWrapper)
                    {
                        //Get object from response
                        FileBodyWrapper fileBodyWrapper = (FileBodyWrapper)responseHandler;

                        //Get StreamWrapper instance from the returned FileBodyWrapper instance
                        StreamWrapper streamWrapper = fileBodyWrapper.File;

                        Stream file = streamWrapper.Stream;

                        string fullFilePath = Path.Combine(destinationFolder, streamWrapper.Name);

                        using (FileStream outputFileStream = new FileStream(fullFilePath, FileMode.Create))
                        {
                            file.CopyTo(outputFileStream);
                        }
                    }
                    //Check if the request returned an exception
                    else if (responseHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)responseHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    if (responseObject != null)
                    {
                        //Get the response object's class
                        Type type = responseObject.GetType();

                        //Get all declared fields of the response class
                        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}) : {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                            }
                            else
                            {
                                Console.WriteLine("{0} ({1}) : <Indexed>", prop.Name, prop.PropertyType.Name);
                            }
                        }
                    }
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// This method is used to upload link attachment to a single record of a module with ID and print the response.
        /// </summary>
        /// <param name="moduleAPIName">The API Name of the record's module</param>
        /// <param name="recordId">The ID of the record to upload Link attachment</param>
        /// <param name="attachmentURL">The attachmentURL of the doc or image link to be attached</param>
        public static void UploadLinkAttachments(string moduleAPIName, long recordId, string attachmentURL)
        {
            //example
            //string moduleAPIName = "Leads";
            //long recordId = 3477002;
            //string attachmentURL = "https://5.imimg.com/data5/KJ/UP/MY-8655440/zoho-crm-500x500.png";

            //Get instance of AttachmentsOperations Class that takes moduleAPIName and recordId as parameter
            AttachmentsOperations attachmentsOperations = new AttachmentsOperations(moduleAPIName, recordId);

            //Get instance of ParameterMap Class
            ParameterMap paramInstance = new ParameterMap();

            paramInstance.Add(UploadLinkAttachmentParam.ATTACHMENTURL, attachmentURL);

            //Call UploadLinkAttachment method that takes paramInstance as parameter
            APIResponse <API.Attachments.ActionHandler> response = attachmentsOperations.UploadLinkAttachment(paramInstance);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    API.Attachments.ActionHandler actionHandler = response.Object;

                    if (actionHandler is API.Attachments.ActionWrapper)
                    {
                        //Get the received ActionWrapper instance
                        API.Attachments.ActionWrapper actionWrapper = (API.Attachments.ActionWrapper)actionHandler;

                        //Get the list of obtained Action Response instances
                        List <API.Attachments.ActionResponse> actionResponses = actionWrapper.Data;

                        foreach (API.Attachments.ActionResponse actionResponse in actionResponses)
                        {
                            //Check if the request is successful
                            if (actionResponse is API.Attachments.SuccessResponse)
                            {
                                //Get the received SuccessResponse instance
                                API.Attachments.SuccessResponse successResponse = (API.Attachments.SuccessResponse)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + successResponse.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + successResponse.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in successResponse.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + successResponse.Message.Value);
                            }
                            //Check if the request returned an exception
                            else if (actionResponse is API.Attachments.APIException)
                            {
                                //Get the received APIException instance
                                API.Attachments.APIException exception = (API.Attachments.APIException)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + exception.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + exception.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in exception.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + exception.Message.Value);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (actionHandler is API.Attachments.APIException)
                    {
                        //Get the received APIException instance
                        API.Attachments.APIException exception = (API.Attachments.APIException)actionHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    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}) : {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) : <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// This method is used to get a single record's attachments' details with ID and print the response.
        /// </summary>
        /// <param name="moduleAPIName">The API Name of the record's module</param>
        /// <param name="recordId">The ID of the record to get attachments</param>
        public static void GetAttachments(string moduleAPIName, long recordId)
        {
            //example
            //string moduleAPIName = "Leads";
            //long recordId = 3477002;

            //Get instance of AttachmentsOperations Class that takes moduleAPIName and recordId as parameter
            AttachmentsOperations attachmentsOperations = new AttachmentsOperations(moduleAPIName, recordId);

            //Get instance of ParameterMap Class
            ParameterMap paramInstance = new ParameterMap();

            paramInstance.Add(GetAttachmentsParam.PAGE, 1);

            paramInstance.Add(GetAttachmentsParam.PER_PAGE, 20);

            List <string> fields = new List <string>()
            {
                "Modified_Time", "File_Name", "Created_By"
            };

            foreach (string name in fields)
            {
                paramInstance.Add(GetAttachmentsParam.FIELDS, name);
            }

            //Call GetAttachments method
            APIResponse <API.Attachments.ResponseHandler> response = attachmentsOperations.GetAttachments(paramInstance);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                if (new List <int>()
                {
                    204, 304
                }.Contains(response.StatusCode))
                {
                    Console.WriteLine(response.StatusCode == 204 ? "No Content" : "Not Modified");

                    return;
                }

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    API.Attachments.ResponseHandler responseHandler = response.Object;

                    if (responseHandler is API.Attachments.ResponseWrapper)
                    {
                        //Get the received ResponseWrapper instance
                        API.Attachments.ResponseWrapper responseWrapper = (API.Attachments.ResponseWrapper)responseHandler;

                        //Get the list of obtained Attachment instances
                        List <Com.Zoho.Crm.API.Attachments.Attachment> attachments = responseWrapper.Data;

                        foreach (Com.Zoho.Crm.API.Attachments.Attachment attachment in attachments)
                        {
                            //Get the owner User instance of each attachment
                            User owner = attachment.Owner;

                            //Check if owner is not null
                            if (owner != null)
                            {
                                //Get the Name of the Owner
                                Console.WriteLine("Attachment Owner User-Name: " + owner.Name);

                                //Get the ID of the Owner
                                Console.WriteLine("Attachment Owner User-ID: " + owner.Id);

                                //Get the Email of the Owner
                                Console.WriteLine("Attachment Owner User-Email: " + owner.Email);
                            }

                            //Get the modified time of each attachment
                            Console.WriteLine("Attachment Modified Time: " + attachment.ModifiedTime.ToString());

                            //Get the name of the File
                            Console.WriteLine("Attachment File Name: " + attachment.FileName);

                            //Get the created time of each attachment
                            Console.WriteLine("Attachment Created Time: " + attachment.CreatedTime.ToString());

                            //Get the Attachment file size
                            Console.WriteLine("Attachment File Size: " + attachment.Size.ToString());

                            //Get the parentId Record instance of each attachment
                            Com.Zoho.Crm.API.Record.Record parentId = attachment.ParentId;

                            //Check if parentId is not null
                            if (parentId != null)
                            {
                                //Get the parent record Name of each attachment
                                Console.WriteLine("Attachment parent record Name: " + parentId.GetKeyValue("name"));

                                //Get the parent record ID of each attachment
                                Console.WriteLine("Attachment parent record ID: " + parentId.Id);
                            }

                            //Get the attachment is Editable
                            Console.WriteLine("Attachment is Editable: " + attachment.Editable.ToString());

                            //Get the attachment SharingPermission
                            Console.WriteLine("Attachment SharingPermission: " + attachment.SharingPermission.ToString());

                            //Get the file ID of each attachment
                            Console.WriteLine("Attachment File ID: " + attachment.FileId);

                            //Get the type of each attachment
                            Console.WriteLine("Attachment File Type: " + attachment.Type);

                            //Get the seModule of each attachment
                            Console.WriteLine("Attachment seModule: " + attachment.SeModule);

                            //Get the modifiedBy User instance of each attachment
                            User modifiedBy = attachment.ModifiedBy;

                            //Check if modifiedBy is not null
                            if (modifiedBy != null)
                            {
                                //Get the Name of the modifiedBy User
                                Console.WriteLine("Attachment Modified By User-Name: " + modifiedBy.Name);

                                //Get the ID of the modifiedBy User
                                Console.WriteLine("Attachment Modified By User-ID: " + modifiedBy.Id);

                                //Get the Email of the modifiedBy User
                                Console.WriteLine("Attachment Modified By User-Email: " + modifiedBy.Email);
                            }

                            //Get the attachmentType of each attachment
                            Console.WriteLine("Attachment Type: " + attachment.AttachmentType);

                            //Get the state of each attachment
                            Console.WriteLine("Attachment State: " + attachment.State);

                            //Get the ID of each attachment
                            Console.WriteLine("Attachment ID: " + attachment.Id);

                            //Get the createdBy User instance of each attachment
                            User createdBy = attachment.CreatedBy;

                            //Check if createdBy is not null
                            if (createdBy != null)
                            {
                                //Get the name of the createdBy User
                                Console.WriteLine("Attachment Created By User-Name: " + createdBy.Name);

                                //Get the ID of the createdBy User
                                Console.WriteLine("Attachment Created By User-ID: " + createdBy.Id);

                                //Get the Email of the createdBy User
                                Console.WriteLine("Attachment Created By User-Email: " + createdBy.Email);
                            }

                            //Get the linkUrl of each attachment
                            Console.WriteLine("Attachment LinkUrl: " + attachment.LinkUrl);
                        }

                        //Get the Object obtained Info instance
                        Info info = responseWrapper.Info;

                        //Check if info is not null
                        if (info != null)
                        {
                            //Get the PerPage of the Info
                            Console.WriteLine("Record Info PerPage: " + info.PerPage.ToString());

                            //Get the Count of the Info
                            Console.WriteLine("Record Info Count: " + info.Count.ToString());

                            //Get the Page of the Info
                            Console.WriteLine("Record Info Page: " + info.Page.ToString());

                            //Get the MoreRecords of the Info
                            Console.WriteLine("Record Info MoreRecords: " + info.MoreRecords.ToString());
                        }
                    }
                    //Check if the request returned an exception
                    else if (responseHandler is API.Attachments.APIException)
                    {
                        //Get the received APIException instance
                        API.Attachments.APIException exception = (API.Attachments.APIException)responseHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                {                 //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    if (responseObject != null)
                    {
                        //Get the response object's class
                        Type type = responseObject.GetType();

                        //Get all declared fields of the response class
                        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}) : {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                            }
                            else
                            {
                                Console.WriteLine("{0} ({1}) : <Indexed>", prop.Name, prop.PropertyType.Name);
                            }
                        }
                    }
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// This method is used to delete Contact Roles and print the response.
        /// </summary>
        /// <param name="contactRoleIds">The List of ContactRole IDs to be deleted.</param>
        public static void DeleteContactRoles(List <long> contactRoleIds)
        {
            //example
            //List<long> contactRoleIds = new List<long>() { 34770615208001, 34770615208002, 34770615177003, 34770616104001 };

            //Get instance of ContactRolesOperations Class
            ContactRolesOperations contactRolesOperations = new ContactRolesOperations();

            //Get instance of ParameterMap Class
            ParameterMap paramInstance = new ParameterMap();

            foreach (long id in contactRoleIds)
            {
                paramInstance.Add(DeleteContactRolesParam.IDS, id);
            }

            //Call DeleteContactRoles method that takes paramInstance as parameter
            APIResponse <ActionHandler> response = contactRolesOperations.DeleteContactRoles(paramInstance);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ActionHandler actionHandler = response.Object;

                    if (actionHandler is ActionWrapper)
                    {
                        //Get the received ActionWrapper instance
                        ActionWrapper actionWrapper = (ActionWrapper)actionHandler;

                        //Get the list of obtained ContactRole instances
                        List <ActionResponse> actionResponses = actionWrapper.ContactRoles;

                        foreach (ActionResponse actionResponse in actionResponses)
                        {
                            //Check if the request is successful
                            if (actionResponse is SuccessResponse)
                            {
                                //Get the received SuccessResponse instance
                                SuccessResponse successResponse = (SuccessResponse)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + successResponse.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + successResponse.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in successResponse.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + successResponse.Message.Value);
                            }
                            //Check if the request returned an exception
                            else if (actionResponse is APIException)
                            {
                                //Get the received APIException instance
                                APIException exception = (APIException)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + exception.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + exception.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in exception.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + exception.Message.Value);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (actionHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)actionHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    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);
                        }
                    }
                }
            }
        }
Beispiel #11
0
        public static void GetEmailTemplates(string moduleAPIName)
        {
            //Get instance of EmailTemplatesOperations Class
            EmailTemplatesOperations emailTemplatesOperations = new EmailTemplatesOperations();

            ParameterMap parameter = new ParameterMap();

            parameter.Add(GetEmailTemplatesParam.MODULE, moduleAPIName);

            //Call GetEmailTemplates method
            APIResponse <ResponseHandler> response = emailTemplatesOperations.GetEmailTemplates(parameter);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                if (new List <int>()
                {
                    204, 304
                }.Contains(response.StatusCode))
                {
                    Console.WriteLine(response.StatusCode == 204 ? "No Content" : "Not Modified");

                    return;
                }

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ResponseHandler responseHandler = response.Object;

                    if (responseHandler is ResponseWrapper)
                    {
                        //Get the received ResponseWrapper instance
                        ResponseWrapper responseWrapper = (ResponseWrapper)responseHandler;

                        //Get the list of obtained EmailTemplate instances
                        List <API.EmailTemplates.EmailTemplate> emailTemplates = responseWrapper.EmailTemplates;

                        foreach (API.EmailTemplates.EmailTemplate emailTemplate in emailTemplates)
                        {
                            //Get the CreatedTime of each EmailTemplate
                            Console.WriteLine("EmailTemplate CreatedTime: " + emailTemplate.CreatedTime);

                            List <Attachment> attachments = emailTemplate.Attachments;

                            if (attachments != null)
                            {
                                foreach (Attachment attachment in attachments)
                                {
                                    //Get the Size of each Attachment
                                    Console.WriteLine("Attachment Size: " + attachment.Size);

                                    //Get the FileId of each Attachment
                                    Console.WriteLine("Attachment FileId: " + attachment.FileId);

                                    //Get the FileName of each Attachment
                                    Console.WriteLine("Attachment FileName: " + attachment.FileName);

                                    //Get the Id of each Attachment
                                    Console.WriteLine("Attachment ID: " + attachment.Id);
                                }
                            }

                            //Get the Subject of each EmailTemplate
                            Console.WriteLine("EmailTemplate Subject: " + emailTemplate.Subject);

                            API.Modules.Module module = emailTemplate.Module;

                            if (module != null)
                            {
                                //Get the Module Name of the EmailTemplate
                                Console.WriteLine("EmailTemplate Module Name : " + module.APIName);

                                //Get the Module Id of the EmailTemplate
                                Console.WriteLine("EmailTemplate Module Id : " + module.Id);
                            }

                            //Get the Type of each EmailTemplate
                            Console.WriteLine("EmailTemplate Type: " + emailTemplate.Type);

                            //Get the CreatedBy User instance of each EmailTemplate
                            User createdBy = emailTemplate.CreatedBy;

                            //Check if createdBy is not null
                            if (createdBy != null)
                            {
                                //Get the Id of the CreatedBy User
                                Console.WriteLine("EmailTemplate Created By User-ID: " + createdBy.Id);

                                //Get the Name of the CreatedBy User
                                Console.WriteLine("EmailTemplate Created By User-Name: " + createdBy.Name);

                                Console.WriteLine("EmailTemplate Created By User-Email : " + createdBy.Email);
                            }

                            //Get the ModifiedTime of each EmailTemplate
                            Console.WriteLine("EmailTemplate ModifiedTime: " + emailTemplate.ModifiedTime);

                            //Get the Folder instance of each EmailTemplate
                            API.EmailTemplates.EmailTemplate folder = emailTemplate.Folder;

                            //Check if folder is not null
                            if (folder != null)
                            {
                                //Get the Id of the Folder
                                Console.WriteLine("EmailTemplate Folder Id: " + folder.Id);

                                //Get the Name of the Folder
                                Console.WriteLine("EmailTemplate Folder Name: " + folder.Name);
                            }

                            //Get the LastUsageTime of each EmailTemplate
                            Console.WriteLine("EmailTemplate LastUsageTime: " + emailTemplate.LastUsageTime);

                            //Get the Associated of each EmailTemplate
                            Console.WriteLine("EmailTemplate Associated: " + emailTemplate.Associated);

                            //Get the name of each EmailTemplate
                            Console.WriteLine("EmailTemplate Name: " + emailTemplate.Name);

                            //Get the ConsentLinked of each EmailTemplate
                            Console.WriteLine("EmailTemplate ConsentLinked: " + emailTemplate.ConsentLinked);

                            //Get the modifiedBy User instance of each EmailTemplate
                            User modifiedBy = emailTemplate.ModifiedBy;

                            //Check if modifiedBy is not null
                            if (modifiedBy != null)
                            {
                                //Get the ID of the ModifiedBy User
                                Console.WriteLine("EmailTemplate Modified By User-ID: " + modifiedBy.Id);

                                //Get the Name of the CreatedBy User
                                Console.WriteLine("EmailTemplate Modified By User-Name: " + modifiedBy.Name);

                                Console.WriteLine("EmailTemplate Modified By User-Email : " + modifiedBy.Email);
                            }

                            //Get the ID of each EmailTemplate
                            Console.WriteLine("EmailTemplate ID: " + emailTemplate.Id);

                            //Get the EditorMode each EmailTemplate
                            Console.WriteLine("EmailTemplate EditorMode: " + emailTemplate.EditorMode);

                            Console.WriteLine("EmailTemplate Content: " + emailTemplate.Content);

                            // Get the Description of each EmailTemplate
                            Console.WriteLine("EmailTemplate Description: " + emailTemplate.Description);

                            // Get the EditorMode of each EmailTemplate
                            Console.WriteLine("EmailTemplate EditorMode: " + emailTemplate.EditorMode);

                            //Get the Favorite of each EmailTemplate
                            Console.WriteLine("EmailTemplate Favorite: " + emailTemplate.Favorite);

                            // Get the Favourite of each EmailTemplate
                            Console.WriteLine("EmailTemplate Subject: " + emailTemplate.Subject);
                        }

                        API.Record.Info info = responseWrapper.Info;

                        Console.WriteLine("EmailTemplate Info PerPage : " + info.PerPage);

                        Console.WriteLine("EmailTemplate Info Count : " + info.Count);

                        Console.WriteLine("EmailTemplate Info Page : " + info.Page);

                        Console.WriteLine("EmailTemplate Info MoreRecords : " + info.MoreRecords);
                    }
                    //Check if the request returned an exception
                    else if (responseHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)responseHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    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);
                        }
                    }
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// This method is used to get the details of a shared record and print the response.
        /// </summary>
        /// <param name="moduleAPIName">The API Name of the module to get shared record details.</param>
        /// <param name="recordId">The ID of the record to be obtained.</param>
        public static void GetSharedRecordDetails(string moduleAPIName, long recordId)
        {
            //example
            //string moduleAPIName = "Leads";
            //long recordId = 34770615177002;

            //Get instance of ShareRecordsOperations Class that takes recordId and moduleAPIName as parameter
            ShareRecordsOperations shareRecordsOperations = new ShareRecordsOperations(recordId, moduleAPIName);

            //Get instance of ParameterMap Class
            ParameterMap paramInstance = new ParameterMap();

            paramInstance.Add(GetSharedRecordDetailsParam.VIEW, "summary");

            //paramInstance.Add(GetSharedRecordDetailsParam.SHAREDTO, 34770615791024);

            //Call GetSharedRecordDetails method that takes paramInstance as parameter
            APIResponse <ResponseHandler> response = shareRecordsOperations.GetSharedRecordDetails(paramInstance);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                if (new List <int>()
                {
                    204, 304
                }.Contains(response.StatusCode))
                {
                    Console.WriteLine(response.StatusCode == 204? "No Content" : "Not Modified");

                    return;
                }
                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ResponseHandler responseHandler = response.Object;

                    if (responseHandler is ResponseWrapper)
                    {
                        //Get the received ResponseWrapper instance
                        ResponseWrapper responseWrapper = (ResponseWrapper)responseHandler;

                        //Get the obtained ShareRecord instance
                        List <ShareRecord> shareRecords = responseWrapper.Share;

                        foreach (ShareRecord shareRecord in shareRecords)
                        {
                            //Get the ShareRelatedRecords of each ShareRecord
                            Console.WriteLine("ShareRecord ShareRelatedRecords: " + shareRecord.ShareRelatedRecords);

                            //Get the SharedThrough instance of each ShareRecord
                            SharedThrough sharedThrough = shareRecord.SharedThrough;

                            //Check if sharedThrough is not null
                            if (sharedThrough != null)
                            {
                                //Get the EntityName of the SharedThrough
                                Console.WriteLine("ShareRecord SharedThrough EntityName: " + sharedThrough.EntityName);

                                //Get the Module instance of each ShareRecord
                                Module module = sharedThrough.Module;

                                if (module != null)
                                {
                                    //Get the ID of the Module
                                    Console.WriteLine("ShareRecord SharedThrough Module ID: " + module.Id);

                                    //Get the name of the Module
                                    Console.WriteLine("ShareRecord SharedThrough Module Name: " + module.Name);
                                }

                                //Get the ID of the SharedThrough
                                Console.WriteLine("ShareRecord SharedThrough ID: " + sharedThrough.Id);
                            }

                            //Get the Permission of each ShareRecord
                            Console.WriteLine("ShareRecord Permission: " + shareRecord.Permission);

                            //Get the shared User instance of each ShareRecord
                            User user = shareRecord.User;

                            //Check if user is not null
                            if (user != null)
                            {
                                //Get the ID of the shared User
                                Console.WriteLine("ShareRecord User-ID: " + user.Id);

                                //Get the FullName of the shared User
                                Console.WriteLine("ShareRecord User-FullName: " + user.FullName);

                                //Get the Zuid of the shared User
                                Console.WriteLine("ShareRecord User-Zuid: " + user.Zuid);
                            }
                        }

                        if (responseWrapper.ShareableUser != null)
                        {
                            List <User> shareableUsers = responseWrapper.ShareableUser;

                            foreach (User shareableUser in shareableUsers)
                            {
                                //Get the ID of the shareable User
                                Console.WriteLine("ShareRecord User-ID: " + shareableUser.Id);

                                //Get the FullName of the shareable User
                                Console.WriteLine("ShareRecord User-FullName: " + shareableUser.FullName);

                                //Get the Zuid of the shareable User
                                Console.WriteLine("ShareRecord User-Zuid: " + shareableUser.Zuid);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (responseHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)responseHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    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}) : {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) : <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }
Beispiel #13
0
        public static void GetAssignmentRule(long ruleId)
        {
            //Get instance of AssignmentRulesOperations Class
            AssignmentRulesOperations assignmentRulesOperations = new AssignmentRulesOperations();

            ParameterMap paramInstance = new ParameterMap();

            paramInstance.Add(GetAssignmentRuleParam.MODULE, "Leads");

            //Call GetAssignmentRules method
            APIResponse <API.AssignmentRules.ResponseHandler> response = assignmentRulesOperations.GetAssignmentRule(ruleId, paramInstance);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                if (new List <int>()
                {
                    204, 304
                }.Contains(response.StatusCode))
                {
                    Console.WriteLine(response.StatusCode == 204 ? "No Content" : "Not Modified");

                    return;
                }

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    API.AssignmentRules.ResponseHandler responseHandler = response.Object;

                    if (responseHandler is API.AssignmentRules.ResponseWrapper)
                    {
                        //Get the received ResponseWrapper instance
                        API.AssignmentRules.ResponseWrapper responseWrapper = (API.AssignmentRules.ResponseWrapper)responseHandler;

                        //Get the list of obtained AssignmentRule instances
                        List <AssignmentRule> assignmentRules = responseWrapper.AssignmentRules;

                        foreach (AssignmentRule assignmentRule in assignmentRules)
                        {
                            //Get the  modifiedTime of each AssignmentRule
                            Console.WriteLine("AssignmentRule ModifiedTime : "); Console.WriteLine(assignmentRule.ModifiedTime);

                            //Get the  createdTime of each AssignmentRule
                            Console.WriteLine("AssignmentRule CreatedTime : "); Console.WriteLine(assignmentRule.CreatedTime);

                            DefaultUser defaultAssignee = assignmentRule.DefaultAssignee;

                            if (defaultAssignee != null)
                            {
                                //Get the id of DefaultAssignee
                                Console.WriteLine("AssignmentRule DefaultAssignee Id : " + defaultAssignee.Id);

                                //Get the name of DefaultAssignee
                                Console.WriteLine("AssignmentRule DefaultAssignee Name : " + defaultAssignee.Name);
                            }

                            API.Modules.Module module = assignmentRule.Module;

                            if (module != null)
                            {
                                //Get the id of  Module
                                Console.WriteLine("AssignmentRule Module Id : " + module.Id);

                                //Get the apiName of  Module
                                Console.WriteLine("AssignmentRule Module APIName : " + module.APIName);
                            }

                            //Get the name of each AssignmentRule
                            Console.WriteLine("AssignmentRule Name : " + assignmentRule.Name);

                            User modifiedBy = assignmentRule.ModifiedBy;

                            if (modifiedBy != null)
                            {
                                //Get the id of ModifiedBy
                                Console.WriteLine("AssignmentRule ModifiedBy Id : " + modifiedBy.Id);

                                //Get the name of ModifiedBy
                                Console.WriteLine("AssignmentRule ModifiedBy Name : " + modifiedBy.Name);

                                //Get the email of ModifiedBy
                                Console.WriteLine("AssignmentRule ModifiedBy User-Email : " + modifiedBy.Email);
                            }

                            User createdBy = assignmentRule.CreatedBy;

                            if (createdBy != null)
                            {
                                //Get the id of CreatedBy
                                Console.WriteLine("AssignmentRule CreatedBy Id : " + createdBy.Id);

                                //Get the name of CreatedBy
                                Console.WriteLine("AssignmentRule CreatedBy Name : " + createdBy.Name);

                                //Get the email of CreatedBy
                                Console.WriteLine("AssignmentRule CreatedBy User-Email : " + createdBy.Email);
                            }

                            //Get the id of each AssignmentRule
                            Console.WriteLine("AssignmentRule Id : " + assignmentRule.Id);

                            //Get the  description of each AssignmentRule
                            Console.WriteLine("AssignmentRule Description : " + assignmentRule.Description);
                        }
                    }
                    //Check if the request returned an exception
                    else if (responseHandler is API.AssignmentRules.APIException)
                    {
                        //Get the received APIException instance
                        API.AssignmentRules.APIException exception = (API.AssignmentRules.APIException)responseHandler;

                        //Get the Status
                        Console.WriteLine("Status : " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code : " + exception.Code.Value);

                        Console.WriteLine("Details : ");

                        //Get the details map
                        foreach (KeyValuePair <string, Object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message : " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    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);
                        }
                    }
                }
            }
        }
Beispiel #14
0
        public static void GetWizardById(long?id, string layoutId)
        {
            //Get instance of WizardsOperations Class
            WizardsOperations wizardsOperations = new WizardsOperations();

            ParameterMap paramInstance = new ParameterMap();

            paramInstance.Add(GetWizardbyIDParam.LAYOUT_ID, layoutId);

            //Call GetWizardById method
            APIResponse <ResponseHandler> response = wizardsOperations.GetWizardById(id, paramInstance);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                if (new List <int>()
                {
                    204, 304
                }.Contains(response.StatusCode))
                {
                    Console.WriteLine(response.StatusCode == 204 ? "No Content" : "Not Modified");

                    return;
                }

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ResponseHandler responseHandler = response.Object;

                    if (responseHandler is ResponseWrapper)
                    {
                        //Get the received ResponseWrapper instance
                        ResponseWrapper responseWrapper = (ResponseWrapper)responseHandler;

                        //Get the list of obtained Wizard instances
                        List <API.Wizards.Wizard> wizards = responseWrapper.Wizards;

                        foreach (API.Wizards.Wizard wizard in wizards)
                        {
                            //Get the CreatedTime of each Wizard
                            Console.WriteLine("Wizard CreatedTime: " + wizard.CreatedTime);

                            //Get the PermissionType of each Wizard
                            Console.WriteLine("Wizard ModifiedTime: " + wizard.ModifiedTime);

                            //Get the manager User instance of each Wizard
                            API.Modules.Module module = wizard.Module;

                            //Check if manager is not null
                            if (module != null)
                            {
                                //Get the Name of the Manager
                                Console.WriteLine("Wizard Module APIName: " + module.APIName);

                                //Get the ID of the Manager
                                Console.WriteLine("Wizard Module Id: " + module.Id);
                            }

                            //Get the Name of each Wizard
                            Console.WriteLine("Wizard Name: " + wizard.Name);

                            //Get the modifiedBy User instance of each Wizard
                            API.Users.User modifiedBy = wizard.ModifiedBy;

                            //Check if modifiedBy is not null
                            if (modifiedBy != null)
                            {
                                //Get the Name of the modifiedBy User
                                Console.WriteLine("Wizard Modified By User-Name: " + modifiedBy.Name);

                                //Get the ID of the modifiedBy User
                                Console.WriteLine("Wizard Modified By User-ID: " + modifiedBy.Id);
                            }

                            //Get the array of Profile instance each Wizard
                            List <API.Profiles.Profile> profiles = wizard.Profiles;

                            //Check if profiles is not null
                            if (profiles != null)
                            {
                                foreach (API.Profiles.Profile profile in profiles)
                                {
                                    //Get the Name of each Profile
                                    Console.WriteLine("Wizard Profile Name: " + profile.Name);

                                    //Get the ID of each Profile
                                    Console.WriteLine("Wizard Profile ID: " + profile.Id);
                                }
                            }

                            //Get the Active of each Wizard
                            Console.WriteLine("Wizard Active: " + wizard.Active);

                            //Get the array of Container instance each Wizard
                            List <Container> containers = wizard.Containers;

                            //Check if containers is not null
                            if (containers != null)
                            {
                                foreach (Container container in containers)
                                {
                                    //Get the array of Layout instance each Wizard
                                    Layout layout = container.Layout;

                                    //Check if layout is not null
                                    if (layout != null)
                                    {
                                        //Get the Name of Layout
                                        Console.WriteLine("Wizard Container Layout Name: " + layout.Name);

                                        //Get the ID of Layout
                                        Console.WriteLine("Wizard Container Layout ID: " + layout.Id);
                                    }

                                    ChartData chartData = container.ChartData;

                                    if (chartData != null)
                                    {
                                        List <Node> nodes = chartData.Nodes;

                                        if (nodes != null)
                                        {
                                            foreach (Node node in nodes)
                                            {
                                                Console.WriteLine("Wizard Container ChartData Node PosY: " + node.PosY);

                                                Console.WriteLine("Wizard Container ChartData Node PosX: " + node.PosX);

                                                Console.WriteLine("Wizard Container ChartData Node StartNode: " + node.StartNode);

                                                Screen screen = node.Screen;

                                                if (screen != null)
                                                {
                                                    Console.WriteLine("Wizard Container ChartData Node Screen DisplayLabel: " + screen.DisplayLabel);

                                                    Console.WriteLine("Wizard Container ChartData Node Screen ID: " + screen.Id);
                                                }
                                            }
                                        }

                                        List <Connection> connections = chartData.Connections;

                                        if (connections != null)
                                        {
                                            foreach (Connection connection in connections)
                                            {
                                                Button sourceButton = connection.SourceButton;

                                                if (sourceButton != null)
                                                {
                                                    PrintButton(sourceButton);
                                                }

                                                Screen targetScreen = connection.TargetScreen;

                                                if (targetScreen != null)
                                                {
                                                    PrintScreen(targetScreen);
                                                }
                                            }
                                        }

                                        Console.WriteLine("Wizard Container ChartData CanvasWidth: " + chartData.CanvasWidth);

                                        Console.WriteLine("Wizard Container ChartData CanvasHeight: " + chartData.CanvasHeight);
                                    }

                                    List <Screen> screens = container.Screens;

                                    if (screens != null)
                                    {
                                        foreach (Screen screen in screens)
                                        {
                                            PrintScreen(screen);
                                        }
                                    }

                                    //Get the ID of each Container
                                    Console.WriteLine("Wizard Container ID: " + container.Id);
                                }
                            }

                            //Get the ID of each Wizard
                            Console.WriteLine("Wizard ID: " + wizard.Id);

                            //Get the createdBy User instance of each Wizard
                            User createdBy = wizard.CreatedBy;

                            //Check if createdBy is not null
                            if (createdBy != null)
                            {
                                //Get the Name of the createdBy Wizard
                                Console.WriteLine("Wizard Created By User-Name: " + createdBy.Name);

                                //Get the ID of the createdBy Wizard
                                Console.WriteLine("Wizard Created By User-ID: " + createdBy.Id);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (responseHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)responseHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    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);
                        }
                    }
                }
            }
        }