Sha256: b22aa7bf0073087b14694ca04554fdd4cb48372ad26dad5e9ffa2f9d48981991

Contents?: true

Size: 877 Bytes

Versions: 15

Compression:

Stored size: 877 Bytes

Contents

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

    OBJECT_NAME = 'file_upload'

    def self.resource_url
      "/v1/files"
    end

    def self.request(method, url, params={}, opts={})
      opts = {
        :api_base => Stripe::uploads_base
      }.merge(Util.normalize_opts(opts))
      super
    end

    def self.create(params={}, opts={})
      # rest-client would accept a vanilla `File` for upload, but Faraday does
      # not. Support the old API by wrapping a `File` with an `UploadIO` object
      # if we're given one.
      if params[:file] && params[:file].is_a?(File)
        params[:file] = Faraday::UploadIO.new(params[:file], nil)
      end

      opts = {
        :content_type => 'multipart/form-data',
      }.merge(Util.normalize_opts(opts))
      super
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
stripe-3.3.2 lib/stripe/file_upload.rb
stripe-3.3.1 lib/stripe/file_upload.rb
stripe-3.3.0 lib/stripe/file_upload.rb
stripe-3.2.0 lib/stripe/file_upload.rb
stripe-3.1.0 lib/stripe/file_upload.rb
stripe-3.0.3 lib/stripe/file_upload.rb
stripe-3.0.1 lib/stripe/file_upload.rb
stripe-3.0.0 lib/stripe/file_upload.rb
stripe-2.12.0 lib/stripe/file_upload.rb
stripe-2.11.0 lib/stripe/file_upload.rb
stripe-2.10.0 lib/stripe/file_upload.rb
stripe-2.9.0 lib/stripe/file_upload.rb
stripe-2.8.0 lib/stripe/file_upload.rb
stripe-2.7.0 lib/stripe/file_upload.rb
stripe-2.6.0 lib/stripe/file_upload.rb