Sha256: b871c54dd0623e80ebbb9897044d6cecd089c59bf1d2eca3a9becdd25f96b2b9

Contents?: true

Size: 720 Bytes

Versions: 1

Compression:

Stored size: 720 Bytes

Contents

require_relative 'url_builder'

module Smartsheet
  module API
    # Specification for a single endpoint's configuration
    class EndpointSpec
      attr_reader :method, :url_segments, :spec

      def initialize(method, url, **spec)
        @method = method
        @url_segments = url
        @spec = spec
      end

      def requires_auth?
        !spec.key?(:no_auth)
      end

      def requires_body?
        spec.key? :body_type
      end

      def sending_file?
        requires_body? && spec[:body_type] == :file
      end

      def sending_json?
        requires_body? && spec[:body_type] == :json
      end

      def headers
        spec.key?(:headers) ? spec[:headers] : {}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smartsheet-1.0.0 lib/smartsheet/api/endpoint_spec.rb