Sha256: 7e66f55b380f10a137f64fffa93eff018de30faf242f20602cbad33a6ddb92b6

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module NgrokAPI
  module Models
    class APIKey
      attr_reader :client,
        :attrs,
        :id,
        :uri,
        :description,
        :metadata,
        :created_at,
        :token

      def initialize(client: nil, attrs: {})
        @client = client
        @attrs = attrs
        @id = @attrs['id']
        @uri = @attrs['uri']
        @description = @attrs['description']
        @metadata = @attrs['metadata']
        @created_at = @attrs['created_at']
        @token = @attrs['token']
      end

      def ==(other)
        @attrs == other.attrs
      end

      def to_s
        @attrs.to_s
      end

      def to_h
        @attrs.to_h
      end

      ##
      # Delete an API key by ID
      #
      # https://ngrok.com/docs/api#api-api-keys-delete
      def delete
        @client.delete(
          id: @id
        )
      end

      ##
      # Update attributes of an API key by ID.
      #
      # https://ngrok.com/docs/api#api-api-keys-update
      def update(
        description: nil,
        metadata: nil
      )
        @description = description if description
        @metadata = metadata if metadata
        @client.update(
          id: @id,
          description: description,
          metadata: metadata
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ngrok-api-0.19.0 lib/ngrokapi/models/api_key.rb