Sha256: 88ea7b1227780d8e0dbe08d96ff16238e8abde41be0817d04a611032c2636121

Contents?: true

Size: 987 Bytes

Versions: 10

Compression:

Stored size: 987 Bytes

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

      opts = {
        api_base: Stripe.uploads_base,
        content_type: MultipartEncoder::MULTIPART_FORM_DATA,
      }.merge(Util.normalize_opts(opts))
      super
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
stripe-5.30.0 lib/stripe/resources/file.rb
stripe-5.29.1 lib/stripe/resources/file.rb
stripe-5.29.0 lib/stripe/resources/file.rb
stripe-5.28.0 lib/stripe/resources/file.rb
stripe-5.27.0 lib/stripe/resources/file.rb
stripe-5.26.0 lib/stripe/resources/file.rb
stripe-5.25.0 lib/stripe/resources/file.rb
stripe-5.24.0 lib/stripe/resources/file.rb
stripe-5.23.1 lib/stripe/resources/file.rb
stripe-5.23.0 lib/stripe/resources/file.rb