ecoportal-api 0.5.6 → 0.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31190d7d5719d21b732605d97eccaad0c042f9fc3212fc5f181e6e18e6f12771
4
- data.tar.gz: e7bb04368723c7da36ca8408b05088ed09753c9f9fa53722b32c3ef0df3f6e0e
3
+ metadata.gz: 8071a9704b5accb61bd9db43b0bd6c8c6d6f88aee00ef80d16fd4b5522aedf3c
4
+ data.tar.gz: fc42e6ea6570565a22cb52d9941ace6bcb081b42553321d552c1d1794ec0f8f9
5
5
  SHA512:
6
- metadata.gz: f10ac460fa44b8750825f46648f54d394b36b9a4bec95b138724dd79f278db4014540bb268fecf9e4a3e719b8eb03da1d398a15203776706643eaa9437ba9fe8
7
- data.tar.gz: 67185025081f552f608ba0512fce293ef5a731d31fee2b2132e276eda04f85bd135b0f268936209af1e948ff066f537d7834c005a302ca251f75359d7cfeb758
6
+ metadata.gz: 52a24b2a8f5326e92b42af2781c6a498580dfda7a16458c288b77e7ac5dea01cfa0ed619f27ea7a86d4ce27e4b004c156205a14076ac51cc06203c6abbc28820
7
+ data.tar.gz: 7146daf930693399e4935f0b00645768b64e0c44a7772f0c128042ab151bf29f0598e2e357e0462af77dd423561646c98cdd350e59830bd733e9c51bc120684a
@@ -1,7 +1,67 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [0.5.6] - 2020-06-xx
4
+ ## [0.7.1] - 2020-09-30
5
+
6
+ ### Added
7
+ - `Ecoportal::API::Internal::Permissions`: **update for new ability `tasks` of ecoPortal release `1.5.3`**
8
+ - `Ecoportal::API::V1::People#each`: added keyword argument `silent:` to display download progress
9
+ ### Fixed
10
+ - `Ecoportal::API::V1::People#each`: when no block provided, it was creating an `Enumarator` without preserving the parameters (i.e. `:q` or `per_page` were lost)
11
+
12
+ ## [0.7.0] - 2020-09-11
13
+
14
+ ### Added
15
+ ### Changed
16
+ - `Ecoportal::API::Internal::Permissions`: **update for new abilities of ecoPortal release `1.5.2`**
17
+ - decoupled abilities: `person_core` into `person_core_create`, `person_core_edit`
18
+ ### Fixed
19
+
20
+
21
+ ## [0.6.0] - 2020-07-14
22
+
23
+ ### Added
24
+ - `Ecoportal::API::Common::BaseModel#initial_doc`: `#consolidate!` modifies `original_doc`
25
+ - this helper allows to know what was the initial document the object was created with
26
+ - `Ecoportal::API::Common::BaseModel#as_update`: added parameter (default: `:last` => compare with `original_doc`)
27
+ - calling it with `:total` will compare the current `doc` with the `initial_doc`
28
+ ### Changed
29
+ - `Ecoportal::API::Internal::Permissions`: **update for new abilities of ecoPortal release `1.5.0`**
30
+ - added abilities: `person_core`, `person_account`, `person_details`
31
+ - removed ability: `people`
32
+ - renamed `print` to `pretty_print` to avoid overriding `$stdout.print`, on:
33
+ - `Ecoportal::API::Common::BaseModel`
34
+ - `Ecoportal::API::Common::BatchReponse`
35
+ - `Ecoportal::API::Common::Response`
36
+ - `Ecoportal::API::Common::WrappedResponse`
37
+ ### Fixed
38
+ - `Ecoportal::API::Internal::Preferences`: **kiosk** settings should default to `false` (`nil`)
39
+
40
+ ## [0.5.8] - 2020-06-23
41
+
42
+ ### Added
43
+ ### Changed
44
+ ### Fixed
45
+ - `Ecoportal::API::V1::Person#filter_tags=`: `original_doc["filter_tags"]` is `nil` when creating a person
46
+ - `Ecoportal::API::Internal::Account#policy_group_ids=`: `original_doc["account"]` is `nil` when creating a person
47
+
48
+
49
+ ## [0.5.7] - 2020-06-22
50
+
51
+ ### Added
52
+ - `Ecoportal::API::V1::PersonSchema`: added `enable_tags` & `tags` properties
53
+ - `Ecoportal::API::Internal::Preferences`: added missing fields for **kiosk**
54
+ ### Changed
55
+ - `Ecoportal::API::V1::People::JOB_TIMEOUT`: from 1 minute to 3 minutes
56
+ - `Ecoportal::API::V1::Person#filter_tags=`: will preserve the original order of the matching tags
57
+ * this change is to prevent `as_update` to generate false update positives
58
+ - `Ecoportal::API::Internal::Account#policy_group_ids=`: will preserve the original order of the matching ids
59
+ * this change is to prevent `as_update` to generate false update positives
60
+ ### Fixed
61
+ - `Ecoportal::API::Internal::Preferences`: access `doc` using string keys (not with `symbol` keys)
62
+
63
+
64
+ ## [0.5.6] - 2020-06-08
5
65
 
6
66
  ### Added
7
67
  - this `CHANGELOG.md` file
@@ -20,12 +20,12 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.16"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rspec", "~> 3.0"
23
+ spec.add_development_dependency "bundler", "~> 2.1", ">= 2.1.3"
24
+ spec.add_development_dependency "rake", "~> 12.0"
25
+ spec.add_development_dependency "rspec", "~> 3", ">= 3.9"
26
26
  spec.add_development_dependency "yard", "~> 0.9", ">= 0.9.18"
27
- spec.add_development_dependency "redcarpet", "~> 3.4", ">= 3.4.0"
28
- spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "redcarpet", "~> 3.5", ">= 3.5.0"
28
+ spec.add_development_dependency "pry" , "~> 0.13"
29
29
 
30
30
  spec.add_dependency 'http', '~> 3'
31
31
  spec.add_dependency 'hash-polyfill', '~> 0'
@@ -48,6 +48,7 @@ module Ecoportal
48
48
  if !_parent || !_key
49
49
  @doc = doc
50
50
  @original_doc = JSON.parse(@doc.to_json)
51
+ @initial_doc = JSON.parse(@doc.to_json)
51
52
  end
52
53
  end
53
54
 
@@ -63,6 +64,12 @@ module Ecoportal
63
64
  _parent.original_doc.dig(*[_key].flatten)
64
65
  end
65
66
 
67
+ def initial_doc
68
+ raise UnlinkedModel.new unless linked?
69
+ return @initial_doc if is_root?
70
+ _parent.initial_doc.dig(*[_key].flatten)
71
+ end
72
+
66
73
  def as_json
67
74
  doc
68
75
  end
@@ -71,9 +78,10 @@ module Ecoportal
71
78
  doc.to_json(*args)
72
79
  end
73
80
 
74
- def as_update
81
+ def as_update(ref = :last)
75
82
  new_doc = as_json
76
- Common::HashDiff.diff(new_doc, original_doc)
83
+ ref_doc = ref == :total ? initial_doc : original_doc
84
+ Common::HashDiff.diff(new_doc, ref_doc)
77
85
  end
78
86
 
79
87
  def dirty?
@@ -100,7 +108,7 @@ module Ecoportal
100
108
  end
101
109
  end
102
110
 
103
- def print
111
+ def pretty_print
104
112
  puts JSON.pretty_generate(as_json)
105
113
  self
106
114
  end
@@ -20,10 +20,10 @@ module Ecoportal
20
20
  yield doc
21
21
  end
22
22
  end
23
-
24
- def print
23
+
24
+ def pretty_print
25
25
  if success?
26
- each(&:print)
26
+ each(&:pretty_print)
27
27
  else
28
28
  puts "Request failed."
29
29
  end
@@ -19,8 +19,8 @@ module Ecoportal
19
19
  def success?
20
20
  @status.success?
21
21
  end
22
-
23
- def print
22
+
23
+ def pretty_print
24
24
  puts "Status: #{@status.code}"
25
25
  puts "Body:"
26
26
  puts JSON.pretty_generate(@body)
@@ -40,14 +40,14 @@ module Ecoportal
40
40
  response.success?
41
41
  end
42
42
 
43
- def print
43
+ def pretty_print
44
44
  if success?
45
- each(&:print)
45
+ each(&:pretty_print)
46
46
  else
47
47
  puts "Request failed."
48
48
  end
49
49
  end
50
-
50
+
51
51
  end
52
52
  end
53
53
  end
@@ -12,6 +12,17 @@ module Ecoportal
12
12
  embeds_one :permissions, key: "permissions_custom", klass: :permissions_class
13
13
  embeds_one :preferences, klass: :preferences_class
14
14
 
15
+ # Sets the `policy_group_ids`
16
+ def policy_group_ids=(value)
17
+ unless value.is_a?(Array)
18
+ raise "policy_group_ids= needs to be passed an Array, got #{value.class}"
19
+ end
20
+
21
+ ini_ids = (original_doc && original_doc["policy_group_ids"]) || []
22
+ # preserve original order to avoid false updates
23
+ doc["policy_group_ids"] = (ini_ids & value) + (value - ini_ids)
24
+ end
25
+
15
26
  # Sets the `permissions_preset`.
16
27
  # @note basically the same as `permissions_preset=` but when `"custom"`, it's changed to `nil`
17
28
  # @param value [nil, String] preset name.
@@ -2,7 +2,10 @@ module Ecoportal
2
2
  module API
3
3
  class Internal
4
4
  class Permissions < Common::BaseModel
5
- passthrough :files, :data, :reports, :organization, :people, :pages, :page_editor, :registers
5
+ passthrough :files, :data, :reports
6
+ passthrough :organization, :person_core, :person_core_create, :person_core_edit
7
+ passthrough :person_account, :person_details
8
+ passthrough :pages, :page_editor, :registers, :tasks
6
9
  end
7
10
  end
8
11
  end
@@ -2,22 +2,18 @@ module Ecoportal
2
2
  module API
3
3
  class Internal
4
4
  class Preferences < Common::BaseModel
5
+ passthrough :kiosk_enabled, :kiosk_workflow_message, :kiosk_create_button_label,
6
+ :kiosk_create_button_help, :kiosk_return_button_label, :kiosk_return_button_help,
7
+ :kiosk_dashboard_button_label, :kiosk_dashboard_button_help
8
+
5
9
  [
6
10
  :show_sidebar,
7
11
  :show_shortcuts,
8
12
  :show_coming_soon,
9
13
  :show_recently_visited_forms,
10
14
  :show_tasks,
11
- :show_task_bubbles,
12
- :kiosk_enabled,
13
- :kiosk_workflow_message,
14
- :kiosk_create_button_label,
15
- :kiosk_create_button_help,
16
- :kiosk_return_button_label,
17
- :kiosk_return_button_help,
18
- :kiosk_dashboard_button_label,
19
- :kiosk_dashboard_button_help
20
- ].each do |field|
15
+ :show_task_bubbles
16
+ ].map(&:to_s).each do |field|
21
17
  define_method(field) do
22
18
  if doc.key?(field)
23
19
  doc[field]
@@ -7,7 +7,7 @@ module Ecoportal
7
7
  include Enumerable
8
8
  include Common::DocHelpers
9
9
 
10
- JOB_TIMEOUT = 60
10
+ JOB_TIMEOUT = 240
11
11
  DELAY_STATUS_CHECK = 5
12
12
 
13
13
  class_resolver :person_class, "Ecoportal::API::V1::Person"
@@ -27,15 +27,27 @@ module Ecoportal
27
27
  # @param params [Hash]
28
28
  # @option params [String] :per_page the number of people you get per request.
29
29
  # @option params [String] :q some text to search. Omit this parameter to target all the people.
30
+ # @param silent [Boolean] `false` to show percentage of progress.
30
31
  # @yield [person] does some stuff with the person.
31
32
  # @yieldparam person [Person]
32
- def each(params: {}, &block)
33
- return to_enum(:each) unless block
34
- cursor_id = nil
33
+ def each(params: {}, silent: false, &block)
34
+ return to_enum(:each, params: params, silent: silent) unless block
35
+ cursor_id = nil; results = 0
36
+ puts "\n"
35
37
  loop do
36
38
  params.update(cursor_id: cursor_id) if cursor_id
37
39
  response = client.get("/people", params: params)
38
- raise "Request failed." unless response.success?
40
+ raise "Request failed - Status #{response.status}: #{response.body}" unless response.success?
41
+
42
+ unless silent || (total = response.body["total_results"]) == 0
43
+ results += response.body["results"].length
44
+ percent = results * 100 / total
45
+ msg = "People GET"
46
+ msg += " (search=#{params[:q]})" if params.key?(:q)
47
+ print "#{msg}: #{percent.round}% (of #{total})\r"
48
+ $stdout.flush
49
+ end
50
+
39
51
  response.body["results"].each do |person|
40
52
  yield person_class.new(person)
41
53
  end
@@ -45,13 +57,14 @@ module Ecoportal
45
57
  end
46
58
 
47
59
  # Gets all the people via api requests.
48
- # @note it ignores the key `:page` in `params:`.
60
+ # @note it ignores the key `:cursor_id` in `params:`.
49
61
  # @param params [Hash]
50
62
  # @option params [Integer] :per_page the number of people you get per request.
51
63
  # @option params [String] :q some text to search.
64
+ # @param silent [Boolean] `false` to show percentage of progress.
52
65
  # @return [Array<Person>] the array of people got via api.
53
- def get_all(params: {})
54
- each(params: params).to_a
66
+ def get_all(params: {}, silent: false)
67
+ each(params: params, silent: silent).to_a
55
68
  end
56
69
 
57
70
  # Gets a person via api.
@@ -49,12 +49,16 @@ module Ecoportal
49
49
  unless value.is_a?(Array)
50
50
  raise "filter_tags= needs to be passed an Array, got #{value.class}"
51
51
  end
52
- doc["filter_tags"] = value.map do |tag|
52
+ end_tags = value.map do |tag|
53
53
  unless tag.match(VALID_TAG_REGEX)
54
54
  raise "Invalid filter tag #{tag.inspect}"
55
55
  end
56
56
  tag.upcase
57
57
  end
58
+
59
+ ini_tags = (original_doc && original_doc["filter_tags"]) || []
60
+ # preserve original order to avoid false updates
61
+ doc["filter_tags"] = (ini_tags & end_tags) + (end_tags - ini_tags)
58
62
  end
59
63
 
60
64
  def as_json
@@ -3,6 +3,7 @@ module Ecoportal
3
3
  class V1
4
4
  class PersonSchema < Common::BaseModel
5
5
  passthrough :id, :name
6
+ passthrough :enable_tags, :tags
6
7
 
7
8
  class_resolver :schema_field_class, "Ecoportal::API::V1::SchemaField"
8
9
 
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- VERSION = "0.5.6"
3
+ VERSION = "0.7.1"
4
4
  end
5
5
  end
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.5.6
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tapio Saarinen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-08 00:00:00.000000000 Z
11
+ date: 2020-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,42 +16,54 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '2.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.1.3
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '1.16'
29
+ version: '2.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.1.3
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rake
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '10.0'
39
+ version: '12.0'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '10.0'
46
+ version: '12.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rspec
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '3.0'
53
+ version: '3'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '3.9'
48
57
  type: :development
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
61
  - - "~>"
53
62
  - !ruby/object:Gem::Version
54
- version: '3.0'
63
+ version: '3'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '3.9'
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: yard
57
69
  requirement: !ruby/object:Gem::Requirement
@@ -78,34 +90,34 @@ dependencies:
78
90
  requirements:
79
91
  - - ">="
80
92
  - !ruby/object:Gem::Version
81
- version: 3.4.0
93
+ version: 3.5.0
82
94
  - - "~>"
83
95
  - !ruby/object:Gem::Version
84
- version: '3.4'
96
+ version: '3.5'
85
97
  type: :development
86
98
  prerelease: false
87
99
  version_requirements: !ruby/object:Gem::Requirement
88
100
  requirements:
89
101
  - - ">="
90
102
  - !ruby/object:Gem::Version
91
- version: 3.4.0
103
+ version: 3.5.0
92
104
  - - "~>"
93
105
  - !ruby/object:Gem::Version
94
- version: '3.4'
106
+ version: '3.5'
95
107
  - !ruby/object:Gem::Dependency
96
108
  name: pry
97
109
  requirement: !ruby/object:Gem::Requirement
98
110
  requirements:
99
- - - ">="
111
+ - - "~>"
100
112
  - !ruby/object:Gem::Version
101
- version: '0'
113
+ version: '0.13'
102
114
  type: :development
103
115
  prerelease: false
104
116
  version_requirements: !ruby/object:Gem::Requirement
105
117
  requirements:
106
- - - ">="
118
+ - - "~>"
107
119
  - !ruby/object:Gem::Version
108
- version: '0'
120
+ version: '0.13'
109
121
  - !ruby/object:Gem::Dependency
110
122
  name: http
111
123
  requirement: !ruby/object:Gem::Requirement
@@ -151,7 +163,6 @@ files:
151
163
  - ".yardopts"
152
164
  - CHANGELOG.md
153
165
  - Gemfile
154
- - Gemfile.lock
155
166
  - LICENSE
156
167
  - README.md
157
168
  - Rakefile
@@ -171,7 +182,6 @@ files:
171
182
  - lib/ecoportal/api/common/response.rb
172
183
  - lib/ecoportal/api/common/wrapped_response.rb
173
184
  - lib/ecoportal/api/internal.rb
174
- - lib/ecoportal/api/internal/.git-keep
175
185
  - lib/ecoportal/api/internal/account.rb
176
186
  - lib/ecoportal/api/internal/login_provider.rb
177
187
  - lib/ecoportal/api/internal/login_providers.rb
@@ -188,7 +198,6 @@ files:
188
198
  - lib/ecoportal/api/internal/schema_field_value.rb
189
199
  - lib/ecoportal/api/logger.rb
190
200
  - lib/ecoportal/api/v1.rb
191
- - lib/ecoportal/api/v1/.git-keep
192
201
  - lib/ecoportal/api/v1/people.rb
193
202
  - lib/ecoportal/api/v1/person.rb
194
203
  - lib/ecoportal/api/v1/person_details.rb
File without changes
File without changes