Exemple #1
0
        public HttpResponseMessage DeleteAction(int actionId)
        {
            DeleteActionResponse response = actionService.DeleteAction(new DeleteActionRequest()
            {
                ActionId = actionId
            });

            return(Request.BuildResponse(response));
        }
        public void DeleteAction_ValidAction_Succeed()
        {
            mockActionRepository.Setup(a => a.DeleteActionForAll(It.IsAny <int>(), It.IsAny <int>())).Verifiable("Unable to delete Action");
            DeleteActionResponse response = actionService.DeleteAction(new DeleteActionRequest()
            {
                ActionId = ACTION_ID
            });

            mockRepository.VerifyAll();
            Assert.AreEqual(null, response.Exception);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DeleteActionResponse response = new DeleteActionResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("ActionArn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ActionArn = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Exemple #4
0
        /// <summary>
        /// This method is used to revoke access to a shared record that was shared to users and print the response.
        /// </summary>
        /// <param name="moduleAPIName">The API Name of the module to revoke shared record.</param>
        /// <param name="recordId">The ID of the record to be obtained.</param>
        public static void RevokeSharedRecord(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);

            //Call RevokeSharedRecord method
            APIResponse <DeleteActionHandler> response = shareRecordsOperations.RevokeSharedRecord();

            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
                    DeleteActionHandler deleteActionHandler = response.Object;

                    if (deleteActionHandler is DeleteActionWrapper)
                    {
                        //Get the received DeleteActionWrapper instance
                        DeleteActionWrapper deleteActionWrapper = (DeleteActionWrapper)deleteActionHandler;

                        //Get the received DeleteActionResponse instance
                        DeleteActionResponse deleteActionResponse = deleteActionWrapper.Share;

                        //Check if the request is successful
                        if (deleteActionResponse is SuccessResponse)
                        {
                            //Get the received SuccessResponse instance
                            SuccessResponse successResponse = (SuccessResponse)deleteActionResponse;

                            //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 (deleteActionResponse is APIException)
                        {
                            //Get the received APIException instance
                            APIException exception = (APIException)deleteActionResponse;

                            //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 (deleteActionHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)deleteActionHandler;

                        //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);
                        }
                    }
                }
            }
        }