Esempio n. 1
0
        public Result <List <AccountInfo> > GetPageAccountCategory(AccountCategory accountCategory = AccountCategory.ALL)
        {
            ApiResponse response = AccountsApi.GetPageAccountCategory((int)accountCategory).Result;
            var         result   = GetResult <List <AccountInfo> >(response);

            return(result);
        }
Esempio n. 2
0
        private async Task <List <Account> > GetAccounts(Configuration configuration)
        {
            AccountsApi      accountsApi = new AccountsApi(configuration);
            AccountsResponse accounts    = await accountsApi.GetAccountsAsync("default");

            return(accounts.Accounts.Where(a => a.Closed == false).ToList());
        }
Esempio n. 3
0
        public Result <AccountInfo> GetNewAddress(string tag)
        {
            ApiResponse response = AccountsApi.GetNewAddress(tag).Result;
            var         result   = GetResult <AccountInfo>(response);

            return(result);
        }
        protected override void InitializeInternal()
        {
            // Data for this method
            // Permission profiles
            // User groups
            var basePath    = RequestItemsService.Session.BasePath + "/restapi";
            var accessToken = RequestItemsService.User.AccessToken;  // Represents your {ACCESS_TOKEN}
            var accountId   = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}
            var apiClient   = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

            var accountsApi = new AccountsApi(apiClient);
            var groupsApi   = new GroupsApi(apiClient);
            var permissions = accountsApi.ListPermissions(accountId);
            var userGroups  = groupsApi.ListGroups(accountId);

            // List all available permission profiles
            ViewBag.PermissionProfiles =
                permissions.PermissionProfiles.Select(pr => new SelectListItem
            {
                Text  = pr.PermissionProfileName,
                Value = pr.PermissionProfileId
            });

            // List all available user groups
            ViewBag.UserGroups =
                userGroups.Groups.Select(pr => new SelectListItem
            {
                Text  = $"{pr.GroupName}",
                Value = pr.GroupId
            });
        }
        private async Task AttemptLogin()
        {
            LabelError.Text          = "";
            ButtonLogin.IsEnabled    = false;
            ButtonRegister.IsEnabled = false;
            EntryEmail.IsEnabled     = false;
            EntryPassword.IsEnabled  = false;

            LayoutLoading.IsVisible            = true;
            ActivityIndicatorRunning.IsRunning = true;

            var loginResult = await AccountsApi.GetJwt(EntryEmail.Text, EntryPassword.Text);

            if (loginResult.IsSuccessful)
            {
                var jwt = loginResult.Content;
                await SecureStorage.SetAsync("300MEmail", EntryEmail.Text);

                await SecureStorage.SetAsync("300MPassword", EntryPassword.Text);
                await OpenDashboardPage(jwt);
            }
            else
            {
                LabelError.Text          = loginResult.Content;
                EntryEmail.IsEnabled     = true;
                EntryPassword.IsEnabled  = true;
                ButtonLogin.IsEnabled    = true;
                ButtonRegister.IsEnabled = true;

                ActivityIndicatorRunning.IsRunning = false;
                LayoutLoading.IsVisible            = false;
            }
        }
Esempio n. 6
0
        public async Task CanSetupSetupGetAccount()
        {
            long accountid = 564781;

            var payeschemes = new List <ResourceViewModel> {
                new ResourceViewModel {
                    Id = "111/ABC00011", Href = ""
                }
            };
            var resourceList = new ResourceList(payeschemes);
            var accounts     = new ObjectCreator().Create <AccountDetailViewModel>(x => { x.AccountId = accountid; x.PayeSchemes = resourceList; });

            apiMessageHandlers.SetupGetAccount(accountid, accounts);

            using (AccountsApi webApi = new AccountsApi(apiMessageHandlers))
            {
                using (HttpClient client = new HttpClient())
                {
                    var jsonresponse = await client.GetAsync(baseAddress + $"api/accounts/{accountid}");

                    var response = JsonConvert.DeserializeObject <AccountDetailViewModel>(jsonresponse.Content.ReadAsStringAsync().Result);
                    Assert.AreEqual(accountid, response.AccountId);
                }
            }
        }
Esempio n. 7
0
        public Result <bool> SetDefaultAccount(string account)
        {
            ApiResponse response = AccountsApi.SetDefaultAccount(account).Result;
            var         result   = GetResult <bool>(response);

            return(result);
        }
        public void BeforeScenario()
        {
            var config = _objectContainer.Resolve <LocalConfiguration>();

            AccountsApiMessageHandler accountsApiMessageHandlers = new AccountsApiMessageHandler(config.AccountsApiBaseUrl);

            AccountsApi = new AccountsApi(accountsApiMessageHandlers);

            ProviderEventsApiMessageHandler providerApiMessageHandlers = new ProviderEventsApiMessageHandler(config.PaymentsApiBaseUrl);

            ProviderEventsApi = new ProviderEventsApi(providerApiMessageHandlers);

            CommitmentsApiMessageHandler commitmentsApiMessageHandlers = new CommitmentsApiMessageHandler(config.CommitmentsApiBaseUrl);

            CommitmentsApi = new CommitmentsApi(commitmentsApiMessageHandlers);

            EventsApiMessageHandler eventsApiMessageHandlers = new EventsApiMessageHandler(config.EventsApiBaseUrl);

            EventsApiSubstitute = new EventsApi(eventsApiMessageHandlers);

            TokenServiceApiMessageHandler tokenApiMessageHandlers = new TokenServiceApiMessageHandler(config.TokenServiceApiBaseUrl);

            TokenApiSubstitute = new TokenServiceApi(tokenApiMessageHandlers);

            HmrcApiMessageHandler hmrcApiMessageHandlers = new HmrcApiMessageHandler(config.HmrcApiBaseUrl);

            HmrcApi = new HmrcApi(hmrcApiMessageHandlers);

            _objectContainer.RegisterInstanceAs(accountsApiMessageHandlers);
            _objectContainer.RegisterInstanceAs(providerApiMessageHandlers);
            _objectContainer.RegisterInstanceAs(commitmentsApiMessageHandlers);
            _objectContainer.RegisterInstanceAs(hmrcApiMessageHandlers);
            _objectContainer.RegisterInstanceAs(eventsApiMessageHandlers);
            _objectContainer.RegisterInstanceAs(tokenApiMessageHandlers);
        }
Esempio n. 9
0
        public Result <List <AccountInfo> > GetAddressesByTag(string tag = "*")
        {
            ApiResponse response = AccountsApi.GetAddressesByTag(tag).Result;
            var         result   = GetResult <List <AccountInfo> >(response);

            return(result);
        }
Esempio n. 10
0
        private async Task <AccountViewModel> GetAccountDetailsAsync(string accountNumber)
        {
            var accountApi       = new AccountsApi(_configuration.ApiHost);
            var accountViewModel = await accountApi.ApiV1AccountsByAccountNumberGetAsyncWithHttpInfo(accountNumber);

            return(accountViewModel.Data);
        }
        protected override void InitializeInternal()
        {
            // Data for this method
            // signerEmail
            // signerName
            var basePath    = RequestItemsService.Session.BasePath + "/restapi";
            var accessToken = RequestItemsService.User.AccessToken;            // Represents your {ACCESS_TOKEN}
            var accountId   = RequestItemsService.Session.AccountId;           // Represents your {ACCOUNT_ID}
            var apiClient   = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

            var accountsApi = new AccountsApi(apiClient);
            var permissions = accountsApi.ListPermissions(accountId);

            PermissionProfiles = permissions.PermissionProfiles;
            var permissionProfile = permissions.PermissionProfiles.FirstOrDefault();

            ProfileModel = new PermissionProfileModel
            {
                ProfileId   = permissionProfile.PermissionProfileId,
                ProfileName = permissionProfile.PermissionProfileName,
                AccountRoleSettingsModel = new AccountRoleSettingsModel(permissionProfile.Settings)
            };
        }
        /// <summary>
        /// Loads the Users into the list,
        /// based on supplied text from the search bar
        /// </summary>
        private async Task LoadUsers()
        {
            LayoutLoading.IsVisible = true;
            LayoutSearch.IsEnabled  = false;
            ViewUsers.IsEnabled     = false;

            // Get the User currently running the app
            var appUser = (await AccountsApi.GetUserByJwt(_settings.Jwt)).Content;
            // Retrieve the current User's friendships from the Friendships microservice
            var usersResult = await AccountsApi.GetUsersByQuery(_settings.Jwt, EntrySearch.Text);

            if (usersResult.IsSuccessful)
            {
                var users = new List <UserInfo>(usersResult.Content.Length);
                // Cycle through each friend
                foreach (var user in usersResult.Content)
                {
                    // Finally, convert the friendUser to a UserInfo, and add to the context list
                    if (user.Email != appUser.Email)
                    {
                        users.Add(await UserToUserInfo(user));
                    }
                }
                users.OrderBy(s => s.FriendStatus);

                _context.ClearAndSetUsersInfo(users);
            }

            LayoutLoading.IsVisible = false;
            LayoutSearch.IsEnabled  = true;
            ViewUsers.IsEnabled     = true;
        }
        async void OnRegisterPressed(object sender, EventArgs e)
        {
            LayoutEntries.IsEnabled = false;
            LayoutLoading.IsVisible = true;

            var registerResult = await AccountsApi.Register(
                new RegisterViewModel
            {
                Email           = Email.Text,
                FirstName       = FirstName.Text,
                LastName        = LastName.Text,
                Password        = Password.Text,
                ConfirmPassword = ConfirmPassword.Text
            }
                );

            if (registerResult.IsSuccessful)
            {
                ErrorCode.Text = "";
                ((RegisterContext)BindingContext).Completed = true;
                await Navigation.PopAsync();
            }
            else
            {
                ErrorCode.Text          = registerResult.Content;
                LayoutEntries.IsEnabled = true;
                LayoutLoading.IsVisible = false;
            }
        }
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            if (_email == null)
            {
                _userContext.User = (await AccountsApi.GetUserByJwt(_settings.Jwt)).Content;
            }
            else
            {
                _userContext.User           = (await AccountsApi.GetUserByEmail(_settings.Jwt, _email)).Content;
                LayoutAddAsFriend.IsVisible = true;
                await SetFriendshipStatus();
            }

            var photoResult = await ImagesApi.GetProfileImage(_userContext.User.Email, false);

            if (photoResult.IsSuccessful)
            {
                _userContext.Photo = photoResult.Content;
            }

            LayoutLoading.IsVisible = false;
            LayoutContent.IsVisible = true;
        }
        public void JwtListBrandTest()
        {
            AccountsApi accApi         = new AccountsApi();
            var         brandsResponse = accApi.ListBrands(testConfig.AccountId);

            Assert.IsNotNull(brandsResponse);
        }
Esempio n. 16
0
        public Result SetAccountTag(string address, string tag)
        {
            ApiResponse response = AccountsApi.ValidateAddress(address).Result;

            if (response.HasError)
            {
                return new Result()
                       {
                           IsFail = true, ApiResponse = response
                       }
            }
            ;

            AddressInfo addressInfo = response.GetResult <AddressInfo>();

            if (addressInfo.IsValid)
            {
                var res = AccountsApi.SetAccountTag(address, tag).Result;

                return(GetResult(res));
            }

            return(new Result()
            {
                IsFail = true, ApiResponse = response
            });
        }
    }
Esempio n. 17
0
        public Result <AddressInfo> ValidateAddress(string account)
        {
            ApiResponse response = AccountsApi.ValidateAddress(account).Result;
            var         result   = GetResult <AddressInfo>(response);

            return(result);
        }
Esempio n. 18
0
        public void OAuthAuthorizationCodeFlowTest()
        {
            // Make an API call with the token
            ApiClient apiClient = new ApiClient(BaseUrl);

            DocuSign.eSign.Client.Configuration.Default.ApiClient = apiClient;

            // Initiate the browser session to the Authentication server
            // so the user can login.
            string accountServerAuthUrl = apiClient.GetAuthorizationUri(client_id, redirect_url, true, stateOptional);

            System.Diagnostics.Process.Start(accountServerAuthUrl);

            WaitForCallbackEvent = new ManualResetEvent(false);

            // Launch a self-hosted web server to accepte the redirect_url call
            // after the user finishes authentication.
            using (WebApp.Start <Startup>("http://localhost:3000"))
            {
                Trace.WriteLine("WebServer Running. Waiting for access_token...");

                // This waits for the redirect_url to be received in the REST controller
                // (see classes below) and then sleeps a short time to allow the response
                // to be returned to the web browser before the server session ends.
                WaitForCallbackEvent.WaitOne(60000, false);
                Thread.Sleep(1000);
            }
            Assert.IsNotNull(AccessCode);

            string accessToken = apiClient.GetOAuthToken(client_id, client_secret, true, AccessCode);

            Assert.IsNotNull(accessToken);
            Trace.WriteLine("Access_token: " + accessToken);

            // we will retrieve this from the login API call
            string accountId = null;

            /////////////////////////////////////////////////////////////////
            // STEP 1: LOGIN API
            /////////////////////////////////////////////////////////////////

            // login call is available in the authentication api
            AuthenticationApi authApi   = new AuthenticationApi();
            LoginInformation  loginInfo = authApi.Login();

            // parse the first account ID that is returned (user might belong to multiple accounts)
            accountId = loginInfo.LoginAccounts[0].AccountId;

            // Update ApiClient with the new base url from login call
            apiClient = new ApiClient(loginInfo.LoginAccounts[0].BaseUrl);

            /////////////////////////////////////////////////////////////////
            // STEP 2: CREATE ACCOUNTS API
            /////////////////////////////////////////////////////////////////
            AccountsApi        accountsApi        = new AccountsApi();
            AccountInformation accountInformation = accountsApi.GetAccountInformation(accountId);

            Trace.WriteLine(accountInformation.ToString());
        }
Esempio n. 19
0
        public LunoApi(IConfig lunoConfig)
        {
            var lunoApiClient = new LunoApiClient(lunoConfig);

            MarketDataApi = new MarketDataApi(lunoApiClient);
            AccountsApi   = new AccountsApi(lunoApiClient);
            QuotesApi     = new QuotesApi(lunoApiClient);
        }
Esempio n. 20
0
        public async Task ValidateAddress()
        {
            ApiResponse response = await AccountsApi.ValidateAddress("fiiitPBzhdXC28KrsbFiF6S6YnDdWX5WEGf5Z5");

            Assert.IsFalse(response.HasError);
            AddressInfo result = response.GetResult <AddressInfo>();

            Assert.IsNotNull(result);
        }
Esempio n. 21
0
        public async Task GetDefaultAccount()
        {
            ApiResponse response = await AccountsApi.GetDefaultAccount();

            Assert.IsFalse(response.HasError);
            AccountInfo result = response.GetResult <AccountInfo>();

            Assert.IsNotNull(result);
        }
Esempio n. 22
0
        public async Task GetAddressesByTag()
        {
            ApiResponse response = await AccountsApi.GetAddressesByTag();

            Assert.IsFalse(response.HasError);
            List <AccountInfo> result = response.GetResult <List <AccountInfo> >();

            Assert.IsNotNull(result);
        }
Esempio n. 23
0
        /// <summary>
        /// Gets a list of all clickwraps
        /// </summary>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <returns>The list of all clickwraps</returns>
        public static ClickwrapVersionsResponse GetClickwraps(string basePath, string accessToken, string accountId)
        {
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var clickAccountApi = new AccountsApi(apiClient);

            return(clickAccountApi.GetClickwraps(accountId));
        }
 private void ConfigureAccountsApi()
 {
     AccountsApi.SetupGet("api/accounts/ABC123/levy", new AccountResourceList <LevyDeclarationViewModel>(new[] { new LevyDeclarationViewModelBuilder().WithDasAccountId("ABC123").Build() }));
     AccountsApi.SetupGet("api/accounts/ZZZ999/levy",
                          new AccountResourceList <LevyDeclarationViewModel>(
                              new[] {
         new LevyDeclarationViewModelBuilder().WithDasAccountId("ZZZ999").Build(),
         new LevyDeclarationViewModelBuilder().WithDasAccountId("ZZZ999").Build()
     }));
 }
        public void JwtGetClickwrapsTest()
        {
            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            AccountsApi accountsApi = new AccountsApi(testConfig.ApiClient);
            ClickwrapVersionsResponse clickwrapVersionsResponse = accountsApi.GetClickwraps(testConfig.AccountId, new AccountsApi.GetClickwrapsOptions());

            Assert.IsNotNull(clickwrapVersionsResponse);
            Assert.IsNotNull(clickwrapVersionsResponse.Clickwraps);
            Assert.IsTrue(clickwrapVersionsResponse.Clickwraps.Count > 0);
        }
        public AccountList AllAccounts(string userId, string userPassword)
        {
            var token = GetUserAccessToken(userId, userPassword);

            var api = new AccountsApi(BasePath);

            api.ApiClient.AddDefaultHeader("Authorization", "Bearer " + token);
            var result = api.GetAndSearchAllAccounts(null, null, null, null, null, null, null, null);

            return(result);
        }
Esempio n. 27
0
        /// <summary>
        /// Deletes a permission profile
        /// </summary>
        /// <param name="permissionProfileId">Permission profile ID</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        public static void DeletePermissionProfile(string permissionProfileId, string accessToken, string basePath, string accountId)
        {
            // Construct your API headers
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            AccountsApi accountsApi = new AccountsApi(config);

            // Call the eSignature REST API
            accountsApi.DeletePermissionProfile(accountId, permissionProfileId);
        }
        /// <summary>
        /// Creates a new clickwrap
        /// </summary>
        /// <param name="name">The name of new clickwrap</param>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <returns>The summary response of a newly created clickwrap</returns>
        public static ClickwrapVersionSummaryResponse Create(string name, string basePath, string accessToken, string accountId)
        {
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var clickAccountApi = new AccountsApi(apiClient);

            var clickwrapRequest = BuildClickwraprequest(name);

            return(clickAccountApi.CreateClickwrap(accountId, clickwrapRequest));
        }
Esempio n. 29
0
        public IActionResult Create(string brandName, string defaultBrandLanguage)
        {
            // Check the token with minimal buffer time.
            bool tokenOk = CheckToken(3);

            if (!tokenOk)
            {
                // We could store the parameters of the requested operation so it could be
                // restarted automatically. But since it should be rare to have a token issue
                // here, we'll make the user re-enter the form data after authentication.
                RequestItemsService.EgName = EgName;
                return(Redirect("/ds/mustAuthenticate"));
            }

            // Data for this method
            // signerEmail
            // signerName
            var basePath = RequestItemsService.Session.BasePath + "/restapi";

            // Step 1. Obtain your OAuth token
            var accessToken = RequestItemsService.User.AccessToken;  // Represents your {ACCESS_TOKEN}
            var accountId   = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

            // Step 2. Construct your API headers
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);

            // Step 3. Construct your request body
            Brand newBrand = new Brand
            {
                BrandName            = brandName,
                DefaultBrandLanguage = defaultBrandLanguage
            };

            try
            {
                // Step 4. Call the eSignature REST API
                AccountsApi accountsApi = new AccountsApi(config);
                var         results     = accountsApi.CreateBrand(accountId, newBrand);
                ViewBag.h1      = "New brand created";
                ViewBag.message = "The brand has been created!<br />Brand ID:" + results.Brands[0].BrandId + ".";
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;
                return(View("Error"));
            }

            return(View("example_done"));
        }
Esempio n. 30
0
        private void ConfigureAccountsApi()
        {
            AccountsApi.SetupGet("api/accounts/ABC123",
                new AccountDetailViewModelBuilder().WithDasAccountId("ABC123")
                    .WithLegalEntity(new ResourceViewModelBuilder().WithHref("api/accounts/ABC123/legalentities/123"))
                    .WithPayeScheme(new ResourceViewModelBuilder().WithHref("api/accounts/ABC123/payeschemes/1234"))
                    .Build());

            AccountsApi.SetupGet("api/accounts/ABC123/legalentities/123", new LegalEntityViewModelBuilder().WithDasAccountId("ABC123").WithLegalEntityId(123).Build());
            AccountsApi.SetupGet("api/accounts/ABC123/payeschemes/1234", new PayeSchemeViewModelBuilder().WithDasAccountId("ABC123").WithRef("1234").Build());

            AccountsApi.SetupGet("api/accounts/ABC123v2", new AccountDetailViewModelBuilder().WithDasAccountId("ABC123").WithName("New Name").Build());
        }