/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateLinkResponse response = new CreateLinkResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Link", targetDepth)) { var unmarshaller = LinkUnmarshaller.Instance; response.Link = unmarshaller.Unmarshall(context); continue; } } return(response); }
public async Task <IActionResult> CreateLink( [FromBody] CreateLinkRequest request, CancellationToken cancellationToken) { var createLink = new CreateLinkCommand( request.Data, request.IsEncrypted, request.Secrets, request.TtlSeconds); var link = await Mediator.Send(createLink, cancellationToken); var response = new CreateLinkResponse { ExpiresAt = link.ExpiresAt, LinkId = link.LinkId }; await LinksService.AddLinksAsync(response); return(Created("links/{{hash}}", response)); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] [RequestBodyType(typeof(CreateLinkRequest), "Get Link")] CreateLinkRequest req, ILogger log) { try { var request = JsonConvert.SerializeObject(req); log.LogInformation($"CreateLink {request}"); CreateLinkResponse response = await _mediator.Send(req); return(new OkObjectResult(ResponseWrapper <CreateLinkResponse, CommunicationServiceErrorCode> .CreateSuccessfulResponse(response))); } catch (Exception exc) { log.LogError("Exception occured in Create Link", exc); return(new ObjectResult(ResponseWrapper <CreateLinkResponse, CommunicationServiceErrorCode> .CreateUnsuccessfulResponse(CommunicationServiceErrorCode.InternalServerError, "Internal Error")) { StatusCode = StatusCodes.Status500InternalServerError }); } }