public AllTransactionsViewModel(YnabApi.YnabApi ynabApi, ISessionStateService sessionStateService) { this._ynabApi = ynabApi; this._sessionStateService = sessionStateService; this.Transactions = new BindableCollection<TransactionsByMonth>(); }
private static async Task Run() { var dropboxFileSystem = new DropboxFileSystem(""); var settings = new YnabApiSettings(new DesktopFileSystem(), "Ynab Api Test Console", "Ynab Api Desktop"); YnabApi api = new YnabApi(settings); var budgets = await api.GetBudgetsAsync(); var testBudget = budgets.First(f => f.BudgetName == "Budget"); var myDevice = (await testBudget.GetRegisteredDevicesAsync()).FirstOrDefault(f => f.HasFullKnowledge); var categories = await myDevice.GetCategoriesAsync(); //var createPayee = new CreatePayeeDeviceAction //{ // Name = "Bücherei" //}; //var createTransaction = new CreateTransactionDeviceAction //{ // Amount = -20.0m, // Account = (await fullKnowledgeDevice.GetAccountsAsync()).First(f => f.Name == "Geldbeutel"), // Category = null, // Memo = "#Mittagspause", // Payee = createPayee //}; //await registeredDevice.ExecuteActions(createPayee, createTransaction); System.Console.ReadLine(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddAuthentication(options => { options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; }) .AddCookie(options => { options.Cookie.Expiration = new TimeSpan(2, 0, 0); options.ExpireTimeSpan = new TimeSpan(2, 0, 0); }) .AddOAuth("ynab", options => { options.ClientId = Configuration["ynab:ClientId"]; options.ClientSecret = Configuration["ynab:ClientSecret"]; options.CallbackPath = new PathString("/signin-ynab"); options.AuthorizationEndpoint = $"https://{Configuration["ynab:Domain"]}/oauth/authorize"; options.TokenEndpoint = $"https://{Configuration["ynab:Domain"]}/oauth/token"; options.UserInformationEndpoint = $"https://{Configuration["ynab:userinfo"]}/v1/user"; options.SaveTokens = true; options.Scope.Clear(); options.Events = new OAuthEvents { OnCreatingTicket = async context => { var api = new YnabApi(context.AccessToken); var user = api.GetUser(); context.Identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Data.User.UserId, ClaimValueTypes.String, context.Options.ClaimsIssuer)); }, OnTicketReceived = context => { context.Properties.IsPersistent = true; context.Properties.ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(90); return(Task.FromResult(0)); } }; }); services.AddMvc().AddRazorPagesOptions(options => { options.Conventions.AddAreaPageRoute("Identity", "/Login", ""); }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddDefaultAWSOptions(Configuration.GetAWSOptions()); services.AddAWSService <IAmazonS3>(); }
public AddTransactionViewModel(YnabApi.YnabApi api, ISavvyNavigationService navigationService, ILoadingService loadingService, ISessionStateService sessionStateService) { this._api = api; this._navigationService = navigationService; this._loadingService = loadingService; this._sessionStateService = sessionStateService; this.Payees = new BindableCollection<Payee>(); this.Accounts = new BindableCollection<Account>(); this.Categories = new BindableCollection<CategoryViewModel>(); this.IsOutflow = true; }
public static BudgetDetail GetApiBudget(string accessToken, string userId) { AWSSDKHandler.RegisterXRayForAllServices(); AWSXRayRecorder.Instance.BeginSubsegment("MyBudgetExplorer.Models.Cache.GetApiBudget()"); try { var binaryFormatter = new BinaryFormatter(); var aesKey = SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(userId)); var aesIV = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(userId)); var hash = BitConverter.ToString(aesKey).Replace("-", "").ToLower(); var fileName = $"budget.{hash}"; var tempFilePath = Path.Combine(Path.GetTempPath(), fileName); BudgetDetail budget = null; byte[] encrypted = null; var api = new YnabApi(accessToken); var tempBudget = api.GetBudget(); budget = tempBudget.Data.Budget; budget.LastModifiedOn = DateTime.UtcNow; using (var ms = new MemoryStream()) { binaryFormatter.Serialize(ms, budget); encrypted = EncryptAES(ms.ToArray(), aesKey, aesIV); } // Store S3 File if (!string.IsNullOrWhiteSpace(awsAccessKey) && !string.IsNullOrWhiteSpace(awsSecretKey)) { using (IAmazonS3 client = new AmazonS3Client(awsAccessKey, awsSecretKey, RegionEndpoint.USEast2)) { using (var ms = new MemoryStream(encrypted)) { var putrequest = new PutObjectRequest { BucketName = bucketName, Key = fileName, InputStream = ms }; client.PutObjectAsync(putrequest).Wait(); } } } // Store Local File if (encrypted != null && encrypted.Length > 0) { File.WriteAllBytes(tempFilePath, encrypted); File.SetCreationTimeUtc(tempFilePath, budget.LastModifiedOn); File.SetLastWriteTimeUtc(tempFilePath, budget.LastModifiedOn); } return(budget); } finally { AWSXRayRecorder.Instance.EndSubsegment(); } }