Class: Sink::Resources::Files

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Files

Returns a new instance of Files.

Parameters:



7
8
9
# File 'lib/sink/resources/files.rb', line 7

def initialize(client:)
  @client = client
end

Instance Method Details

#create_multipart(params = {}, opts = {}) ⇒ Sink::Models::FileCreateMultipartResponse

Endpoint for testing file uploads

Parameters:

  • params (Hash{Symbol => Object}) (defaults to: {})

    Attributes to send in this request. @option params [String] :file @option params [String] :purpose

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



20
21
22
23
24
25
26
27
28
29
# File 'lib/sink/resources/files.rb', line 20

def create_multipart(params = {}, opts = {})
  req = {
    method: :post,
    path: "/files/multipart",
    body: params,
    headers: {"Content-Type" => "multipart/form-data"},
    model: Sink::Models::FileCreateMultipartResponse
  }
  @client.request(req, opts)
end

#everything_multipart(params = {}, opts = {}) ⇒ Sink::Models::FileEverythingMultipartResponse

Endpoint for testing file uploads with all kinds of properties

Parameters:

  • params (Hash{Symbol => Object}) (defaults to: {})

    Attributes to send in this request. @option params [Boolean] :b @option params [Symbol, E] :e @option params [Float] :f @option params [String] :file @option params [Integer] :i @option params [String] :purpose @option params [String] :s

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



45
46
47
48
49
50
51
52
53
54
# File 'lib/sink/resources/files.rb', line 45

def everything_multipart(params = {}, opts = {})
  req = {
    method: :post,
    path: "/files/multipart_everything",
    body: params,
    headers: {"Content-Type" => "multipart/form-data"},
    model: Sink::Models::FileEverythingMultipartResponse
  }
  @client.request(req, opts)
end

#no_file_multipart(params = {}, opts = {}) ⇒ Sink::Models::FileNoFileMultipartResponse

Endpoint for multipart requests without a file parameter.

Parameters:

  • params (Hash{Symbol => Object}) (defaults to: {})

    Attributes to send in this request. @option params [String] :purpose

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



64
65
66
67
68
69
70
71
72
73
# File 'lib/sink/resources/files.rb', line 64

def no_file_multipart(params = {}, opts = {})
  req = {
    method: :post,
    path: "/files/no_file_multipart",
    body: params,
    headers: {"Content-Type" => "multipart/form-data"},
    model: Sink::Models::FileNoFileMultipartResponse
  }
  @client.request(req, opts)
end

#with_optional_param(params = {}, opts = {}) ⇒ Sink::Models::FileWithOptionalParamResponse

Multipart request with a required and an optional file request param.

Parameters:

  • params (Hash{Symbol => Object}) (defaults to: {})

    Attributes to send in this request. @option params [String] :image The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask

    is not provided, image must have transparency, which will be used as the mask.
    

    @option params [String] :prompt A text description of the desired image(s). The maximum length is 1000

    characters.
    

    @option params [String, nil] :mask An additional image whose fully transparent areas (e.g. where alpha is zero)

    indicate where `image` should be edited. Must be a valid PNG file, less than
    4MB, and have the same dimensions as `image`.
    
  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



89
90
91
92
93
94
95
96
97
98
# File 'lib/sink/resources/files.rb', line 89

def with_optional_param(params = {}, opts = {})
  req = {
    method: :post,
    path: "/files/with_optional_param",
    body: params,
    headers: {"Content-Type" => "multipart/form-data"},
    model: Sink::Models::FileWithOptionalParamResponse
  }
  @client.request(req, opts)
end