discourse_api 0.24.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/README.md +13 -0
- data/lib/discourse_api/client.rb +4 -4
- data/lib/discourse_api/error.rb +6 -0
- data/lib/discourse_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e90f0e873e3f4704e132a4be3b7bc5982c804bf71536c426f90a6008bcf68765
|
4
|
+
data.tar.gz: ab6e8ff566a35424fd5baf81641fef179a73978c7b860fda97dd34c62e597599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae8f232c209917ece93c461619873da8e9883f333345a7d5000637aa5a548cc32044fea30e3b5d815910748fafd49cde11969f829d09ecb6e9647a3c2290bd91
|
7
|
+
data.tar.gz: 9980a0850e4597bbc93cd359d38de90f9b3396eed81d73c14b842e7347d2b65bca4db76c5028e441bff67fedb6ce00cfaf2044da37723624a02d327ebe6a0fc3
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [0.25.0] - 2018-08-15
|
6
|
+
### Added
|
7
|
+
- Added ability to rescue certain error classes and inspect the response object
|
8
|
+
|
5
9
|
## [0.24.0] - 2018-05-30
|
6
10
|
### Added
|
7
11
|
- Added support for custom `user_fields` when creating a user
|
data/README.md
CHANGED
@@ -66,6 +66,19 @@ client.create_private_message( #=> Creates a private messages b
|
|
66
66
|
|
67
67
|
```
|
68
68
|
|
69
|
+
You can handle some basic errors by rescuing from certain error classes and inspecting the response object passed to those errors:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
begin
|
73
|
+
client.create_group({ name: 'NO' })
|
74
|
+
rescue DiscourseApi::UnprocessableEntity => error
|
75
|
+
# `body` is something like `{ errors: ["Name must be at least 3 characters"] }`
|
76
|
+
# This outputs "Name must be at least 3 characters"
|
77
|
+
puts error.response.body['errors'].first
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
Check out [lib/discourse_api/error.rb](lib/discourse_api/error.rb) and [lib/discourse_api/client.rb](lib/discourse_api/client.rb)'s `handle_error` method for the types of errors raised by the API.
|
69
82
|
|
70
83
|
## Contributing
|
71
84
|
|
data/lib/discourse_api/client.rb
CHANGED
@@ -138,13 +138,13 @@ module DiscourseApi
|
|
138
138
|
def handle_error(response)
|
139
139
|
case response.status
|
140
140
|
when 403
|
141
|
-
raise DiscourseApi::UnauthenticatedError.new(response.env[:body])
|
141
|
+
raise DiscourseApi::UnauthenticatedError.new(response.env[:body], response.env)
|
142
142
|
when 404, 410
|
143
|
-
raise DiscourseApi::NotFoundError.new(response.env[:body])
|
143
|
+
raise DiscourseApi::NotFoundError.new(response.env[:body], response.env)
|
144
144
|
when 422
|
145
|
-
raise DiscourseApi::UnprocessableEntity.new(response.env[:body])
|
145
|
+
raise DiscourseApi::UnprocessableEntity.new(response.env[:body], response.env)
|
146
146
|
when 429
|
147
|
-
raise DiscourseApi::TooManyRequests.new(response.env[:body])
|
147
|
+
raise DiscourseApi::TooManyRequests.new(response.env[:body], response.env)
|
148
148
|
when 500...600
|
149
149
|
raise DiscourseApi::Error.new(response.env[:body])
|
150
150
|
end
|
data/lib/discourse_api/error.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discourse_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
@@ -307,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
307
307
|
version: '0'
|
308
308
|
requirements: []
|
309
309
|
rubyforge_project:
|
310
|
-
rubygems_version: 2.
|
310
|
+
rubygems_version: 2.7.7
|
311
311
|
signing_key:
|
312
312
|
specification_version: 4
|
313
313
|
summary: Allows access to the Discourse API
|