esa 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +11 -1
- data/lib/esa/api_methods.rb +16 -1
- data/lib/esa/client.rb +16 -2
- data/lib/esa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31ac99673b27154dd0f51e26e9b2df21cc5ae9748836882d783fb20313844f60
|
|
4
|
+
data.tar.gz: ab2481808f8e74884def974efdcb432263917608e0e8effa6233eaff51eee09e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3bb3fddea7149f744e344eaf9113a67cf3cbf2032dbfa9b14255657909bb3172431f9d100170e788f5744eb7593eb617b93661b73cf9791b2c85aaf3e217e0e
|
|
7
|
+
data.tar.gz: e03f488a818d740f1a303512ec5c9871372313e66c3a656354f98aa7962b3be942b6d5ec2a510356b983a1ae76103b0b6623e26d0c2990a76e4d95ac642bdeca
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
## Unreleased
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Nothing
|
|
4
|
+
|
|
5
|
+
## 3.7.0 (2026-08-04)
|
|
6
|
+
|
|
7
|
+
- add: [Add create_attachment instead of upload_attachment](https://github.com/esaio/esa-ruby/pull/102)
|
|
8
|
+
- **deprecated**: `#upload_attachment` has been deprecated. Use `#create_attachment` instead.
|
|
9
|
+
- ci: [CI: Use latest bundler for ruby-head](https://github.com/esaio/esa-ruby/pull/103)
|
|
4
10
|
|
|
5
11
|
## 3.6.0 (2026-06-17)
|
|
6
12
|
|
data/README.md
CHANGED
|
@@ -202,7 +202,17 @@ client.create_emoji(code: 'alias_code', origin_code: 'team_emoji')
|
|
|
202
202
|
client.delete_emoji('team_emoji')
|
|
203
203
|
#=> DELETE /v1/teams/foobar/emojis/team_emoji
|
|
204
204
|
|
|
205
|
-
# Upload Attachment
|
|
205
|
+
# Upload Attachment
|
|
206
|
+
client.create_attachment('/Users/foo/Desktop/foo.png') # Path
|
|
207
|
+
client.create_attachment(File.open('/Users/foo/Desktop/foo.png')) # File
|
|
208
|
+
client.create_attachment('http://example.com/foo.png') # Remote URL
|
|
209
|
+
client.create_attachment(['http://example.com/foo.png', cookie_str]) # Remote URL + Cookie
|
|
210
|
+
client.create_attachment(['http://example.com/foo.png', headers_hash]) # Remote URL + Headers
|
|
211
|
+
client.create_attachment('/Users/foo/Desktop/foo.png', name: 'bar.png') # Path + Name
|
|
212
|
+
#=> POST /v1/teams/foobar/attachments
|
|
213
|
+
#=> { "attachment" => { "url" => "https://img.esa.io/uploads/...", "name" => "foo.png", "size" => 12345, "content_type" => "image/png" } }
|
|
214
|
+
|
|
215
|
+
# Upload Attachment(beta): deprecated, use create_attachment instead
|
|
206
216
|
client.upload_attachment('/Users/foo/Desktop/foo.png') # Path
|
|
207
217
|
client.upload_attachment(File.open('/Users/foo/Desktop/foo.png')) # File
|
|
208
218
|
client.upload_attachment('http://example.com/foo.png') # Remote URL
|
data/lib/esa/api_methods.rb
CHANGED
|
@@ -196,8 +196,23 @@ module Esa
|
|
|
196
196
|
end
|
|
197
197
|
end
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
def create_attachment(path_or_file_or_url, params = {}, headers = nil)
|
|
200
|
+
file = file_from(path_or_file_or_url)
|
|
201
|
+
content_type = params.delete(:content_type) || content_type_from_file(file) || 'application/octet-stream'
|
|
202
|
+
|
|
203
|
+
form_data = { file: Faraday::FilePart.new(file, content_type) }
|
|
204
|
+
form_data[:name] = params[:name] if params[:name]
|
|
205
|
+
|
|
206
|
+
send_multipart_post("/v1/teams/#{current_team!}/attachments", form_data, headers)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# deprecated: Use #create_attachment instead
|
|
200
210
|
def upload_attachment(path_or_file_or_url, params = {}, headers = nil)
|
|
211
|
+
unless @upload_attachment_deprecation_warned
|
|
212
|
+
warn '[DEPRECATION] `upload_attachment` is deprecated. Use `create_attachment` instead.'
|
|
213
|
+
@upload_attachment_deprecation_warned = true
|
|
214
|
+
end
|
|
215
|
+
|
|
201
216
|
file = file_from(path_or_file_or_url)
|
|
202
217
|
setup_params_for_upload(params, file)
|
|
203
218
|
|
data/lib/esa/client.rb
CHANGED
|
@@ -43,8 +43,12 @@ module Esa
|
|
|
43
43
|
send_request(:delete, path, params, headers)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
def
|
|
47
|
-
|
|
46
|
+
def send_multipart_post(path, params = nil, headers = nil)
|
|
47
|
+
send_request(:post, path, params, headers, connection: multipart_connection)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def send_request(method, path, params = nil, headers = nil, connection: esa_connection)
|
|
51
|
+
response = connection.send(method, path, params, headers)
|
|
48
52
|
raise TooManyRequestError if retry_on_rate_limit_exceeded && response.status == 429 # too_many_requests
|
|
49
53
|
Esa::Response.new(response)
|
|
50
54
|
rescue TooManyRequestError
|
|
@@ -71,6 +75,16 @@ module Esa
|
|
|
71
75
|
end
|
|
72
76
|
end
|
|
73
77
|
|
|
78
|
+
def multipart_connection
|
|
79
|
+
@multipart_connection ||= Faraday.new(faraday_options) do |c|
|
|
80
|
+
faraday_middlewares.each { |faraday_middleware| c.use faraday_middleware }
|
|
81
|
+
c.request :multipart
|
|
82
|
+
c.request :url_encoded
|
|
83
|
+
c.response :json
|
|
84
|
+
c.adapter Faraday.default_adapter
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
74
88
|
def s3_connection
|
|
75
89
|
@s3_connection ||= Faraday.new do |c|
|
|
76
90
|
faraday_middlewares.each { |faraday_middleware| c.use faraday_middleware }
|
data/lib/esa/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: esa
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- fukayatsu
|
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
201
201
|
- !ruby/object:Gem::Version
|
|
202
202
|
version: '0'
|
|
203
203
|
requirements: []
|
|
204
|
-
rubygems_version: 4.0.
|
|
204
|
+
rubygems_version: 4.0.16
|
|
205
205
|
specification_version: 4
|
|
206
206
|
summary: esa API v1 client library, written in Ruby
|
|
207
207
|
test_files: []
|