ecoportal-api 0.8.4 → 0.8.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4364abf59cd6460788d315eb5012df5e8ad254a208e8af7314a766463eb35ed0
|
4
|
+
data.tar.gz: d71fe7e38402e827aea0f95c6a0c379e191e525d597ab8b225990f48c6879764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e055587b4aafbfabf25996cf4e67d85b0a0d9be936d4b0bdae194b431e4f2bb12b09fc99562d594cf355767aae3081a1fbea70d10a48dc204ce839284bbf0256
|
7
|
+
data.tar.gz: 5cd7284e455af271f1642775844636fd0ea11b590c0036d3b4a43868a9ffd6ece97ceebb9a3d6dfcdae7891dd65dedd0df9dac5944578cb18484b07342640c3e
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,24 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [0.8.
|
4
|
+
## [0.8.5] - 2022-02-28
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- `Ecoportal::API::V1::PersonDetails#[]` to raise a specific error type to allow handling
|
8
|
+
- `Ecoportal::API::V1::PersonDetails.key?` to allow to check if a field exists
|
9
|
+
- `Ecoportal::API::Internal::Account#force_send_invites` support for back-end new method
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
- `Ecoportal::API::V1::People#get` fixed typo
|
13
|
+
- `Ecoportal::API::Common::BaseModel` `#original_doc` and `#initial_doc` maybe empty for the parent object
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
- `Ecoportal::API::V1::People#each` limited the `GET` retries to `5`
|
17
|
+
- `Ecoportal::API::Internal::Account#default_tag=`
|
18
|
+
- Controls input type to be `String` or `nil`
|
19
|
+
- Inherent `upcase`
|
20
|
+
|
21
|
+
## [0.8.4] - 2021-11-05
|
5
22
|
|
6
23
|
### Added
|
7
24
|
- `Ecoportal::API::Internal::Permissions` added abilities
|
@@ -68,13 +68,13 @@ module Ecoportal
|
|
68
68
|
def original_doc
|
69
69
|
raise UnlinkedModel.new(from: "#{self.class}#original_doc", key: _key) unless linked?
|
70
70
|
return @original_doc if is_root?
|
71
|
-
_parent.original_doc
|
71
|
+
_parent.original_doc&.dig(*[_key].flatten)
|
72
72
|
end
|
73
73
|
|
74
74
|
def initial_doc
|
75
75
|
raise UnlinkedModel.new(from: "#{self.class}#initial_doc", key: _key) unless linked?
|
76
76
|
return @initial_doc if is_root?
|
77
|
-
_parent.initial_doc
|
77
|
+
_parent.initial_doc&.dig(*[_key].flatten)
|
78
78
|
end
|
79
79
|
|
80
80
|
def as_json
|
@@ -6,7 +6,7 @@ module Ecoportal
|
|
6
6
|
"user_id", "policy_group_ids", "default_tag", "prefilter",
|
7
7
|
"permissions_custom", "permissions_merged", "preferences",
|
8
8
|
"login_provider_ids", "starred_ids", "landing_page_id",
|
9
|
-
"accept_eula", "send_invites"
|
9
|
+
"accept_eula", "send_invites", "force_send_invites"
|
10
10
|
]
|
11
11
|
passthrough *PROPERTIES.map(&:to_sym)
|
12
12
|
|
@@ -17,6 +17,23 @@ module Ecoportal
|
|
17
17
|
embeds_one :perms_merged, key: "permissions_merged", klass: :permissions_class
|
18
18
|
embeds_one :preferences, klass: :preferences_class
|
19
19
|
|
20
|
+
# Sets the `default_tag` of the user
|
21
|
+
# @note it upcases the value
|
22
|
+
# @param value [String, nil] the tag
|
23
|
+
# @return [String, nil] the value set in `default_tag`
|
24
|
+
def default_tag=(value)
|
25
|
+
unless !value || value.is_a?(String)
|
26
|
+
raise ArgumentError.new("default_tag= needs to be passed a String or nil, got #{value.class}")
|
27
|
+
end
|
28
|
+
if value
|
29
|
+
unless value.match(Ecoportal::API::V1::Person::VALID_TAG_REGEX)
|
30
|
+
raise ArgumentError.new("Invalid default tag #{value.inspect}")
|
31
|
+
end
|
32
|
+
value = value.upcase
|
33
|
+
end
|
34
|
+
doc["default_tag"] = value
|
35
|
+
end
|
36
|
+
|
20
37
|
# Sets the `policy_group_ids`
|
21
38
|
# @note it preserves the original order
|
22
39
|
# @param value [Array<String>] the policy group ids to be set.
|
@@ -36,16 +36,16 @@ module Ecoportal
|
|
36
36
|
puts "\n" unless silent
|
37
37
|
loop do
|
38
38
|
params.update(cursor_id: cursor_id) if cursor_id
|
39
|
-
body = nil; response = nil
|
39
|
+
body = nil; response = nil; count = 5
|
40
40
|
loop do
|
41
41
|
response = client.get("/people", params: params)
|
42
42
|
body = response && body_data(response.body)
|
43
|
-
break if response.success?
|
43
|
+
break if response.success? || count <= 0
|
44
44
|
puts "Request failed - Status #{response.status}: #{body}"
|
45
|
+
count -= 1
|
46
|
+
sleep(0.5)
|
45
47
|
end
|
46
|
-
|
47
|
-
#body = response && body_data(response.body)
|
48
|
-
#raise "Request failed - Status #{response.status}: #{body}" unless response.success?
|
48
|
+
raise "Request failed - Status #{response.status}: #{body}" unless response.success?
|
49
49
|
|
50
50
|
unless silent || (total = body["total_results"]) == 0
|
51
51
|
results += body["results"].length
|
@@ -84,7 +84,7 @@ module Ecoportal
|
|
84
84
|
response = client.get("/people/"+CGI.escape(id))
|
85
85
|
body = body_data(response.body)
|
86
86
|
return person_class.new(body) if response.success?
|
87
|
-
raise "Could not get person #{id} - Error #{
|
87
|
+
raise "Could not get person #{id} - Error #{response.status}: #{body}"
|
88
88
|
end
|
89
89
|
|
90
90
|
# Requests an update of a person via api.
|
@@ -2,6 +2,9 @@ module Ecoportal
|
|
2
2
|
module API
|
3
3
|
class V1
|
4
4
|
class PersonDetails < Common::BaseModel
|
5
|
+
class MissingId < StandardError
|
6
|
+
end
|
7
|
+
|
5
8
|
passthrough :schema_id
|
6
9
|
|
7
10
|
class_resolver :schema_field_value_class, "Ecoportal::API::V1::SchemaFieldValue"
|
@@ -43,16 +46,24 @@ module Ecoportal
|
|
43
46
|
end
|
44
47
|
|
45
48
|
# Sets the value to one specific field of the PersonDetails.
|
49
|
+
# @raise MisssingId if the `id` or `alt_id` is missing.
|
46
50
|
# @param id [String] the `id` or the `alt_id` of the target field.
|
47
51
|
# @return [void]
|
48
52
|
def []=(id, value)
|
49
53
|
if field = get_field(id)
|
50
54
|
field.value = value
|
51
55
|
else
|
52
|
-
raise "details[#{id.inspect}] is missing. Did you forget to load the schema?"
|
56
|
+
raise MissingId.new("details[#{id.inspect}] is missing. Did you forget to load the schema?")
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
60
|
+
# Checks if an `id` or `alt_id` exists
|
61
|
+
# @param id [String] the `id` or the `alt_id` of the target field.
|
62
|
+
# @return [Boolean] `true` if it exists, `false` otherwise
|
63
|
+
def key?(id)
|
64
|
+
@fields_by_id.key?(id) || @fields_by_alt_id.key?(id)
|
65
|
+
end
|
66
|
+
|
56
67
|
protected
|
57
68
|
|
58
69
|
# Rebuilds the internal `id` and `alt_id` references to the fields.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecoportal-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tapio Saarinen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
281
|
- !ruby/object:Gem::Version
|
282
282
|
version: '0'
|
283
283
|
requirements: []
|
284
|
-
rubygems_version: 3.
|
284
|
+
rubygems_version: 3.3.5
|
285
285
|
signing_key:
|
286
286
|
specification_version: 4
|
287
287
|
summary: A collection of helpers for interacting with the ecoPortal MS's various APIs
|