updox 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +1 -0
- data/lib/updox.rb +10 -1
- data/lib/updox/models/appointment.rb +4 -1
- data/lib/updox/models/model.rb +11 -1
- data/lib/updox/models/reminder.rb +1 -1
- data/lib/updox/updox_exception.rb +8 -5
- data/lib/updox/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: fd8b2034246435b98b4d29ec70697b0d89d8d2ff6ec802cea01eb8ae70084eed
|
4
|
+
data.tar.gz: 07ce5cb4a144d0c244b975105795e561e0006e2ec9e355b563cd680355302a4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da03e1b1cf8aa70cb65e1e91b0147b2680f7e5307695c9ad071dd0f08d546ba122b43c3c5576b40d7699196d2121d0cffa9365822bca4c0b5a77b2def5f4c567
|
7
|
+
data.tar.gz: 9afd1c083421450366536f88212a27ae2142dafff9c9f5928b9976a2faa3c2896ac7ede4cf18bdc16bc49001804f0ba415f23191d8960f427b3697553a7e805d
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.12.0] - [2020-02-21]
|
8
|
+
### Added
|
9
|
+
- Configuration to `raise` on non-success response
|
10
|
+
- Configuration to call a lambda on non-success response
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- Bug with `as_json` method
|
14
|
+
- Bug when no date returns on statuses
|
15
|
+
|
7
16
|
## [0.11.0] - [2020-02-19]
|
8
17
|
### Added
|
9
18
|
- More fields to User model
|
data/README.md
CHANGED
@@ -161,6 +161,7 @@ Updox.configure do |c|
|
|
161
161
|
c.application_password = ENV['UPDOX_APP_PASS']
|
162
162
|
c.api_endpoint = 'http://hello.com' # Defaults to Updox endpoint
|
163
163
|
c.parse_responses = false # Defaults to true
|
164
|
+
c.failure_response = :raise # Defaults to do nothing and allows lambdas
|
164
165
|
end
|
165
166
|
```
|
166
167
|
|
data/lib/updox.rb
CHANGED
@@ -19,6 +19,7 @@ require 'updox/models/user'
|
|
19
19
|
module Updox
|
20
20
|
class Configuration
|
21
21
|
attr_accessor :application_id, :application_password, :parse_responses
|
22
|
+
attr_reader :failure_action
|
22
23
|
|
23
24
|
alias_method :parse_responses?, :parse_responses
|
24
25
|
|
@@ -26,6 +27,12 @@ module Updox
|
|
26
27
|
@application_id = nil
|
27
28
|
@application_password = nil
|
28
29
|
@parse_responses = true
|
30
|
+
@failure_action = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def failure_action=(value)
|
34
|
+
raise "Failure action must be 'nil', ':raise' or callable object!" unless value.nil? || value.respond_to?(:call) || :raise == value
|
35
|
+
@failure_action = value
|
29
36
|
end
|
30
37
|
|
31
38
|
def api_endpoint=(endpoint)
|
@@ -41,7 +48,8 @@ module Updox
|
|
41
48
|
application_id: @application_id,
|
42
49
|
application_password: @application_password,
|
43
50
|
api_endpoint: api_endpoint,
|
44
|
-
parse_responses: @parse_responses
|
51
|
+
parse_responses: @parse_responses,
|
52
|
+
failure_action: @failure_action
|
45
53
|
}
|
46
54
|
end
|
47
55
|
|
@@ -50,6 +58,7 @@ module Updox
|
|
50
58
|
self.application_password = h[:application_password]
|
51
59
|
self.api_endpoint = h[:api_endpoint]
|
52
60
|
self.parse_responses = h[:parse_responses]
|
61
|
+
self.failure_action = h[:failure_action]
|
53
62
|
|
54
63
|
return self
|
55
64
|
end
|
data/lib/updox/models/model.rb
CHANGED
@@ -103,7 +103,17 @@ module Updox
|
|
103
103
|
model.item = data
|
104
104
|
end
|
105
105
|
|
106
|
-
|
106
|
+
if (data.is_a?(Hash))
|
107
|
+
model.updox_status = data&.select {|k,v| ['successful', 'responseMessage', 'responseCode'].include?(k)} || {}
|
108
|
+
|
109
|
+
if false == model.successful? && false == Updox.configuration.failure_action.nil?
|
110
|
+
if Updox.configuration.failure_action.respond_to?(:call)
|
111
|
+
Updox.configuration.failure_action.call(model)
|
112
|
+
elsif :raise == Updox.configuration.failure_action
|
113
|
+
raise UpdoxException.from_response(response, msg: 'request')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
107
117
|
else
|
108
118
|
raise UpdoxException.from_response(response)
|
109
119
|
end
|
@@ -3,7 +3,7 @@ module Updox
|
|
3
3
|
class Reminder < Model
|
4
4
|
property :reminderId
|
5
5
|
property :reminderStatus
|
6
|
-
property :reminderStatusDate, transform_with: ->(v) { DateTime.strptime(v, DATETIME_OTHER_FORMAT) }
|
6
|
+
property :reminderStatusDate, transform_with: ->(v) { DateTime.strptime(v, DATETIME_OTHER_FORMAT) unless v.nil? || v.empty? }
|
7
7
|
property :reminderType
|
8
8
|
|
9
9
|
alias_method :reminder_id, :reminderId
|
@@ -1,27 +1,30 @@
|
|
1
1
|
module Updox
|
2
2
|
class UpdoxException < Exception
|
3
3
|
def self.from_response(response, msg: nil)
|
4
|
+
data = {}
|
4
5
|
exception_msg = "Failed #{msg}:"
|
5
|
-
|
6
|
+
data['HTTP_CODE'] = response.code
|
6
7
|
|
7
8
|
begin
|
8
9
|
error_response = JSON.parse(response.body)
|
9
10
|
|
10
11
|
if error_response.is_a?(Hash)
|
11
12
|
if error_response.include?('responseMessage')
|
12
|
-
|
13
|
+
data['MSG'] = error_response['responseMessage']
|
13
14
|
end
|
14
15
|
|
15
16
|
if error_response.include?('responseCode')
|
16
|
-
|
17
|
+
data['UPDOX_CODE'] = error_response['responseCode']
|
17
18
|
end
|
18
19
|
else
|
19
|
-
|
20
|
+
data['MSG'] = error_response
|
20
21
|
end
|
21
22
|
rescue JSON::ParserError
|
22
|
-
|
23
|
+
data['MSG'] = response.body
|
23
24
|
end
|
24
25
|
|
26
|
+
data.each {|k,v| exception_msg << " #{k} '#{v}'" }
|
27
|
+
|
25
28
|
return UpdoxException.new(exception_msg)
|
26
29
|
end
|
27
30
|
end
|
data/lib/updox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: updox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Crockett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|