Sha256: 1820ccc0caa6cc0a71e397c52090fc49c864145783ad4c466ede81bc872a929e

Contents?: true

Size: 728 Bytes

Versions: 1

Compression:

Stored size: 728 Bytes

Contents

# frozen_string_literal: true

require 'httparty'
require 'zt/conf'

module Zt
  module RemoteAPI
    class ZeroTierAPI
      include HTTParty

      base_uri 'https://my.zerotier.com/api'

      def initialize
        @ztc = Zt::Conf.instance.conf
        # noinspection RubyStringKeysInHashInspection
        @req_opts = {
          headers: {
            'Authorization' => "Bearer #{@ztc.zt['token']}"
          }
        }
      end

      def networks
        get_parsed('/network')
      end

      def network_members(network_id)
        get_parsed("/network/#{network_id}/member")
      end

      private

      def get_parsed(path)
        self.class.get(path, @req_opts).parsed_response
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zt-0.1.1 lib/zt/remote_api.rb