4me-sdk 1.1.8 → 2.0.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/4me-sdk.gemspec +12 -13
- data/Gemfile.lock +58 -39
- data/LICENSE +1 -1
- data/README.md +53 -44
- data/lib/sdk4me.rb +7 -5
- data/lib/sdk4me/ca-bundle.crt +1327 -1802
- data/lib/sdk4me/client.rb +110 -87
- data/lib/sdk4me/client/attachments.rb +107 -116
- data/lib/sdk4me/client/multipart.rb +16 -18
- data/lib/sdk4me/client/response.rb +17 -19
- data/lib/sdk4me/client/version.rb +1 -1
- data/spec/lib/sdk4me/attachments_spec.rb +317 -219
- data/spec/lib/sdk4me/certificate_spec.rb +17 -4
- data/spec/lib/sdk4me/client_spec.rb +490 -475
- data/spec/lib/sdk4me/response_spec.rb +249 -232
- data/spec/lib/sdk4me_spec.rb +7 -7
- data/spec/spec_helper.rb +5 -8
- data/spec/support/matchers/never_raise.rb +16 -21
- data/spec/support/util.rb +2 -2
- metadata +36 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 32cfcbac334dbc605b6488e54db56eb8c7db3dfca80724b08114affc264d4d59
|
|
4
|
+
data.tar.gz: ed44080e2df04693b32d62bd0a0086511af32301ba6e5d4a4e401ba0ab4d70f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b4d62a29b08e73e7afce649acbccf27f3192f46d50b533e02429e0da45f3f1c99ccd5201343da550c3a7f2561d27e732a39c22794fb78f8f182831ec42a97f7
|
|
7
|
+
data.tar.gz: '08c618e5b35ec1a7bc3a47e5800b64da25a992475ccc7fa5f99d8e781b4b724a3caf32dbf0936d8ca79d244fac2a4c5ddb9facd5be06893c867f7d97a8dbc6fd'
|
data/4me-sdk.gemspec
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
require 'sdk4me/client/version'
|
|
5
4
|
|
|
@@ -7,34 +6,34 @@ Gem::Specification.new do |spec|
|
|
|
7
6
|
spec.name = '4me-sdk'
|
|
8
7
|
spec.version = Sdk4me::Client::VERSION
|
|
9
8
|
spec.platform = Gem::Platform::RUBY
|
|
10
|
-
spec.required_ruby_version = '>= 2.
|
|
9
|
+
spec.required_ruby_version = '>= 2.5.0'
|
|
11
10
|
spec.authors = ['4me']
|
|
12
|
-
spec.email =
|
|
13
|
-
spec.description =
|
|
14
|
-
spec.summary =
|
|
15
|
-
spec.homepage =
|
|
11
|
+
spec.email = 'developers@4me.com'
|
|
12
|
+
spec.description = 'SDK for accessing the 4me REST API'
|
|
13
|
+
spec.summary = 'The official 4me SDK for Ruby. Provides easy access to the REST APIs found at https://developer.4me.com'
|
|
14
|
+
spec.homepage = 'https://github.com/code4me/4me-sdk-ruby'
|
|
16
15
|
spec.license = 'MIT'
|
|
17
16
|
|
|
18
|
-
spec.files = Dir.glob('lib/**/*') + %w
|
|
17
|
+
spec.files = Dir.glob('lib/**/*') + %w[
|
|
19
18
|
LICENSE
|
|
20
19
|
README.md
|
|
21
20
|
Gemfile
|
|
22
21
|
Gemfile.lock
|
|
23
22
|
4me-sdk.gemspec
|
|
24
|
-
|
|
25
|
-
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
23
|
+
]
|
|
24
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
26
25
|
spec.test_files = `git ls-files -- {test,spec}/*`.split("\n")
|
|
27
26
|
spec.require_paths = ['lib']
|
|
28
27
|
spec.rdoc_options = ['--charset=UTF-8']
|
|
29
28
|
|
|
30
|
-
spec.add_runtime_dependency 'gem_config', '>=0.3'
|
|
31
29
|
spec.add_runtime_dependency 'activesupport', '>= 4.2'
|
|
30
|
+
spec.add_runtime_dependency 'gem_config', '>=0.3'
|
|
32
31
|
spec.add_runtime_dependency 'mime-types', '>= 3.0'
|
|
33
32
|
|
|
34
33
|
spec.add_development_dependency 'bundler', '~> 1'
|
|
35
34
|
spec.add_development_dependency 'rake', '~> 12'
|
|
36
35
|
spec.add_development_dependency 'rspec', '~> 3.3'
|
|
37
|
-
spec.add_development_dependency '
|
|
36
|
+
spec.add_development_dependency 'rubocop', '>= 0.49.0'
|
|
38
37
|
spec.add_development_dependency 'simplecov', '~> 0'
|
|
39
|
-
|
|
38
|
+
spec.add_development_dependency 'webmock', '~> 3'
|
|
40
39
|
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
4me-sdk (
|
|
4
|
+
4me-sdk (2.0.0.pre.rc.2)
|
|
5
5
|
activesupport (>= 4.2)
|
|
6
6
|
gem_config (>= 0.3)
|
|
7
7
|
mime-types (>= 3.0)
|
|
@@ -9,55 +9,73 @@ PATH
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
activesupport (
|
|
12
|
+
activesupport (6.0.3.4)
|
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
14
14
|
i18n (>= 0.7, < 2)
|
|
15
15
|
minitest (~> 5.1)
|
|
16
16
|
tzinfo (~> 1.1)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
|
18
|
+
addressable (2.7.0)
|
|
19
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
20
|
+
ast (2.4.1)
|
|
21
|
+
concurrent-ruby (1.1.7)
|
|
22
|
+
crack (0.4.4)
|
|
23
|
+
diff-lcs (1.4.4)
|
|
24
|
+
docile (1.3.2)
|
|
25
|
+
gem_config (0.3.2)
|
|
26
|
+
hashdiff (1.0.1)
|
|
27
|
+
i18n (1.8.5)
|
|
27
28
|
concurrent-ruby (~> 1.0)
|
|
28
|
-
|
|
29
|
-
mime-types (3.2.2)
|
|
29
|
+
mime-types (3.3.1)
|
|
30
30
|
mime-types-data (~> 3.2015)
|
|
31
|
-
mime-types-data (3.
|
|
32
|
-
minitest (5.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
rspec
|
|
31
|
+
mime-types-data (3.2020.1104)
|
|
32
|
+
minitest (5.14.2)
|
|
33
|
+
parallel (1.19.2)
|
|
34
|
+
parser (2.7.2.0)
|
|
35
|
+
ast (~> 2.4.1)
|
|
36
|
+
public_suffix (4.0.6)
|
|
37
|
+
rainbow (3.0.0)
|
|
38
|
+
rake (12.3.3)
|
|
39
|
+
regexp_parser (1.8.2)
|
|
40
|
+
rexml (3.2.4)
|
|
41
|
+
rspec (3.10.0)
|
|
42
|
+
rspec-core (~> 3.10.0)
|
|
43
|
+
rspec-expectations (~> 3.10.0)
|
|
44
|
+
rspec-mocks (~> 3.10.0)
|
|
45
|
+
rspec-core (3.10.0)
|
|
46
|
+
rspec-support (~> 3.10.0)
|
|
47
|
+
rspec-expectations (3.10.0)
|
|
42
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
43
|
-
rspec-support (~> 3.
|
|
44
|
-
rspec-mocks (3.
|
|
49
|
+
rspec-support (~> 3.10.0)
|
|
50
|
+
rspec-mocks (3.10.0)
|
|
45
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
46
|
-
rspec-support (~> 3.
|
|
47
|
-
rspec-support (3.
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
rspec-support (~> 3.10.0)
|
|
53
|
+
rspec-support (3.10.0)
|
|
54
|
+
rubocop (0.93.1)
|
|
55
|
+
parallel (~> 1.10)
|
|
56
|
+
parser (>= 2.7.1.5)
|
|
57
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
58
|
+
regexp_parser (>= 1.8)
|
|
59
|
+
rexml
|
|
60
|
+
rubocop-ast (>= 0.6.0)
|
|
61
|
+
ruby-progressbar (~> 1.7)
|
|
62
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
63
|
+
rubocop-ast (1.1.1)
|
|
64
|
+
parser (>= 2.7.1.5)
|
|
65
|
+
ruby-progressbar (1.10.1)
|
|
66
|
+
simplecov (0.19.1)
|
|
50
67
|
docile (~> 1.1)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
simplecov-html (0.10.2)
|
|
68
|
+
simplecov-html (~> 0.11)
|
|
69
|
+
simplecov-html (0.12.3)
|
|
54
70
|
thread_safe (0.3.6)
|
|
55
|
-
tzinfo (1.2.
|
|
71
|
+
tzinfo (1.2.7)
|
|
56
72
|
thread_safe (~> 0.1)
|
|
57
|
-
|
|
73
|
+
unicode-display_width (1.7.0)
|
|
74
|
+
webmock (3.9.4)
|
|
58
75
|
addressable (>= 2.3.6)
|
|
59
76
|
crack (>= 0.3.2)
|
|
60
|
-
hashdiff
|
|
77
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
78
|
+
zeitwerk (2.4.1)
|
|
61
79
|
|
|
62
80
|
PLATFORMS
|
|
63
81
|
ruby
|
|
@@ -67,8 +85,9 @@ DEPENDENCIES
|
|
|
67
85
|
bundler (~> 1)
|
|
68
86
|
rake (~> 12)
|
|
69
87
|
rspec (~> 3.3)
|
|
88
|
+
rubocop (>= 0.49.0)
|
|
70
89
|
simplecov (~> 0)
|
|
71
|
-
webmock (~>
|
|
90
|
+
webmock (~> 3)
|
|
72
91
|
|
|
73
92
|
BUNDLED WITH
|
|
74
|
-
1.
|
|
93
|
+
1.16.6
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sdk4me::Client
|
|
2
2
|
|
|
3
|
-
Client for accessing the [4me REST API](
|
|
3
|
+
Client for accessing the [4me REST API](https://developer.4me.com/v1/)
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
|
22
22
|
|
|
23
23
|
```
|
|
24
24
|
Sdk4me.configure do |config|
|
|
25
|
-
config.
|
|
25
|
+
config.access_token = 'd41f5868feb65fc87fa2311a473a8766ea38bc40'
|
|
26
26
|
config.account = 'my-sandbox'
|
|
27
27
|
config.logger = Rails.logger
|
|
28
28
|
...
|
|
@@ -32,18 +32,20 @@ end
|
|
|
32
32
|
All options available:
|
|
33
33
|
|
|
34
34
|
* _logger_: The [Ruby Logger](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html) instance, default: `Logger.new(STDOUT)`
|
|
35
|
-
* _host_: The [4me API host](
|
|
36
|
-
* _api_version_: The [4me API version](
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
35
|
+
* _host_: The [4me REST API host](https://developer.4me.com/v1/#service-url), default: 'https://api.4me.com'
|
|
36
|
+
* _api_version_: The [4me REST API version](https://developer.4me.com/v1/#service-url), default: 'v1'
|
|
37
|
+
* _access_token_: (**required**) The [4me access token](https://developer.4me.com/v1/#authentication)
|
|
38
|
+
* _api_token_: (**deprecated**) The [4me API token](https://developer.4me.com/v1/#api-tokens)
|
|
39
|
+
* _account_: Specify a [different account](https://developer.4me.com/v1/#multiple-accounts) to work with
|
|
40
|
+
* _source_: The [source](https://developer.4me.com/v1/general/source/) used when creating new records
|
|
41
|
+
* _user_agent_: The User-Agent header of each request. Defaults to 4me-sdk-ruby/(version)
|
|
40
42
|
* _max_retry_time_: maximum nr of seconds to retry a request on a failed response (default = 300 = 5 minutes)<br/>
|
|
41
43
|
The sleep time between retries starts at 2 seconds and doubles after each retry, i.e.
|
|
42
44
|
2, 6, 18, 54, 162, 486, 1458, ... seconds.<br/>
|
|
43
45
|
Set to 0 to prevent retries.
|
|
44
46
|
* _read_timeout_: [HTTP read timeout](http://ruby-doc.org/stdlib-2.0.0/libdoc/net/http/rdoc/Net/HTTP.html#method-i-read_timeout-3D) in seconds (default = 25)
|
|
45
|
-
* _block_at_rate_limit_: Set to `true` to block the request until the [rate limit](
|
|
46
|
-
The `Retry-After` header is used to compute when the retry should be performed. If that moment is later than the _max_throttle_time_ the request will not be blocked and the throttled response is returned.
|
|
47
|
+
* _block_at_rate_limit_: Set to `true` to block the request until the [rate limit](https://developer.4me.com/v1/#rate-limiting) is lifted, default: `true`<br/>
|
|
48
|
+
The `Retry-After` header is used to compute when the retry should be performed. If that moment is later than the _max_throttle_time_ the request will not be blocked and the throttled response is returned.
|
|
47
49
|
* _max_throttle_time_: maximum nr of seconds to retry a request on a rate limiter (default = 3660 = 1 hour and 1 minute)<br/>
|
|
48
50
|
* _proxy_host_: Define in case HTTP traffic needs to go through a proxy
|
|
49
51
|
* _proxy_port_: Port of the proxy, defaults to 8080
|
|
@@ -70,7 +72,7 @@ Minimal example:
|
|
|
70
72
|
```
|
|
71
73
|
require 'sdk4me/client'
|
|
72
74
|
|
|
73
|
-
client = Sdk4me::Client.new(
|
|
75
|
+
client = Sdk4me::Client.new(access_token: '3a4e4590179263839...')
|
|
74
76
|
response = client.get('me')
|
|
75
77
|
puts response[:primary_email]
|
|
76
78
|
```
|
|
@@ -84,7 +86,7 @@ response = Sdk4me::Client.new.get('organizations/4321')
|
|
|
84
86
|
puts response[:name]
|
|
85
87
|
```
|
|
86
88
|
|
|
87
|
-
By default this call will return all [fields](
|
|
89
|
+
By default this call will return all [fields](https://developer.4me.com/v1/organizations/#fields) of the Organization.
|
|
88
90
|
|
|
89
91
|
The fields can be accessed using *symbols* and *strings*, and it is possible chain a number of keys in one go:
|
|
90
92
|
```
|
|
@@ -105,8 +107,8 @@ end
|
|
|
105
107
|
puts "Found #{count} organizations"
|
|
106
108
|
```
|
|
107
109
|
|
|
108
|
-
By default this call will return all [collection fields](
|
|
109
|
-
For more fields, check out the [field selection](
|
|
110
|
+
By default this call will return all [collection fields](https://developer.4me.com/v1/organizations/#collection-fields) for each Organization.
|
|
111
|
+
For more fields, check out the [field selection](https://developer.4me.com/v1/general/field_selection/#collection-of-resources) documentation.
|
|
110
112
|
|
|
111
113
|
The fields can be accessed using *symbols* and *strings*, and it is possible chain a number of keys in one go:
|
|
112
114
|
```
|
|
@@ -123,7 +125,7 @@ Note that an `Sdk4me::Exception` could be thrown in case one of the API requests
|
|
|
123
125
|
|
|
124
126
|
The `each` method [described above](#browse-through-a-collection-of-records) is the preferred way to work with collections of data.
|
|
125
127
|
|
|
126
|
-
If you really want to [paginate](
|
|
128
|
+
If you really want to [paginate](https://developer.4me.com/v1/general/pagination/) yourself, the `get` method is your friend.
|
|
127
129
|
|
|
128
130
|
```
|
|
129
131
|
@client = Sdk4me::Client.new
|
|
@@ -141,8 +143,8 @@ next_page = @client.get(response.pagination_link(:next))
|
|
|
141
143
|
last_page = @client.get(response.pagination_link(:last))
|
|
142
144
|
```
|
|
143
145
|
|
|
144
|
-
By default this call will return all [collection fields](
|
|
145
|
-
For more fields, check out the [field selection](
|
|
146
|
+
By default this call will return all [collection fields](https://developer.4me.com/v1/organizations/#collection-fields) for each Organization.
|
|
147
|
+
For more fields, check out the [field selection](https://developer.4me.com/v1/general/field_selection/#collection-of-resources) documentation.
|
|
146
148
|
|
|
147
149
|
The fields can be accessed using *symbols* and *strings*, and it is possible chain a number of keys in one go:
|
|
148
150
|
```
|
|
@@ -198,39 +200,38 @@ end
|
|
|
198
200
|
Make sure to validate the success by calling `response.valid?` and to take appropriate action in case the response is not valid.
|
|
199
201
|
|
|
200
202
|
|
|
201
|
-
###
|
|
203
|
+
### Attachments
|
|
202
204
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
Adding attachments and inline images to rich text fields is a two-step process.
|
|
206
|
+
First upload the attachments to 4me, and then refer to the uploaded attachments
|
|
207
|
+
when creating or updating a 4me record.
|
|
205
208
|
|
|
206
|
-
To make
|
|
209
|
+
To make this process easy, refer to the files using string filepaths or
|
|
210
|
+
File references:
|
|
207
211
|
|
|
208
212
|
```
|
|
209
213
|
response = Sdk4me::Client.new.put('requests/416621', {
|
|
210
214
|
status: 'waiting_for_customer',
|
|
211
|
-
note: 'Please complete the attached forms and
|
|
212
|
-
|
|
215
|
+
note: 'Please complete the attached forms and assign the request back to us.',
|
|
216
|
+
note_attachments: [
|
|
217
|
+
'/tmp/forms/README.txt',
|
|
218
|
+
File.open('/tmp/forms/PersonalData.xls', 'rb')
|
|
219
|
+
]
|
|
213
220
|
})
|
|
214
221
|
```
|
|
215
222
|
|
|
216
|
-
It is also possible to add inline attachments
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
note: 'Here is some inspiration for you: [attachment:/tmp/images/puppy.png]'
|
|
220
|
-
})
|
|
221
|
-
```
|
|
222
|
-
Note that only images are accepted as inline attachments.
|
|
223
|
-
|
|
224
|
-
If an attachment upload fails, the errors are logged but the `post` or `put` request will still be sent to 4me without the
|
|
225
|
-
failed attachments. To receive exceptions add `attachments_exception: true` to the data.
|
|
223
|
+
It is also possible to add inline attachments. Refer to attachments by their
|
|
224
|
+
array index, with the index being zero-based. Text can only refer to inline
|
|
225
|
+
images in its own attachments collection. For example:
|
|
226
226
|
|
|
227
227
|
```
|
|
228
228
|
begin
|
|
229
|
-
|
|
229
|
+
data = {
|
|
230
230
|
status: 'waiting_for_customer',
|
|
231
|
-
note: '
|
|
232
|
-
|
|
233
|
-
}
|
|
231
|
+
note: 'See [note_attachments: 0] and [note_attachments: 1]',
|
|
232
|
+
note_attachments: ['/tmp/info.png', '/tmp/help.png']
|
|
233
|
+
}
|
|
234
|
+
response = Sdk4me::Client.new.put('requests/416621', data)
|
|
234
235
|
if response.valid?
|
|
235
236
|
puts "Request #{response[:id]} updated and attachments added to the note"
|
|
236
237
|
else
|
|
@@ -243,7 +244,7 @@ end
|
|
|
243
244
|
|
|
244
245
|
### Importing CSV files
|
|
245
246
|
|
|
246
|
-
4me also provides an [Import API](
|
|
247
|
+
4me also provides an [Import API](https://developer.4me.com/v1/import/). The 4me SDK Client can be used to upload files to that API.
|
|
247
248
|
|
|
248
249
|
```
|
|
249
250
|
response = Sdk4me::Client.new.import('\tmp\people.csv', 'people')
|
|
@@ -255,9 +256,9 @@ end
|
|
|
255
256
|
|
|
256
257
|
```
|
|
257
258
|
|
|
258
|
-
The second argument contains the [import type](
|
|
259
|
+
The second argument contains the [import type](https://developer.4me.com/v1/import/#parameters).
|
|
259
260
|
|
|
260
|
-
It is also possible to [monitor the progress](
|
|
261
|
+
It is also possible to [monitor the progress](https://developer.4me.com/v1/import/#import-progress) of the import and block until the import is complete. In that case you will need to add some exception handling to your code.
|
|
261
262
|
|
|
262
263
|
```
|
|
263
264
|
begin
|
|
@@ -277,7 +278,7 @@ Note that blocking for the import to finish is required when you import multiple
|
|
|
277
278
|
|
|
278
279
|
### Exporting CSV files
|
|
279
280
|
|
|
280
|
-
4me also provides an [Export API](
|
|
281
|
+
4me also provides an [Export API](https://developer.4me.com/v1/export/). The 4me SDK Client can be used to download (zipped) CSV files using that API.
|
|
281
282
|
|
|
282
283
|
```
|
|
283
284
|
response = Sdk4me::Client.new.export(['people', 'people_contact_details'], DateTime.new(2012,03,30,23,00,00))
|
|
@@ -289,10 +290,10 @@ end
|
|
|
289
290
|
|
|
290
291
|
```
|
|
291
292
|
|
|
292
|
-
The first argument contains the [export types](
|
|
293
|
+
The first argument contains the [export types](https://developer.4me.com/v1/export/#parameters).
|
|
293
294
|
The second argument is optional and limits the export to all changed records since the given time.
|
|
294
295
|
|
|
295
|
-
It is also possible to [monitor the progress](
|
|
296
|
+
It is also possible to [monitor the progress](https://developer.4me.com/v1/export/#export-progress) of the export and block until the export is complete. In that case you will need to add some exception handling to your code.
|
|
296
297
|
|
|
297
298
|
```
|
|
298
299
|
require 'open-uri'
|
|
@@ -314,7 +315,7 @@ Note that blocking for the export to finish is recommended as you will get direc
|
|
|
314
315
|
|
|
315
316
|
### Blocking
|
|
316
317
|
|
|
317
|
-
When the currently used API token hits the [4me rate limiter](
|
|
318
|
+
When the currently used API token hits the [4me rate limiter](https://developer.4me.com/v1/#rate-limiting) a HTTP 429 response is returned that specifies after how many seconds the rate limit will be lifted.
|
|
318
319
|
|
|
319
320
|
If that time lies within the _max_throttle_time_ the 4me SDK Client will wait and retry the action, if not, the throttled response will be returned. You can verify if a response was throttled using:
|
|
320
321
|
```
|
|
@@ -336,7 +337,7 @@ When exporting translations, the _locale_ parameter is required:
|
|
|
336
337
|
|
|
337
338
|
### Exception handling
|
|
338
339
|
|
|
339
|
-
The standard methods `get`, `post`, `put` and `delete` will always return a Response with an [error message](
|
|
340
|
+
The standard methods `get`, `post`, `put` and `delete` will always return a Response with an [error message](https://developer.4me.com/v1/#http-status-codes) in case something went wrong.
|
|
340
341
|
|
|
341
342
|
By calling `response.valid?` you will know if the action succeeded or not, and `response.message` provides additinal information in case the response was invalid.
|
|
342
343
|
|
|
@@ -347,3 +348,11 @@ puts response.message
|
|
|
347
348
|
```
|
|
348
349
|
|
|
349
350
|
The methods `each` and `import` may throw an `Sdk4me::Exception` in case something failed, see the examples above.
|
|
351
|
+
|
|
352
|
+
## Changelog
|
|
353
|
+
|
|
354
|
+
The changelog is available [here](CHANGELOG.md).
|
|
355
|
+
|
|
356
|
+
## Copyright
|
|
357
|
+
|
|
358
|
+
Copyright (c) 2020 4me, Inc. See [LICENSE](LICENSE) for further details.
|
data/lib/sdk4me.rb
CHANGED
|
@@ -5,10 +5,11 @@ module Sdk4me
|
|
|
5
5
|
include GemConfig::Base
|
|
6
6
|
|
|
7
7
|
with_configuration do
|
|
8
|
-
has :logger, classes: ::Logger, default: ::Logger.new(
|
|
8
|
+
has :logger, classes: ::Logger, default: ::Logger.new($stdout)
|
|
9
9
|
|
|
10
10
|
has :host, classes: String, default: 'https://api.4me.com'
|
|
11
11
|
has :api_version, values: ['v1'], default: 'v1'
|
|
12
|
+
has :access_token, classes: String
|
|
12
13
|
has :api_token, classes: String
|
|
13
14
|
|
|
14
15
|
has :account, classes: String
|
|
@@ -30,8 +31,9 @@ module Sdk4me
|
|
|
30
31
|
configuration.logger
|
|
31
32
|
end
|
|
32
33
|
|
|
33
|
-
class Exception < ::Exception
|
|
34
|
-
|
|
35
|
-
class UploadFailed < Exception; end # ::Sdk4me::UploadFailed class
|
|
34
|
+
class Exception < ::Exception
|
|
35
|
+
end
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
class UploadFailed < Exception
|
|
38
|
+
end
|
|
39
|
+
end
|