예제 #1
0
        /// <summary>
        /// Processes a request into a response.
        /// </summary>
        public ApiResponse ProcessRequest(ApiRequest request)
        {
            Initialize(request);
              ApiResponse response = null;
              try
              {
            response = new ApiResponse(AuthUser, request);
            bool success = ProcessCoreFunctions(request, response);
            if (!success)
              success = ProcessApplicationFunctions(request, response);

            if (!success)
            {
              response.Status = MethodStatus.Fail;
              response.ErrorMessages.Add("Method not found.");
            }
              }
              catch
              {
            response = new ApiResponse(null, request);
            response.Status = MethodStatus.Fail;
            response.ErrorMessages.Add("An exception has occurred.");
              }
              return response;
        }
예제 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ApiResponse(SessionAuthUser authUser, ApiRequest request)
            : base(authUser)
        {
            if (request == null)
            throw new ArgumentNullException("request");

              TrackingID = request.TrackingID;
              Function = request.Function;
              ErrorMessages = new StringList();
        }
예제 #3
0
        /// <summary>
        /// Calls the listed endpoint on this controller.
        /// </summary>
        public static ApiResponse CallApi(SessionAuthUser authUser, string function, object dataObject = null)
        {
            CommonApiController controller = BaseCallApiController.GetController<CommonApiController>();

              ApiRequest request = new ApiRequest(authUser, function);
              request.DataObject = dataObject;

              IHttpActionResult actionResult = controller.ProcessRequest(request);

              ApiResponse response = AssertAsValid<ApiResponse>(actionResult);
              Assert.IsNotNull(response.DataObject);

              return response;
        }
예제 #4
0
        public IHttpActionResult ProcessRequest(ApiRequest request)
        {
            if (PublicConfigurationSettings.GetApiProcessor == null)
              {
            throw new HttpResponseException(
             Request.CreateErrorResponse(HttpStatusCode.InternalServerError, PublicConfigurationSettings.CONFIG_ERROR));
              }

              ApiProcessor processor = PublicConfigurationSettings.GetApiProcessor.Invoke();
              ApiResponse response = processor.ProcessRequest(request);
              if (response == null)
              {
            return NotFound();
              }

              return Ok(response);
        }
예제 #5
0
 /// <summary>
 /// Processes any core functions.
 /// </summary>
 private bool ProcessCoreFunctions(ApiRequest request, ApiResponse response)
 {
     if (request.Function.Equals(CoreFunctions.AddressGetClientAddresses))
       {
     response.DataObject = PublicLogicManager.Address.GetClientAddresses();
     return true;
       }
       return false;
 }
예제 #6
0
 private void Initialize(ApiRequest request)
 {
     AuthManager authManager = PublicConfigurationSettings.GetAuthManager();
       AuthUser = authManager.GetAuthUser(request.UserIdentifier);
       InitializeSpecificItems();
 }
예제 #7
0
 /// <summary>
 /// Processes application specific functions.
 /// </summary>
 protected abstract bool ProcessApplicationFunctions(ApiRequest request, ApiResponse response);