Skip to content

Commit

Permalink
Merge pull request #212 from getyoti/development
Browse files Browse the repository at this point in the history
Release 3.4.0
  • Loading branch information
emmas-yoti committed Apr 13, 2021
2 parents 7ae4d24 + b74614a commit a15220b
Show file tree
Hide file tree
Showing 21 changed files with 269 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: check-yaml
Expand All @@ -26,7 +26,7 @@ repos:
description: "Go imports"

- repo: git://github.com/dnephin/pre-commit-golang
rev: master
rev: v0.3.5
hooks:
- id: go-vet
exclude: _examples
Expand Down
5 changes: 5 additions & 0 deletions _examples/docscan/handlers.session.go
Expand Up @@ -178,3 +178,8 @@ func getMedia(c *gin.Context) {
c.Data(http.StatusOK, media.MIME(), media.Data())
return
}

func showPrivacyPolicyPage(c *gin.Context) {
render(c, gin.H{}, "privacy.html")
return
}
9 changes: 9 additions & 0 deletions _examples/docscan/models.sessionspec.go
Expand Up @@ -56,6 +56,13 @@ func buildSessionSpec() (sessionSpec *create.SessionSpecification, err error) {
return nil, err
}

var thirdPartyCheck *check.RequestedThirdPartyIdentityCheck
thirdPartyCheck, err = check.NewRequestedThirdPartyIdentityCheckBuilder().
Build()
if err != nil {
return nil, err
}

var sdkConfig *create.SDKConfig
sdkConfig, err = create.NewSdkConfigBuilder().
WithAllowsCameraAndUpload().
Expand All @@ -66,6 +73,7 @@ func buildSessionSpec() (sessionSpec *create.SessionSpecification, err error) {
WithPresetIssuingCountry("GBR").
WithSuccessUrl("https://localhost:8080/success").
WithErrorUrl("https://localhost:8080/error").
WithPrivacyPolicyUrl("https://localhost:8080/privacy-policy").
Build()

if err != nil {
Expand Down Expand Up @@ -108,6 +116,7 @@ func buildSessionSpec() (sessionSpec *create.SessionSpecification, err error) {
WithRequestedCheck(documentAuthenticityCheck).
WithRequestedCheck(livenessCheck).
WithRequestedCheck(idDocsComparisonCheck).
WithRequestedCheck(thirdPartyCheck).
WithRequestedTask(textExtractionTask).
WithRequestedTask(supplementaryDocTextExtractionTask).
WithSDKConfig(sdkConfig).
Expand Down
1 change: 1 addition & 0 deletions _examples/docscan/routes.go
Expand Up @@ -10,4 +10,5 @@ func initializeRoutes() {
router.GET("/", showIndexPage)
router.GET("/success", showSuccessPage)
router.GET("/media", getMedia)
router.GET("/privacy-policy", showPrivacyPolicyPage)
}
10 changes: 10 additions & 0 deletions _examples/docscan/templates/privacy.html
@@ -0,0 +1,10 @@
{{ template "header.html" .}}
<div class="container">
<div class="row pt-4">
<div class="col">
<h1>Privacy Policy</h1>
<p>Demo privacy policy</p>
</div>
</div>
</div>
{{ template "footer.html" .}}
23 changes: 22 additions & 1 deletion _examples/docscan/templates/success.html
Expand Up @@ -127,7 +127,7 @@ <h3 class="mb-0">
</div>
<div id="collapse-liveness-checks" class="collapse" aria-labelledby="liveness-checks">
<div class="card-body">
{{ range $check := .getSessionResult.AuthenticityChecks }}
{{ range $check := .getSessionResult.LivenessChecks }}
{{ template "check.html" $check}}
{{ end }}
</div>
Expand Down Expand Up @@ -175,6 +175,27 @@ <h3 class="mb-0">
</div>
</div>
{{ end }}

{{ if .getSessionResult.ThirdPartyIdentityChecks }}
<div class="card">
<div class="card-header" id="third-party-identity-checks">
<h3 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse"
data-target="#collapse-third-party-identity-checks" aria-expanded="true"
aria-controls="collapse-third-party-identity-checks">
Third Party Identity Checks
</button>
</h3>
</div>
<div id="collapse-third-party-identity-checks" class="collapse" aria-labelledby="third-party-identity-checks">
<div class="card-body">
{{ range $check := .getSessionResult.ThirdPartyIdentityChecks }}
{{ template "check.html" $check }}
{{ end }}
</div>
</div>
</div>
{{ end }}

</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion _examples/profile/README.md
Expand Up @@ -40,7 +40,6 @@ Keeping your settings and access keys outside your repository is highly recommen
* Set the application domain of your app to `localhost:8080`
* Set the scenario callback URL to `/profile`
* Rename the [.env.example](_examples/profile/.env.example) file to `.env` and fill in the required configuration values (mentioned in the [Configuration](#configuration) section)
* Install the dependencies with `go get`
* Start the server with `go run main.go certificatehelper.go`

Visiting `https://localhost:8080/` should show a webpage with a Yoti button rendered on it
2 changes: 1 addition & 1 deletion consts/version.go
Expand Up @@ -2,5 +2,5 @@ package consts

const (
SDKIdentifier = "Go"
SDKVersionIdentifier = "3.3.0"
SDKVersionIdentifier = "3.4.0"
)
1 change: 1 addition & 0 deletions docscan/constants/constants.go
Expand Up @@ -7,6 +7,7 @@ const (
IDDocumentTextDataExtraction string = "ID_DOCUMENT_TEXT_DATA_EXTRACTION"
IDDocumentFaceMatch string = "ID_DOCUMENT_FACE_MATCH"
SupplementaryDocumentTextDataCheck string = "SUPPLEMENTARY_DOCUMENT_TEXT_DATA_CHECK"
ThirdPartyIdentityCheck string = "THIRD_PARTY_IDENTITY"
SupplementaryDocumentTextDataExtraction string = "SUPPLEMENTARY_DOCUMENT_TEXT_DATA_EXTRACTION"
Liveness string = "LIVENESS"
Zoom string = "ZOOM"
Expand Down
37 changes: 37 additions & 0 deletions docscan/sandbox/request/check/third_party_identity_check.go
@@ -0,0 +1,37 @@
package check

import "github.com/getyoti/yoti-go-sdk/v3/docscan/sandbox/request/check/report"

// ThirdPartyIdentityCheck defines a sandbox check with a third party credit reporting agency
type ThirdPartyIdentityCheck struct {
*check
}

// ThirdPartyIdentityCheckBuilder builds a ThirdPartyIdentityCheck
type ThirdPartyIdentityCheckBuilder struct {
checkBuilder
}

// NewThirdPartyIdentityCheckBuilder creates a new ThirdPartyIdentityCheckBuilder
func NewThirdPartyIdentityCheckBuilder() *ThirdPartyIdentityCheckBuilder {
return &ThirdPartyIdentityCheckBuilder{}
}

// Build creates a new ThirdPartyIdentityCheck
func (b *ThirdPartyIdentityCheckBuilder) Build() (*ThirdPartyIdentityCheck, error) {
tpiCheck := ThirdPartyIdentityCheck{
check: b.checkBuilder.build(),
}

return &tpiCheck, nil
}

func (b *ThirdPartyIdentityCheckBuilder) WithBreakdown(breakdown *report.Breakdown) *ThirdPartyIdentityCheckBuilder {
b.checkBuilder.withBreakdown(breakdown)
return b
}

func (b *ThirdPartyIdentityCheckBuilder) WithRecommendation(recommendation *report.Recommendation) *ThirdPartyIdentityCheckBuilder {
b.checkBuilder.withRecommendation(recommendation)
return b
}
45 changes: 45 additions & 0 deletions docscan/sandbox/request/check/third_party_identity_check_test.go
@@ -0,0 +1,45 @@
package check

import (
"encoding/json"
"fmt"

"github.com/getyoti/yoti-go-sdk/v3/docscan/sandbox/request/check/report"
)

func ExampleThirdPartyIdentityCheckBuilder() {
breakdown, err := report.NewBreakdownBuilder().
WithResult("some_result").
WithSubCheck("some_check").
Build()
if err != nil {
fmt.Printf("error: %s", err.Error())
return
}

recommendation, err := report.NewRecommendationBuilder().
WithValue("some_value").
Build()
if err != nil {
fmt.Printf("error: %s", err.Error())
return
}

check, err := NewThirdPartyIdentityCheckBuilder().
WithBreakdown(breakdown).
WithRecommendation(recommendation).
Build()
if err != nil {
fmt.Printf("error: %s", err.Error())
return
}

data, err := json.Marshal(check)
if err != nil {
fmt.Printf("error: %s", err.Error())
return
}

fmt.Println(string(data))
// Output: {"result":{"report":{"recommendation":{"value":"some_value"},"breakdown":[{"sub_check":"some_check","result":"some_result","details":[]}]}}}
}
8 changes: 8 additions & 0 deletions docscan/sandbox/request/check_reports.go
Expand Up @@ -13,6 +13,7 @@ type CheckReports struct {
IDDocumentComparisonChecks []*check.IDDocumentComparisonCheck `json:"ID_DOCUMENT_COMPARISON"`
SupplementaryDocumentTextDataChecks []*check.SupplementaryDocumentTextDataCheck `json:"SUPPLEMENTARY_DOCUMENT_TEXT_DATA_CHECK"`
AsyncReportDelay uint32 `json:"async_report_delay,omitempty"`
ThirdPartyIdentityCheck *check.ThirdPartyIdentityCheck `json:"THIRD_PARTY_IDENTITY,omitempty"`
}

// CheckReportsBuilder builds CheckReports
Expand All @@ -23,6 +24,7 @@ type CheckReportsBuilder struct {
livenessChecks []*check.LivenessCheck
idDocumentComparisonChecks []*check.IDDocumentComparisonCheck
supplementaryDocumentTextDataChecks []*check.SupplementaryDocumentTextDataCheck
thirdPartyIdentityCheck *check.ThirdPartyIdentityCheck
asyncReportDelay uint32
}

Expand Down Expand Up @@ -83,6 +85,11 @@ func (b *CheckReportsBuilder) WithAsyncReportDelay(asyncReportDelay uint32) *Che
return b
}

func (b *CheckReportsBuilder) WithThirdPartyIdentityCheck(thirdPartyIdentityCheck *check.ThirdPartyIdentityCheck) *CheckReportsBuilder {
b.thirdPartyIdentityCheck = thirdPartyIdentityCheck
return b
}

// Build creates CheckReports
func (b *CheckReportsBuilder) Build() (CheckReports, error) {
return CheckReports{
Expand All @@ -93,5 +100,6 @@ func (b *CheckReportsBuilder) Build() (CheckReports, error) {
IDDocumentComparisonChecks: b.idDocumentComparisonChecks,
SupplementaryDocumentTextDataChecks: b.supplementaryDocumentTextDataChecks,
AsyncReportDelay: b.asyncReportDelay,
ThirdPartyIdentityCheck: b.thirdPartyIdentityCheck,
}, nil
}
12 changes: 11 additions & 1 deletion docscan/sandbox/request/check_reports_test.go
Expand Up @@ -63,6 +63,15 @@ func ExampleCheckReportsBuilder() {
return
}

thirdPartyCheck, err := check.NewThirdPartyIdentityCheckBuilder().
WithBreakdown(breakdown).
WithRecommendation(recommendation).
Build()
if err != nil {
fmt.Printf("error: %s", err.Error())
return
}

zoomLivenessCheck, err := check.NewZoomLivenessCheckBuilder().Build()
if err != nil {
fmt.Printf("error: %s", err.Error())
Expand All @@ -85,6 +94,7 @@ func ExampleCheckReportsBuilder() {
WithLivenessCheck(zoomLivenessCheck).
WithIDDocumentComparisonCheck(idDocumentComparisonCheck).
WithSupplementaryDocumentTextDataCheck(supplementaryDocumentTextDataCheck).
WithThirdPartyIdentityCheck(thirdPartyCheck).
WithAsyncReportDelay(10).
Build()
if err != nil {
Expand All @@ -99,7 +109,7 @@ func ExampleCheckReportsBuilder() {
}

fmt.Println(string(data))
// Output: {"ID_DOCUMENT_AUTHENTICITY":[{"result":{"report":{"recommendation":{"value":"some_value"},"breakdown":[{"sub_check":"some_check","result":"some_result","details":[]}]}}}],"ID_DOCUMENT_TEXT_DATA_CHECK":[{"result":{"report":{"recommendation":{"value":"some_value"},"breakdown":[{"sub_check":"some_check","result":"some_result","details":[]}]}}}],"ID_DOCUMENT_FACE_MATCH":[{"result":{"report":{"recommendation":{"value":"some_value"},"breakdown":[{"sub_check":"some_check","result":"some_result","details":[]}]}}}],"LIVENESS":[{"result":{"report":{}},"liveness_type":"ZOOM"}],"ID_DOCUMENT_COMPARISON":[{"result":{"report":{}},"secondary_document_filter":{"document_types":[],"country_codes":[]}}],"SUPPLEMENTARY_DOCUMENT_TEXT_DATA_CHECK":[{"result":{"report":{"recommendation":{"value":"some_value"},"breakdown":[{"sub_check":"some_check","result":"some_result","details":[]}]}}}],"async_report_delay":10}
// Output: {"ID_DOCUMENT_AUTHENTICITY":[{"result":{"report":{"recommendation":{"value":"some_value"},"breakdown":[{"sub_check":"some_check","result":"some_result","details":[]}]}}}],"ID_DOCUMENT_TEXT_DATA_CHECK":[{"result":{"report":{"recommendation":{"value":"some_value"},"breakdown":[{"sub_check":"some_check","result":"some_result","details":[]}]}}}],"ID_DOCUMENT_FACE_MATCH":[{"result":{"report":{"recommendation":{"value":"some_value"},"breakdown":[{"sub_check":"some_check","result":"some_result","details":[]}]}}}],"LIVENESS":[{"result":{"report":{}},"liveness_type":"ZOOM"}],"ID_DOCUMENT_COMPARISON":[{"result":{"report":{}},"secondary_document_filter":{"document_types":[],"country_codes":[]}}],"SUPPLEMENTARY_DOCUMENT_TEXT_DATA_CHECK":[{"result":{"report":{"recommendation":{"value":"some_value"},"breakdown":[{"sub_check":"some_check","result":"some_result","details":[]}]}}}],"async_report_delay":10,"THIRD_PARTY_IDENTITY":{"result":{"report":{"recommendation":{"value":"some_value"},"breakdown":[{"sub_check":"some_check","result":"some_result","details":[]}]}}}}
}

func ExampleCheckReportsBuilder_minimal() {
Expand Down
55 changes: 55 additions & 0 deletions docscan/session/create/check/third_party_identity.go
@@ -0,0 +1,55 @@
package check

import (
"encoding/json"

"github.com/getyoti/yoti-go-sdk/v3/docscan/constants"
)

// RequestedThirdPartyIdentityCheck requests creation of a third party CRA check
type RequestedThirdPartyIdentityCheck struct {
config RequestedThirdPartyIdentityCheckConfig
}

// Type is the type of the requested check
func (c *RequestedThirdPartyIdentityCheck) Type() string {
return constants.ThirdPartyIdentityCheck
}

// Config is the configuration of the requested check
func (c *RequestedThirdPartyIdentityCheck) Config() RequestedCheckConfig {
return RequestedCheckConfig(c.config)
}

// MarshalJSON returns the JSON encoding
func (c *RequestedThirdPartyIdentityCheck) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type string `json:"type"`
Config RequestedCheckConfig `json:"config,omitempty"`
}{
Type: c.Type(),
Config: c.Config(),
})
}

// RequestedThirdPartyIdentityCheckConfig is the configuration applied when creating
// a third party identity check
type RequestedThirdPartyIdentityCheckConfig struct {
}

// RequestedThirdPartyIdentityCheckBuilder builds a RequestedThirdPartyIdentityCheck
type RequestedThirdPartyIdentityCheckBuilder struct {
config RequestedThirdPartyIdentityCheckConfig
}

// NewRequestedThirdPartyIdentityCheckBuilder creates a new builder for RequestedThirdPartyIdentityCheck
func NewRequestedThirdPartyIdentityCheckBuilder() *RequestedThirdPartyIdentityCheckBuilder {
return &RequestedThirdPartyIdentityCheckBuilder{}
}

// Build builds te RequestedThirdPartyIdentityCheck
func (b *RequestedThirdPartyIdentityCheckBuilder) Build() (*RequestedThirdPartyIdentityCheck, error) {
return &RequestedThirdPartyIdentityCheck{
config: b.config,
}, nil
}
24 changes: 24 additions & 0 deletions docscan/session/create/check/third_party_identity_test.go
@@ -0,0 +1,24 @@
package check

import (
"encoding/json"
"fmt"
)

func ExampleRequestedThirdPartyIdentityCheck() {
thirdPartyCheck, err := NewRequestedThirdPartyIdentityCheckBuilder().Build()

if err != nil {
fmt.Printf("error: %s", err.Error())
return
}

data, err := json.Marshal(thirdPartyCheck)
if err != nil {
fmt.Printf("error: %s", err.Error())
return
}

fmt.Println(string(data))
// Output: {"type":"THIRD_PARTY_IDENTITY","config":{}}
}

0 comments on commit a15220b

Please sign in to comment.