Skip to content

Commit c64d558

Browse files
feat(api): manual updates
1 parent a4ed0df commit c64d558

File tree

10 files changed

+43
-57
lines changed

10 files changed

+43
-57
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml
3-
openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-eab9713fd85da68b41e881dfd9cd71f654e8620132da2023bab7dd01e5f7852e.yml
3+
openapi_spec_hash: b5037b26fbe7360c6bfaf9947a65bb85
44
config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c

README.md

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ image_kit = Imagekit::Client.new(
3333
password: ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"] # This is the default and can be omitted
3434
)
3535

36-
response = image_kit.files.upload(
37-
file: StringIO.new("https://www.example.com/public-url.jpg"),
38-
file_name: "file-name.jpg"
39-
)
36+
response = image_kit.files.upload(file: "https://www.example.com/public-url.jpg", file_name: "file-name.jpg")
4037

4138
puts(response.videoCodec)
4239
```
@@ -49,14 +46,14 @@ Request parameters that correspond to file uploads can be passed as raw contents
4946
require "pathname"
5047

5148
# Use `Pathname` to send the filename and/or avoid paging a large file into memory:
52-
response = image_kit.files.upload(file: Pathname("/path/to/file"))
49+
response = image_kit.beta.v2.files.upload(file: Pathname("/path/to/file"))
5350

5451
# Alternatively, pass file contents or a `StringIO` directly:
55-
response = image_kit.files.upload(file: File.read("/path/to/file"))
52+
response = image_kit.beta.v2.files.upload(file: File.read("/path/to/file"))
5653

5754
# Or, to control the filename and/or content type:
5855
file = Imagekit::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "")
59-
response = image_kit.files.upload(file: file)
56+
response = image_kit.beta.v2.files.upload(file: file)
6057

6158
puts(response.videoCodec)
6259
```
@@ -69,10 +66,7 @@ When the library is unable to connect to the API, or if the API returns a non-su
6966

7067
```ruby
7168
begin
72-
file = image_kit.files.upload(
73-
file: StringIO.new("https://www.example.com/public-url.jpg"),
74-
file_name: "file-name.jpg"
75-
)
69+
file = image_kit.files.upload(file: "https://www.example.com/public-url.jpg", file_name: "file-name.jpg")
7670
rescue Imagekit::Errors::APIConnectionError => e
7771
puts("The server could not be reached")
7872
puts(e.cause) # an underlying Exception, likely raised within `net/http`
@@ -116,7 +110,7 @@ image_kit = Imagekit::Client.new(
116110

117111
# Or, configure per-request:
118112
image_kit.files.upload(
119-
file: StringIO.new("https://www.example.com/public-url.jpg"),
113+
file: "https://www.example.com/public-url.jpg",
120114
file_name: "file-name.jpg",
121115
request_options: {max_retries: 5}
122116
)
@@ -134,7 +128,7 @@ image_kit = Imagekit::Client.new(
134128

135129
# Or, configure per-request:
136130
image_kit.files.upload(
137-
file: StringIO.new("https://www.example.com/public-url.jpg"),
131+
file: "https://www.example.com/public-url.jpg",
138132
file_name: "file-name.jpg",
139133
request_options: {timeout: 5}
140134
)
@@ -169,7 +163,7 @@ Note: the `extra_` parameters of the same name overrides the documented paramete
169163
```ruby
170164
response =
171165
image_kit.files.upload(
172-
file: StringIO.new("https://www.example.com/public-url.jpg"),
166+
file: "https://www.example.com/public-url.jpg",
173167
file_name: "file-name.jpg",
174168
request_options: {
175169
extra_query: {my_query_parameter: value},
@@ -216,26 +210,17 @@ This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitio
216210
You can provide typesafe request parameters like so:
217211

218212
```ruby
219-
image_kit.files.upload(
220-
file: StringIO.new("https://www.example.com/public-url.jpg"),
221-
file_name: "file-name.jpg"
222-
)
213+
image_kit.files.upload(file: "https://www.example.com/public-url.jpg", file_name: "file-name.jpg")
223214
```
224215

225216
Or, equivalently:
226217

227218
```ruby
228219
# Hashes work, but are not typesafe:
229-
image_kit.files.upload(
230-
file: StringIO.new("https://www.example.com/public-url.jpg"),
231-
file_name: "file-name.jpg"
232-
)
220+
image_kit.files.upload(file: "https://www.example.com/public-url.jpg", file_name: "file-name.jpg")
233221

234222
# You can also splat a full Params class:
235-
params = Imagekit::FileUploadParams.new(
236-
file: StringIO.new("https://www.example.com/public-url.jpg"),
237-
file_name: "file-name.jpg"
238-
)
223+
params = Imagekit::FileUploadParams.new(file: "https://www.example.com/public-url.jpg", file_name: "file-name.jpg")
239224
image_kit.files.upload(**params)
240225
```
241226

lib/imagekit/models/file_upload_params.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class FileUploadParams < Imagekit::Internal::Type::BaseModel
1818
# When supplying a URL, the server must receive the response headers within 8
1919
# seconds; otherwise the request fails with 400 Bad Request.
2020
#
21-
# @return [Pathname, StringIO, IO, String, Imagekit::FilePart]
22-
required :file, Imagekit::Internal::Type::FileInput
21+
# @return [String]
22+
required :file, String
2323

2424
# @!attribute file_name
2525
# The name with which the file has to be uploaded. The file name can contain:
@@ -240,7 +240,7 @@ class FileUploadParams < Imagekit::Internal::Type::BaseModel
240240
# Some parameter documentations has been truncated, see
241241
# {Imagekit::Models::FileUploadParams} for more details.
242242
#
243-
# @param file [Pathname, StringIO, IO, String, Imagekit::FilePart] The API accepts any of the following:
243+
# @param file [String] The API accepts any of the following:
244244
#
245245
# @param file_name [String] The name with which the file has to be uploaded.
246246
#

lib/imagekit/resources/files.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def rename(params)
221221
#
222222
# @overload upload(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, expire: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, public_key: nil, response_fields: nil, signature: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {})
223223
#
224-
# @param file [Pathname, StringIO, IO, String, Imagekit::FilePart] The API accepts any of the following:
224+
# @param file [String] The API accepts any of the following:
225225
#
226226
# @param file_name [String] The name with which the file has to be uploaded.
227227
#

rbi/imagekit/models/file_upload_params.rbi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module Imagekit
2020
#
2121
# When supplying a URL, the server must receive the response headers within 8
2222
# seconds; otherwise the request fails with 400 Bad Request.
23-
sig { returns(Imagekit::Internal::FileInput) }
23+
sig { returns(String) }
2424
attr_accessor :file
2525

2626
# The name with which the file has to be uploaded. The file name can contain:
@@ -290,7 +290,7 @@ module Imagekit
290290

291291
sig do
292292
params(
293-
file: Imagekit::Internal::FileInput,
293+
file: String,
294294
file_name: String,
295295
token: String,
296296
checks: String,
@@ -462,7 +462,7 @@ module Imagekit
462462
sig do
463463
override.returns(
464464
{
465-
file: Imagekit::Internal::FileInput,
465+
file: String,
466466
file_name: String,
467467
token: String,
468468
checks: String,

rbi/imagekit/resources/files.rbi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ module Imagekit
189189
# technologies.
190190
sig do
191191
params(
192-
file: Imagekit::Internal::FileInput,
192+
file: String,
193193
file_name: String,
194194
token: String,
195195
checks: String,

sig/imagekit/models/file_upload_params.rbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Imagekit
22
module Models
33
type file_upload_params =
44
{
5-
file: Imagekit::Internal::file_input,
5+
file: String,
66
file_name: String,
77
token: String,
88
checks: String,
@@ -32,7 +32,7 @@ module Imagekit
3232
extend Imagekit::Internal::Type::RequestParameters::Converter
3333
include Imagekit::Internal::Type::RequestParameters
3434

35-
attr_accessor file: Imagekit::Internal::file_input
35+
attr_accessor file: String
3636

3737
attr_accessor file_name: String
3838

@@ -127,7 +127,7 @@ module Imagekit
127127
def webhook_url=: (String) -> String
128128

129129
def initialize: (
130-
file: Imagekit::Internal::file_input,
130+
file: String,
131131
file_name: String,
132132
?token: String,
133133
?checks: String,
@@ -154,7 +154,7 @@ module Imagekit
154154
) -> void
155155

156156
def to_hash: -> {
157-
file: Imagekit::Internal::file_input,
157+
file: String,
158158
file_name: String,
159159
token: String,
160160
checks: String,

sig/imagekit/resources/files.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module Imagekit
4444
) -> Imagekit::Models::FileRenameResponse
4545

4646
def upload: (
47-
file: Imagekit::Internal::file_input,
47+
file: String,
4848
file_name: String,
4949
?token: String,
5050
?checks: String,

test/imagekit/client_test.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_client_default_request_default_retry_attempts
4545
)
4646

4747
assert_raises(Imagekit::Errors::InternalServerError) do
48-
image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName")
48+
image_kit.files.upload(file: "https://www.example.com/path/to-image.jpg", file_name: "fileName")
4949
end
5050

5151
assert_requested(:any, /./, times: 3)
@@ -63,7 +63,7 @@ def test_client_given_request_default_retry_attempts
6363
)
6464

6565
assert_raises(Imagekit::Errors::InternalServerError) do
66-
image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName")
66+
image_kit.files.upload(file: "https://www.example.com/path/to-image.jpg", file_name: "fileName")
6767
end
6868

6969
assert_requested(:any, /./, times: 4)
@@ -81,7 +81,7 @@ def test_client_default_request_given_retry_attempts
8181

8282
assert_raises(Imagekit::Errors::InternalServerError) do
8383
image_kit.files.upload(
84-
file: Pathname(__FILE__),
84+
file: "https://www.example.com/path/to-image.jpg",
8585
file_name: "fileName",
8686
request_options: {max_retries: 3}
8787
)
@@ -103,7 +103,7 @@ def test_client_given_request_given_retry_attempts
103103

104104
assert_raises(Imagekit::Errors::InternalServerError) do
105105
image_kit.files.upload(
106-
file: Pathname(__FILE__),
106+
file: "https://www.example.com/path/to-image.jpg",
107107
file_name: "fileName",
108108
request_options: {max_retries: 4}
109109
)
@@ -128,7 +128,7 @@ def test_client_retry_after_seconds
128128
)
129129

130130
assert_raises(Imagekit::Errors::InternalServerError) do
131-
image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName")
131+
image_kit.files.upload(file: "https://www.example.com/path/to-image.jpg", file_name: "fileName")
132132
end
133133

134134
assert_requested(:any, /./, times: 2)
@@ -152,7 +152,7 @@ def test_client_retry_after_date
152152

153153
assert_raises(Imagekit::Errors::InternalServerError) do
154154
Thread.current.thread_variable_set(:time_now, Time.now)
155-
image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName")
155+
image_kit.files.upload(file: "https://www.example.com/path/to-image.jpg", file_name: "fileName")
156156
Thread.current.thread_variable_set(:time_now, nil)
157157
end
158158

@@ -176,7 +176,7 @@ def test_client_retry_after_ms
176176
)
177177

178178
assert_raises(Imagekit::Errors::InternalServerError) do
179-
image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName")
179+
image_kit.files.upload(file: "https://www.example.com/path/to-image.jpg", file_name: "fileName")
180180
end
181181

182182
assert_requested(:any, /./, times: 2)
@@ -194,7 +194,7 @@ def test_retry_count_header
194194
)
195195

196196
assert_raises(Imagekit::Errors::InternalServerError) do
197-
image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName")
197+
image_kit.files.upload(file: "https://www.example.com/path/to-image.jpg", file_name: "fileName")
198198
end
199199

200200
3.times do
@@ -214,7 +214,7 @@ def test_omit_retry_count_header
214214

215215
assert_raises(Imagekit::Errors::InternalServerError) do
216216
image_kit.files.upload(
217-
file: Pathname(__FILE__),
217+
file: "https://www.example.com/path/to-image.jpg",
218218
file_name: "fileName",
219219
request_options: {extra_headers: {"x-stainless-retry-count" => nil}}
220220
)
@@ -237,7 +237,7 @@ def test_overwrite_retry_count_header
237237

238238
assert_raises(Imagekit::Errors::InternalServerError) do
239239
image_kit.files.upload(
240-
file: Pathname(__FILE__),
240+
file: "https://www.example.com/path/to-image.jpg",
241241
file_name: "fileName",
242242
request_options: {extra_headers: {"x-stainless-retry-count" => "42"}}
243243
)
@@ -266,7 +266,7 @@ def test_client_redirect_307
266266

267267
assert_raises(Imagekit::Errors::APIConnectionError) do
268268
image_kit.files.upload(
269-
file: Pathname(__FILE__),
269+
file: "https://www.example.com/path/to-image.jpg",
270270
file_name: "fileName",
271271
request_options: {extra_headers: {}}
272272
)
@@ -304,7 +304,7 @@ def test_client_redirect_303
304304

305305
assert_raises(Imagekit::Errors::APIConnectionError) do
306306
image_kit.files.upload(
307-
file: Pathname(__FILE__),
307+
file: "https://www.example.com/path/to-image.jpg",
308308
file_name: "fileName",
309309
request_options: {extra_headers: {}}
310310
)
@@ -337,7 +337,7 @@ def test_client_redirect_auth_keep_same_origin
337337

338338
assert_raises(Imagekit::Errors::APIConnectionError) do
339339
image_kit.files.upload(
340-
file: Pathname(__FILE__),
340+
file: "https://www.example.com/path/to-image.jpg",
341341
file_name: "fileName",
342342
request_options: {extra_headers: {"authorization" => "Bearer xyz"}}
343343
)
@@ -373,7 +373,7 @@ def test_client_redirect_auth_strip_cross_origin
373373

374374
assert_raises(Imagekit::Errors::APIConnectionError) do
375375
image_kit.files.upload(
376-
file: Pathname(__FILE__),
376+
file: "https://www.example.com/path/to-image.jpg",
377377
file_name: "fileName",
378378
request_options: {extra_headers: {"authorization" => "Bearer xyz"}}
379379
)
@@ -395,7 +395,7 @@ def test_default_headers
395395
password: "My Password"
396396
)
397397

398-
image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName")
398+
image_kit.files.upload(file: "https://www.example.com/path/to-image.jpg", file_name: "fileName")
399399

400400
assert_requested(:any, /./) do |req|
401401
headers = req.headers.transform_keys(&:downcase).fetch_values("accept", "content-type")

test/imagekit/resources/files_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def test_rename_required_params
113113
def test_upload_required_params
114114
skip("Prism tests are disabled")
115115

116-
response = @image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName")
116+
response =
117+
@image_kit.files.upload(file: "https://www.example.com/path/to-image.jpg", file_name: "fileName")
117118

118119
assert_pattern do
119120
response => Imagekit::Models::FileUploadResponse

0 commit comments

Comments
 (0)