ecoportal-api 0.3.8 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +11 -3
- data/.yardopts +10 -0
- data/Gemfile.lock +10 -5
- data/Rakefile +22 -1
- data/ecoportal-api.gemspec +6 -4
- data/lib/ecoportal/api/common.rb +7 -4
- data/lib/ecoportal/api/common/base_class.rb +29 -0
- data/lib/ecoportal/api/common/base_model.rb +89 -20
- data/lib/ecoportal/api/common/batch_operation.rb +0 -1
- data/lib/ecoportal/api/common/batch_response.rb +5 -0
- data/lib/ecoportal/api/common/client.rb +61 -1
- data/lib/ecoportal/api/common/doc_helpers.rb +2 -0
- data/lib/ecoportal/api/common/hash_diff.rb +25 -23
- data/lib/ecoportal/api/common/response.rb +4 -0
- data/lib/ecoportal/api/common/wrapped_response.rb +19 -10
- data/lib/ecoportal/api/internal.rb +17 -20
- data/lib/ecoportal/api/internal/account.rb +23 -16
- data/lib/ecoportal/api/internal/login_provider.rb +1 -1
- data/lib/ecoportal/api/internal/login_providers.rb +10 -0
- data/lib/ecoportal/api/internal/people.rb +3 -8
- data/lib/ecoportal/api/internal/permissions.rb +1 -1
- data/lib/ecoportal/api/internal/person.rb +18 -16
- data/lib/ecoportal/api/internal/person_details.rb +1 -5
- data/lib/ecoportal/api/internal/person_schema.rb +1 -5
- data/lib/ecoportal/api/internal/person_schemas.rb +2 -6
- data/lib/ecoportal/api/internal/policy_group.rb +1 -1
- data/lib/ecoportal/api/internal/policy_groups.rb +10 -1
- data/lib/ecoportal/api/v1.rb +27 -4
- data/lib/ecoportal/api/v1/people.rb +62 -25
- data/lib/ecoportal/api/v1/person.rb +47 -28
- data/lib/ecoportal/api/v1/person_details.rb +27 -13
- data/lib/ecoportal/api/v1/person_schema.rb +3 -6
- data/lib/ecoportal/api/v1/person_schemas.rb +26 -9
- data/lib/ecoportal/api/v1/schema_field.rb +1 -1
- data/lib/ecoportal/api/v1/schema_field_value.rb +2 -1
- data/lib/ecoportal/api/version.rb +1 -1
- metadata +45 -3
@@ -1,28 +1,45 @@
|
|
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
5
|
class PersonSchemas
|
6
|
+
extend Common::BaseClass
|
5
7
|
include Enumerable
|
8
|
+
|
9
|
+
class_resolver :person_schema_class, "Ecoportal::API::V1::PersonSchema"
|
10
|
+
|
6
11
|
attr_reader :client
|
12
|
+
|
13
|
+
# @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
|
14
|
+
# @return [Schemas] an instance object ready to make schema api requests.
|
7
15
|
def initialize(client)
|
8
16
|
@client = client
|
9
17
|
end
|
10
18
|
|
19
|
+
# Gets all the schemas via api request.
|
20
|
+
# @return [Enumerable<PersonSchema>] an `Enumerable` with all schemas already wrapped as `PersonSchema` objects.
|
21
|
+
def get_all
|
22
|
+
response = client.get("/person_schemas")
|
23
|
+
Common::WrappedResponse.new(response, person_schema_class)
|
24
|
+
end
|
25
|
+
|
26
|
+
# If a `block` is **not** given it calls [Object#to_enum](https://ruby-doc.org/core-2.6.2/Object.html#method-i-to_enum)
|
27
|
+
# Otherwise it calls `get_all`.
|
28
|
+
# @note
|
29
|
+
# - `:params` doesn't really do anything.
|
30
|
+
# - same as #get_all but with block :)
|
31
|
+
# - `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
|
+
# @yield [schema] does some stuff with the schema.
|
34
|
+
# @yieldparam schema [PersonSchema]
|
35
|
+
# @yieldreturn [PersonSchema]
|
36
|
+
# @return [Enumerable<PersonSchema>] an `Enumerable` with all the person schema objects.
|
11
37
|
def each(params: {}, &block)
|
12
38
|
return to_enum(:each) unless block
|
13
39
|
get_all.each(&block)
|
14
40
|
end
|
15
41
|
|
16
|
-
def get_all
|
17
|
-
response = @client.get("/person_schemas")
|
18
|
-
Common::WrappedResponse.new(response, person_schema_class)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
42
|
|
23
|
-
def person_schema_class
|
24
|
-
V1::PersonSchema
|
25
|
-
end
|
26
43
|
end
|
27
44
|
end
|
28
45
|
end
|
@@ -2,7 +2,7 @@ module Ecoportal
|
|
2
2
|
module API
|
3
3
|
class V1
|
4
4
|
class SchemaField < Common::BaseModel
|
5
|
-
passthrough :id, :alt_id, :name, :optional, :shared, :multiple, :type, :options
|
5
|
+
passthrough :id, :alt_id, :name, :optional, :shared, :multiple, :type, :options
|
6
6
|
|
7
7
|
def parse_text(value)
|
8
8
|
values = [*value.to_s.lines].map do |line|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module Ecoportal
|
2
2
|
module API
|
3
3
|
class V1
|
4
|
+
# @todo Rename to PersonDetailsField
|
4
5
|
class SchemaFieldValue < Common::BaseModel
|
5
|
-
passthrough :id, :alt_id, :type, :name, :shared, :multiple
|
6
|
+
passthrough :id, :alt_id, :type, :name, :shared, :multiple
|
6
7
|
|
7
8
|
def value
|
8
9
|
return @value if defined?(@value)
|
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.
|
4
|
+
version: 0.4.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: 2019-
|
11
|
+
date: 2019-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,46 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.9.18
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0.9'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.9.18
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: redcarpet
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 3.4.0
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '3.4'
|
85
|
+
type: :development
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 3.4.0
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '3.4'
|
55
95
|
- !ruby/object:Gem::Dependency
|
56
96
|
name: http
|
57
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,6 +130,7 @@ files:
|
|
90
130
|
- ".gitignore"
|
91
131
|
- ".rspec"
|
92
132
|
- ".travis.yml"
|
133
|
+
- ".yardopts"
|
93
134
|
- Gemfile
|
94
135
|
- Gemfile.lock
|
95
136
|
- LICENSE
|
@@ -100,6 +141,7 @@ files:
|
|
100
141
|
- ecoportal-api.gemspec
|
101
142
|
- lib/ecoportal/api.rb
|
102
143
|
- lib/ecoportal/api/common.rb
|
144
|
+
- lib/ecoportal/api/common/base_class.rb
|
103
145
|
- lib/ecoportal/api/common/base_model.rb
|
104
146
|
- lib/ecoportal/api/common/batch_operation.rb
|
105
147
|
- lib/ecoportal/api/common/batch_response.rb
|
@@ -155,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
197
|
- !ruby/object:Gem::Version
|
156
198
|
version: '0'
|
157
199
|
requirements: []
|
158
|
-
rubygems_version: 3.0.
|
200
|
+
rubygems_version: 3.0.3
|
159
201
|
signing_key:
|
160
202
|
specification_version: 4
|
161
203
|
summary: A collection of helpers for interacting with the ecoPortal MS's various APIs
|