Beispiel #1
0
        public async Task <GuidMethodsModel> GetHttpMethodsByGuid(Guid guid)
        {
            GuidMethodsModel guidMethods     = null;
            string           jsonGuidMethods = await _githubService.GetFileContent(_guidMethodsFolderPath, guid);

            jsonGuidMethods.IsNotNull(() =>
            {
                guidMethods = JsonSerializer.Deserialize <GuidMethodsModel>(jsonGuidMethods);
            });

            return(guidMethods);
        }
Beispiel #2
0
        public async Task <MockModel> GetMock(Guid guid, string httpMethod)
        {
            MockModel        mock        = null;
            GuidMethodsModel guidMethods = await GetHttpMethodsByGuid(guid);

            await guidMethods.IsNotNullAsync(async() =>
            {
                httpMethod = guidMethods.HttpMethods.Contains(httpMethod) ? httpMethod : "GET";

                string path = Path.Combine(_githubSetting.HttpMethodsFolderPath, httpMethod.ToUpper());

                string content = await _githubService.GetFileContent(path, guid);
                mock           = JsonSerializer.Deserialize <MockModel>(content);
            });

            return(mock);
        }
Beispiel #3
0
        public async Task <Guid> Create(IEnumerable <MockModel> request)
        {
            Guid guid = Guid.NewGuid();

            GuidMethodsModel guidMethodsModel = new GuidMethodsModel
            {
                HttpMethods = request.Select(x => x.HttpMethod.ToUpper()).ToArray()
            };

            await _githubService.CreateFile(_guidMethodsFolderPath, guid, JsonSerializer.Serialize(guidMethodsModel));

            foreach (MockModel mock in request)
            {
                string content = JsonSerializer.Serialize(mock);
                string path    = Path.Combine(_githubSetting.HttpMethodsFolderPath, mock.HttpMethod.ToUpper());
                await _githubService.CreateFile(path, guid, content);
            }

            return(guid);
        }