Sha256: d556a147b2df77ae1d1d02ad71ca8fbcdd256e759f03fa6129968d769b4ad4a4

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

Contents

require 'json'
require 'awrence'

module Smartsheet
  module API
    class RequestSpec
      attr_reader :file_spec, :url_args, :params, :header_overrides, :body, :filename, :content_type
      private :file_spec

      def initialize(params: {}, header_overrides: {}, body: nil, file_spec: nil, **url_args)
        @url_args = url_args
        @params = params
        @header_overrides = header_overrides
        @body = body
        @file_spec = file_spec
      end

      def filename
        file_spec.filename
      end

      def content_type
        file_spec.content_type
      end

      def file_length
        file_spec.file_length
      end

      def json_body
        if body.nil? || body.is_a?(String)
          body
        else
          body.to_camelback_keys.to_json
        end
      end

      def file_body
        file_spec.upload_io
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smartsheet-1.0.0.beta.2 lib/smartsheet/api/request_spec.rb
smartsheet-1.0.0.beta.0 lib/smartsheet/api/request_spec.rb