Skip to content

Commit

Permalink
SDK-2469-added-go-idv-support-brand-id-in-session-config
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-yoti committed Sep 19, 2024
1 parent 2839077 commit 1c429aa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docscan/session/create/sdk_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type SDKConfig struct {
PrivacyPolicyUrl string `json:"privacy_policy_url,omitempty"`
AttemptsConfiguration *AttemptsConfiguration `json:"attempts_configuration,omitempty"`
AllowHandOff bool `json:"allow_handoff,omitempty"`
BrandId string `json:"brand_id,omitempty"`
}

type AttemptsConfiguration struct {
Expand All @@ -39,6 +40,7 @@ type SdkConfigBuilder struct {
privacyPolicyUrl string
idDocumentTextDataExtractionAttempts map[string]int
allowHandOff bool
brandId string
}

// WithAllowedCaptureMethods sets the allowed capture methods on the builder
Expand Down Expand Up @@ -126,6 +128,11 @@ func (b *SdkConfigBuilder) WithAllowHandOff(allowHandOff bool) *SdkConfigBuilder
return b
}

func (b *SdkConfigBuilder) WithBrandId(brandId string) *SdkConfigBuilder {
b.brandId = brandId
return b
}

// Build builds the SDKConfig struct using the supplied values
func (b *SdkConfigBuilder) Build() (*SDKConfig, error) {
sdkConf := &SDKConfig{
Expand All @@ -140,6 +147,7 @@ func (b *SdkConfigBuilder) Build() (*SDKConfig, error) {
b.privacyPolicyUrl,
nil,
b.allowHandOff,
b.brandId,
}

if b.idDocumentTextDataExtractionAttempts != nil {
Expand Down
20 changes: 20 additions & 0 deletions docscan/session/create/sdk_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,23 @@ func ExampleSdkConfigBuilder_WithAllowHandOff() {
fmt.Println(string(data))
// Output: {"allow_handoff":true}
}

func ExampleSdkConfigBuilder_WithBrandId() {
sdkConfig, err := NewSdkConfigBuilder().
WithBrandId("some_brand_id").
Build()

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

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

fmt.Println(string(data))
// Output: {"brand_id":"some_brand_id"}
}

0 comments on commit 1c429aa

Please sign in to comment.