ecoportal-api 0.10.7 → 0.10.9
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/CHANGELOG.md +30 -1
- data/lib/ecoportal/api/common/base_class.rb +11 -12
- data/lib/ecoportal/api/common/base_model.rb +22 -8
- data/lib/ecoportal/api/common/batch_operation.rb +10 -10
- data/lib/ecoportal/api/common/batch_response.rb +1 -1
- data/lib/ecoportal/api/common/client/elastic_apm_integration.rb +9 -9
- data/lib/ecoportal/api/common/client/error/checks.rb +1 -1
- data/lib/ecoportal/api/common/client/with_retry.rb +1 -1
- data/lib/ecoportal/api/common/client.rb +13 -14
- data/lib/ecoportal/api/common/doc_helpers.rb +7 -6
- data/lib/ecoportal/api/common/hash_diff.rb +8 -5
- data/lib/ecoportal/api/common/logging.rb +1 -0
- data/lib/ecoportal/api/common/response.rb +1 -1
- data/lib/ecoportal/api/common/wrapped_response.rb +1 -1
- data/lib/ecoportal/api/internal/account.rb +18 -18
- data/lib/ecoportal/api/internal/people.rb +1 -1
- data/lib/ecoportal/api/internal/person.rb +24 -18
- data/lib/ecoportal/api/internal/person_details.rb +1 -1
- data/lib/ecoportal/api/internal/person_schema.rb +1 -1
- data/lib/ecoportal/api/internal/person_schemas.rb +1 -1
- data/lib/ecoportal/api/internal/policy_groups.rb +3 -2
- data/lib/ecoportal/api/internal/preferences.rb +13 -10
- data/lib/ecoportal/api/internal.rb +5 -5
- data/lib/ecoportal/api/logger.rb +8 -7
- data/lib/ecoportal/api/v1/job/awaiter/timer.rb +9 -7
- data/lib/ecoportal/api/v1/job/status.rb +2 -2
- data/lib/ecoportal/api/v1/job.rb +4 -4
- data/lib/ecoportal/api/v1/people.rb +12 -10
- data/lib/ecoportal/api/v1/person.rb +27 -15
- data/lib/ecoportal/api/v1/person_details.rb +7 -7
- data/lib/ecoportal/api/v1/person_schema.rb +5 -4
- data/lib/ecoportal/api/v1/person_schemas.rb +9 -6
- data/lib/ecoportal/api/v1/schema_field.rb +8 -8
- data/lib/ecoportal/api/v1/schema_field_value.rb +15 -15
- data/lib/ecoportal/api/v1.rb +4 -4
- data/lib/ecoportal/api/version.rb +1 -1
- data/lib/ecoportal/api.rb +9 -9
- metadata +2 -2
@@ -1,12 +1,13 @@
|
|
1
1
|
module Ecoportal
|
2
2
|
module API
|
3
3
|
class V1
|
4
|
-
# @attr_reader client [Common::Client] a `Common::Client` object that holds
|
4
|
+
# @attr_reader client [Common::Client] a `Common::Client` object that holds
|
5
|
+
# the configuration of the api connection.
|
5
6
|
class PersonSchemas
|
6
7
|
extend Common::BaseClass
|
7
8
|
include Enumerable
|
8
9
|
|
9
|
-
class_resolver :person_schema_class,
|
10
|
+
class_resolver :person_schema_class, 'Ecoportal::API::V1::PersonSchema'
|
10
11
|
|
11
12
|
attr_reader :client
|
12
13
|
|
@@ -18,8 +19,8 @@ module Ecoportal
|
|
18
19
|
|
19
20
|
# Gets all the schemas via api request.
|
20
21
|
# @return [Enumerable<PersonSchema>] an `Enumerable` with all schemas already wrapped as `PersonSchema` objects.
|
21
|
-
def get_all
|
22
|
-
response = client.get(
|
22
|
+
def get_all # rubocop:disable Naming/AccessorMethodName
|
23
|
+
response = client.get('/person_schemas')
|
23
24
|
Common::WrappedResponse.new(response, person_schema_class)
|
24
25
|
end
|
25
26
|
|
@@ -29,13 +30,15 @@ module Ecoportal
|
|
29
30
|
# - `:params` doesn't really do anything.
|
30
31
|
# - same as #get_all but with block :)
|
31
32
|
# - `to_a` will call `each` (see this [detailed explanation](https://stackoverflow.com/a/45201663/4352306))
|
32
|
-
# - however, as far as you have an iterator, such as `each`,
|
33
|
+
# - however, as far as you have an iterator, such as `each`,
|
34
|
+
# `to_a` should be last resource (see [this explanation](https://stackoverflow.com/a/44186921/4352306))
|
33
35
|
# @yield [schema] does some stuff with the schema.
|
34
36
|
# @yieldparam schema [PersonSchema]
|
35
37
|
# @yieldreturn [PersonSchema]
|
36
38
|
# @return [Enumerable<PersonSchema>] an `Enumerable` with all the person schema objects.
|
37
39
|
def each(params: {}, &block)
|
38
|
-
return to_enum(:each) unless block
|
40
|
+
return to_enum(:each, params: params) unless block
|
41
|
+
|
39
42
|
get_all.each(&block)
|
40
43
|
end
|
41
44
|
end
|
@@ -7,19 +7,19 @@ module Ecoportal
|
|
7
7
|
def parse_text(value)
|
8
8
|
values = [*value.to_s.lines].map do |line|
|
9
9
|
line = line.chomp
|
10
|
-
next if line ==
|
10
|
+
next if line == ''
|
11
11
|
case type
|
12
|
-
when
|
12
|
+
when 'text', 'phone_number'
|
13
13
|
line
|
14
|
-
when
|
15
|
-
Float(line) rescue return nil, false
|
16
|
-
when
|
14
|
+
when 'number'
|
15
|
+
Float(line) rescue return nil, false # rubocop:disable Style/RescueModifier
|
16
|
+
when 'boolean'
|
17
17
|
%w[true TRUE True Y y YES X x].include?(line)
|
18
|
-
when
|
18
|
+
when 'select'
|
19
19
|
return nil, false unless options.include?(line)
|
20
20
|
line
|
21
|
-
when
|
22
|
-
Date.parse(line) rescue return nil, false
|
21
|
+
when 'date'
|
22
|
+
Date.parse(line) rescue return nil, false # rubocop:disable Style/RescueModifier
|
23
23
|
end
|
24
24
|
end.compact
|
25
25
|
|
@@ -6,18 +6,18 @@ module Ecoportal
|
|
6
6
|
passthrough :id, :alt_id, :type, :name, :shared, :multiple
|
7
7
|
|
8
8
|
def clear
|
9
|
-
return doc[
|
9
|
+
return doc['value'] = [] if multiple
|
10
10
|
|
11
|
-
doc[
|
11
|
+
doc['value'] = nil
|
12
12
|
end
|
13
13
|
|
14
14
|
def value
|
15
15
|
case type
|
16
|
-
when
|
17
|
-
doc[
|
18
|
-
when
|
19
|
-
if doc[
|
20
|
-
maybe_multiple(doc[
|
16
|
+
when 'text', 'phone_number', 'number', 'boolean', 'select'
|
17
|
+
doc['value']
|
18
|
+
when 'date'
|
19
|
+
if doc['value']
|
20
|
+
maybe_multiple(doc['value']) do |v|
|
21
21
|
Date.iso8601(v)
|
22
22
|
end
|
23
23
|
end
|
@@ -28,28 +28,28 @@ module Ecoportal
|
|
28
28
|
|
29
29
|
def value=(value) # rubocop:disable Metrics/AbcSize
|
30
30
|
case type
|
31
|
-
when
|
32
|
-
doc[
|
31
|
+
when 'text', 'phone_number', 'select'
|
32
|
+
doc['value'] = maybe_multiple(value) do |v|
|
33
33
|
v&.to_s
|
34
34
|
end
|
35
|
-
when
|
35
|
+
when 'number'
|
36
36
|
maybe_multiple(value) do |v|
|
37
37
|
next if v.nil? || v.is_a?(Numeric)
|
38
38
|
|
39
39
|
raise "Invalid number type #{v.class}"
|
40
40
|
end
|
41
41
|
|
42
|
-
doc[
|
43
|
-
when
|
44
|
-
doc[
|
45
|
-
when
|
42
|
+
doc['value'] = value
|
43
|
+
when 'boolean'
|
44
|
+
doc['value'] = !!value
|
45
|
+
when 'date'
|
46
46
|
maybe_multiple(value) do |v|
|
47
47
|
next if v.nil? || v.respond_to?(:to_date)
|
48
48
|
|
49
49
|
raise "Invalid date type #{v.class}"
|
50
50
|
end
|
51
51
|
|
52
|
-
doc[
|
52
|
+
doc['value'] = maybe_multiple(value) do |v|
|
53
53
|
v&.to_date&.to_s
|
54
54
|
end
|
55
55
|
else
|
data/lib/ecoportal/api/v1.rb
CHANGED
@@ -6,10 +6,10 @@ module Ecoportal
|
|
6
6
|
extend Common::BaseClass
|
7
7
|
include Common::Logging
|
8
8
|
|
9
|
-
VERSION =
|
9
|
+
VERSION = 'v1'.freeze
|
10
10
|
|
11
|
-
class_resolver :people_class,
|
12
|
-
class_resolver :person_schemas_class,
|
11
|
+
class_resolver :people_class, 'Ecoportal::API::V1::People'
|
12
|
+
class_resolver :person_schemas_class, 'Ecoportal::API::V1::PersonSchemas'
|
13
13
|
|
14
14
|
attr_reader :client, :logger
|
15
15
|
|
@@ -21,7 +21,7 @@ module Ecoportal
|
|
21
21
|
# @param host [String] api server domain.
|
22
22
|
# @param logger [Logger] an object with `Logger` interface to generate logs.
|
23
23
|
# @return [V1] an object with the api version suit.
|
24
|
-
def initialize(api_key, host:
|
24
|
+
def initialize(api_key, host: 'live.ecoportal.com', logger: default_logger)
|
25
25
|
@logger = logger
|
26
26
|
@client = Common::Client.new(
|
27
27
|
api_key: api_key,
|
data/lib/ecoportal/api.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'cgi'
|
2
|
+
require 'logger'
|
3
|
+
require 'ecoportal/api/version'
|
4
|
+
require 'dotenv/load'
|
5
5
|
|
6
6
|
module Ecoportal
|
7
7
|
module API
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
11
|
+
require 'ecoportal/api/logger'
|
12
|
+
require 'ecoportal/api/common'
|
13
|
+
require 'ecoportal/api/errors'
|
14
|
+
require 'ecoportal/api/v1'
|
15
|
+
require 'ecoportal/api/internal'
|
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.10.
|
4
|
+
version: 0.10.9
|
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: 2025-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|