Sha256: 06a1687a6c4ca64d0801ff06c00f39fef1248209bad6e2f57247d3f71755cbc0

Contents?: true

Size: 1.45 KB

Versions: 35

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

module Faraday
  module Multipart
    # Multipart value used to POST data with a content type.
    class ParamPart
      # @param value [String] Uploaded content as a String.
      # @param content_type [String] String content type of the value.
      # @param content_id [String] Optional String of this value's Content-ID.
      #
      # @return [Faraday::ParamPart]
      def initialize(value, content_type, content_id = nil)
        @value = value
        @content_type = content_type
        @content_id = content_id
      end

      # Converts this value to a form part.
      #
      # @param boundary [String] String multipart boundary that must not exist in
      #   the content exactly.
      # @param key [String] String key name for this value.
      #
      # @return [Faraday::Parts::Part]
      def to_part(boundary, key)
        Faraday::Multipart::Parts::Part.new(boundary, key, value, headers)
      end

      # Returns a Hash of String key/value pairs.
      #
      # @return [Hash]
      def headers
        {
          'Content-Type' => content_type,
          'Content-ID' => content_id
        }
      end

      # The content to upload.
      #
      # @return [String]
      attr_reader :value

      # The value's content type.
      #
      # @return [String]
      attr_reader :content_type

      # The value's content ID, if given.
      #
      # @return [String, nil]
      attr_reader :content_id
    end
  end
end

Version data entries

35 entries across 35 versions & 9 rubygems

Version Path
es_cli-0.1.0 vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/param_part.rb
avalara_sdk-24.12.2 vendor/bundle/ruby/2.7.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/param_part.rb
avalara_sdk-24.12.1 vendor/bundle/ruby/2.7.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/param_part.rb
avalara_sdk-24.12.0 vendor/bundle/ruby/2.7.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/param_part.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
faraday-multipart-1.1.0 lib/faraday/multipart/param_part.rb
moneykit-0.1.15 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.14 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.13 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.12 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.11 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.10 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.9 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
avalara_sdk-24.2.29 vendor/bundle/ruby/2.7.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.6 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.5 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.4 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.3 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.2 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb
moneykit-0.1.1 vendor/bundle/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/param_part.rb