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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -1
  3. data/lib/ecoportal/api/common/base_class.rb +11 -12
  4. data/lib/ecoportal/api/common/base_model.rb +22 -8
  5. data/lib/ecoportal/api/common/batch_operation.rb +10 -10
  6. data/lib/ecoportal/api/common/batch_response.rb +1 -1
  7. data/lib/ecoportal/api/common/client/elastic_apm_integration.rb +9 -9
  8. data/lib/ecoportal/api/common/client/error/checks.rb +1 -1
  9. data/lib/ecoportal/api/common/client/with_retry.rb +1 -1
  10. data/lib/ecoportal/api/common/client.rb +13 -14
  11. data/lib/ecoportal/api/common/doc_helpers.rb +7 -6
  12. data/lib/ecoportal/api/common/hash_diff.rb +8 -5
  13. data/lib/ecoportal/api/common/logging.rb +1 -0
  14. data/lib/ecoportal/api/common/response.rb +1 -1
  15. data/lib/ecoportal/api/common/wrapped_response.rb +1 -1
  16. data/lib/ecoportal/api/internal/account.rb +18 -18
  17. data/lib/ecoportal/api/internal/people.rb +1 -1
  18. data/lib/ecoportal/api/internal/person.rb +24 -18
  19. data/lib/ecoportal/api/internal/person_details.rb +1 -1
  20. data/lib/ecoportal/api/internal/person_schema.rb +1 -1
  21. data/lib/ecoportal/api/internal/person_schemas.rb +1 -1
  22. data/lib/ecoportal/api/internal/policy_groups.rb +3 -2
  23. data/lib/ecoportal/api/internal/preferences.rb +13 -10
  24. data/lib/ecoportal/api/internal.rb +5 -5
  25. data/lib/ecoportal/api/logger.rb +8 -7
  26. data/lib/ecoportal/api/v1/job/awaiter/timer.rb +9 -7
  27. data/lib/ecoportal/api/v1/job/status.rb +2 -2
  28. data/lib/ecoportal/api/v1/job.rb +4 -4
  29. data/lib/ecoportal/api/v1/people.rb +12 -10
  30. data/lib/ecoportal/api/v1/person.rb +27 -15
  31. data/lib/ecoportal/api/v1/person_details.rb +7 -7
  32. data/lib/ecoportal/api/v1/person_schema.rb +5 -4
  33. data/lib/ecoportal/api/v1/person_schemas.rb +9 -6
  34. data/lib/ecoportal/api/v1/schema_field.rb +8 -8
  35. data/lib/ecoportal/api/v1/schema_field_value.rb +15 -15
  36. data/lib/ecoportal/api/v1.rb +4 -4
  37. data/lib/ecoportal/api/version.rb +1 -1
  38. data/lib/ecoportal/api.rb +9 -9
  39. 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 the configuration of the api connection.
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, "Ecoportal::API::V1::PersonSchema"
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("/person_schemas")
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`, `to_a` should be last resource (see [this explanation](https://stackoverflow.com/a/44186921/4352306))
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 "text", "phone_number"
12
+ when 'text', 'phone_number'
13
13
  line
14
- when "number"
15
- Float(line) rescue return nil, false
16
- when "boolean"
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 "select"
18
+ when 'select'
19
19
  return nil, false unless options.include?(line)
20
20
  line
21
- when "date"
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["value"] = [] if multiple
9
+ return doc['value'] = [] if multiple
10
10
 
11
- doc["value"] = nil
11
+ doc['value'] = nil
12
12
  end
13
13
 
14
14
  def value
15
15
  case type
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|
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 "text", "phone_number", "select"
32
- doc["value"] = maybe_multiple(value) do |v|
31
+ when 'text', 'phone_number', 'select'
32
+ doc['value'] = maybe_multiple(value) do |v|
33
33
  v&.to_s
34
34
  end
35
- when "number"
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["value"] = value
43
- when "boolean"
44
- doc["value"] = !!value
45
- when "date"
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["value"] = maybe_multiple(value) do |v|
52
+ doc['value'] = maybe_multiple(value) do |v|
53
53
  v&.to_date&.to_s
54
54
  end
55
55
  else
@@ -6,10 +6,10 @@ module Ecoportal
6
6
  extend Common::BaseClass
7
7
  include Common::Logging
8
8
 
9
- VERSION = "v1".freeze
9
+ VERSION = 'v1'.freeze
10
10
 
11
- class_resolver :people_class, "Ecoportal::API::V1::People"
12
- class_resolver :person_schemas_class, "Ecoportal::API::V1::PersonSchemas"
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: "live.ecoportal.com", logger: default_logger)
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,
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- VERSION = '0.10.7'.freeze
3
+ VERSION = '0.10.9'.freeze
4
4
  end
5
5
  end
data/lib/ecoportal/api.rb CHANGED
@@ -1,15 +1,15 @@
1
- require "cgi"
2
- require "logger"
3
- require "ecoportal/api/version"
4
- require "dotenv/load"
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 "ecoportal/api/logger"
12
- require "ecoportal/api/common"
13
- require "ecoportal/api/errors"
14
- require "ecoportal/api/v1"
15
- require "ecoportal/api/internal"
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.7
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: 2024-11-20 00:00:00.000000000 Z
11
+ date: 2025-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry