4me-sdk 2.0.0.pre.rc.1 → 2.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c4c1ac14f3525802639a4aa78223d0635533ffee6527fed0a02e9f8b41aca54
4
- data.tar.gz: 5e8b18fa02b940a0883b2ed6349a619cda9048201c87c4d953f53e373e64d88f
3
+ metadata.gz: b1e79341f006b8b4c2b7298c9d5e571acfaaa0c405e4b19b33357385935f805d
4
+ data.tar.gz: 1560ad1534d1b0a57d57de3f980be7e2d3c6892cb98950e9ad597eee70da68d5
5
5
  SHA512:
6
- metadata.gz: 5e0752a3cac273d81a7cafa7d43ca5a69088db6143418a9bb70b6a95f1111db422d8eb03d8f669f5d74efd1f0e05d2004f284f21e173605da0f4f3fcb601d62b
7
- data.tar.gz: 41079af50a9db8a791614849197a5d5aee2049d1b2f9900c345802ff1a6439869f86f9f341309883cfe2c0233c590f352b1ef4c9f5ba81f4cf7506183d95c139
6
+ metadata.gz: 3ae58f939ad53857fc35676818476bfefdc57ca687f70958a792bb15297e2e18068ed320347f9c80d506a49bcb3a307459c2b1338e1afc75d76694609c180db5
7
+ data.tar.gz: 3becf25a73045be2c246ac1903443e6418d4c8ac196e4f537e6bba4863dccd903478728d6438901263a529565fdba4ecbea781e5e083ca31df1ba3cf34445152
data/4me-sdk.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_runtime_dependency 'gem_config', '>=0.3'
31
31
  spec.add_runtime_dependency 'mime-types', '>= 3.0'
32
32
 
33
- spec.add_development_dependency 'bundler', '~> 1'
33
+ spec.add_development_dependency 'bundler'
34
34
  spec.add_development_dependency 'rake', '~> 12'
35
35
  spec.add_development_dependency 'rspec', '~> 3.3'
36
36
  spec.add_development_dependency 'rubocop', '>= 0.49.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- 4me-sdk (2.0.0.pre.rc.1)
4
+ 4me-sdk (2.0.1)
5
5
  activesupport (>= 4.2)
6
6
  gem_config (>= 0.3)
7
7
  mime-types (>= 3.0)
@@ -9,80 +9,82 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.0.3.4)
12
+ activesupport (6.1.3)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- zeitwerk (~> 2.2, >= 2.2.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
18
  addressable (2.7.0)
19
19
  public_suffix (>= 2.0.2, < 5.0)
20
- ast (2.4.1)
21
- concurrent-ruby (1.1.7)
22
- crack (0.4.4)
20
+ ast (2.4.2)
21
+ concurrent-ruby (1.1.8)
22
+ crack (0.4.5)
23
+ rexml
23
24
  diff-lcs (1.4.4)
24
- docile (1.3.2)
25
+ docile (1.3.5)
25
26
  gem_config (0.3.2)
26
27
  hashdiff (1.0.1)
27
- i18n (1.8.5)
28
+ i18n (1.8.9)
28
29
  concurrent-ruby (~> 1.0)
29
30
  mime-types (3.3.1)
30
31
  mime-types-data (~> 3.2015)
31
- mime-types-data (3.2020.1104)
32
- minitest (5.14.2)
33
- parallel (1.19.2)
34
- parser (2.7.2.0)
32
+ mime-types-data (3.2021.0225)
33
+ minitest (5.14.4)
34
+ parallel (1.20.1)
35
+ parser (3.0.0.0)
35
36
  ast (~> 2.4.1)
36
37
  public_suffix (4.0.6)
37
38
  rainbow (3.0.0)
38
39
  rake (12.3.3)
39
- regexp_parser (1.8.2)
40
+ regexp_parser (2.1.1)
40
41
  rexml (3.2.4)
41
42
  rspec (3.10.0)
42
43
  rspec-core (~> 3.10.0)
43
44
  rspec-expectations (~> 3.10.0)
44
45
  rspec-mocks (~> 3.10.0)
45
- rspec-core (3.10.0)
46
+ rspec-core (3.10.1)
46
47
  rspec-support (~> 3.10.0)
47
- rspec-expectations (3.10.0)
48
+ rspec-expectations (3.10.1)
48
49
  diff-lcs (>= 1.2.0, < 2.0)
49
50
  rspec-support (~> 3.10.0)
50
- rspec-mocks (3.10.0)
51
+ rspec-mocks (3.10.2)
51
52
  diff-lcs (>= 1.2.0, < 2.0)
52
53
  rspec-support (~> 3.10.0)
53
- rspec-support (3.10.0)
54
- rubocop (0.93.1)
54
+ rspec-support (3.10.2)
55
+ rubocop (1.11.0)
55
56
  parallel (~> 1.10)
56
- parser (>= 2.7.1.5)
57
+ parser (>= 3.0.0.0)
57
58
  rainbow (>= 2.2.2, < 4.0)
58
- regexp_parser (>= 1.8)
59
+ regexp_parser (>= 1.8, < 3.0)
59
60
  rexml
60
- rubocop-ast (>= 0.6.0)
61
+ rubocop-ast (>= 1.2.0, < 2.0)
61
62
  ruby-progressbar (~> 1.7)
62
- unicode-display_width (>= 1.4.0, < 2.0)
63
- rubocop-ast (1.1.1)
63
+ unicode-display_width (>= 1.4.0, < 3.0)
64
+ rubocop-ast (1.4.1)
64
65
  parser (>= 2.7.1.5)
65
- ruby-progressbar (1.10.1)
66
- simplecov (0.19.1)
66
+ ruby-progressbar (1.11.0)
67
+ simplecov (0.21.2)
67
68
  docile (~> 1.1)
68
69
  simplecov-html (~> 0.11)
70
+ simplecov_json_formatter (~> 0.1)
69
71
  simplecov-html (0.12.3)
70
- thread_safe (0.3.6)
71
- tzinfo (1.2.7)
72
- thread_safe (~> 0.1)
73
- unicode-display_width (1.7.0)
74
- webmock (3.9.4)
72
+ simplecov_json_formatter (0.1.2)
73
+ tzinfo (2.0.4)
74
+ concurrent-ruby (~> 1.0)
75
+ unicode-display_width (2.0.0)
76
+ webmock (3.12.1)
75
77
  addressable (>= 2.3.6)
76
78
  crack (>= 0.3.2)
77
79
  hashdiff (>= 0.4.0, < 2.0.0)
78
- zeitwerk (2.4.1)
80
+ zeitwerk (2.4.2)
79
81
 
80
82
  PLATFORMS
81
- ruby
83
+ x86_64-darwin-19
82
84
 
83
85
  DEPENDENCIES
84
86
  4me-sdk!
85
- bundler (~> 1)
87
+ bundler
86
88
  rake (~> 12)
87
89
  rspec (~> 3.3)
88
90
  rubocop (>= 0.49.0)
@@ -90,4 +92,4 @@ DEPENDENCIES
90
92
  webmock (~> 3)
91
93
 
92
94
  BUNDLED WITH
93
- 1.16.6
95
+ 2.2.14
data/lib/sdk4me/client.rb CHANGED
@@ -216,9 +216,8 @@ module Sdk4me
216
216
  request
217
217
  end
218
218
 
219
- URI_ESCAPE_PATTERN = Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")
220
219
  def uri_escape(value)
221
- URI.escape(value, URI_ESCAPE_PATTERN).gsub('.', '%2E')
220
+ URI.encode_www_form_component(value).gsub('+', '%20').gsub('.', '%2E')
222
221
  end
223
222
 
224
223
  # Expand the given header with the default header
@@ -32,7 +32,7 @@ module Sdk4me
32
32
  # data = {
33
33
  # note: "Hello ![](storage/abc/adjhajdhjaadf.png) and ![](storage/abc/fskdhakjfkjdssdf.png])",
34
34
  # note_attachments: [
35
- # { key: 'storage/abc/fskdhakjfkjdssdf.png', filesize: 12345, inline: true },
35
+ # { key: 'storage/abc/adjhajdhjaadf.png', filesize: 12345, inline: true },
36
36
  # { key: 'storage/abc/fskdhakjfkjdssdf.png'], filesize: 98765, inline: true }
37
37
  # ],
38
38
  # ...
@@ -97,11 +97,11 @@ module Sdk4me
97
97
  key_template = storage[provider][:key]
98
98
  key = key_template.sub(FILENAME_TEMPLATE, File.basename(attachment.path))
99
99
 
100
- if provider == S3_PROVIDER
101
- upload_to_s3(key, attachment)
102
- else
103
- upload_to_4me_local(key, attachment)
104
- end
100
+ key = if provider == S3_PROVIDER
101
+ upload_to_s3(key, attachment)
102
+ else
103
+ upload_to_4me_local(key, attachment)
104
+ end
105
105
 
106
106
  # return the values for the attachments param
107
107
  { key: key, filesize: File.size(attachment.path) }
@@ -118,6 +118,8 @@ module Sdk4me
118
118
  xml = response.body || ''
119
119
  error = xml[%r{<Error>.*<Message>(.*)</Message>.*</Error>}, 1]
120
120
  raise "AWS S3 upload to #{uri} for #{key} failed: #{error}" if error
121
+
122
+ xml[%r{<Key>(.*)</Key>}, 1]
121
123
  end
122
124
 
123
125
  # Upload the file directly to 4me local storage
@@ -125,6 +127,8 @@ module Sdk4me
125
127
  uri = storage[:upload_uri]
126
128
  response = send_file(uri, storage[:local].merge({ file: attachment }), @client.send(:expand_header))
127
129
  raise "4me upload to #{uri} for #{key} failed: #{response.message}" unless response.valid?
130
+
131
+ JSON.parse(response.body)['key']
128
132
  end
129
133
 
130
134
  def send_file(uri, params, basic_auth_header = {})
@@ -66,7 +66,8 @@ module Sdk4me
66
66
  def to_multipart
67
67
  # If we can tell the possible mime-type from the filename, use the first in the list; otherwise, use "application/octet-stream"
68
68
  mime_type = MIME::Types.type_for(filename)[0] || MIME::Types['application/octet-stream'][0]
69
- %(Content-Disposition: form-data; name="#{CGI.escape(k.to_s)}"; filename="#{filename}"\r\nContent-Type: #{mime_type.simplified}\r\n\r\n#{content}\r\n)
69
+ %(Content-Disposition: form-data; name="#{CGI.escape(k.to_s)}"; filename="#{filename}"\r\n) +
70
+ %(Content-Type: #{mime_type.simplified}\r\n\r\n#{content.force_encoding('UTF-8')}\r\n)
70
71
  end
71
72
  end
72
73
  end
@@ -1,5 +1,5 @@
1
1
  module Sdk4me
2
2
  class Client
3
- VERSION = '2.0.0-rc.1'.freeze
3
+ VERSION = '2.0.2'.freeze
4
4
  end
5
5
  end
@@ -260,10 +260,10 @@ describe Sdk4me::Attachments do
260
260
  'User-Agent' => "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/523.10.6 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6 4me/#{Sdk4me::Client::VERSION}"
261
261
  }
262
262
  )
263
- .to_return(status: 200, body: '', headers: {})
263
+ .to_return(status: 200, headers: {}, body: %(<?xml version="1.0" encoding="UTF-8"?>\n<PostResponse><Location>foo</Location><Bucket>example</Bucket><Key>attachments/5/zxxb4ot60xfd6sjg/s3test.txt</Key><ETag>"bar"</ETag></PostResponse>))
264
264
 
265
265
  expect(a.send(:upload_attachment, file.path)).to eq({
266
- key: "attachments/5/reqs/000/070/451/zxxb4ot60xfd6sjg/#{File.basename(file.path)}",
266
+ key: 'attachments/5/zxxb4ot60xfd6sjg/s3test.txt',
267
267
  filesize: 6
268
268
  })
269
269
  end
@@ -311,7 +311,7 @@ describe Sdk4me::Attachments do
311
311
  end
312
312
 
313
313
  it 'should upload a file from disk' do
314
- Tempfile.create('4me_attachments_spec.txt') do |file|
314
+ Tempfile.create('4me_我attáchments_spec.txt') do |file|
315
315
  file << 'foobar'
316
316
  file.flush
317
317
 
@@ -328,10 +328,10 @@ describe Sdk4me::Attachments do
328
328
  'User-Agent' => "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/523.10.6 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6 4me/#{Sdk4me::Client::VERSION}"
329
329
  }
330
330
  )
331
- .to_return(status: 204, body: '', headers: {})
331
+ .to_return(status: 200, headers: {}, body: %({"key":"attachments/5/zxxb4ot60xfd6sjg/s3test.txt"}))
332
332
 
333
333
  expect(a.send(:upload_attachment, file.path)).to eq({
334
- key: "attachments/5/requests/000/000/777/abc/#{File.basename(file.path)}",
334
+ key: 'attachments/5/zxxb4ot60xfd6sjg/s3test.txt',
335
335
  filesize: 6
336
336
  })
337
337
  end
@@ -12,7 +12,7 @@ describe 'ca-bundle.crt' do
12
12
  expect(response.valid?).to be_falsey
13
13
 
14
14
  # expecting 401 error
15
- expect(response.message).to eq('401: Bad credentials')
15
+ expect(response.message).to start_with('401:')
16
16
  end
17
17
 
18
18
  it 'should be able to connect to the 4me REST API (access token)' do
@@ -26,7 +26,7 @@ describe 'ca-bundle.crt' do
26
26
  expect(response.valid?).to be_falsey
27
27
 
28
28
  # expecting 401 error
29
- expect(response.message).to eq('401: Bad credentials')
29
+ expect(response.message).to start_with('401:')
30
30
  end
31
31
 
32
32
  it 'should be able to connect to S3' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 4me-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.rc.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 4me
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-14 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -180,12 +180,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  version: 2.5.0
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  requirements:
183
- - - ">"
183
+ - - ">="
184
184
  - !ruby/object:Gem::Version
185
- version: 1.3.1
185
+ version: '0'
186
186
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.7.9
187
+ rubygems_version: 3.2.14
189
188
  signing_key:
190
189
  specification_version: 4
191
190
  summary: The official 4me SDK for Ruby. Provides easy access to the REST APIs found