Sha256: d5a439eb56a4b0f501ae07e3ae8b5502768ec7463fb7cfca83496947544b5de0

Contents?: true

Size: 1.02 KB

Versions: 36

Compression:

Stored size: 1.02 KB

Contents

# File generated from our OpenAPI spec
# frozen_string_literal: true

module Stripe
  class File < APIResource
    extend Stripe::APIOperations::Create
    extend Stripe::APIOperations::List

    OBJECT_NAME = "file"

    # This resource can have two different object names. In latter API
    # versions, only `file` is used, but since stripe-ruby may be used with
    # any API version, we need to support deserializing the older
    # `file_upload` object into the same class.
    OBJECT_NAME_ALT = "file_upload"

    def self.resource_url
      "/v1/files"
    end

    def self.create(params = {}, opts = {})
      if params[:file] && !params[:file].is_a?(String)
        unless params[:file].respond_to?(:read)
          raise ArgumentError, "file must respond to `#read`"
        end
      end

      config = opts[:client]&.config || Stripe.config
      opts = {
        api_base: config.uploads_base,
        content_type: MultipartEncoder::MULTIPART_FORM_DATA,
      }.merge(Util.normalize_opts(opts))
      super
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
stripe-7.1.0 lib/stripe/resources/file.rb
stripe-7.1.0.pre.beta.2 lib/stripe/resources/file.rb
stripe-7.1.0.pre.beta.1 lib/stripe/resources/file.rb
stripe-7.0.0 lib/stripe/resources/file.rb
stripe-6.6.0.pre.beta.1 lib/stripe/resources/file.rb
stripe-6.5.0 lib/stripe/resources/file.rb
stripe-6.4.0 lib/stripe/resources/file.rb
stripe-6.3.0 lib/stripe/resources/file.rb
stripe-6.2.0 lib/stripe/resources/file.rb
stripe-6.1.0 lib/stripe/resources/file.rb
stripe-6.0.0 lib/stripe/resources/file.rb
stripe-5.55.0 lib/stripe/resources/file.rb
stripe-5.54.0 lib/stripe/resources/file.rb
stripe-5.53.0 lib/stripe/resources/file.rb
stripe-5.52.0 lib/stripe/resources/file.rb
stripe-5.50.0 lib/stripe/resources/file.rb
stripe-5.49.0 lib/stripe/resources/file.rb
stripe-5.48.0 lib/stripe/resources/file.rb
stripe-5.47.0 lib/stripe/resources/file.rb
stripe-5.46.0 lib/stripe/resources/file.rb