Class: Increase::Resources::Files

Inherits:
Object
  • Object
show all
Defined in:
lib/increase/resources/files.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Files

Returns a new instance of Files.



6
7
8
# File 'lib/increase/resources/files.rb', line 6

def initialize(client:)
  @client = client
end

Instance Method Details

#create(params = {}, opts = {}) ⇒ Increase::Models::File

To upload a file to Increase, you'll need to send a request of Content-Type multipart/form-data. The request should contain the file you would like to upload, as well as the parameters for creating a file.

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :file (String)

    The file contents. This should follow the specifications of RFC 7578 which defines file transfers for the multipart/form-data protocol.

  • :purpose (Symbol)

    What the File will be used for in Increase's systems.

  • :description (String)

    The description you choose to give the File.

Returns:



24
25
26
27
28
29
30
31
# File 'lib/increase/resources/files.rb', line 24

def create(params = {}, opts = {})
  req = {}
  req[:method] = :post
  req[:path] = "/files"
  req[:body] = params
  req[:model] = Increase::Models::File
  @client.request(req, opts)
end

#list(params = {}, opts = {}) ⇒ Increase::Page<Increase::Models::File>

List Files

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :created_at (CreatedAt)
  • :cursor (String)

    Return the page of entries after this one.

  • :idempotency_key (String)

    Filter records to the one with the specified idempotency_key you chose for that object. This value is unique across Increase and is used to ensure that a request is only processed once. Learn more about idempotency.

  • :limit (Integer)

    Limit the size of the list that is returned. The default (and maximum) is 100 objects.

  • :purpose (Purpose)

Returns:



63
64
65
66
67
68
69
70
71
# File 'lib/increase/resources/files.rb', line 63

def list(params = {}, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/files"
  req[:query] = params
  req[:page] = Increase::Page
  req[:model] = Increase::Models::File
  @client.request(req, opts)
end

#retrieve(file_id, opts = {}) ⇒ Increase::Models::File

Retrieve a File

Parameters:

  • file_id (String)

    The identifier of the File.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



39
40
41
42
43
44
45
# File 'lib/increase/resources/files.rb', line 39

def retrieve(file_id, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/files/#{file_id}"
  req[:model] = Increase::Models::File
  @client.request(req, opts)
end