Skip to content

Commit

Permalink
added support for vchecked message queue
Browse files Browse the repository at this point in the history
  • Loading branch information
sbreitf1 committed Sep 22, 2021
1 parent 257681b commit e8f219b
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 49 deletions.
26 changes: 23 additions & 3 deletions commandline.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ func prepareCLE() *commandline.Environment {
registerDomainCommand(cle, "chholder", cmdChangeHolder)
registerDomainCommand(cle, "chprov", cmdChangeProvider)

registerDomainCommand(cle, "verify-queue-read", cmdVerifyQueueRead)
registerDomainCommand(cle, "verify-queue-delete", cmdVerifyQueueDelete)

// register custom commands
for _, cmd := range customCommands {
registerCustomCommand(cle, cmd)
Expand Down Expand Up @@ -263,6 +266,9 @@ func cmdHelp(args []string) error {
//TODO create-authinfo2
//TODO delete-authinfo1
{[]string{"chprov"}, []string{"domain", "secret"}, "send a CHPROV command for a specific domain"},
{},
{[]string{"verify-queue-read"}, nil, "send a VERIFY-QUEUE-READ command"},
{[]string{"verify-queue-delete"}, []string{"msgid"}, "send a VERIFY-QUEUE-DELETE command for a specific vChecked message"},
//TODO verify
// -
//TODO queue-read
Expand All @@ -278,9 +284,9 @@ func cmdHelp(args []string) error {
}

if len(customCommands) > 0 {
head := commands[:21]
head := commands[:25]
tail := make([]customCmd, 6)
copy(tail, commands[21:])
copy(tail, commands[25:])
commands = head
for _, cmd := range customCommands {
args := make([]string, 0)
Expand Down Expand Up @@ -419,7 +425,7 @@ func addToListRemoveDouble(list []string, new ...string) []string {
// filter out all values equal to one in new (ignore case)
found := false
for _, newStr := range new {
if strings.ToLower(str) == strings.ToLower(newStr) {
if strings.EqualFold(str, newStr) {
found = true
break
}
Expand Down Expand Up @@ -778,6 +784,20 @@ func cmdChangeProvider(args []string) error {
return err
}

func cmdVerifyQueueRead(args []string) error {
_, err := processQuery(rri.NewVerifyQueueReadQuery())
return err
}

func cmdVerifyQueueDelete(args []string) error {
if len(args) < 1 {
return fmt.Errorf("missing message id")
}

_, err := processQuery(rri.NewVerifyQueueDeleteQuery(args[0]))
return err
}

func cmdRaw(args []string) error {
var rawCommand string
if len(args) > 0 {
Expand Down
16 changes: 9 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ go 1.16

require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 // indirect
github.com/alecthomas/units v0.0.0-20210912230133-d1bdfacee922 // indirect
github.com/juju/ansiterm v0.0.0-20210706145210-9283cdf370b5 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/manifoldco/promptui v0.8.0
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/nsf/termbox-go v1.1.1 // indirect
github.com/sbreitf1/go-console v0.11.1
github.com/sbreitf1/go-jcrypt v0.1.0
github.com/stretchr/testify v1.6.1
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
golang.org/x/net v0.0.0-20210525063256-abc453219eb5
golang.org/x/sys v0.0.0-20210601080250-7ecdf8ef093b // indirect
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf
golang.org/x/sys v0.0.0-20210921065528-437939a70204 // indirect
golang.org/x/term v0.0.0-20210916214954-140adaaadfaf // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)
36 changes: 20 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 h1:AUNCr9CiJuwrRYS3XieqF+Z9B9gNxo/eANAJCF2eiN4=
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
github.com/alecthomas/units v0.0.0-20210912230133-d1bdfacee922 h1:8ypNbf5sd3Sm3cKJ9waOGoQv6dKAFiFty9L6NP1AqJ4=
github.com/alecthomas/units v0.0.0-20210912230133-d1bdfacee922/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
Expand All @@ -17,8 +17,9 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell v1.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU=
github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0=
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a h1:FaWFmfWdAUKbSCtOU2QjDaorUexogfaMgbipgYATUMU=
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU=
github.com/juju/ansiterm v0.0.0-20210706145210-9283cdf370b5 h1:Q5klzs6BL5FkassBX65t+KkG0XjYcjxEm+GNcQAsuaw=
github.com/juju/ansiterm v0.0.0-20210706145210-9283cdf370b5/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand All @@ -33,12 +34,12 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm
github.com/manifoldco/promptui v0.8.0 h1:R95mMF+McvXZQ7j1g8ucVZE1gLP3Sv6j9vlF9kyRqQo=
github.com/manifoldco/promptui v0.8.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEXGwov2nIKuGQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
Expand All @@ -61,12 +62,12 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf h1:R150MpwJIv1MpS0N/pc+NhTM8ajzvlmxlY5OYsrevXQ=
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -76,16 +77,19 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210601080250-7ecdf8ef093b h1:qh4f65QIVFjq9eBURLEYWqaEXmOyqdUyiBSgaXWccWk=
golang.org/x/sys v0.0.0-20210601080250-7ecdf8ef093b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210921065528-437939a70204 h1:JJhkWtBuTQKyz2bd5WG9H8iUsJRU3En/KRfN8B2RnDs=
golang.org/x/sys v0.0.0-20210921065528-437939a70204/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
golang.org/x/term v0.0.0-20210916214954-140adaaadfaf h1:Ihq/mm/suC88gF8WFcVwk+OV6Tq+wyA1O0E5UEvDglI=
golang.org/x/term v0.0.0-20210916214954-140adaaadfaf/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
Expand Down
2 changes: 1 addition & 1 deletion pkg/rri/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (client *Client) SendQuery(query *Query) (*Response, error) {
// save credentials to restore session after lost connections
client.lastUser = client.currentUser
pwField := query.Field(QueryFieldNamePassword)
if pwField != nil && len(pwField) > 0 {
if len(pwField) > 0 {
client.lastPass = query.Field(QueryFieldNamePassword)[0]
} else {
client.lastPass = ""
Expand Down
8 changes: 4 additions & 4 deletions pkg/rri/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func TestClientConfDefaults(t *testing.T) {
return nil, nil
},
})
require.NoError(t, err)
defer client.Close()

require.NoError(t, err)
assert.Equal(t, 1, dialCount)
}

Expand All @@ -76,9 +76,9 @@ func TestClientConf(t *testing.T) {
return nil, nil
},
})
require.NoError(t, err)
defer client.Close()

require.NoError(t, err)
assert.Equal(t, 1, dialCount)
}

Expand All @@ -98,8 +98,8 @@ func TestClientNoAutoRetry(t *testing.T) {
return conn, nil
},
})
defer client.Close()
require.NoError(t, err)
defer client.Close()

require.NoError(t, client.Login("DENIC-1000011-RRI", "secret"))
client.NoAutoRetry = true
Expand Down Expand Up @@ -132,8 +132,8 @@ func TestClientAutoRetry(t *testing.T) {
return conn, nil
},
})
defer client.Close()
require.NoError(t, err)
defer client.Close()

require.NoError(t, client.Login("DENIC-1000011-RRI", "secret"))
resp, err := client.SendQuery(NewInfoDomainQuery("denic.de"))
Expand Down
93 changes: 81 additions & 12 deletions pkg/rri/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ const (
QueryFieldNameCountryCode QueryFieldName = "countrycode"
// QueryFieldNameEMail denotes the query field name for email.
QueryFieldNameEMail QueryFieldName = "email"
// QueryFieldNameSSOEMail denotes the e-mail address to link after CSP registration for vChecked.
QueryFieldNameSSOEMail QueryFieldName = "ssoemail"
// QueryFieldNameBusinessNumber denotes the business number of a legal entity.
QueryFieldNameBusinessNumber QueryFieldName = "businessnumber"
// QueryFieldNameAuthSigFirstName denotes the first name of an authorized signatory.
QueryFieldNameAuthSigFirstName QueryFieldName = "authorizedsignatoryfirstname"
// QueryFieldNameAuthSigLastName denotes the last name of an authorized signatory.
Expand All @@ -79,6 +83,26 @@ const (
QueryFieldNameAuthSigStreet QueryFieldName = "authorizedsignatorystreet"
// QueryFieldNameAuthSigPhone denotes the phone number of an authorized signatory.
QueryFieldNameAuthSigPhone QueryFieldName = "authorizedsignatoryphone"
// QueryFieldNamePersonFirstName denotes the first name of an authorized signatory.
QueryFieldNamePersonFirstName QueryFieldName = "personfirstname"
// QueryFieldNamePersonLastName denotes the last name of an authorized signatory.
QueryFieldNamePersonLastName QueryFieldName = "personlastname"
// QueryFieldNamePersonEMail denotes the email address of an authorized signatory.
QueryFieldNamePersonEMail QueryFieldName = "personemail"
// QueryFieldNamePersonDateOfBirth denotes the date of birth of an authorized signatory.
QueryFieldNamePersonDateOfBirth QueryFieldName = "persondateofbirth"
// QueryFieldNamePersonCountryCode denotes the country of an authorized signatory.
QueryFieldNamePersonCountryCode QueryFieldName = "personcountrycode"
// QueryFieldNamePersonCity denotes the city of an authorized signatory.
QueryFieldNamePersonCity QueryFieldName = "personcity"
// QueryFieldNamePersonPostalCode denotes the postal code of an authorized signatory.
QueryFieldNamePersonPostalCode QueryFieldName = "personpostalcode"
// QueryFieldNamePersonStreet denotes the street of an authorized signatory.
QueryFieldNamePersonStreet QueryFieldName = "personstreet"
// QueryFieldNamePersonPhone denotes the phone number of an authorized signatory.
QueryFieldNamePersonPhone QueryFieldName = "personphone"
// QueryFieldNameMsgID denotes the query field name for an message id.
QueryFieldNameMsgID QueryFieldName = "msgid"

// ActionLogin denotes the action value for login.
ActionLogin QueryAction = "LOGIN"
Expand All @@ -104,10 +128,16 @@ const (
ActionCreateAuthInfo1 QueryAction = "CREATE-AUTHINFO1"
// ActionCreateAuthInfo2 denotes the action value for create AuthInfo2.
ActionCreateAuthInfo2 QueryAction = "CREATE-AUTHINFO2"
// ActionVerify denotes the action value for verify.
ActionVerify QueryAction = "VERIFY"
// ActionChangeProvider denotes the action value for change provider.
ActionChangeProvider QueryAction = "CHPROV"
// ActionVerifyLegalEntity denotes the action value to verify a legal entity.
ActionVerifyLegalEntity QueryAction = "VERIFY-LEGAL-ENTITY"
// ActionVerifyNaturalPerson denotes the action value to verify a natural person.
ActionVerifyNaturalPerson QueryAction = "VERIFY-NATURAL-PERSON"
// ActionVerifyQueueRead denotes the action value to read from the vChecked message queue.
ActionVerifyQueueRead QueryAction = "VERIFY-QUEUE-READ"
// ActionVerifyQueueDelete denotes the action value to delete from the vChecked message queue.
ActionVerifyQueueDelete QueryAction = "VERIFY-QUEUE-DELETE"

// ContactTypePerson denotes a person.
ContactTypePerson ContactType = "PERSON"
Expand Down Expand Up @@ -463,8 +493,17 @@ func NewCreateAuthInfo2Query(domain string) *Query {
return NewQuery(LatestVersion, ActionCreateAuthInfo2, fields)
}

// AuthorizedSignatory represents the authorized signatory for a VERIFY query.
type AuthorizedSignatory struct {
// NewChangeProviderQuery returns a query to create a domain.
func NewChangeProviderQuery(domain, authInfo string, domainData DomainData) *Query {
fields := NewQueryFieldList()
putDomainToQueryFields(&fields, domain)
domainData.putToQueryFields(&fields)
fields.Add(QueryFieldNameAuthInfo, authInfo)
return NewQuery(LatestVersion, ActionChangeProvider, fields)
}

// PersonToVerify represents the natural person that will be verified for vChecked.
type PersonToVerify struct {
FirstName string
LastName string
EMail string
Expand All @@ -476,8 +515,8 @@ type AuthorizedSignatory struct {
Phone string
}

// NewVerifyDomainQuery returns a query to create a verify domain.
func NewVerifyDomainQuery(domain string, authSignatory AuthorizedSignatory) *Query {
// NewVerifyLegalEntityQuery returns a query to verify a domain that is registered for a legal entity.
func NewVerifyLegalEntityQuery(domain string, ssoEMail string, authSignatory PersonToVerify, businessNumber string) *Query {
fields := NewQueryFieldList()
putDomainToQueryFields(&fields, domain)
fields.Add(QueryFieldNameAuthSigFirstName, authSignatory.FirstName)
Expand All @@ -491,16 +530,46 @@ func NewVerifyDomainQuery(domain string, authSignatory AuthorizedSignatory) *Que
if len(authSignatory.Phone) > 0 {
fields.Add(QueryFieldNameAuthSigPhone, authSignatory.Phone)
}
return NewQuery(LatestVersion, ActionVerify, fields)
if len(ssoEMail) > 0 {
fields.Add(QueryFieldNameSSOEMail, ssoEMail)
}
if len(businessNumber) > 0 {
fields.Add(QueryFieldNameBusinessNumber, businessNumber)
}
return NewQuery(LatestVersion, ActionVerifyLegalEntity, fields)
}

// NewChangeProviderQuery returns a query to create a domain.
func NewChangeProviderQuery(domain, authInfo string, domainData DomainData) *Query {
// VerifyNaturalPersonQuery returns a query to verify a domain that is registered for a natural person.
func NewVerifyNaturalPersonQuery(domain string, ssoEMail string, person PersonToVerify) *Query {
fields := NewQueryFieldList()
putDomainToQueryFields(&fields, domain)
domainData.putToQueryFields(&fields)
fields.Add(QueryFieldNameAuthInfo, authInfo)
return NewQuery(LatestVersion, ActionChangeProvider, fields)
fields.Add(QueryFieldNamePersonFirstName, person.FirstName)
fields.Add(QueryFieldNamePersonLastName, person.LastName)
fields.Add(QueryFieldNamePersonEMail, person.EMail)
fields.Add(QueryFieldNamePersonDateOfBirth, person.DateOfBirth.Format("2006-01-02"))
fields.Add(QueryFieldNamePersonCountryCode, person.CountryCode)
fields.Add(QueryFieldNamePersonCity, person.City)
fields.Add(QueryFieldNamePersonPostalCode, person.PostalCode)
fields.Add(QueryFieldNamePersonStreet, person.Street)
if len(person.Phone) > 0 {
fields.Add(QueryFieldNamePersonPhone, person.Phone)
}
if len(ssoEMail) > 0 {
fields.Add(QueryFieldNameSSOEMail, ssoEMail)
}
return NewQuery(LatestVersion, ActionVerifyLegalEntity, fields)
}

// NewVerifyQueueReadQuery returns a query to read from the vChecked message queue.
func NewVerifyQueueReadQuery() *Query {
return NewQuery(LatestVersion, ActionVerifyQueueRead, nil)
}

// NewVerifyQueueReadQuery returns a query to read from the vChecked message queue.
func NewVerifyQueueDeleteQuery(msgID string) *Query {
fields := NewQueryFieldList()
fields.Add(QueryFieldNameMsgID, msgID)
return NewQuery(LatestVersion, ActionVerifyQueueDelete, fields)
}

// ParseQueryKV parses a single key-value encoded query.
Expand Down
Loading

0 comments on commit e8f219b

Please sign in to comment.