-
Notifications
You must be signed in to change notification settings - Fork 537
/
file.rb
36 lines (30 loc) · 1.02 KB
/
file.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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.configuration
opts = {
api_base: config.uploads_base,
content_type: MultipartEncoder::MULTIPART_FORM_DATA,
}.merge(Util.normalize_opts(opts))
super
end
end
end