Exemplo n.º 1
0
        public async Task <BaseResponse> AddKeyAsync(string accesToken, string key, string title)
        {
            if (ServiceValidator.StringIsNullOrEmpty(accesToken))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(GitLabAPIClientService),
                        nameof(AddKeyAsync),
                        nameof(accesToken),
                        "invalid_parameter_null_or_empty")
                }));
            }

            if (ServiceValidator.StringIsNullOrEmpty(key))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(GitLabAPIClientService),
                        nameof(AddKeyAsync),
                        nameof(key),
                        "invalid_parameter_null_or_empty")
                }));
            }

            if (ServiceValidator.StringIsNullOrEmpty(title))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(GitLabAPIClientService),
                        nameof(AddKeyAsync),
                        nameof(title),
                        "invalid_parameter_null_or_empty")
                }));
            }

            try
            {
                var result = await this.client.AddRepoKey(accesToken, key, title);

                return(new BaseResponse(true));
            }
            catch (Exception ex)
            {
                return(new BaseResponse(false, new List <string>()
                {
                    ex.Message
                }));
            }
        }
Exemplo n.º 2
0
        public async Task <BaseResponse> CreateHubAsync(string name, string accesTokken)
        {
            if (ServiceValidator.StringIsNullOrEmpty(name))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(GitLabAPIClientService),
                        nameof(CreateHubAsync),
                        nameof(name),
                        "invalid_parameter_null_or_empty")
                }));
            }

            if (ServiceValidator.StringIsNullOrEmpty(accesTokken))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(GitLabAPIClientService),
                        nameof(CreateHubAsync),
                        nameof(accesTokken),
                        "invalid_parameter_null_or_empty")
                }));
            }

            try
            {
                var result = await client.PostCreateAsync(name, accesTokken);

                return(new BaseResponse(true, new List <string>()
                {
                    result
                }));
            }
            catch (Exception ex)
            {
                return(new BaseResponse(false, new List <string>()
                {
                    ex.Message
                }));
            }
        }
Exemplo n.º 3
0
        public async Task <BaseResponse> CreateDeployKey(string accesToken)
        {
            if (ServiceValidator.StringIsNullOrEmpty(accesToken))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(NetlifyApiClientService),
                        nameof(CreateDeployKey),
                        nameof(accesToken),
                        "invalid_parameter_null_or_empty")
                }));
            }

            try
            {
                var result = await client.DeployKeys(accesToken);

                var id        = result.Id;
                var publicKey = result.PublicKey;

                var responseMessage = new List <string>();
                responseMessage.Add(id);
                responseMessage.Add(publicKey);

                return(new BaseResponse(true, new List <string>(responseMessage)));
            }
            catch (Exception ex)
            {
                return(new BaseResponse(false, new List <string>()
                {
                    ex.Message
                }));
            }
        }
Exemplo n.º 4
0
        public async Task <BaseResponse> CreateHubAsync(string netlifySiteName, string repositoryName, string repositoryId,
                                                        string deployKeyId, string accesToken, string netlifyCMDCommand, string netlifyDirBuildName)
        {
            if (ServiceValidator.ObjectIsNull(netlifySiteName))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(NetlifyApiClientService),
                        nameof(CreateHubAsync),
                        nameof(netlifySiteName),
                        "invalid_parameter_is_null")
                }));
            }

            if (ServiceValidator.ObjectIsNull(repositoryName))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(NetlifyApiClientService),
                        nameof(CreateHubAsync),
                        nameof(repositoryName),
                        "invalid_parameter_is_null")
                }));
            }

            if (ServiceValidator.ObjectIsNull(repositoryId))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(NetlifyApiClientService),
                        nameof(CreateHubAsync),
                        nameof(repositoryId),
                        "invalid_parameter_is_null")
                }));
            }

            if (ServiceValidator.ObjectIsNull(deployKeyId))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(NetlifyApiClientService),
                        nameof(CreateHubAsync),
                        nameof(deployKeyId),
                        "invalid_parameter_is_null")
                }));
            }

            if (ServiceValidator.ObjectIsNull(accesToken))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(NetlifyApiClientService),
                        nameof(CreateHubAsync),
                        nameof(accesToken),
                        "invalid_parameter_is_null")
                }));
            }

            if (ServiceValidator.ObjectIsNull(netlifyCMDCommand))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(NetlifyApiClientService),
                        nameof(CreateHubAsync),
                        nameof(netlifyCMDCommand),
                        "invalid_parameter_is_null")
                }));
            }

            if (ServiceValidator.ObjectIsNull(netlifyDirBuildName))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(NetlifyApiClientService),
                        nameof(CreateHubAsync),
                        nameof(netlifyDirBuildName),
                        "invalid_parameter_is_null")
                }));
            }

            try
            {
                var result = await client.PostCreateAsync(netlifySiteName, repositoryName, repositoryId, deployKeyId, accesToken, netlifyCMDCommand, netlifyDirBuildName);

                return(new BaseResponse(true, new List <string>()
                {
                    result
                }));
            }
            catch (Exception ex)
            {
                return(new BaseResponse(false, new List <string>()
                {
                    ex.Message
                }));
            }
        }
Exemplo n.º 5
0
        public async Task <BaseResponse> PushDataToHubAsync(
            string hubId, string accesTokken, IList <string> filePaths, IList <string> fileContents)
        {
            if (ServiceValidator.StringIsNullOrEmpty(hubId))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(GitLabAPIClientService),
                        nameof(PushDataToHubAsync),
                        nameof(hubId),
                        "invalid_parameter_null_or_empty")
                }));
            }

            if (ServiceValidator.StringIsNullOrEmpty(accesTokken))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(GitLabAPIClientService),
                        nameof(PushDataToHubAsync),
                        nameof(accesTokken),
                        "invalid_parameter_null_or_empty")
                }));
            }

            if (ServiceValidator.ObjectIsNull(filePaths))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(GitLabAPIClientService),
                        nameof(PushDataToHubAsync),
                        nameof(filePaths),
                        "invalid_parameter_is_null")
                }));
            }

            if (ServiceValidator.ObjectIsNull(fileContents))
            {
                return(new BaseResponse(false,
                                        new List <string>()
                {
                    ServiceValidator.MessageCreator(
                        nameof(GitLabAPIClientService),
                        nameof(PushDataToHubAsync),
                        nameof(fileContents),
                        "invalid_parameter_is_null")
                }));
            }

            try
            {
                var result = await client.PushToHubAsync(hubId, accesTokken, filePaths, fileContents);

                return(new BaseResponse(true));
            }
            catch (Exception ex)
            {
                return(new BaseResponse(false, new List <string>()
                {
                    ex.Message
                }));
            }
        }