public async Task<IEnumerable<CardResponseModel>> Post(CardsRequestModel requestModel) { var scraper = new SlScreenScraper(requestModel.CookieHeader); try { var cards = await scraper.GetAccessCards(requestModel.PartyRef); return cards.Select(card => new CardResponseModel(card)); } catch (HttpResponseException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } }
public async Task<AuthenticateResponseModel> Post(AuthenticateRequestModel requestModel) { var scraper = new SlScreenScraper(requestModel.Username, requestModel.Password); var success = await scraper.Authenticate(); if (!success.Authenticated) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } return new AuthenticateResponseModel { Authenticated = true, CookieHeader = scraper.GetCookieHeader(), PartyRef = success.PartyRef }; }