Class: Stripe::File
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::File
- Extended by:
- APIOperations::Create, APIOperations::List
- Defined in:
- lib/stripe/resources/file.rb
Overview
This object represents files hosted on Stripe’s servers. You can upload files with the [create file](stripe.com/docs/api#create_file) request (for example, when uploading dispute evidence). Stripe also creates files independently (for example, the results of a [Sigma scheduled query](stripe.com/docs/api#scheduled_queries)).
Related guide: [File upload guide](stripe.com/docs/file-upload)
Constant Summary collapse
- OBJECT_NAME =
"file"
- OBJECT_NAME_ALT =
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.
"file_upload"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
To upload a file to Stripe, you need to send a request of type multipart/form-data.
-
.list(filters = {}, opts = {}) ⇒ Object
Returns a list of the files that your account has access to.
- .object_name ⇒ Object
- .object_name_alt ⇒ Object
- .resource_url ⇒ Object
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, #resource_url, retrieve, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
To upload a file to Stripe, you need to send a request of type multipart/form-data. Include the file you want to upload in the request, and the parameters for creating a file.
All of Stripe’s officially supported Client libraries support sending multipart/form-data.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/stripe/resources/file.rb', line 24 def self.create(params = {}, opts = {}) if params[:file] && !params[:file].is_a?(String) && !params[:file].respond_to?(:read) raise ArgumentError, "file must respond to `#read`" end opts = { content_type: MultipartEncoder::MULTIPART_FORM_DATA }.merge(Util.normalize_opts(opts)) request_stripe_object( method: :post, path: "/v1/files", params: params, opts: opts, base_address: :files ) end |
.list(filters = {}, opts = {}) ⇒ Object
Returns a list of the files that your account has access to. Stripe sorts and returns the files by their creation dates, placing the most recently created files at the top.
41 42 43 |
# File 'lib/stripe/resources/file.rb', line 41 def self.list(filters = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/files", params: filters, opts: opts) end |
.object_name ⇒ Object
17 18 19 |
# File 'lib/stripe/resources/file.rb', line 17 def self.object_name "file" end |
.object_name_alt ⇒ Object
50 51 52 |
# File 'lib/stripe/resources/file.rb', line 50 def self.object_name_alt "file_upload" end |
.resource_url ⇒ Object
54 55 56 |
# File 'lib/stripe/resources/file.rb', line 54 def self.resource_url "/v1/files" end |