/
invoicefunctions.go
73 lines (64 loc) · 2.52 KB
/
invoicefunctions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// --- cmd specific functions which are best to remain within the package ---------------------------------------------------------------------------
package cmdroutes
import (
"fmt"
. "github.com/instance-id/GoVerifier-dgo/data"
. "github.com/instance-id/GoVerifier-dgo/utils"
)
// --- Generic input text query -------------------------------------------------------------------
func GenericQuery(l LocalContext, prompt string) string {
return func(string) string {
query, err := QueryInput(l.C, l.Ctx, prompt, TimeoutDuration)
result := InputWarn("Input not received: ", err)
if result == true {
return "Input not received: Action timed out"
}
return query.Content
}(prompt)
}
// --- Queries user for invoice input ------------------------------------------------------------- TODO Test Function
func GetInvoice(l LocalContext, prompt string) string {
return func(string) string {
invoice, err := QueryInput(l.C, l.Ctx, prompt, TimeoutDuration)
result := InputWarn("Input not received: ", err)
if result == true {
return "Input not received: Action timed out"
}
return TrimInvoice(invoice.Content)
}(prompt)
}
// --- Obtain asset identification ----------------------------------------------------------------
func EnterAsset(l LocalContext, prompt string) string {
return func(string) string {
asset, err := QueryInput(l.C, l.Ctx, prompt, TimeoutDuration)
result := InputWarn("Input not received: ", err)
if result == true {
return "Input not received: Action timed out"
}
return asset.Content
}(prompt)
}
// --- Obtain invoice number ----------------------------------------------------------------------
func EnterInvoice(l LocalContext, asset string, assetDesc string) string {
prompt := fmt.Sprintf("Please enter invoice number for %s: %s", assetDesc, asset)
return func(string) string {
invoice, err := QueryInput(l.C, l.Ctx, prompt, TimeoutDuration)
result := InputWarn("Input not received: ", err)
if result == true {
return "Input not received: Action timed out"
}
return TrimInvoice(invoice.Content)
}(prompt)
}
// --- Obtain email address ----------------------------------------------------------------------
func EnterEmail(l LocalContext) string {
prompt := fmt.Sprintf("Please enter email address associated with asset purchase")
return func(string) string {
email, err := QueryInput(l.C, l.Ctx, prompt, TimeoutDuration)
result := InputWarn("Input not received: ", err)
if result == true {
return "Input not received: Action timed out"
}
return email.Content
}(prompt)
}