public AuthorizedKeychainRequestModel GetAuthorizedKeychainRequestModel()
 {
     if (this.model != null)
     {
         var credentials = new AuthorizedKeychainRequestModel()
         {
             AccessToken  = this.model.AccessToken,
             RefreshToken = this.model.RefreshToken
         };
         return(credentials);
     }
     else
     {
         //something to do with null
         return(null);
     }
 }
Beispiel #2
0
        /// <summary>
        /// The get Authorized Keychain Request Model.
        /// </summary>
        /// <returns>The <see cref="AuthorizedKeychainRequestModel" />.</returns>>
        public AuthorizedKeychainRequestModel GetAuthorizedKeychainRequestModel()
        {
            var account = AccountStore.Create(Forms.Context).FindAccountsForService(App.AppName).FirstOrDefault();

            if (account != null)
            {
                var credentials = new AuthorizedKeychainRequestModel()
                {
                    AccessToken  = account.Properties[GrosvenorConstants.AccessToken],
                    RefreshToken = account.Properties[GrosvenorConstants.RefreshToken]
                };
                return(credentials);
            }
            else
            {
                //something to do with null
                return(null);
            }
        }
        /// <summary>The my profile.</summary>
        /// <param name="model">The model.</param>
        /// <returns>The <see cref="Task"/>.</returns>
        public async Task <BaseFacadeResponseModel <MyProfileResponseModel> > MyProfile(AuthorizedKeychainRequestModel model)
        {
            var runner = await this._authWrapper.TraverseReauth(
                () => this._accountApi.MyProfile(model.AccessToken),
                model.RefreshToken);

            // generic runner response that sets up the return object
            var runnerResponse = await new ApiRunnerResponseHelper().ReturnRunnerResponse(
                runner,
                new MyProfileResponseModel(),
                new MyProfileApiResponseModel());

            var mappedFacadeResponse =
                runnerResponse.FacadeResponseModel as BaseFacadeResponseModel <MyProfileResponseModel>;

            // here we need to translate the api content response into the UI response
            if (runnerResponse.ApiContentResponseModelContent != null)
            {
                var apiResponse = runnerResponse.ApiContentResponseModelContent as MyProfileApiResponseModel;
                if (apiResponse != null)
                {
                    mappedFacadeResponse.Content =
                        new MyProfileResponseModel {
                        MyProfile = Mapper.Map <MyProfile>(apiResponse.MyProfile)
                    }
                }
                ;
            }

            return(mappedFacadeResponse);
        }
    }