Sha256: e9991f66697268602bfe8598c5468a9817c021c11213e6ecc0602d283049cf74

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

module NgrokAPI
  module Models
    ##
    # A resource representing data from the tls_certificate API
    class TlsCertificate
      attr_reader :id,
        :client,
        :created_at,
        :description,
        :metadata,
        :result,
        :uri

      def initialize(client:, result:)
        @client = client
        @result = result
        @created_at = @result['created_at']
        @id = @result['id']
        @description = @result['description']
        @metadata = @result['metadata']
        @uri = @result['uri']
      end

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

      def to_s
        @result.to_s
      end

      ##
      # Delete this TLS certificate.
      #
      # @return [nil] result from delete request
      #
      # https://ngrok.com/docs/api#api-tls-certificates-delete
      def delete
        @client.delete(id: @id)
      end

      # rubocop:disable LineLength

      ##
      # Update the attributes of this TLS Certificate.
      #
      # @param [string] description human-readable description of this TLS certificate. optional, max 255 bytes.
      # @param [string] metadata arbitrary user-defined machine-readable data of this TLS certificate. optional, max 4096 bytes.
      # @return [NgrokAPI::Models::TlsCertificate] result from update request
      #
      # https://ngrok.com/docs/api#api-tls-certificates-update
      def update(description: nil, metadata: nil)
        @description = description if description
        @metadata = metadata if metadata
        @client.update(id: @id, description: description, metadata: metadata)
      end
      # rubocop:enable LineLength
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ngrok-api-0.9.0 lib/ngrokapi/models/tls_certificate.rb