public CreateHouseholdInviteLinkResponse CreateInviteLink() { var response = new CreateHouseholdInviteLinkResponse(); try { if (_userService.AuthenticateSession(Request.Headers["Authorization"].ToString()) == false) { response.AddError("The authorization credentails were invalid", ErrorCode.SESSION_INVALID); return(response); } string sessionId = Request.Headers["Authorization"].ToString(); ActiveUser user = _userService.GetUserInformationFromAuthHeader(sessionId); response.InviteLink = _inviteLinkService.GenerateInviteLinkForHousehold(user); } catch (ErrorCodeException exception) { response.AddError($"An unexpected exception occured: {exception}", exception.Code); } catch (Exception exception) { response.AddError($"An unexpected exception occured: {exception}"); } return(response); }
public IEndpointHelperSetup CreateHouseholdInviteLink() { var result = _fakeSever.GetAsync("/Api/v2/Household/InviteLink").Result; var responseBody = result.Content.ReadAsStringAsync().Result; _inviteLinkResponse = JsonConvert.DeserializeObject <CreateHouseholdInviteLinkResponse>(responseBody); return(this); }
public void Initialize() { _fakeAccountHelper = new FakeAccountHelper(); Guid validSessionId = _fakeAccountHelper.GenerateValidCredentials(); _endpointHelper = new EndpointHelper(); _inviteLink = _endpointHelper.Setup() .SetAuthenticationToken(validSessionId.ToString()) .CreateHouseholdInviteLink() .ReturnHouseholdLink(); }
public void Initialize() { _accountHelper = new RealAccountHelper(); Guid firstUserSession = _accountHelper.GenerateValidCredentials(); _endpointHelper = new EndpointHelper(); CreateHouseholdInviteLinkResponse inviteLinkResponse = _endpointHelper.Setup() .SetAuthenticationToken(firstUserSession.ToString()) .AddHousehold(typeof(WhenTheRequestIsValid).Name) .CreateHouseholdInviteLink() .ReturnHouseholdLink(); Guid secondUserSession = _accountHelper.GenerateValidCredentials(); _endpointHelper.Setup().SetAuthenticationToken(secondUserSession.ToString()); _joinHouseholdResponse = _endpointHelper.JoinHousehold(inviteLinkResponse.InviteLink); }