Class: Stripe::FileService
- Inherits:
-
StripeService
- Object
- StripeService
- Stripe::FileService
- Defined in:
- lib/stripe/services/file_service.rb
Defined Under Namespace
Classes: CreateParams, ListParams, RetrieveParams
Instance 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(params = {}, opts = {}) ⇒ Object
Returns a list of the files that your account has access to.
-
#retrieve(file, params = {}, opts = {}) ⇒ Object
Retrieves the details of an existing file object.
Methods inherited from StripeService
#initialize, #request, #request_stream
Constructor Details
This class inherits a constructor from Stripe::StripeService
Instance 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.
98 99 100 101 102 103 104 105 106 |
# File 'lib/stripe/services/file_service.rb', line 98 def 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(method: :post, path: "/v1/files", params: params, opts: opts, base_address: :files) end |
#list(params = {}, 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.
109 110 111 |
# File 'lib/stripe/services/file_service.rb', line 109 def list(params = {}, opts = {}) request(method: :get, path: "/v1/files", params: params, opts: opts, base_address: :api) end |
#retrieve(file, params = {}, opts = {}) ⇒ Object
Retrieves the details of an existing file object. After you supply a unique file ID, Stripe returns the corresponding file object. Learn how to [access file contents](stripe.com/docs/file-upload#download-file-contents).
114 115 116 117 118 119 120 121 122 |
# File 'lib/stripe/services/file_service.rb', line 114 def retrieve(file, params = {}, opts = {}) request( method: :get, path: format("/v1/files/%<file>s", { file: CGI.escape(file) }), params: params, opts: opts, base_address: :api ) end |