4me-sdk 2.0.0.pre.rc.3 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5de11ee2bbe3de9d781f371555831ad8f7c6aa64037b182c38ba085ff3de6f92
4
- data.tar.gz: 4e2a09d4a0933dcc2228d676b5000264df122edbe4210e07c0ffba174bd2eece
3
+ metadata.gz: da996ddd9ef66ae1e2b296bcf8ae34406163bbcbe157c1dc9ce8809e253468c4
4
+ data.tar.gz: 9c4aa5c40c50d5dc9365cb27c89851914d9a3361e6c1df113aa241d00599d522
5
5
  SHA512:
6
- metadata.gz: d14140f3859fc5e3acaf2072d84963a241f85f2788dba897cef0ee1d269cdcc0e1ef7dbc42f9ea4913d5cf85c1807b11dda4721a941f2f1e3b19363c5c822f58
7
- data.tar.gz: 51afb397d2fbdc8e46dbc65599080d2514425cc0764fc14828c63c7bf66800c49d85590130c0343797de76148e884dbfa2757008876bbdb63795b3a3e5bd92ca
6
+ metadata.gz: d338d9c4069d1a6d643f04dae0f6e98afe6059f2fa9f5c61f77cdb8869096a468cb369c47d702bec1caf2fff9c7e7d454dd67bc80b89c66dc4ebce8fcaf9b543
7
+ data.tar.gz: 7262b78d780457b9569c7143e39e8fbc2e1d13e5fa9d971ce263a1d666327ee7517952c428d20de1e1c851a8f082a7a45508f3abd60cf556950108a1a175d570
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.2)
4
+ 4me-sdk (2.0.2)
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/README.md CHANGED
@@ -129,18 +129,16 @@ If you really want to [paginate](https://developer.4me.com/v1/general/pagination
129
129
 
130
130
  ```
131
131
  @client = Sdk4me::Client.new
132
- response = @client.get('organizations', {per_page: 10, page: 2})
132
+ response = @client.get('organizations', { per_page: 100 })
133
133
 
134
134
  puts response.json # all data in an array
135
135
 
136
136
  puts "showing page #{response.current_page}/#{response.total_pages}, with #{response.per_page} records per page"
137
137
  puts "total number of records #{response.total_entries}"
138
138
 
139
- # retrieve collection for other pages directly from the response
140
- first_page = @client.get(response.pagination_link(:first))
141
- prev_page = @client.get(response.pagination_link(:prev))
142
- next_page = @client.get(response.pagination_link(:next))
143
- last_page = @client.get(response.pagination_link(:last))
139
+ # retrieve collection for previous and next pages directly from the response
140
+ prev_page = @client.get(response.pagination_relative_link(:prev))
141
+ next_page = @client.get(response.pagination_relative_link(:next))
144
142
  ```
145
143
 
146
144
  By default this call will return all [collection fields](https://developer.4me.com/v1/organizations/#collection-fields) for each Organization.
@@ -148,7 +146,7 @@ For more fields, check out the [field selection](https://developer.4me.com/v1/ge
148
146
 
149
147
  The fields can be accessed using *symbols* and *strings*, and it is possible chain a number of keys in one go:
150
148
  ```
151
- response = Sdk4me::Client.new.get('organizations', {per_page: 10, page: 2, fields: 'parent'})
149
+ response = Sdk4me::Client.new.get('organizations', { per_page: 100, fields: 'parent' })
152
150
  puts response[:parent, :name] # an array with the parent organization names
153
151
  puts response['parent', 'name'] # strings are also accepted as keys
154
152
  ```
@@ -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
  # ...
@@ -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
@@ -98,14 +98,17 @@ module Sdk4me
98
98
  @total_entries ||= @response.header['X-Pagination-Total-Entries'].to_i
99
99
  end
100
100
 
101
- # pagination urls (full paths with server) - relations :first, :prev, :next, :last
101
+ # pagination urls (full paths with server) - relations :first, :prev
102
102
  # Link: <https://api.4me.com/v1/requests?page=1&per_page=25>; rel="first", <https://api.4me.com/v1/requests?page=2&per_page=25>; rel="prev", etc.
103
103
  def pagination_link(relation)
104
104
  # split on ',' select the [url] in '<[url]>; rel="[relation]"', compact to all url's found (at most one) and take the first
105
- (@pagination_links ||= {})[relation] ||= @response.header['Link'] && @response.header['Link'].split(/,\s*<?/).map { |link| link[/^\s*<?(.*?)>?;\s*rel="#{relation}"\s*$/, 1] }.compact.first
105
+ (@pagination_links ||= {})[relation] ||= @response.header['Link'] &&
106
+ @response.header['Link']
107
+ .split(/,\s*(?:<|$)/)
108
+ .map { |link| link[/^\s*<?(.*?)>?;\s*rel="#{relation}"\s*$/, 1] }.compact.first
106
109
  end
107
110
 
108
- # pagination urls (relative paths without server) - relations :first, :prev, :next, :last
111
+ # pagination urls (relative paths without server) - relations :first, :prev, :next
109
112
  def pagination_relative_link(relation)
110
113
  (@pagination_relative_links ||= {})[relation] ||= pagination_link(relation) && pagination_link(relation)[%r{^https?://[^/]*(.*)}, 1]
111
114
  end
@@ -1,5 +1,5 @@
1
1
  module Sdk4me
2
2
  class Client
3
- VERSION = '2.0.0-rc.3'.freeze
3
+ VERSION = '2.0.3'.freeze
4
4
  end
5
5
  end
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
@@ -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
 
@@ -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
@@ -214,7 +214,7 @@ describe Sdk4me::Response do
214
214
  'X-Pagination-Current-Page' => 1,
215
215
  'X-Pagination-Total-Pages' => 2,
216
216
  'X-Pagination-Total-Entries' => 5,
217
- 'Link' => '<https://api.4me.com/v1/people?page=1&per_page=3>; rel="first",<https://api.4me.com/v1/people?page=2&per_page=3>; rel="next", <https://api.4me.com/v1/people?page=2&per_page=3>; rel="last"'
217
+ 'Link' => '<https://api.4me.com/v1/people?page=1&per_page=3&fields=id,name>; rel="first",<https://api.4me.com/v1/people?fields=id%2Cname&page=2&per_page=3>; rel="next", <https://api.4me.com/v1/people?page=2&per_page=3>; rel="last"'
218
218
  }
219
219
  allow(@response_array.response).to receive('header') { @pagination_header }
220
220
  end
@@ -235,16 +235,16 @@ describe Sdk4me::Response do
235
235
  expect(@response_array.total_entries).to eq(5)
236
236
  end
237
237
 
238
- { first: 'https://api.4me.com/v1/people?page=1&per_page=3',
239
- next: 'https://api.4me.com/v1/people?page=2&per_page=3',
238
+ { first: 'https://api.4me.com/v1/people?page=1&per_page=3&fields=id,name',
239
+ next: 'https://api.4me.com/v1/people?fields=id%2Cname&page=2&per_page=3',
240
240
  last: 'https://api.4me.com/v1/people?page=2&per_page=3' }.each do |relation, link|
241
241
  it "should define pagination link for :#{relation}" do
242
242
  expect(@response_array.pagination_link(relation)).to eq(link)
243
243
  end
244
244
  end
245
245
 
246
- { first: '/v1/people?page=1&per_page=3',
247
- next: '/v1/people?page=2&per_page=3',
246
+ { first: '/v1/people?page=1&per_page=3&fields=id,name',
247
+ next: '/v1/people?fields=id%2Cname&page=2&per_page=3',
248
248
  last: '/v1/people?page=2&per_page=3' }.each do |relation, link|
249
249
  it "should define pagination relative link for :#{relation}" do
250
250
  expect(@response_array.pagination_relative_link(relation)).to eq(link)
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.3
4
+ version: 2.0.3
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-17 00:00:00.000000000 Z
11
+ date: 2021-12-01 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