Module: Relaton::Un::TokenGenerator
- Defined in:
- lib/relaton/un/token_generator.rb
Defined Under Namespace
Classes: Heap
Constant Summary collapse
- WASMTIME_AVAILABLE =
WASMTIME_LOADED- WASM_PATH =
File.join(__dir__, "wasm_v_bg.wasm")
- DOMAIN =
"documents.un.org"
Class Method Summary collapse
-
.generate ⇒ String
Generates an auth token for the UN documents API.
Class Method Details
.generate ⇒ String
Generates an auth token for the UN documents API. Tokens are cached per-minute since the WASM output changes each minute.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/relaton/un/token_generator.rb', line 20 def self.generate unless WASMTIME_AVAILABLE warn "[relaton-un] wasmtime gem is not available on this platform. Token generation is disabled." return nil end now = Time.now.utc key = [now.year, now.month, now.day, now.hour, now.min] return @cached_token if @cached_key == key && @cached_token @cached_key = key @cached_token = call_wasm(*key) end |