GithubHelp home page GithubHelp logo

f3c's Introduction

Build Status

Client library for Form3 API

as per https://github.com/form3tech-oss/interview-accountapi

Run all-in-one tests

This will have the needed docker image built and run the docker-compose with the unit tests. Tested in OSx.

make test

In case you have trouble running it you can still see the tests run in the latest travis build.

Import

import (
    "github.com/zerogvt/f3c"
    "github.com/zerogvt/f3c/http"
)

Create

To create an account to Form3 system you need to first define the basic account elements locally using an f3c.Attributes composite literal with at least the minimum required fields and then have f3c.NewAccount() bind them in a local account.

You can then use that account as input to AccountSvc.Create() which will create the account in Form3 remote system.

Next snippet should clarify these steps:

import (
    "github.com/zerogvt/f3c"
    "github.com/zerogvt/f3c/http"
)

// >> create a local Account instance
uid := "ad27e265-9605-4b4b-a0e5-123456789012"
oid := "eb0bd6f5-c3f5-44b2-b677-123456789012"
attr := f3c.Attributes{
    Country:               "GB",
    BaseCurrency:          "GBP",
    BankID:                "400300",
    BankIDCode:            "GBDSC",
    Bic:                   "NWBKGB22",
    AccountClassification: "Personal",
}
// >> using the NewAccount makes sure that the Account is properly initialised
act := f3c.NewAccount(uid, oid, attr)

// >> finally use AccountSvc to create the Account in Form3 remote system
svc := http.AccountSvc{
            Base: "http://form3_api_service",
        }
svc.Create(act)

Fetch

Fetching an existing account can be done via AccountSvc.Fetch() function

svc := http.AccountSvc{
    Base: "http://form3_api_service",
}
id := "id_of_target_account"
if act, err := svc.Fetch(id); err != nil {
    t.Fatal(err)
}

Delete

Deleting an existing account can be done via AccountSvc.Delete() function

svc := http.AccountSvc{
    Base: "http://form3_api_service",
}
id := "id_of_target_account"
version := 0
if act, err := svc.Delete(id, version); err != nil {
    t.Fatal(err)
}

List

Listing existing accounts can be done via AccountSvc.Delete() function

svc := http.AccountSvc{
    Base: "http://form3_api_service",
}
// get all accounts
acts, res := []f3c.AccountXL{}, []f3c.AccountXL{}
var err error
for pg := 0; true; pg += 1 {
    if res, err = svc.List(pg, 100); err != nil {
        t.Fatal(err)
    }
    if len(res) == 0 {
        break
    }
    acts = append(acts, res...)
}

Full Reference

See documentation

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.