ecoportal-api 0.8.5 → 0.9.2
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/.gitignore +20 -20
- data/.rspec +3 -3
- data/.rubocop.yml +55 -55
- data/.travis.yml +5 -5
- data/.yardopts +10 -10
- data/CHANGELOG.md +257 -236
- data/Gemfile +6 -6
- data/LICENSE +21 -21
- data/README.md +34 -34
- data/Rakefile +27 -27
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/ecoportal-api.gemspec +36 -36
- data/lib/ecoportal/api/common/base_class.rb +33 -29
- data/lib/ecoportal/api/common/base_model.rb +195 -177
- data/lib/ecoportal/api/common/batch_operation.rb +119 -119
- data/lib/ecoportal/api/common/batch_response.rb +34 -34
- data/lib/ecoportal/api/common/client.rb +198 -196
- data/lib/ecoportal/api/common/doc_helpers.rb +29 -29
- data/lib/ecoportal/api/common/elastic_apm_integration.rb +112 -112
- data/lib/ecoportal/api/common/hash_diff.rb +41 -41
- data/lib/ecoportal/api/common/logging.rb +12 -12
- data/lib/ecoportal/api/common/response.rb +31 -31
- data/lib/ecoportal/api/common/wrapped_response.rb +54 -54
- data/lib/ecoportal/api/common.rb +18 -18
- data/lib/ecoportal/api/errors/base.rb +8 -8
- data/lib/ecoportal/api/errors/time_out.rb +8 -8
- data/lib/ecoportal/api/errors.rb +9 -9
- data/lib/ecoportal/api/internal/account.rb +99 -100
- data/lib/ecoportal/api/internal/login_provider.rb +9 -9
- data/lib/ecoportal/api/internal/login_providers.rb +33 -33
- data/lib/ecoportal/api/internal/people.rb +14 -14
- data/lib/ecoportal/api/internal/permissions.rb +14 -13
- data/lib/ecoportal/api/internal/person.rb +101 -53
- data/lib/ecoportal/api/internal/person_details.rb +9 -9
- data/lib/ecoportal/api/internal/person_schema.rb +10 -10
- data/lib/ecoportal/api/internal/person_schemas.rb +11 -11
- data/lib/ecoportal/api/internal/policy_group.rb +9 -9
- data/lib/ecoportal/api/internal/policy_groups.rb +32 -32
- data/lib/ecoportal/api/internal/preferences.rb +31 -31
- data/lib/ecoportal/api/internal/schema_field.rb +8 -8
- data/lib/ecoportal/api/internal/schema_field_value.rb +8 -8
- data/lib/ecoportal/api/internal.rb +31 -31
- data/lib/ecoportal/api/logger.rb +62 -62
- data/lib/ecoportal/api/v1/people.rb +218 -218
- data/lib/ecoportal/api/v1/person.rb +138 -135
- data/lib/ecoportal/api/v1/person_details.rb +94 -82
- data/lib/ecoportal/api/v1/person_schema.rb +53 -53
- data/lib/ecoportal/api/v1/person_schemas.rb +48 -48
- data/lib/ecoportal/api/v1/schema_field.rb +34 -34
- data/lib/ecoportal/api/v1/schema_field_value.rb +65 -65
- data/lib/ecoportal/api/v1.rb +49 -49
- data/lib/ecoportal/api/version.rb +5 -5
- data/lib/ecoportal/api.rb +16 -16
- metadata +3 -3
@@ -1,100 +1,99 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
class Account < Common::BaseModel
|
5
|
-
PROPERTIES = [
|
6
|
-
"user_id", "policy_group_ids", "default_tag", "prefilter",
|
7
|
-
"permissions_custom", "permissions_merged", "preferences",
|
8
|
-
"login_provider_ids", "starred_ids", "landing_page_id",
|
9
|
-
"accept_eula", "send_invites", "force_send_invites"
|
10
|
-
]
|
11
|
-
passthrough *PROPERTIES.map(&:to_sym)
|
12
|
-
|
13
|
-
class_resolver :preferences_class, "Ecoportal::API::Internal::Preferences"
|
14
|
-
class_resolver :permissions_class, "Ecoportal::API::Internal::Permissions"
|
15
|
-
|
16
|
-
embeds_one :permissions, key: "permissions_custom", klass: :permissions_class
|
17
|
-
embeds_one :perms_merged, key: "permissions_merged", klass: :permissions_class
|
18
|
-
embeds_one :preferences, klass: :preferences_class
|
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
|
-
|
37
|
-
# Sets the `policy_group_ids`
|
38
|
-
# @note it preserves the original order
|
39
|
-
# @param value [Array<String>] the policy group ids to be set.
|
40
|
-
def policy_group_ids=(value)
|
41
|
-
set_uniq_array_keep_order("policy_group_ids", value)
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [Array<String>] the policy group ids of this user.
|
45
|
-
def policy_group_ids
|
46
|
-
doc["policy_group_ids"] ||= []
|
47
|
-
end
|
48
|
-
|
49
|
-
# Sets the `login_provider_ids`
|
50
|
-
def login_provider_ids=(value)
|
51
|
-
set_uniq_array_keep_order("login_provider_ids", value)
|
52
|
-
end
|
53
|
-
|
54
|
-
# @return [Array<String>] the login provider ids of this user.
|
55
|
-
def login_provider_ids
|
56
|
-
doc["login_provider_ids"] ||= []
|
57
|
-
end
|
58
|
-
|
59
|
-
# Sets the `starred_ids`
|
60
|
-
def starred_ids=(value)
|
61
|
-
set_uniq_array_keep_order("starred_ids", value)
|
62
|
-
end
|
63
|
-
|
64
|
-
# @return [Array<String>] the starred page ids of this user.
|
65
|
-
def starred_ids
|
66
|
-
doc["starred_ids"] ||= []
|
67
|
-
end
|
68
|
-
|
69
|
-
# It preserves the values of keys that are not defined in `value`.
|
70
|
-
# @param value [Hash] the abilities that you want to update.
|
71
|
-
def permissions_custom=(value)
|
72
|
-
doc["permissions_custom"] ||= {}
|
73
|
-
doc["permissions_custom"].merge!(value)
|
74
|
-
end
|
75
|
-
|
76
|
-
# It preserves the values of keys that are not defined in `value`.
|
77
|
-
# @param value [Hash] the preferences that you want to update.
|
78
|
-
def preferences=(value)
|
79
|
-
doc["preferences"] ||= {}
|
80
|
-
doc["preferences"].merge!(value)
|
81
|
-
end
|
82
|
-
|
83
|
-
def as_json
|
84
|
-
super.tap do |hash|
|
85
|
-
hash["permissions_custom"] = permissions.as_json
|
86
|
-
hash["permissions_merged"] = perms_merged.as_json
|
87
|
-
hash["preferences"] = preferences.as_json
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def as_update(ref = :last, ignore: [])
|
92
|
-
super(ref, ignore: ignore | ["user_id", "permissions_merged", "prefilter"])
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
require 'ecoportal/api/internal/
|
100
|
-
require 'ecoportal/api/internal/preferences'
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
class Account < Common::BaseModel
|
5
|
+
PROPERTIES = [
|
6
|
+
"user_id", "policy_group_ids", "default_tag", "prefilter",
|
7
|
+
"permissions_custom", "permissions_merged", "preferences",
|
8
|
+
"login_provider_ids", "starred_ids", "landing_page_id",
|
9
|
+
"accept_eula", "send_invites", "force_send_invites"
|
10
|
+
]
|
11
|
+
passthrough *PROPERTIES.map(&:to_sym)
|
12
|
+
|
13
|
+
class_resolver :preferences_class, "Ecoportal::API::Internal::Preferences"
|
14
|
+
class_resolver :permissions_class, "Ecoportal::API::Internal::Permissions"
|
15
|
+
|
16
|
+
embeds_one :permissions, key: "permissions_custom", klass: :permissions_class
|
17
|
+
embeds_one :perms_merged, key: "permissions_merged", klass: :permissions_class
|
18
|
+
embeds_one :preferences, klass: :preferences_class
|
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
|
+
|
37
|
+
# Sets the `policy_group_ids`
|
38
|
+
# @note it preserves the original order
|
39
|
+
# @param value [Array<String>] the policy group ids to be set.
|
40
|
+
def policy_group_ids=(value)
|
41
|
+
set_uniq_array_keep_order("policy_group_ids", value)
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Array<String>] the policy group ids of this user.
|
45
|
+
def policy_group_ids
|
46
|
+
doc["policy_group_ids"] ||= []
|
47
|
+
end
|
48
|
+
|
49
|
+
# Sets the `login_provider_ids`
|
50
|
+
def login_provider_ids=(value)
|
51
|
+
set_uniq_array_keep_order("login_provider_ids", value)
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [Array<String>] the login provider ids of this user.
|
55
|
+
def login_provider_ids
|
56
|
+
doc["login_provider_ids"] ||= []
|
57
|
+
end
|
58
|
+
|
59
|
+
# Sets the `starred_ids`
|
60
|
+
def starred_ids=(value)
|
61
|
+
set_uniq_array_keep_order("starred_ids", value)
|
62
|
+
end
|
63
|
+
|
64
|
+
# @return [Array<String>] the starred page ids of this user.
|
65
|
+
def starred_ids
|
66
|
+
doc["starred_ids"] ||= []
|
67
|
+
end
|
68
|
+
|
69
|
+
# It preserves the values of keys that are not defined in `value`.
|
70
|
+
# @param value [Hash] the abilities that you want to update.
|
71
|
+
def permissions_custom=(value)
|
72
|
+
doc["permissions_custom"] ||= {}
|
73
|
+
doc["permissions_custom"].merge!(value)
|
74
|
+
end
|
75
|
+
|
76
|
+
# It preserves the values of keys that are not defined in `value`.
|
77
|
+
# @param value [Hash] the preferences that you want to update.
|
78
|
+
def preferences=(value)
|
79
|
+
doc["preferences"] ||= {}
|
80
|
+
doc["preferences"].merge!(value)
|
81
|
+
end
|
82
|
+
|
83
|
+
def as_json
|
84
|
+
super.tap do |hash|
|
85
|
+
hash["permissions_custom"] = permissions.as_json
|
86
|
+
hash["permissions_merged"] = perms_merged.as_json
|
87
|
+
hash["preferences"] = preferences.as_json
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def as_update(ref = :last, ignore: [])
|
92
|
+
super(ref, ignore: ignore | ["user_id", "permissions_merged", "prefilter"])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
require 'ecoportal/api/internal/permissions'
|
99
|
+
require 'ecoportal/api/internal/preferences'
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
class LoginProvider < Common::BaseModel
|
5
|
-
passthrough :id, :name, :type, :enabled_for
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
class LoginProvider < Common::BaseModel
|
5
|
+
passthrough :id, :name, :type, :enabled_for
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -1,33 +1,33 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
# @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
|
5
|
-
class LoginProviders
|
6
|
-
include Enumerable
|
7
|
-
|
8
|
-
attr_reader :client
|
9
|
-
|
10
|
-
# @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
|
11
|
-
# @return [LoginProviders] an instance object ready to make login providers api requests.
|
12
|
-
def initialize(client)
|
13
|
-
@client = client
|
14
|
-
end
|
15
|
-
|
16
|
-
# Gets all the login providers via api request.
|
17
|
-
# @return [Enumerable<LoginProvider>] an `Enumerable` with all login providers already wrapped as `LoginProvider` objects.
|
18
|
-
def get_all
|
19
|
-
response = @client.get("/login_providers")
|
20
|
-
Common::WrappedResponse.new(response, Internal::LoginProvider)
|
21
|
-
end
|
22
|
-
|
23
|
-
def each(&block)
|
24
|
-
return to_enum(:each) unless block
|
25
|
-
get_all.each(&block)
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
require 'ecoportal/api/internal/login_provider'
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
# @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
|
5
|
+
class LoginProviders
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
attr_reader :client
|
9
|
+
|
10
|
+
# @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
|
11
|
+
# @return [LoginProviders] an instance object ready to make login providers api requests.
|
12
|
+
def initialize(client)
|
13
|
+
@client = client
|
14
|
+
end
|
15
|
+
|
16
|
+
# Gets all the login providers via api request.
|
17
|
+
# @return [Enumerable<LoginProvider>] an `Enumerable` with all login providers already wrapped as `LoginProvider` objects.
|
18
|
+
def get_all
|
19
|
+
response = @client.get("/login_providers")
|
20
|
+
Common::WrappedResponse.new(response, Internal::LoginProvider)
|
21
|
+
end
|
22
|
+
|
23
|
+
def each(&block)
|
24
|
+
return to_enum(:each) unless block
|
25
|
+
get_all.each(&block)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'ecoportal/api/internal/login_provider'
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
class People < V1::People
|
5
|
-
class_resolver :person_class, "Ecoportal::API::Internal::Person"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
require 'ecoportal/api/internal/schema_field_value'
|
12
|
-
require 'ecoportal/api/internal/person_details'
|
13
|
-
require 'ecoportal/api/internal/account'
|
14
|
-
require 'ecoportal/api/internal/person'
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
class People < V1::People
|
5
|
+
class_resolver :person_class, "Ecoportal::API::Internal::Person"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'ecoportal/api/internal/schema_field_value'
|
12
|
+
require 'ecoportal/api/internal/person_details'
|
13
|
+
require 'ecoportal/api/internal/account'
|
14
|
+
require 'ecoportal/api/internal/person'
|
@@ -1,13 +1,14 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
class Permissions < Common::BaseModel
|
5
|
-
passthrough :files, :data, :reports
|
6
|
-
passthrough :organization, :pages, :page_editor, :registers, :tasks
|
7
|
-
passthrough :person_core, :person_core_create, :person_core_edit
|
8
|
-
passthrough :person_details, :person_account, :person_abilities
|
9
|
-
passthrough :visitor_management, :
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
class Permissions < Common::BaseModel
|
5
|
+
passthrough :files, :data, :reports
|
6
|
+
passthrough :organization, :pages, :page_editor, :registers, :tasks
|
7
|
+
passthrough :person_core, :person_core_create, :person_core_edit
|
8
|
+
passthrough :person_details, :person_account, :person_abilities
|
9
|
+
passthrough :visitor_management, :contractor_management
|
10
|
+
passthrough :broadcast_notifications, :cross_register_reporting
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,53 +1,101 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
# @attr account [Account, nil] the account of the person or `nil` if missing.
|
5
|
-
class Person < V1::Person
|
6
|
-
class_resolver :person_details_class, "Ecoportal::API::Internal::PersonDetails"
|
7
|
-
class_resolver :person_account_class, "Ecoportal::API::Internal::Account"
|
8
|
-
embeds_one :account, nullable: true, klass: :person_account_class
|
9
|
-
|
10
|
-
def
|
11
|
-
super
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
# @attr account [Account, nil] the account of the person or `nil` if missing.
|
5
|
+
class Person < V1::Person
|
6
|
+
class_resolver :person_details_class, "Ecoportal::API::Internal::PersonDetails"
|
7
|
+
class_resolver :person_account_class, "Ecoportal::API::Internal::Account"
|
8
|
+
embeds_one :account, nullable: true, klass: :person_account_class
|
9
|
+
|
10
|
+
def initialize(doc = {}, *args, **kargs, &block)
|
11
|
+
super(doc, *args, **kargs, &block)
|
12
|
+
@is_new = @prev_is_new = no_account_nor_details?(@doc)
|
13
|
+
end
|
14
|
+
|
15
|
+
def consolidate!
|
16
|
+
@prev_is_new = @is_new
|
17
|
+
@is_new = false
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def reset!(*args)
|
22
|
+
@is_new = @prev_is_new
|
23
|
+
super(*args)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @note
|
27
|
+
# - `original_doc` should technically hold the model as it is on **server side**
|
28
|
+
# - Once this person has been successfullyupdated, `#consolidate!` should be called.
|
29
|
+
# - The above sets a copy of `doc` as `original_doc` (meaning: _no pending changes_)
|
30
|
+
# - Therefore we can safely assume that this is a **new record** if the `original_doc`
|
31
|
+
# does not have details nor account (as all people should have either to exist).
|
32
|
+
# - **However**, to the purpose of getting a clean `as_update`, `original_doc` is filled
|
33
|
+
# with `details` right on creation. For this reason, a workaround is necessary via `@is_new`
|
34
|
+
# @return [Boolean] whether or not this entry is being created now (i.e. non existent on server)
|
35
|
+
def new?(value = :original)
|
36
|
+
return @is_new if value == :original
|
37
|
+
no_account_nor_details?(initial_doc)
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [Boolean] if the account has been added to `doc`
|
41
|
+
def account_added?(value = :original)
|
42
|
+
ref_doc = (value == :original) ? original_doc : initial_doc
|
43
|
+
!!account && !ref_doc["account"]
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [Boolean] if the account has been removed from `doc`
|
47
|
+
def account_removed?(value = :original)
|
48
|
+
ref_doc = (value == :original) ? original_doc : initial_doc
|
49
|
+
!account && !!ref_doc["account"]
|
50
|
+
end
|
51
|
+
|
52
|
+
def as_json
|
53
|
+
super.update("account" => account&.as_json)
|
54
|
+
end
|
55
|
+
|
56
|
+
def as_update(ref = :last, ignore: [])
|
57
|
+
super(ref, ignore: ignore | ["user_id", "permissions_merged", "prefilter"])
|
58
|
+
end
|
59
|
+
|
60
|
+
# Sets the Account to the person, depending on the paramter received:
|
61
|
+
# - `nil`: blanks the account.
|
62
|
+
# - `Account`: sets a copy of the object param as account.
|
63
|
+
# - `Hash`: slices the properties of `Account` (keeping the value of `user_id` if there was already account).
|
64
|
+
# @note this method does not make dirty the account (meaning that `as_json` will be an empty hash `{}`)
|
65
|
+
# @param value [nil, Account, Hash] value to be set.
|
66
|
+
# @return [nil, Account] the resulting `Account` set to the person.
|
67
|
+
def account=(value)
|
68
|
+
case value
|
69
|
+
when NilClass
|
70
|
+
doc["account"] = nil
|
71
|
+
when Internal::Account
|
72
|
+
doc["account"] = JSON.parse(value.to_json)
|
73
|
+
when Hash
|
74
|
+
user_id = account.user_id if account
|
75
|
+
doc["account"] = value.slice(*Internal::Account::PROPERTIES)
|
76
|
+
doc["account"]["user_id"] = user_id if user_id
|
77
|
+
else
|
78
|
+
# TODO
|
79
|
+
raise "Invalid set on account: Need nil, Account or Hash; got #{value.class}"
|
80
|
+
end
|
81
|
+
remove_instance_variable("@account") if defined?(@account)
|
82
|
+
return account
|
83
|
+
end
|
84
|
+
|
85
|
+
# Adds an empty account to the person.
|
86
|
+
# @note if the person exists, and does not have an account, an this will send an invite.
|
87
|
+
# @note this will **not** change the account properties of this person.
|
88
|
+
def add_account
|
89
|
+
self.account = {}
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def no_account_nor_details?(value = @doc)
|
95
|
+
return true unless value.is_a?(Hash)
|
96
|
+
!value.key?("details") && !value.key?("account")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
class PersonDetails < V1::PersonDetails
|
5
|
-
class_resolver :schema_field_value_class, "Ecoportal::API::Internal::SchemaFieldValue"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
class PersonDetails < V1::PersonDetails
|
5
|
+
class_resolver :schema_field_value_class, "Ecoportal::API::Internal::SchemaFieldValue"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
class PersonSchema < V1::PersonSchema
|
5
|
-
class_resolver :schema_field_class, "Ecoportal::API::Internal::SchemaField"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
require 'ecoportal/api/internal/schema_field'
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
class PersonSchema < V1::PersonSchema
|
5
|
+
class_resolver :schema_field_class, "Ecoportal::API::Internal::SchemaField"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
require 'ecoportal/api/internal/schema_field'
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
class PersonSchemas < V1::PersonSchemas
|
5
|
-
class_resolver :person_schema_class, "Ecoportal::API::Internal::PersonSchema"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
require 'ecoportal/api/internal/person_schema'
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
class PersonSchemas < V1::PersonSchemas
|
5
|
+
class_resolver :person_schema_class, "Ecoportal::API::Internal::PersonSchema"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'ecoportal/api/internal/person_schema'
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
class PolicyGroup < Common::BaseModel
|
5
|
-
passthrough :id, :name
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
class PolicyGroup < Common::BaseModel
|
5
|
+
passthrough :id, :name
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -1,32 +1,32 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
# @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
|
5
|
-
class PolicyGroups
|
6
|
-
include Enumerable
|
7
|
-
|
8
|
-
attr_reader :client
|
9
|
-
|
10
|
-
# @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
|
11
|
-
# @return [PolicyGroups] an instance object ready to make policy groups api requests.
|
12
|
-
def initialize(client)
|
13
|
-
@client = client
|
14
|
-
end
|
15
|
-
|
16
|
-
# Gets all the policy groups via api request.
|
17
|
-
# @return [Enumerable<PolicyGroup>] an `Enumerable` with all the policy groups already wrapped as `PolicyGroup` objects.
|
18
|
-
def get_all
|
19
|
-
response = client.get("/policy_groups")
|
20
|
-
Common::WrappedResponse.new(response, Internal::PolicyGroup)
|
21
|
-
end
|
22
|
-
|
23
|
-
def each(&block)
|
24
|
-
return to_enum(:each) unless block
|
25
|
-
get_all.each(&block)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
require 'ecoportal/api/internal/policy_group'
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class Internal
|
4
|
+
# @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
|
5
|
+
class PolicyGroups
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
attr_reader :client
|
9
|
+
|
10
|
+
# @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
|
11
|
+
# @return [PolicyGroups] an instance object ready to make policy groups api requests.
|
12
|
+
def initialize(client)
|
13
|
+
@client = client
|
14
|
+
end
|
15
|
+
|
16
|
+
# Gets all the policy groups via api request.
|
17
|
+
# @return [Enumerable<PolicyGroup>] an `Enumerable` with all the policy groups already wrapped as `PolicyGroup` objects.
|
18
|
+
def get_all
|
19
|
+
response = client.get("/policy_groups")
|
20
|
+
Common::WrappedResponse.new(response, Internal::PolicyGroup)
|
21
|
+
end
|
22
|
+
|
23
|
+
def each(&block)
|
24
|
+
return to_enum(:each) unless block
|
25
|
+
get_all.each(&block)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'ecoportal/api/internal/policy_group'
|