Example #1
0
        public static async Task <OpenBankingSoftwareStatementResponse> SubmitAsync(
            this SoftwareStatementProfileContext context)
        {
            context.ArgNotNull(nameof(context));

            IList <FluentResponseMessage> validationErrors = Validate(context);

            if (validationErrors.Count > 0)
            {
                return(new OpenBankingSoftwareStatementResponse(messages: validationErrors, data: null));
            }

            CreateSoftwareStatementProfile creator = new CreateSoftwareStatementProfile(
                softwareStatementProfileService: context.Context.SoftwareStatementProfileService);

            List <FluentResponseMessage> messages = new List <FluentResponseMessage>();

            try
            {
                SoftwareStatementProfileResponse response = await creator.CreateAsync(context.Data);

                return(new OpenBankingSoftwareStatementResponse(messages: messages, data: response));
            }
            catch (Exception ex)
            {
                context.Context.Instrumentation.Exception(ex);

                return(new OpenBankingSoftwareStatementResponse(message: ex.CreateErrorMessage(), data: null));
            }
        }
Example #2
0
        public static SoftwareStatementProfileContext DefaultFragmentRedirectUrl(
            this SoftwareStatementProfileContext context,
            string url)
        {
            context.ArgNotNull(nameof(context))
            .GetOrCreateDefault(DataLens).DefaultFragmentRedirectUrl = url;

            return(context);
        }
Example #3
0
        public static SoftwareStatementProfileContext SoftwareStatement(
            this SoftwareStatementProfileContext context,
            string statement)
        {
            context.ArgNotNull(nameof(context))
            .GetOrCreateDefault(DataLens).SoftwareStatement = statement;

            return(context);
        }
Example #4
0
        public static SoftwareStatementProfileContext Id(
            this SoftwareStatementProfileContext context,
            string id)
        {
            context.ArgNotNull(nameof(context))
            .GetOrCreateDefault(DataLens).Id = id;

            return(context);
        }
Example #5
0
        public static SoftwareStatementProfileContext Data(
            this SoftwareStatementProfileContext context,
            SoftwareStatementProfile value)
        {
            context.ArgNotNull(nameof(context));
            value.ArgNotNull(nameof(value));

            context.Data = value;

            return(context);
        }
Example #6
0
        public static SoftwareStatementProfileContext TransportKeyInfo(
            this SoftwareStatementProfileContext context,
            string keySecretName,
            string certificate)
        {
            SoftwareStatementProfile data = context.ArgNotNull(nameof(context)).GetOrCreateDefault(DataLens);

            data.TransportKey         = keySecretName;
            data.TransportCertificate = certificate;

            return(context);
        }
Example #7
0
 private static IList <FluentResponseMessage> Validate(SoftwareStatementProfileContext context)
 {
     return(new SoftwareStatementProfileValidator()
            .Validate(context.Data)
            .GetOpenBankingResponses());
 }