From becc4a63703bacd58d1cde534c171c7cbe732196 Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Wed, 30 Mar 2022 23:30:20 +0300 Subject: [PATCH] Credentials docs. --- .travis.yml | 4 ++-- README.md | 23 ++++++++++++++++++++--- VERSION | 1 + client/client_test.go | 2 +- go.mod | 7 +++++-- go.sum | 11 +++++++---- 6 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 VERSION diff --git a/.travis.yml b/.travis.yml index 0d375e4..393b89a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: go go: - - "1.14.x" - - "1.15.x" + - "1.17.x" + - "1.18.x" - tip #before_script: diff --git a/README.md b/README.md index 527215f..aa062a2 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ Forked from https://github.com/webdeskltd/dadata. -[![Build Status](https://travis-ci.org/ekomobile/dadata.svg)](https://travis-ci.org/ekomobile/dadata) +[![Build Status](https://travis-ci.org/ekomobile/dadata.svg)](https://travis-ci.com/ekomobile/dadata) [![GitHub release](https://img.shields.io/github/release/ekomobile/dadata.svg)](https://github.com/ekomobile/dadata/releases) -[![Go Report Card](https://goreportcard.com/badge/github.com/ekomobile/dadata)](https://goreportcard.com/report/github.com/ekomobile/dadata) -[![GoDoc](https://godoc.org/github.com/ekomobile/dadata?status.svg)](https://godoc.org/github.com/ekomobile/dadata) +[![Go Report Card](https://goreportcard.com/badge/github.com/ekomobile/dadata)](https://goreportcard.com/report/github.com/ekomobile/dadata/v2) +[![GoDoc](https://godoc.org/github.com/ekomobile/dadata/v2?status.svg)](https://godoc.org/github.com/ekomobile/dadata/v2) DaData API v2 @@ -44,5 +44,22 @@ func DaDataExample() { } ``` +## Credentials + +`DADATA_API_KEY` and `DADATA_SECRET_KEY` environment variables are used by default to authenticate client. + +Custom credential provider may be used by implementing `client.CredentialProvider` interface. + +Also, there is a "simple" credential provider `client.Credentials` you may utilize. + +```go +creds := client.Credentials{ + ApiKeyValue: "", + SecretKeyValue: "", +} + +api := NewSuggestApi(client.WithCredentialProvider(&creds)) +``` + ## Licence MIT see [LICENSE](LICENSE) diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..005119b --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.4.1 diff --git a/client/client_test.go b/client/client_test.go index 3e42a9f..4b42235 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -42,7 +42,7 @@ func ExampleCredentials() { creds := Credentials{ ApiKeyValue: "", - SecretKeyValue: "", + SecretKeyValue: "", } api := suggest.Api{ diff --git a/go.mod b/go.mod index e53bbeb..7a28249 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,11 @@ module github.com/ekomobile/dadata/v2 -go 1.15 +go 1.17 + +require github.com/stretchr/testify v1.7.1 require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/stretchr/testify v1.3.0 + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/go.sum b/go.sum index 08b9528..9c7312f 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,13 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=