Sha256: 533f557d1522d542beb7b7324cbd1841a325c0a6df2742dc957e2b736975011b
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
module Vng # Provides methods to interact with Vonigo work security tokens. class SecurityToken attr_reader :token def initialize(token:, host:) @token = token @host = host end def self.create(host:, username:, password:) body = { app_version: '1', company: 'Vonigo', host: host, password: Digest::MD5.hexdigest(password), username: username, } uri = URI::HTTPS.build host: host, path: '/api/v1/security/login/' request = Net::HTTP::Get.new(uri.request_uri) request.initialize_http_header 'Content-Type' => 'application/json; charset=utf-8' request.body = body.to_json response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| http.request request end token = JSON(response.body)['securityToken'] new token: token, host: host end def destroy body = { securityToken: @token, } uri = URI::HTTPS.build host: @host, path: '/api/v1/security/login/' request = Net::HTTP::Post.new(uri.request_uri) request.initialize_http_header 'Content-Type' => 'application/json' request.body = body.to_json response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| http.request request end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vng-0.1.13 | lib/vng/security_token.rb |