Skip to content

Restore WizardAPI Service#1

Open
suseal4kontur wants to merge 1 commit intokontur-course-nsk:masterfrom
suseal4kontur:master
Open

Restore WizardAPI Service#1
suseal4kontur wants to merge 1 commit intokontur-course-nsk:masterfrom
suseal4kontur:master

Conversation

@suseal4kontur
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Contributor

@stex43 stex43 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом неплохо, надеюсь, что таски и апишки стали после этого понятнее. :)

Task<ClientResult<Elixir>> GetElixirAsync(string id);

// GET /elixirs?ingredient={ingredientName}&inventorFullName={inventorFullName}
Task<ClientResult<Elixir[]>> GetElixirAsync(string ingredientName, string inventorFullName);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetElixirsAsync

Task<ClientResult<Wizard>> GetWizardAsync(string id);

// GET /wizards?firstName={firstName}&lastName={lastName}
Task<ClientResult<Wizard>> GetWizardAsync(string firstName, string lastName);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не пробовал этот метод заюзать? :) Технически здесь GetWizardsAsync. Поэтому он у тебя упадёт

// GET /wizards/{id}
Task<ClientResult<Wizard>> GetWizardAsync(string id);

// GET /wizards?firstName={firstName}&lastName={lastName}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В этом методе и в поиске эликсира по имени ингредиента и/или создателя, прикольнее использовать значения параметров по умолчанию, чтобы они были необязательными. Т.е. если тебе надо будет поискать эликсир только по имени ингредиента, тебе не надо будет передавать пустую строку или null вместо имени создателя, оно там автоматом подставится.


// POST /feedback
// body : FeedbackInfo
Task<ClientResult<Uri>> CreateFeedbackAsync(FeedbackType feedbackType, string feedback);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь я в целом предполагала возвращение просто ClientResult, не дженерик. Типа нам неинтересно, что нам там вернули в теле

public interface IWizardClient
{
// GET /wizards/{id}
Task<ClientResult<Wizard>> GetWizardAsync(string id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь можно было в целом Guid id (да и везде здесь надо было Guid id, просто если бы я везде прописала Guid, не было бы возможности получить 400 от апишки)

HttpResponseMessage response = await httpClient.PostAsync($"feedback/", stringContent);
response.EnsureSuccessStatusCode();

if (response.IsSuccessStatusCode)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Постоянно повторяется этот кусочек кода про возврат ответа, попробуй вынести в отдельный метод

return 0;

var elixirs = new List<Models.Elixir>();
foreach (var elixir in wizard.Elixirs)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А можно просто запросить все эликсиры по имени-фамилии создателя

var inventedElixirsResult = await wizardClient.GetElixirAsync("",
$"{wizard.FirstName} {wizard.LastName}");
if (!inventedElixirsResult.IsSuccessful())
return 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот прям сразу return?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants