@@ -82,15 +82,15 @@ function TilloProvider(this: any, options: TilloProviderOptions) {
82
82
const path = "brands"
83
83
const timestamp = new Date ( ) . getTime ( ) . toString ( )
84
84
85
- const options : Map < string , string > = new Map ( [
85
+ const signData : Map < string , string > = new Map ( [
86
86
[ "apikey" , this . shared . headers [ "API-Key" ] ] ,
87
87
[ "method" , "GET" ] ,
88
88
[ "path" , path ] ,
89
89
[ "timestamp" , timestamp ] ,
90
90
[ "apiSecret" , this . shared . secret ] ,
91
91
] )
92
92
93
- this . shared . headers . Signature = getAuthSignature ( options )
93
+ this . shared . headers . Signature = getAuthSignature ( signData )
94
94
this . shared . headers . Timestamp = timestamp
95
95
this . shared . headers . Accept = "application/json"
96
96
@@ -103,45 +103,45 @@ function TilloProvider(this: any, options: TilloProviderOptions) {
103
103
}
104
104
}
105
105
} ,
106
- digitalGC : {
106
+ dgc : {
107
107
cmd : {
108
108
save : {
109
109
action : async function ( this : any , entize : any , msg : any ) {
110
110
const timestamp = new Date ( ) . getTime ( ) . toString ( )
111
- const clientRequestId = `${ msg . q . user_id } -digitalissue-${ timestamp } `
112
- const brand = msg . q . brand
113
- const currency = msg . q ?. currency || "GBP"
114
- const value = msg . q . value
115
- const sector = msg . q ?. sector || "other"
116
111
117
- const options : Map < string , string > = new Map ( [
112
+ const { clientRequestId, brand, currency, value, sector } = msg . q
113
+
114
+ const clientRId = clientRequestId || `${ msg . q . user_id } -digitalissue-${ timestamp } `
115
+ const curr = currency || "GBP"
116
+
117
+ const signData : Map < string , string > = new Map ( [
118
118
[ "apikey" , this . shared . headers [ "API-Key" ] ] ,
119
119
[ "method" , "POST" ] ,
120
120
[ "path" , "digital-issue" ] ,
121
- [ "clientRequestId" , clientRequestId ] ,
121
+ [ "clientRequestId" , clientRId ] ,
122
122
[ "brand" , brand ] ,
123
- [ "currency" , currency ] ,
123
+ [ "currency" , curr ] ,
124
124
[ "value" , value ] ,
125
125
[ "timestamp" , timestamp ] ,
126
126
[ "apiSecret" , this . shared . secret ] ,
127
127
] )
128
128
129
- this . shared . headers . Signature = getAuthSignature ( options )
129
+ this . shared . headers . Signature = getAuthSignature ( signData )
130
130
this . shared . headers . Timestamp = timestamp
131
131
this . shared . headers . Accept = "application/json"
132
132
133
133
let json : any =
134
134
await postJSON ( makeUrl ( 'digital/issue' ) , makeConfig ( {
135
135
body : {
136
- client_request_id : clientRequestId ,
136
+ client_request_id : clientRId ,
137
137
brand : brand ,
138
138
face_value : {
139
139
amount : value ,
140
- currency,
140
+ currency : curr ,
141
141
} ,
142
142
delivery_method : 'url' ,
143
143
fulfilment_by : 'partner' ,
144
- sector : sector
144
+ sector : sector || "other"
145
145
}
146
146
} ) )
147
147
0 commit comments