Coder Social home page Coder Social logo

nikitakoselev / go-form3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from form3tech-oss/go-form3

1.0 1.0 0.0 4.52 MB

go client library for the form3 api http://api-docs.form3.tech/

License: Apache License 2.0

Makefile 10.77% Go 84.80% Python 4.42%

go-form3's Introduction

Form3 logotype

Form3 Go client library

A simple go client library for the Form3 REST APIs built with custom operation names and swagger templates for a cleaner interface.

This is ideal for:

  • Calling the API interactively (e.g. investigating resources or testing new features).
  • Scripting (e.g. multi-call investigation or cleanup scripts)
  • Testing, particularly when multiple calls to the API are involved.
  • Load Testing, with K6 integration for initiating the requests

What's included

A simple client library with:

  • Automatic authentication and re-authentication based on environment variables
  • Pre-populated request objects with configurable defaults
  • Sensible operation naming
  • A fluent API with reduced repetition compared with vanilla swagger-go generated clients
  • All the power and flexibility of Go!

Getting started

For interactive usage we recommend using gore.

Note that the usage of client IDs and secrets is deprecated but still supported using form3.WithTokenTransport. Mutual TLS (not yet available in all environments) is supported using form3.NewMTLSTransport.

Example usage

u, err := url.Parse(ts.URL)
if err != nil {
    log.Fatal(err)
}

o, err := uuid.Parse(os.Getenv("FORM3_ORGANISATION_ID"))
if err != nil {
    log.Fatal(err)
}

f3, err := form3.New(
    form3.WithBaseURL(*u),
    form3.WithOrganisationID(o),
    form3.WithRequestSigningTransport(
        form3.NewRequestSigningTransport(
            form3.WithPrivateKey(privKey),
            form3.WithPublicKeyID(pubKeyID))))
if err != nil {
    log.Fatal(err)
}

Environment variables

The following environment variables need to be set when constructing the client using form3.NewFromEnv.

Environment variable Description
FORM3_HOST Form3 host URL, e.g. https://api.form3.tech
FORM3_PUBLIC_KEY_ID Public key ID for request signing
FORM3_PRIVATE_KEY Private key in PEM format for request signing
FORM3_ORGANISATION_ID Organisation ID
DEBUG Output full HTTP calls and responses

Updating the client

The client is generated using go-swagger.

Prerequisites

  • yq
  • Python 3 with pyaml

Regenerate client

Tasks in the Makefile download and preprocess the latest API swagger version:

  1. make install-swagger to install go-swagger if not already installed.
  2. make to regenerate the client files.

License

Copyright 2019-2021 Form3 Financial Cloud

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

go-form3's People

Contributors

rh-f3 avatar jeeves-form3 avatar pengux avatar english avatar janakerman-form3 avatar iyadassaf avatar markhowardform3 avatar samphillips-f3 avatar alexeiras-form3 avatar marcin-piwowarczyk-form3 avatar alistair-ferguson-form3 avatar hallabro avatar albert-f3 avatar jzimny-form3 avatar enriquerecarte avatar kevholditch avatar georgijd-form3 avatar earncef-form3 avatar acroca avatar stevecookform3 avatar sam-io avatar m-wrona-form3 avatar pedro-gutierrez-f3 avatar nvloff-f3 avatar mebowler avatar michaelbowler-form3 avatar joshua-hill-form3 avatar jamesjoshuahill avatar janakerman avatar diogovieira avatar

Stargazers

Nikita Koselev, Open Source DevRel avatar

Watchers

 avatar

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.