goinsee

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: MIT Imports: 10 Imported by: 0

README

Report Report doc build workflow

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

Return the value of the call from sirene API

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date added in v0.0.3

type Date struct {
	time.Time
}

Date return the Correct date format for the API

func (*Date) IsSet added in v0.0.3

func (ct *Date) IsSet() bool

func (*Date) MarshalJSON added in v0.0.3

func (ct *Date) MarshalJSON() ([]byte, error)

func (*Date) UnmarshalJSON added in v0.0.3

func (ct *Date) UnmarshalJSON(b []byte) (err error)

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) GetSiren added in v0.0.3

func (i *Insee) GetSiren(siren string) (resp SirenBaseResponse, err error)

GetSiren return the API response

func (*Insee) GetSirenMultiRequest added in v0.0.4

func (i *Insee) GetSirenMultiRequest(query []string) (resp SirenBaseResponses, err error)

GetSirenMultiRequest return a request with multiple parameters

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

type SirenBaseHeader added in v0.0.3

type SirenBaseHeader struct {
	Status  int    `json:"statut"`
	Message string `json:"message"`
}

SirenBaseHeader Header structure for a Sirene API Response

type SirenBaseResponse added in v0.0.3

type SirenBaseResponse struct {
	Header    SirenBaseHeader `json:"header"`
	LegalUnit SirenLegalUnit  `json:"uniteLegale"`
}

SirenBaseResponse structure for a Sirene API Response

type SirenBaseResponses added in v0.0.4

type SirenBaseResponses struct {
	Header    SirenBaseHeader  `json:"header"`
	LegalUnit []SirenLegalUnit `json:"unitesLegales"`
}

type SirenLegalUnit added in v0.0.3

type SirenLegalUnit struct {
	Siren                   string                 `json:"siren"`                             //: "443061841",
	Status                  string                 `json:"statutDiffusionUniteLegale"`        //: "O",
	DateCreationUniteLegale Date                   `json:"dateCreationUniteLegale"`           //: "2002-05-16",
	Sigle                   null.String            `json:"sigleUniteLegale"`                  //: null,
	Sexe                    null.String            `json:"sexeUniteLegale"`                   //: null,
	Prenom1                 null.String            `json:"prenom1UniteLegale"`                //: null,
	Prenom2                 null.String            `json:"prenom2UniteLegale"`                //: null,
	Prenom3                 null.String            `json:"prenom3UniteLegale"`                //: null,
	Prenom4                 null.String            `json:"prenom4UniteLegale"`                //: null,
	Prenom                  null.String            `json:"prenomUsuelUniteLegale"`            //: null,
	Pseudo                  null.String            `json:"pseudonymeUniteLegale"`             //: null,
	IdentifiantAssociation  null.String            `json:"identifiantAssociationUniteLegale"` //: null,
	TrancheEffective        null.String            `json:"trancheEffectifsUniteLegale"`       //: "41",
	AnneeEffectifs          null.String            `json:"anneeEffectifsUniteLegale"`         //: "2018",
	DateDernier             Date                   `json:"dateDernierTraitementUniteLegale"`  //: "2021-07-09T15:09:46",
	NombrePeriodes          int                    `json:"nombrePeriodesUniteLegale"`         //: 10,
	CategorieEntreprise     null.String            `json:"categorieEntreprise"`               //: "ETI",
	AnneeCategorie          null.String            `json:"anneeCategorieEntreprise"`          //: "2018",
	Periods                 []SirenPeriodLegalUnit `json:"periodesUniteLegale"`               //:
}

SirenLegalUnit return the values of the entitie of a siren API Call

type SirenPeriodLegalUnit added in v0.0.3

type SirenPeriodLegalUnit struct {
	DateFin                            Date        `json:"dateFin"`                                       //: null,
	DateDebut                          Date        `json:"dateDebut"`                                     //: "2019-01-24",
	EtatAdministratif                  string      `json:"etatAdministratifUniteLegale"`                  //: "A",
	ChangementEtatAdministratif        bool        `json:"changementEtatAdministratifUniteLegale"`        //: false,
	Nom                                null.String `json:"nomUniteLegale"`                                //: null,
	ChangementNom                      bool        `json:"changementNomUniteLegale"`                      //: false,
	NomUsage                           null.String `json:"nomUsageUniteLegale"`                           //: null,
	ChangementNomUsage                 bool        `json:"changementNomUsageUniteLegale"`                 //: false,
	Denomination                       string      `json:"denominationUniteLegale"`                       //: "GOOGLE FRANCE",
	ChangementDenomination             bool        `json:"changementDenominationUniteLegale"`             //: false,
	DenominationUsuelle1               null.String `json:"denominationUsuelle1UniteLegale"`               //: null,
	DenominationUsuelle2               null.String `json:"denominationUsuelle2UniteLegale"`               //: null,
	DenominationUsuelle3               null.String `json:"denominationUsuelle3UniteLegale"`               //: null,
	ChangementDenominationUsuelle      bool        `json:"changementDenominationUsuelleUniteLegale"`      //: false,
	CategorieJuridique                 null.String `json:"categorieJuridiqueUniteLegale"`                 //: "5499",
	ChangementCategorieJuridique       bool        `json:"changementCategorieJuridiqueUniteLegale"`       //: false,
	ActivitePrincipale                 null.String `json:"activitePrincipaleUniteLegale"`                 //: "70.10Z",
	NomenclatureActivitePrincipale     null.String `json:"nomenclatureActivitePrincipaleUniteLegale"`     //: "NAFRev2",
	ChangementActivitePrincipale       bool        `json:"changementActivitePrincipaleUniteLegale"`       //: false,
	NicSiege                           null.String `json:"nicSiegeUniteLegale"`                           //: "00047",
	ChangementNicSiege                 bool        `json:"changementNicSiegeUniteLegale"`                 //: false,
	EconomieSocialeSolidaire           null.String `json:"economieSocialeSolidaireUniteLegale"`           //: "N",
	ChangementEconomieSocialeSolidaire bool        `json:"changementEconomieSocialeSolidaireUniteLegale"` //: true,
	CaractereEmployeur                 null.String `json:"caractereEmployeurUniteLegale"`                 //: "O",
	ChangementCaractereEmployeur       bool        `json:"changementCaractereEmployeurUniteLegale"`       //: false
}

SirenPeriodLegalUnit return each periods data from the API

Jump to

Keyboard shortcuts

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