Sha256: 14802520f5d4a6a882a5619d0956e4a21964795eb5803ef6dd5f28e32fe5078e
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require_relative 'service' require 'singleton' module Zzlink # Client of zzEnv service. class Env < Service include Singleton def name 'zzEnv' end def version 'v1.0' end # Get a environment variable's value. # @param name [String] name of the environment variable. # @return [String] value of the variable. def get_env(name) resp = get("/env/#{name}") resp = JSON.parse(resp) resp[name] end # Get a zzLink ticket. # @param ttl_in_sec [Integer] TTL (in seconds) of the new ticket. # @return [String] a ticket which is URL-safe encoded. def new_ticket(ttl_in_sec = 60) resp = get('/ticket', ttl: ttl_in_sec) resp = JSON.parse(resp) resp['ticket'] end # Check a zzLink ticket. # @param ticket [String] the string representation of the ticket. # @return [Boolean] whether the ticket is valid. def check_ticket(ticket) resp = put('/ticket', ticket: ticket); resp = JSON.parse(resp) resp['status'] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zzlink-0.0.2 | lib/zzlink/env.rb |