workato-connector-sdk 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/VERSION +1 -0
- data/lib/workato/cli/edit_command.rb +3 -1
- data/lib/workato/cli/exec_command.rb +76 -10
- data/lib/workato/cli/generate_command.rb +2 -2
- data/lib/workato/cli/main.rb +17 -10
- data/lib/workato/cli/oauth2_command.rb +4 -4
- data/lib/workato/cli/push_command.rb +2 -2
- data/lib/workato/cli/schema_command.rb +2 -2
- data/lib/workato/connector/sdk/account_properties.rb +2 -2
- data/lib/workato/connector/sdk/action.rb +20 -70
- data/lib/workato/connector/sdk/block_invocation_refinements.rb +2 -10
- data/lib/workato/connector/sdk/connection.rb +36 -19
- data/lib/workato/connector/sdk/connector.rb +65 -77
- data/lib/workato/connector/sdk/core.rb +62 -0
- data/lib/workato/connector/sdk/dsl/aws.rb +3 -3
- data/lib/workato/connector/sdk/dsl/call.rb +1 -1
- data/lib/workato/connector/sdk/dsl/csv_package.rb +133 -0
- data/lib/workato/connector/sdk/dsl/execution_context.rb +1 -0
- data/lib/workato/connector/sdk/dsl/http.rb +1 -1
- data/lib/workato/connector/sdk/dsl/reinvoke_after.rb +84 -0
- data/lib/workato/connector/sdk/dsl/stream_package.rb +65 -0
- data/lib/workato/connector/sdk/dsl/time.rb +0 -14
- data/lib/workato/connector/sdk/dsl/workato_package.rb +146 -0
- data/lib/workato/connector/sdk/dsl.rb +63 -10
- data/lib/workato/connector/sdk/errors.rb +28 -11
- data/lib/workato/connector/sdk/operation.rb +9 -2
- data/lib/workato/connector/sdk/request.rb +63 -25
- data/lib/workato/connector/sdk/schema/field/convertors.rb +2 -2
- data/lib/workato/connector/sdk/schema/type/unicode_string.rb +1 -1
- data/lib/workato/connector/sdk/schema.rb +7 -5
- data/lib/workato/connector/sdk/settings.rb +10 -1
- data/lib/workato/connector/sdk/stream.rb +243 -0
- data/lib/workato/connector/sdk/streams.rb +71 -0
- data/lib/workato/connector/sdk/summarize.rb +2 -2
- data/lib/workato/connector/sdk/trigger.rb +14 -7
- data/lib/workato/connector/sdk/version.rb +1 -1
- data/lib/workato/connector/sdk.rb +19 -46
- data/lib/workato/extension/array.rb +2 -0
- data/lib/workato/extension/case_sensitive_headers.rb +0 -1
- data/lib/workato/extension/content_encoding_decoder.rb +2 -0
- data/lib/workato/extension/currency/countries.rb +79 -0
- data/lib/workato/extension/currency/countries.yml +18433 -0
- data/lib/workato/extension/currency/currencies.rb +55 -0
- data/lib/workato/extension/currency/currencies.yml +479 -0
- data/lib/workato/extension/currency.rb +73 -5
- data/lib/workato/extension/enumerable.rb +2 -2
- data/lib/workato/extension/metadata_fix_wrap_kw_args.rb +11 -0
- data/lib/workato/extension/string.rb +14 -111
- data/lib/workato/testing/vcr_encrypted_cassette_serializer.rb +2 -0
- data/lib/workato/types/binary.rb +55 -0
- metadata +46 -61
- data/lib/workato/connector/sdk/dsl/csv.rb +0 -125
- data/lib/workato/connector/sdk/dsl/workato_code_lib.rb +0 -167
@@ -0,0 +1,55 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Workato
|
5
|
+
module Extension
|
6
|
+
module Currency
|
7
|
+
class Currencies
|
8
|
+
extend T::Sig
|
9
|
+
|
10
|
+
include Singleton
|
11
|
+
|
12
|
+
class << self
|
13
|
+
extend T::Sig
|
14
|
+
|
15
|
+
sig { params(value: ::String).returns(T.nilable(Currency)) }
|
16
|
+
def find_currency(value)
|
17
|
+
instance.find_currency(value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Currency < T::Struct
|
22
|
+
const :code, ::String
|
23
|
+
const :name, ::String
|
24
|
+
const :symbol, T.nilable(::String)
|
25
|
+
end
|
26
|
+
|
27
|
+
private_constant :Currency
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
@currency_by_code = load_currencies.index_by(&:code).freeze
|
31
|
+
end
|
32
|
+
|
33
|
+
sig { params(value: ::String).returns(T.nilable(Currency)) }
|
34
|
+
def find_currency(value)
|
35
|
+
@currency_by_code[value]
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
sig { returns(T::Array[Currency]) }
|
41
|
+
def load_currencies
|
42
|
+
YAML.load_file(File.expand_path('./currencies.yml', __dir__)).map do |data|
|
43
|
+
Currency.new(
|
44
|
+
code: data['code'].freeze,
|
45
|
+
name: data['name'].freeze,
|
46
|
+
symbol: data['symbol']&.freeze
|
47
|
+
).freeze
|
48
|
+
end.freeze
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private_constant :Currencies
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,479 @@
|
|
1
|
+
# based on data from currencies@0.4.2 gem
|
2
|
+
---
|
3
|
+
- code: AED
|
4
|
+
name: Dirhams
|
5
|
+
symbol:
|
6
|
+
- code: AFN
|
7
|
+
name: Afghanis
|
8
|
+
symbol: "؋"
|
9
|
+
- code: ALL
|
10
|
+
name: Leke
|
11
|
+
symbol: LEK
|
12
|
+
- code: AMD
|
13
|
+
name: Drams
|
14
|
+
symbol:
|
15
|
+
- code: ANG
|
16
|
+
name: Guilders
|
17
|
+
symbol: ƒ
|
18
|
+
- code: AOA
|
19
|
+
name: Kwanza
|
20
|
+
symbol:
|
21
|
+
- code: ARS
|
22
|
+
name: Pesos
|
23
|
+
symbol: "$"
|
24
|
+
- code: AUD
|
25
|
+
name: Dollars
|
26
|
+
symbol: "$"
|
27
|
+
- code: AWG
|
28
|
+
name: Guilders
|
29
|
+
symbol: ƒ
|
30
|
+
- code: AZN
|
31
|
+
name: New Manats
|
32
|
+
symbol: ман
|
33
|
+
- code: BAM
|
34
|
+
name: Convertible Marka
|
35
|
+
symbol: KM
|
36
|
+
- code: BBD
|
37
|
+
name: Dollars
|
38
|
+
symbol: "$"
|
39
|
+
- code: BDT
|
40
|
+
name: Taka
|
41
|
+
symbol:
|
42
|
+
- code: BGN
|
43
|
+
name: Leva
|
44
|
+
symbol: лв
|
45
|
+
- code: BHD
|
46
|
+
name: Dinars
|
47
|
+
symbol:
|
48
|
+
- code: BIF
|
49
|
+
name: Francs
|
50
|
+
symbol:
|
51
|
+
- code: BMD
|
52
|
+
name: Dollars
|
53
|
+
symbol: "$"
|
54
|
+
- code: BND
|
55
|
+
name: Dollars
|
56
|
+
symbol: "$"
|
57
|
+
- code: BOB
|
58
|
+
name: Bolivianos
|
59
|
+
symbol: "$b"
|
60
|
+
- code: BRL
|
61
|
+
name: Real
|
62
|
+
symbol: R$
|
63
|
+
- code: BSD
|
64
|
+
name: Dollars
|
65
|
+
symbol: "$"
|
66
|
+
- code: BTN
|
67
|
+
name: Ngultrum
|
68
|
+
symbol:
|
69
|
+
- code: BWP
|
70
|
+
name: Pulas
|
71
|
+
symbol: P
|
72
|
+
- code: BYR
|
73
|
+
name: Rubles
|
74
|
+
symbol: p.
|
75
|
+
- code: BZD
|
76
|
+
name: Dollars
|
77
|
+
symbol: BZ$
|
78
|
+
- code: CAD
|
79
|
+
name: Dollars
|
80
|
+
symbol: "$"
|
81
|
+
- code: CDF
|
82
|
+
name: Franc
|
83
|
+
symbol:
|
84
|
+
- code: CHF
|
85
|
+
name: Switzerland Francs
|
86
|
+
symbol: CHF
|
87
|
+
- code: CLP
|
88
|
+
name: Pesos
|
89
|
+
symbol: "$"
|
90
|
+
- code: CNY
|
91
|
+
name: Yuan Renminbi
|
92
|
+
symbol: "¥"
|
93
|
+
- code: COP
|
94
|
+
name: Pesos
|
95
|
+
symbol: "$"
|
96
|
+
- code: CRC
|
97
|
+
name: Colones
|
98
|
+
symbol: "₡"
|
99
|
+
- code: CUP
|
100
|
+
name: Pesos
|
101
|
+
symbol: "₱"
|
102
|
+
- code: CVE
|
103
|
+
name: Escudos
|
104
|
+
symbol:
|
105
|
+
- code: CZK
|
106
|
+
name: Koruny
|
107
|
+
symbol: Kč
|
108
|
+
- code: DJF
|
109
|
+
name: Francs
|
110
|
+
symbol:
|
111
|
+
- code: DKK
|
112
|
+
name: Kroner
|
113
|
+
symbol: kr
|
114
|
+
- code: DOP
|
115
|
+
name: Pesos
|
116
|
+
symbol: RD$
|
117
|
+
- code: DZD
|
118
|
+
name: Dinars
|
119
|
+
symbol:
|
120
|
+
- code: EEK
|
121
|
+
name: Krooni
|
122
|
+
symbol: kr
|
123
|
+
- code: EGP
|
124
|
+
name: Pounds
|
125
|
+
symbol: "£"
|
126
|
+
- code: ETB
|
127
|
+
name: Ethopia Birr
|
128
|
+
symbol:
|
129
|
+
- code: EUR
|
130
|
+
name: Euro
|
131
|
+
symbol: "€"
|
132
|
+
- code: FJD
|
133
|
+
name: Dollar
|
134
|
+
symbol:
|
135
|
+
- code: FKP
|
136
|
+
name: Pounds
|
137
|
+
symbol: "£"
|
138
|
+
- code: GBP
|
139
|
+
name: Pounds
|
140
|
+
symbol: "£"
|
141
|
+
- code: GEL
|
142
|
+
name: Lari
|
143
|
+
symbol:
|
144
|
+
- code: GGP
|
145
|
+
name: Pounds
|
146
|
+
symbol: "£"
|
147
|
+
- code: GHS
|
148
|
+
name: Cedis
|
149
|
+
symbol: "¢"
|
150
|
+
- code: GIP
|
151
|
+
name: Pounds
|
152
|
+
symbol: "£"
|
153
|
+
- code: GMD
|
154
|
+
name: Lari
|
155
|
+
symbol:
|
156
|
+
- code: GNF
|
157
|
+
name: Francs
|
158
|
+
symbol:
|
159
|
+
- code: GTQ
|
160
|
+
name: Quetzales
|
161
|
+
symbol: Q
|
162
|
+
- code: GYD
|
163
|
+
name: Dollars
|
164
|
+
symbol:
|
165
|
+
- code: HKD
|
166
|
+
name: Dollars
|
167
|
+
symbol: "$"
|
168
|
+
- code: HNL
|
169
|
+
name: Lempiras
|
170
|
+
symbol: L
|
171
|
+
- code: HRK
|
172
|
+
name: Kuna
|
173
|
+
symbol: kn
|
174
|
+
- code: HTG
|
175
|
+
name: Haitian Gourde
|
176
|
+
symbol:
|
177
|
+
- code: HUF
|
178
|
+
name: Forint
|
179
|
+
symbol: Ft
|
180
|
+
- code: IDR
|
181
|
+
name: Indonesian Rupiahs
|
182
|
+
symbol: Rp
|
183
|
+
- code: ILS
|
184
|
+
name: New Shekels
|
185
|
+
symbol: "₪"
|
186
|
+
- code: IMP
|
187
|
+
name: Pounds
|
188
|
+
symbol: "£"
|
189
|
+
- code: INR
|
190
|
+
name: Rupees
|
191
|
+
symbol: "₨"
|
192
|
+
- code: IQD
|
193
|
+
name: Dinars
|
194
|
+
symbol:
|
195
|
+
- code: IRR
|
196
|
+
name: Riais
|
197
|
+
symbol: "﷼"
|
198
|
+
- code: ISK
|
199
|
+
name: Kronur
|
200
|
+
symbol: kr
|
201
|
+
- code: JEP
|
202
|
+
name: Pounds
|
203
|
+
symbol: "£"
|
204
|
+
- code: JMD
|
205
|
+
name: Dollars
|
206
|
+
symbol:
|
207
|
+
- code: JOD
|
208
|
+
name: Dinars
|
209
|
+
symbol:
|
210
|
+
- code: JPY
|
211
|
+
name: Yen
|
212
|
+
symbol: "¥"
|
213
|
+
- code: KES
|
214
|
+
name: Shillings
|
215
|
+
symbol:
|
216
|
+
- code: KGS
|
217
|
+
name: Soms
|
218
|
+
symbol: лв
|
219
|
+
- code: KHR
|
220
|
+
name: Rieis
|
221
|
+
symbol:
|
222
|
+
- code: KMF
|
223
|
+
name: Francs
|
224
|
+
symbol:
|
225
|
+
- code: KPW
|
226
|
+
name: Won
|
227
|
+
symbol: "₩"
|
228
|
+
- code: KRW
|
229
|
+
name: Won
|
230
|
+
symbol: "₩"
|
231
|
+
- code: KWD
|
232
|
+
name: Dinars
|
233
|
+
symbol:
|
234
|
+
- code: KYD
|
235
|
+
name: Dollars
|
236
|
+
symbol: "$"
|
237
|
+
- code: KZT
|
238
|
+
name: Tenege
|
239
|
+
symbol: лв
|
240
|
+
- code: LAK
|
241
|
+
name: Kips
|
242
|
+
symbol: "₭"
|
243
|
+
- code: LBP
|
244
|
+
name: Pounds
|
245
|
+
symbol: "£"
|
246
|
+
- code: LKR
|
247
|
+
name: Rupees
|
248
|
+
symbol: "₨"
|
249
|
+
- code: LRD
|
250
|
+
name: Dollars
|
251
|
+
symbol: "$"
|
252
|
+
- code: LSL
|
253
|
+
name: Maloti
|
254
|
+
symbol:
|
255
|
+
- code: LTL
|
256
|
+
name: Litai
|
257
|
+
symbol: Lt
|
258
|
+
- code: LVL
|
259
|
+
name: Lati
|
260
|
+
symbol: Ls
|
261
|
+
- code: LYD
|
262
|
+
name: Dinars
|
263
|
+
symbol:
|
264
|
+
- code: MAD
|
265
|
+
name: Dirhams
|
266
|
+
symbol:
|
267
|
+
- code: MDL
|
268
|
+
name: Lei
|
269
|
+
symbol:
|
270
|
+
- code: MKD
|
271
|
+
name: Macedonian Denar
|
272
|
+
symbol:
|
273
|
+
- code: MGA
|
274
|
+
name: Ariary
|
275
|
+
symbol:
|
276
|
+
- code: MMK
|
277
|
+
name: Kyat
|
278
|
+
symbol:
|
279
|
+
- code: MNK
|
280
|
+
name: Kyats
|
281
|
+
symbol:
|
282
|
+
- code: MNT
|
283
|
+
name: Tugriks
|
284
|
+
symbol: "₮"
|
285
|
+
- code: MRO
|
286
|
+
name: Ouguiyas
|
287
|
+
symbol:
|
288
|
+
- code: MUR
|
289
|
+
name: Rupees
|
290
|
+
symbol: "₨"
|
291
|
+
- code: MVR
|
292
|
+
name: Rufiyaa
|
293
|
+
symbol:
|
294
|
+
- code: MWK
|
295
|
+
name: Kwachas
|
296
|
+
symbol:
|
297
|
+
- code: MXN
|
298
|
+
name: Pesos
|
299
|
+
symbol: "$"
|
300
|
+
- code: MYR
|
301
|
+
name: Ringgits
|
302
|
+
symbol: RM
|
303
|
+
- code: MZN
|
304
|
+
name: Meticals
|
305
|
+
symbol: MT
|
306
|
+
- code: NAD
|
307
|
+
name: Dollars
|
308
|
+
symbol: "$"
|
309
|
+
- code: NGN
|
310
|
+
name: Nairas
|
311
|
+
symbol: "₦"
|
312
|
+
- code: NIO
|
313
|
+
name: Cordobas
|
314
|
+
symbol: C$
|
315
|
+
- code: NOK
|
316
|
+
name: Kroner
|
317
|
+
symbol: kr
|
318
|
+
- code: NPR
|
319
|
+
name: Rupees
|
320
|
+
symbol: "₨"
|
321
|
+
- code: NZD
|
322
|
+
name: New Zealand Dollars
|
323
|
+
symbol: "$"
|
324
|
+
- code: OMR
|
325
|
+
name: Riais
|
326
|
+
symbol: "﷼"
|
327
|
+
- code: PAB
|
328
|
+
name: Balboa
|
329
|
+
symbol: B/.
|
330
|
+
- code: PEN
|
331
|
+
name: Nuevos Soles
|
332
|
+
symbol: S/.
|
333
|
+
- code: PGK
|
334
|
+
name: Kina
|
335
|
+
symbol:
|
336
|
+
- code: PHP
|
337
|
+
name: Pesos
|
338
|
+
symbol: Php
|
339
|
+
- code: PKR
|
340
|
+
name: Rupees
|
341
|
+
symbol: "₨"
|
342
|
+
- code: PLN
|
343
|
+
name: Zlotych
|
344
|
+
symbol: zł
|
345
|
+
- code: PYG
|
346
|
+
name: Guarani
|
347
|
+
symbol: Gs
|
348
|
+
- code: QAR
|
349
|
+
name: Rials
|
350
|
+
symbol: "﷼"
|
351
|
+
- code: RON
|
352
|
+
name: New Lei
|
353
|
+
symbol: lei
|
354
|
+
- code: RSD
|
355
|
+
name: Dinars
|
356
|
+
symbol: Дин.
|
357
|
+
- code: RUB
|
358
|
+
name: Rubles
|
359
|
+
symbol: руб
|
360
|
+
- code: RWF
|
361
|
+
name: Francs
|
362
|
+
symbol:
|
363
|
+
- code: SAR
|
364
|
+
name: Riyals
|
365
|
+
symbol: "﷼"
|
366
|
+
- code: SBD
|
367
|
+
name: Dollars
|
368
|
+
symbol: "$"
|
369
|
+
- code: SCR
|
370
|
+
name: Rupees
|
371
|
+
symbol: "₨"
|
372
|
+
- code: SDG
|
373
|
+
name: Pounds
|
374
|
+
symbol:
|
375
|
+
- code: SEK
|
376
|
+
name: Kronor
|
377
|
+
symbol: kr
|
378
|
+
- code: SGD
|
379
|
+
name: Dollars
|
380
|
+
symbol: "$"
|
381
|
+
- code: SHP
|
382
|
+
name: Pounds
|
383
|
+
symbol: "£"
|
384
|
+
- code: SLL
|
385
|
+
name: Leones
|
386
|
+
symbol:
|
387
|
+
- code: SOS
|
388
|
+
name: Shillings
|
389
|
+
symbol: S
|
390
|
+
- code: SRD
|
391
|
+
name: Dollars
|
392
|
+
symbol: "$"
|
393
|
+
- code: STD
|
394
|
+
name: Dobras
|
395
|
+
symbol:
|
396
|
+
- code: SVC
|
397
|
+
name: Salvadoran Colón
|
398
|
+
symbol:
|
399
|
+
- code: SYP
|
400
|
+
name: Pounds
|
401
|
+
symbol: "£"
|
402
|
+
- code: SZL
|
403
|
+
name: Emalangeni
|
404
|
+
symbol:
|
405
|
+
- code: THB
|
406
|
+
name: Baht
|
407
|
+
symbol: "฿"
|
408
|
+
- code: TJS
|
409
|
+
name: Somoni
|
410
|
+
symbol:
|
411
|
+
- code: TMM
|
412
|
+
name: Manat
|
413
|
+
symbol:
|
414
|
+
- code: TND
|
415
|
+
name: Dollars
|
416
|
+
symbol:
|
417
|
+
- code: TOP
|
418
|
+
name: Pa'anga
|
419
|
+
symbol:
|
420
|
+
- code: TRY
|
421
|
+
name: Lira
|
422
|
+
symbol: TL
|
423
|
+
- code: TTD
|
424
|
+
name: Dollars
|
425
|
+
symbol: "$"
|
426
|
+
- code: TVD
|
427
|
+
name: Tuvalu Dollars
|
428
|
+
symbol:
|
429
|
+
- code: TWD
|
430
|
+
name: New Dollars
|
431
|
+
symbol: NT$
|
432
|
+
- code: TZS
|
433
|
+
name: Shillings
|
434
|
+
symbol:
|
435
|
+
- code: UAH
|
436
|
+
name: Hryvnia
|
437
|
+
symbol: "₴"
|
438
|
+
- code: UGX
|
439
|
+
name: Shillings
|
440
|
+
symbol:
|
441
|
+
- code: USD
|
442
|
+
name: Dollars
|
443
|
+
symbol: "$"
|
444
|
+
- code: UYU
|
445
|
+
name: Pesos
|
446
|
+
symbol: "$U"
|
447
|
+
- code: UZS
|
448
|
+
name: Sums
|
449
|
+
symbol: лв
|
450
|
+
- code: VEF
|
451
|
+
name: Bolivares Fuertes
|
452
|
+
symbol: Bs
|
453
|
+
- code: VND
|
454
|
+
name: Dong
|
455
|
+
symbol: "₫"
|
456
|
+
- code: XAF
|
457
|
+
name: Communauté Financière Africaine Francs
|
458
|
+
symbol:
|
459
|
+
- code: XCD
|
460
|
+
name: East Caribbean Dollars
|
461
|
+
symbol: "$"
|
462
|
+
- code: XOF
|
463
|
+
name: Communauté Financière Africaine Francs
|
464
|
+
symbol:
|
465
|
+
- code: XPF
|
466
|
+
name: Comptoirs Français du Pacifique Francs
|
467
|
+
symbol:
|
468
|
+
- code: YER
|
469
|
+
name: Rials
|
470
|
+
symbol: "﷼"
|
471
|
+
- code: ZAR
|
472
|
+
name: Rand
|
473
|
+
symbol: R
|
474
|
+
- code: ZMK
|
475
|
+
name: Kwacha
|
476
|
+
symbol:
|
477
|
+
- code: ZWD
|
478
|
+
name: Zimbabwe Dollars
|
479
|
+
symbol: Z$
|
@@ -1,16 +1,84 @@
|
|
1
1
|
# typed: false
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
require_relative './currency/currencies'
|
5
|
+
require_relative './currency/countries'
|
6
|
+
|
4
7
|
module Workato
|
5
8
|
module Extension
|
6
9
|
module Currency
|
7
|
-
|
8
|
-
|
10
|
+
module NumberToCurrencyConverter
|
11
|
+
def to_currency(options = {})
|
12
|
+
ActiveSupport::NumberHelper::NumberToCurrencyConverter.convert(self, options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module String
|
17
|
+
def to_country_alpha2
|
18
|
+
to_country&.alpha2.dup
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_country_alpha3
|
22
|
+
to_country&.alpha3.dup
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_country_name
|
26
|
+
to_country&.name.dup
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_country_number
|
30
|
+
to_country&.number.dup
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_currency_code
|
34
|
+
to_currency_obj&.code.dup
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_currency_name
|
38
|
+
to_currency_obj&.name.dup
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_currency_symbol
|
42
|
+
to_currency_obj&.symbol.dup
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_state_code(country_name = 'US')
|
46
|
+
to_state(country_name)&.first.dup
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_state_name(country_name = 'US')
|
50
|
+
to_state(country_name)&.last&.name&.upcase
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def to_country
|
56
|
+
Countries.find_country(self)
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_state(country_name = 'US')
|
60
|
+
country = Countries.find_country(country_name.presence || 'US')
|
61
|
+
return nil unless country
|
62
|
+
|
63
|
+
value = upcase
|
64
|
+
country.states.find do |code, state|
|
65
|
+
code == value || state.name.upcase == value || state.names.any? { |name| name.upcase == value }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_currency_obj
|
70
|
+
currency = Currencies.find_currency(upcase)
|
71
|
+
return currency if currency
|
72
|
+
|
73
|
+
country_currency_code = to_country&.currency_code&.upcase
|
74
|
+
Currencies.find_currency(country_currency_code) if country_currency_code
|
75
|
+
end
|
9
76
|
end
|
10
77
|
end
|
11
78
|
end
|
12
79
|
end
|
13
80
|
|
14
|
-
String.include(Workato::Extension::Currency)
|
15
|
-
|
16
|
-
|
81
|
+
String.include(Workato::Extension::Currency::NumberToCurrencyConverter)
|
82
|
+
String.include(Workato::Extension::Currency::String)
|
83
|
+
Integer.include(Workato::Extension::Currency::NumberToCurrencyConverter)
|
84
|
+
Float.include(Workato::Extension::Currency::NumberToCurrencyConverter)
|
@@ -18,7 +18,7 @@ module Enumerable
|
|
18
18
|
end
|
19
19
|
|
20
20
|
map do |val|
|
21
|
-
format % (Array(val).map { |v| v.is_a?(HashWithIndifferentAccess) ? v.symbolize_keys : v })
|
21
|
+
format % (Array.wrap(val).map { |v| v.is_a?(HashWithIndifferentAccess) ? v.symbolize_keys : v })
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -51,6 +51,6 @@ module Enumerable
|
|
51
51
|
map do |*items|
|
52
52
|
result = block.call(*items)
|
53
53
|
result || nil
|
54
|
-
end.
|
54
|
+
end.compact
|
55
55
|
end
|
56
56
|
end
|