Git Product home page Git Product logo

net-figo's Introduction

figo.net NuGet Version

.net bindings for the figo connect API: http://figo.io

Simply add figo.net from NuGet. In the Package Manager Console run the following command:

PM> Install-Package figo

And just as easy to use:

using figo;
using System;
using System.Security.Cryptography.X509Certificates;
using System.Net;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace figo.ConsoleDemo {
    class Program {
        static void WaitTask(Task task)
        {
            try
            {
                task.Wait();
            }
            catch (AggregateException ae)
            {
                foreach (var e in ae.InnerExceptions)
                {
                    // Handle only WebException
                    if (e is WebException)
                    {
                        Console.WriteLine("Message: {0}\nSource: {1}\nStackTrace: {2}", e.Message, e.Source, e.StackTrace);
                        Console.ReadLine();
                        Environment.Exit(1);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }

        static void Main(string[] args)  {
            var validCertificates = new string[]
            {
                "38AE4A326F16EA1581338BB0D8E4A635E727F107",
                "DBE2E9158FC9903084FE36CAA61138D85A205D93"
            };
            FigoSession session = new FigoSession {
                AccessToken = "ASHWLIkouP2O6_bgA2wWReRhletgWKHYjLqDaqb0LFfamim9RjexTo22ujRIP_cjLiRiSyQXyt2kM1eXU2XLFZQ0Hro15HikJQT_eNeT_9XQ",
                // the same as default one here, but can be modified for testing purposes
                ApiEndpoint = "https://api.figo.me",
                OnRequestInitialize = (request) =>
                {
                    // figo.net is portable, not all of the platforms have a support for ServerCertificateValidationCallback
                    // that's why check certificate on the client side 
                    request.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => {
                        X509Certificate x509Certificate = cert;
                        return validCertificates.Contains(x509Certificate.GetCertHashString());
                    };
                }
            };
            // print out a list of accounts including its balance
            var task_accounts = session.GetAccounts();
            WaitTask(task_accounts);
            foreach(FigoAccount account in task_accounts.Result) {
                Console.WriteLine(account.Name);

                var task_balance = session.GetAccountBalance(account);
                WaitTask(task_balance);
                Console.WriteLine(task_balance.Result.Balance);
		    }

		    // print out the list of all transactions on a specific account
            var task_transactions = session.GetTransactions("A1.2");
            WaitTask(task_transactions);
		    foreach(FigoTransaction transaction in task_transactions.Result) {
			    Console.WriteLine(transaction.Purpose);
		    }
        }
    }
}

A more detailed documentation of the figo connect API can be found at http://docs.figo.io.

Demos

In this repository you can also have a look at a simple console and web demo in the folders ConsoleDemo and WebDemo respectively. While the console demo simply accesses the figo API, the web demo implements the full OAuth flow.

Building the NuGet package

It might be neccessary to call nuget like this to build the package:

nuget pack figo.net.csproj -Prop Platform=AnyCPU -Prop Configuration=Release

net-figo's People

Contributors

02strich avatar qrist0ph avatar javaes avatar makst avatar

Stargazers

Ingvi Rafn avatar Matthias Gernand avatar Mato avatar

Watchers

 avatar Christian Hüning avatar Lars Markull avatar James Cloos avatar Lilith Wittmann avatar  avatar Lutz Behnke avatar  avatar matthias avatar  avatar Doc avatar Lennart avatar  avatar

net-figo's Issues

Example App does not work

Hi,

when trying to run the WebDemo application from Visual Studio 2019 I encounter two problems:

  • The Solution can't be compiled in VS2019
  • Even when I reference the nuget package in the WebDemo project (to workaround the compile issue), the application gets redirect to https://www.figo.io/blog/ when opening http://localhost:3000"

Would be great if the project could get some updates.

Invalid certificate hash

I've continued working on a project where I will make use of Figo API. Before it was working, but now I receive an SSL error stating certificate's invalid. So certificate validation seems not to work with latest hash (used here in console demo source file Program.cs line ?40?) anymore.
Did they change? If so where are they coming from and where can we check for latest, correct and secure values on our own?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.