goinsee

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2021 License: MIT Imports: 9 Imported by: 0

README

Report Report doc

Check Siren validity

Overview

Simply provide the key and secret of the API

i := NewInsee(os.Getenv("insee_key"), os.Getenv("insee_secret"))
i.SirenExist("443061841")

If you are on a server that will last more than 7 days up, you will require to refresh the token which only valid for 7 days, you can use the one that will refresh itself automatically

i := NewInseeRefreshed(os.Getenv("insee_key"), os.Getenv("insee_secret"))
i.SirenExist("443061841")

May provide others options from Insee database API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Insee

type Insee struct {
	AuthKey       string
	AuthSecret    string
	AuthToken     InseeToken
	Authed        bool
	AuthLastToken time.Time
}

Insee basic object to manage the API https://api.gouv.fr/documentation/sirene_v3

func NewInsee

func NewInsee(authKey string, authSecret string) Insee

NewInsee create a non refreshed token Insee stuff

func NewInseeRefreshed

func NewInseeRefreshed(authKey string, authSecret string) Insee

NewInseeRefreshed create a refreshed token Insee stuff

func (*Insee) RefreshAuthToken

func (i *Insee) RefreshAuthToken() (err error)

RefreshAuthToken automatically refresh the auth token based on expiry time

func (*Insee) SetAuthToken

func (i *Insee) SetAuthToken() (err error)

SetAuthToken will set Token from given Key and Secret

func (*Insee) SirenExist

func (i *Insee) SirenExist(siren string) bool

SirenExist return if the siren exist

type InseeToken

type InseeToken struct {
	Token   string `json:"access_token"`
	Type    string `json:"token_type"`
	Scope   string `json:"scope"`
	Expires int    `json:"expires_in"`
}

InseeToken to manage token auth response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL