Skip to content

Commit

Permalink
Merge pull request #74 from fingerprintjs/feature/release-6.0.0-test
Browse files Browse the repository at this point in the history
Refactor request sending logic, update Open API schema
  • Loading branch information
TheUnderScorer authored Jun 21, 2024
2 parents 7e955b3 + b968719 commit 3b5e3ae
Show file tree
Hide file tree
Showing 41 changed files with 448 additions and 250 deletions.
52 changes: 0 additions & 52 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,3 @@
## [6.0.0-test.1](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/compare/v5.0.2...v6.0.0-test.1) (2024-06-19)


### ⚠ BREAKING CHANGES

* it is now easier to check for too many requests error (429):

```go
response, httpRes, err := client.FingerprintApi.GetVisits(auth, visitorId, &opts)
fmt.Printf("%+v\n", httpRes)

if err != nil {
var tooManyRequestsError *sdk.TooManyRequestsError

if errors.As(err, &tooManyRequestsError) {
log.Fatalf("Too many requests, retry after %d seconds", tooManyRequestsError.RetryAfter())
} else {
log.Fatal(err)
}
}
```
* rename `GenericSwaggerError` to `ApiError`
* rename `ManyRequestsResponse` to `TooManyRequestsResponse`
* go 1.20 has reached EOL. Minimal supported version of go is now 1.21
* right now we use native `errors` package for joining errors, meaning that multiple error messages are now joined by new line rather than colon (:)
* optional pkg is no longer used in this SDK. Please pass native GO types instead.

### Features

* add `IsValidWebhookSignature` function for validating webhook signature ([a5bf13d](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/a5bf13d62171ce06ec031e26a33d27d3f0b851bb))
* add delete API ([0e077c3](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/0e077c3546c4a29d4ca8ae42da2eff6c587fee6f))
* add os Mismatch ([30b0215](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/30b0215128f488db116ce29e8c531cbb8718eafb))
* add revision string field to confidence object ([8a2f270](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/8a2f270a3cc057dec78bf7b4aaa36522ca960d9c))
* drop support for go 1.20 ([46953bc](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/46953bc345e5d6c8acdb215c2b665b54c91fe5a8))
* drop usage of `github.com/pkg/errors` ([186d30a](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/186d30a6ae0135a02f6abd20e0746ee59bee024a))
* introduce `TooManyRequestsError` ([6ee7ff2](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/6ee7ff270b40b05fe5761b378afbeee78c0615ac))
* provide `HttpResponse()` in `ApiError` ([acd1274](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/acd1274a1e7b157f0b3dad1ff1d9b53a2730b4e6))
* re-write request handling logic ([14b7e7f](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/14b7e7f2f26280e5ffe59269273995b17ab19126))
* remove usage of github.com/antihax/optional package ([62db97f](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/62db97f9373b7bf929cee3f8b5fccb50d8b82bd8))
* rename `GenericSwaggerError` to `ApiError` ([259b7b4](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/259b7b417c7dcab31021e67aaa34e8daa3e41d82))
* rename `ManyRequestsResponse` to `TooManyRequestsResponse` ([3f66641](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/3f66641c610d34db4cd0657833ff2696948f2f3b))


### Bug Fixes

* move test related dependencies to test module ([298275d](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/298275d75d13298745304916425539f905b0225f))


### Reverts

* "chore(release): 6.0.0-test.1 [skip ci]" ([84ec138](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/commit/84ec138b42fe10a7ffe649c031692da68e2cfaff))

## [5.0.2](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/compare/v5.0.1...v5.0.2) (2024-03-28)


Expand Down
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Fingerprint Pro Server API allows you to get information about visitors and abou
This Go package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:

- API version: 3
- Package version: 6.0.0-test.1
- Package version: 5.0.2
- Build package: io.swagger.codegen.v3.generators.go.GoClientCodegen

## Requirements
Expand All @@ -35,7 +35,7 @@ We keep the [Go support policy](https://go.dev/doc/devel/release) and support th

1. Get the package from GitHub:
```shell
go get github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk
go get github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk
```

2. Import and use the library:
Expand All @@ -46,7 +46,7 @@ package main
import (
"context"
"fmt"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk"
"log"
)

Expand Down Expand Up @@ -97,7 +97,7 @@ If your subscription is in region other than US, you need to change the region i
```go
import (
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk"
)
func main() {
Expand All @@ -112,7 +112,7 @@ func main() {
This SDK provides utility methods for decoding [sealed results](https://dev.fingerprint.com/docs/sealed-client-results).
Install the sealed results dependency as below:
```shell
go get github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk/sealed
go get github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk/sealed
```
Then you can use below code to unseal results:
```go
Expand All @@ -121,7 +121,7 @@ package main
import (
"encoding/base64"
"fmt"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk/sealed"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk/sealed"
"os"
)

Expand Down Expand Up @@ -163,15 +163,15 @@ func main() {
This SDK provides utility method for verifing the HMAC signature of the incoming webhook request.
Install the webhook dependency as below:
```shell
go get github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk/webhook
go get github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk/webhook
```

Then you can use below code to verify signature:
```go
package main

import (
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk/webhook"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk/webhook"
)

func main() {
Expand Down Expand Up @@ -219,9 +219,13 @@ Class | Method | HTTP request | Description
- [DeprecatedIpLocationCity](docs/DeprecatedIpLocationCity.md)
- [EmulatorResult](docs/EmulatorResult.md)
- [ErrorCommon403Response](docs/ErrorCommon403Response.md)
- [ErrorCommon429Response](docs/ErrorCommon429Response.md)
- [ErrorCommon429ResponseError](docs/ErrorCommon429ResponseError.md)
- [ErrorEvent404Response](docs/ErrorEvent404Response.md)
- [ErrorEvent404ResponseError](docs/ErrorEvent404ResponseError.md)
- [ErrorVisits403](docs/ErrorVisits403.md)
- [ErrorVisitsDelete400Response](docs/ErrorVisitsDelete400Response.md)
- [ErrorVisitsDelete400ResponseError](docs/ErrorVisitsDelete400ResponseError.md)
- [ErrorVisitsDelete404Response](docs/ErrorVisitsDelete404Response.md)
- [ErrorVisitsDelete404ResponseError](docs/ErrorVisitsDelete404ResponseError.md)
- [EventResponse](docs/EventResponse.md)
Expand Down
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
module.exports = { extends: ['@fingerprintjs/commit-lint-dx-team'] };
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packageVersion": "6.0.0-test.1",
"packageVersion": "5.0.2",
"gitRepoId": "fingerprint-pro-server-api-go-sdk",
"gitUserId": "fingerprintjs",
"packageName": "sdk",
Expand Down
9 changes: 9 additions & 0 deletions docs/ErrorCommon429Response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ErrorCommon429Response

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Error_** | [***ErrorCommon429ResponseError**](ErrorCommon429Response_error.md) | | [optional] [default to null]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

10 changes: 10 additions & 0 deletions docs/ErrorCommon429ResponseError.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ErrorCommon429ResponseError

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Code** | **string** | Error code: * `TooManyRequests` - The request is throttled. | [default to null]
**Message** | **string** | | [default to null]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

9 changes: 9 additions & 0 deletions docs/ErrorVisitsDelete400Response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ErrorVisitsDelete400Response

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Error_** | [***ErrorVisitsDelete400ResponseError**](ErrorVisitsDelete400Response_error.md) | | [optional] [default to null]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

10 changes: 10 additions & 0 deletions docs/ErrorVisitsDelete400ResponseError.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ErrorVisitsDelete400ResponseError

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Code** | **string** | Error code: * `RequestCannotBeParsed` - The visitor ID parameter is missing or in the wrong format. | [default to null]
**Message** | **string** | | [default to null]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

2 changes: 1 addition & 1 deletion example/deleteVisit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"context"
"fmt"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk"
"log"
"os"

Expand Down
2 changes: 1 addition & 1 deletion example/getEvent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"log"
"os"

"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk"
"github.com/joho/godotenv"
)

Expand Down
2 changes: 1 addition & 1 deletion example/getVisits.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk"
"log"
"os"

Expand Down
2 changes: 1 addition & 1 deletion example/sealedResults.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk/sealed"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk/sealed"
"github.com/joho/godotenv"
"os"
)
Expand Down
2 changes: 1 addition & 1 deletion example/webhookSignature.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk/webhook"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/sdk/webhook"
)

func main() {
Expand Down
4 changes: 3 additions & 1 deletion generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"path/filepath"
"strings"

"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/config"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5/config"
)

var files = []string{"README.md", "docs", ".swagger-codegen"}
Expand Down Expand Up @@ -246,7 +246,9 @@ func getExamples() {
"get_event_200_identification_too_many_requests_error.json",
"get_visits_429_too_many_requests_error.json",
"delete_visits_404_error.json",
"delete_visits_400_error.json",
"delete_visits_403_error.json",
"delete_visits_429_error.json",
}

for _, file := range list {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6
module github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v5

go 1.21
2 changes: 1 addition & 1 deletion install_hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
git config core.hooksPath .git_hooks/

# install commitlint and @commitlint/config-conventional globally
npm install -g commitlint @commitlint/config-conventional
npm install -g commitlint @commitlint/config-conventional @fingerprintjs/commit-lint-dx-team
57 changes: 57 additions & 0 deletions res/fingerprint-server-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ paths:
responses:
'200':
description: OK. The visitor ID is scheduled for deletion.
'400':
description: >-
Bad request. The visitor ID parameter is missing or in the wrong
format.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorVisitsDelete400Response'
'403':
description: Forbidden. Access to this API is denied.
content:
Expand All @@ -272,6 +280,12 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorVisitsDelete404Response'
'429':
description: Too Many Requests. The request is throttled.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorCommon429Response'
/webhook:
trace:
tags:
Expand Down Expand Up @@ -631,6 +645,27 @@ components:
required:
- code
- message
ErrorCommon429Response:
type: object
additionalProperties: false
properties:
error:
type: object
additionalProperties: false
properties:
code:
type: string
description: |
Error code: * `TooManyRequests` - The request is throttled.
enum:
- TooManyRequests
example: TooManyRequests
message:
type: string
example: request throttled
required:
- code
- message
ErrorEvent404Response:
type: object
additionalProperties: false
Expand Down Expand Up @@ -697,6 +732,28 @@ components:
required:
- code
- message
ErrorVisitsDelete400Response:
type: object
additionalProperties: false
properties:
error:
type: object
additionalProperties: false
properties:
code:
type: string
description: >
Error code: * `RequestCannotBeParsed` - The visitor ID parameter
is missing or in the wrong format.
enum:
- RequestCannotBeParsed
example: RequestCannotBeParsed
message:
type: string
example: invalid visitor id
required:
- code
- message
WebhookVisit:
type: object
properties:
Expand Down
4 changes: 3 additions & 1 deletion sdk/api_fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strings"
)

const IntegrationInfo = "fingerprint-pro-server-go-sdk/6.0.0-test.1"
const IntegrationInfo = "fingerprint-pro-server-go-sdk/5.0.2"

type FingerprintApiServiceInterface interface {
/*
Expand Down Expand Up @@ -71,8 +71,10 @@ func createDeleteVisitorDataDefinition() requestDefinition {
return path
},
StatusCodeResultsFactoryMap: map[int]func() interface{}{
400: func() interface{} { return &ErrorVisitsDelete400Response{} },
403: func() interface{} { return &ErrorCommon403Response{} },
404: func() interface{} { return &ErrorVisitsDelete404Response{} },
429: func() interface{} { return &ErrorCommon429Response{} },
},
}
}
Expand Down
Loading

0 comments on commit 3b5e3ae

Please sign in to comment.