void _SendEnvelope() { TemplateInfo send = new TemplateInfo(); send.notification.expirations.expireAfter = "40"; send.notification.expirations.expireEnabled = true; send.notification.expirations.expireWarn = "5"; DocusignResponse response = new DocusignResponse(); SendRestRequest(response, HttpMethod.Put, "templates/" + templateID, send).Wait(); if (response.IsError) { response.Throw(); } resObj = response.GetData <TemplateSummaryResponse>(); }
public async Task <ActionResult <IEnumerable <PublishedFundingTemplate> > > GetFundingTemplates(string fundingStreamId, string fundingPeriodId) { IEnumerable <PublishedFundingTemplate> publishFundingTemplates = await SearchTemplates($"{fundingStreamId}/{fundingPeriodId}/"); IEnumerable <TemplateSummaryResponse> templateResponses = await _templateBuilderService.FindVersionsByFundingStreamAndPeriod(new FindTemplateVersionQuery() { FundingStreamId = fundingStreamId, FundingPeriodId = fundingPeriodId, Statuses = new List <TemplateStatus>() { TemplateStatus.Published } }); foreach (PublishedFundingTemplate publishedFundingTemplate in publishFundingTemplates) { string[] versionParts = publishedFundingTemplate.TemplateVersion.Split("."); if (versionParts.Length >= 2) { TemplateSummaryResponse templateResponse = templateResponses.FirstOrDefault(x => x.MajorVersion.ToString() == versionParts[0] && x.MinorVersion.ToString() == versionParts[1]); if (templateResponse != null) { publishedFundingTemplate.PublishNote = templateResponse.Comments; publishedFundingTemplate.AuthorId = templateResponse.AuthorId; publishedFundingTemplate.AuthorName = templateResponse.AuthorName; publishedFundingTemplate.SchemaVersion = templateResponse.SchemaVersion; } } } if (!publishFundingTemplates.Any()) { return(new NotFoundResult()); } return(publishFundingTemplates.ToList()); }
public async Task GetFundingTemplates_GivenTemplateIsInBlob_Metatdata_In_TemplateBuilder_Collection_ReturnsOkObjectResultWithAMetadata() { //Arrange const string fundingStreamId = "PES"; const string fundingPeriodId = "AY-2020"; string blobNamePrefix = $"{fundingStreamId}/{ fundingPeriodId}/"; IEnumerable <TemplateSummaryResponse> templateVersions = new[] { new TemplateSummaryResponse() { FundingPeriodId = fundingPeriodId, FundingStreamId = fundingStreamId, MajorVersion = 1, MinorVersion = 1, Status = TemplateStatus.Published, AuthorId = "Auth-Id", AuthorName = "Auth-Name", Comments = "SomeComments", SchemaVersion = "1.1" }, new TemplateSummaryResponse() { FundingPeriodId = fundingPeriodId, FundingStreamId = fundingStreamId, MajorVersion = 1, MinorVersion = 0, Status = TemplateStatus.Published, AuthorId = "Auth-Id2", AuthorName = "Auth-Name2", Comments = "SomeComments2", SchemaVersion = "1.2" } }; IEnumerable <PublishedFundingTemplate> pubblishedFundingTempaltes = new[] { new PublishedFundingTemplate() { TemplateVersion = "1.0", PublishDate = new DateTime(2020, 06, 15, 10, 30, 50) } }; IFundingTemplateRepository fundingTemplateRepository = CreateFundingTemplateRepository(); fundingTemplateRepository .SearchTemplates(Arg.Is(blobNamePrefix)) .Returns(pubblishedFundingTempaltes); ITemplateBuilderService templateBuilderService = CreateTemplateBuilderService(); templateBuilderService.FindVersionsByFundingStreamAndPeriod(Arg.Is <FindTemplateVersionQuery>(x => x.FundingStreamId == fundingStreamId && x.FundingPeriodId == fundingPeriodId)) .Returns(templateVersions); ILogger logger = CreateLogger(); FundingTemplateService fundingTemplateService = CreateFundingTemplateService( logger, fundingTemplateRepository: fundingTemplateRepository, templateBuilderService: templateBuilderService); //Act ActionResult <IEnumerable <PublishedFundingTemplate> > result = await fundingTemplateService.GetFundingTemplates(fundingStreamId, fundingPeriodId); //Assert PublishedFundingTemplate resultTemplate = result.Value.FirstOrDefault(); TemplateSummaryResponse templateResponse = templateVersions.First(x => x.MajorVersion == 1 && x.MinorVersion == 0); resultTemplate.TemplateVersion.Should().Be(pubblishedFundingTempaltes.First().TemplateVersion); resultTemplate.PublishDate.Should().Be(pubblishedFundingTempaltes.First().PublishDate); resultTemplate.AuthorId.Should().Be(templateResponse.AuthorId); resultTemplate.AuthorName.Should().Be(templateResponse.AuthorName); resultTemplate.PublishNote.Should().Be(templateResponse.Comments); resultTemplate.SchemaVersion.Should().Be(templateResponse.SchemaVersion); }