Skip to content

Commit

Permalink
Add appVersion for Login, Signup and Payment risk assessments (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
soareswallace authored Feb 7, 2025
1 parent c53c066 commit 6432a09
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions incognia.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http"
"runtime"
"runtime/debug"
"strings"
"time"
)

Expand Down Expand Up @@ -51,6 +52,8 @@ type Payment struct {
InstallationID *string
SessionToken *string
RequestToken string
AppVersion string
DeviceOs string
AccountID string
ExternalID string
PolicyID string
Expand All @@ -71,6 +74,8 @@ type Login struct {
PolicyID string
PaymentMethodIdentifier string
Eval *bool
AppVersion string
DeviceOs string
CustomProperties map[string]interface{}
}

Expand All @@ -95,6 +100,8 @@ type Signup struct {
InstallationID string
RequestToken string
SessionToken string
AppVersion string
DeviceOs string
Address *Address
AccountID string
PolicyID string
Expand Down Expand Up @@ -199,6 +206,8 @@ func (c *Client) registerSignup(params *Signup) (ret *SignupAssessment, err erro
AccountID: params.AccountID,
PolicyID: params.PolicyID,
ExternalID: params.ExternalID,
AppVersion: params.AppVersion,
DeviceOs: strings.ToLower(params.DeviceOs),
}
if params.Address != nil {
requestBody.AddressLine = params.Address.AddressLine
Expand Down Expand Up @@ -316,6 +325,8 @@ func (c *Client) registerPayment(payment *Payment) (ret *TransactionAssessment,
Addresses: payment.Addresses,
PaymentValue: payment.Value,
PaymentMethods: payment.Methods,
AppVersion: payment.AppVersion,
DeviceOs: strings.ToLower(payment.DeviceOs),
CustomProperties: payment.CustomProperties,
})
if err != nil {
Expand Down Expand Up @@ -376,6 +387,8 @@ func (c *Client) registerLogin(login *Login) (*TransactionAssessment, error) {
PaymentMethodIdentifier: login.PaymentMethodIdentifier,
SessionToken: login.SessionToken,
RequestToken: login.RequestToken,
AppVersion: login.AppVersion,
DeviceOs: strings.ToLower(login.DeviceOs),
CustomProperties: login.CustomProperties,
})
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions incognia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ var (
InstallationID: installationId,
RequestToken: requestToken,
AddressLine: "address line",
DeviceOs: "ios",
AppVersion: "1.2.3",
StructuredAddress: &StructuredAddress{
Locale: "locale",
CountryName: "country-name",
Expand Down Expand Up @@ -183,6 +185,8 @@ var (
InstallationID: &installationId,
AccountID: "account-id",
ExternalID: "external-id",
DeviceOs: "android",
AppVersion: "1.2.3",
PolicyID: "policy-id",
Type: paymentType,
Coupon: &CouponType{
Expand Down Expand Up @@ -296,6 +300,8 @@ var (
AccountID: "account-id",
ExternalID: "external-id",
PolicyID: "policy-id",
DeviceOs: "android",
AppVersion: "1.2.3",
Coupon: &CouponType{
Type: "coupon_type",
Value: 55.02,
Expand Down Expand Up @@ -426,6 +432,8 @@ var (
AccountID: "account-id",
ExternalID: "external-id",
PolicyID: "policy-id",
DeviceOs: "Android",
AppVersion: "1.2.3",
CustomProperties: customProperty,
PaymentMethodIdentifier: "payment-method-identifier",
}
Expand All @@ -434,6 +442,8 @@ var (
AccountID: "account-id",
ExternalID: "external-id",
PolicyID: "policy-id",
DeviceOs: "Android",
AppVersion: "1.2.3",
PaymentMethodIdentifier: "payment-method-identifier",
Eval: &shouldEval,
CustomProperties: customProperty,
Expand All @@ -456,6 +466,8 @@ var (
InstallationID: &installationId,
AccountID: "account-id",
ExternalID: "external-id",
DeviceOs: "android",
AppVersion: "1.2.3",
PolicyID: "policy-id",
PaymentMethodIdentifier: "payment-method-identifier",
Type: loginType,
Expand Down Expand Up @@ -553,6 +565,8 @@ func (suite *IncogniaTestSuite) TestSuccessRegisterSignupWithParams() {
InstallationID: postSignupRequestBodyWithAllParamsFixture.InstallationID,
RequestToken: postSignupRequestBodyWithAllParamsFixture.RequestToken,
SessionToken: postSignupRequestBodyWithAllParamsFixture.SessionToken,
DeviceOs: postSignupRequestBodyWithAllParamsFixture.DeviceOs,
AppVersion: postSignupRequestBodyWithAllParamsFixture.AppVersion,
Address: addressFixture,
AccountID: postSignupRequestBodyWithAllParamsFixture.AccountID,
PolicyID: postSignupRequestBodyWithAllParamsFixture.PolicyID,
Expand Down
4 changes: 4 additions & 0 deletions request_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type postAssessmentRequestBody struct {
InstallationID string `json:"installation_id,omitempty"`
RequestToken string `json:"request_token,omitempty"`
SessionToken string `json:"session_token,omitempty"`
AppVersion string `json:"app_version,omitempty"`
DeviceOs string `json:"device_os,omitempty"`
AddressLine string `json:"address_line,omitempty"`
StructuredAddress *StructuredAddress `json:"structured_address,omitempty"`
Coordinates *Coordinates `json:"address_coordinates,omitempty"`
Expand Down Expand Up @@ -144,6 +146,8 @@ type PaymentMethod struct {
type postTransactionRequestBody struct {
ExternalID string `json:"external_id,omitempty"`
PolicyID string `json:"policy_id,omitempty"`
AppVersion string `json:"app_version,omitempty"`
DeviceOs string `json:"device_os,omitempty"`
Coupon *CouponType `json:"coupon,omitempty"`
InstallationID *string `json:"installation_id,omitempty"`
PaymentMethodIdentifier string `json:"payment_method_identifier,omitempty"`
Expand Down

0 comments on commit 6432a09

Please sign in to comment.