public static List<ApiConfiguration> Get(IHandleGettingConfiguration configuration, IHandleGettingIntegrationClient client)
 {
     var config = new GetAllConfigurations();
     var clientCommand = new GetIntegrationClients();
     configuration.Handle(config);
     client.Handle(clientCommand);
     return config.Configurations.Select(s => new ApiConfiguration(s, clientCommand.Clients.FirstOrDefault(w => w.Id == s.ClientId))).ToList();
 }
        public ClientModule(IHandleGettingIntegrationClient client, IHandleSavingClient save)
        {
            this.RequiresAnyClaim(new[] { RoleType.Admin.ToString(), RoleType.ProductManager.ToString(), RoleType.Support.ToString() });

            Get["/client/new"] = _ => View["client/client", ClientDto.Create()];

            Get["/client/edit/{id}"] = _ => View["client/client", LimClientView.Existing(client, new GetIntegrationClient(_.Id))];

            Post["/client/save"] = _ =>
            {
                var model = this.Bind<ClientDto>();
                save.Handle(new AddClient(model));
                return Response.AsRedirect("/client/view");
            };

            Get["/client/view"] = _ => View["client/clients", LimClientView.Get(client)];
        }
 public void SetIntegrationClients(IHandleGettingIntegrationClient handler, GetIntegrationClients command)
 {
     handler.Handle(command);
     SelectableIntegrationClients = command.Clients.ToList();
 }
 public static ClientDto Existing(IHandleGettingIntegrationClient client, GetIntegrationClient command)
 {
     client.Handle(command);
     return command.Client;
 }
 public static IEnumerable<LimClientView> Get(IHandleGettingIntegrationClient client)
 {
     var command = new GetIntegrationClients();
     client.Handle(command);
     return command.Clients.Select(s => new LimClientView(s));
 }
Ejemplo n.º 6
0
        public ApiModule(IHandleGettingConfiguration setup, IHandleSavingConfiguration save, IHandleGettingIntegrationClient client,
            IUserManagementApiClient api, IHandleGettingDataPlatformClient dataPlatform, IHandleGettingMetadata metadata)
        {
            this.RequiresAnyClaim(new[] { RoleType.Admin.ToString(), RoleType.ProductManager.ToString(), RoleType.Support.ToString() });

            Get["/integrations/for/api/push"] = _ =>
            {
                var model = PushConfiguration.Create();
                var token = Context.Request.Headers.Authorization.Any() ? Context.Request.Headers.Authorization.Split(' ')[1] : string.Empty;
                model.SetFrequency(setup, new GetFrequencyTypes());
                model.SetAuthentication(setup, new GetAuthenticationTypes());
                model.SetDataPlatformClients(dataPlatform, new GetDataPlatformClients(api, token));
                model.SetWeekdays(setup, new GetWeekdays());
                model.SetIntegrationClients(client, new GetIntegrationClients());
                return View["integrations/api/push", model];
            };

            Get["/integrations/for/api/push/edit/{id}/{clientId}"] = _ =>
                {
                    int id;
                    int clientId;

                    int.TryParse(_.Id, out id);
                    int.TryParse(_.clientId, out clientId);

                    if (id == 0 || clientId == 0)
                        return HttpStatusCode.NoResponse;

                    var token = Context.Request.Headers.Authorization.Any() ? Context.Request.Headers.Authorization.Split(' ')[1] : string.Empty;
                    var model = PushConfiguration.Existing(setup, new GetApiPushConfiguration(id, clientId));
                    model.SetFrequency(setup, new GetFrequencyTypes());
                    model.SetAuthentication(setup, new GetAuthenticationTypes());
                    model.SetDataPlatformClients(dataPlatform, new GetDataPlatformClients(api, token));
                    model.SetWeekdays(setup, new GetWeekdays());
                    model.SetIntegrationClients(client, new GetIntegrationClients());
                    return View["integrations/api/push", model];
                };

            Post["/integrations/for/api/push/save"] = _ =>
            {
                var configuration = this.Bind<PushConfiguration>();
                var token = Context.Request.Headers.Authorization.Any() ? Context.Request.Headers.Authorization.Split(' ')[1] : string.Empty;
                configuration.SetDataPlatformClients(dataPlatform, new GetDataPlatformClients(api, token));
                var command = new AddApiPushConfiguration(configuration);
                save.Handle(command);
                return Response.AsRedirect("/integrations/for/api/configurations");
            };

            Get["/integrations/for/api/pull"] = _ =>
            {
                var model = PullConfiguration.Create();
                model.SetAuthentication(setup);
                model.SetFrequency(setup);
                model.SetWeekdays(setup, new GetWeekdays());
                model.SetIntegrationClients(client, new GetIntegrationClients());
                return View["integrations/api/pull", model];
            };

            Get["/integrations/for/api/configurations"] = _ => View["integrations/api/configurations", ApiConfiguration.Get(setup, client)];

            Get["/integrations/for/api/metadata/push"] = _ =>
            {
                var command = new GetApiResponseMetadataCommand();
                metadata.Handle(command);
                return View["integrations/api/pushmetadata", command.Metadata];
            };
        }