ecoportal-api 0.10.11 → 0.10.14
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/.rubocop.yml +1 -1
- data/CHANGELOG.md +19 -1
- data/lib/ecoportal/api/common/client.rb +22 -9
- data/lib/ecoportal/api/v1/person.rb +25 -0
- data/lib/ecoportal/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42c60da1fe6f9c6176e85d65b5283b75b54af11f5e977788eddd7fde57bba953
|
4
|
+
data.tar.gz: d5bf03e2eaec6dad5778f8a0ce693b9a29d9786331e5517facab0e28941abccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5d0dfc99e97e97b857a1f424b80e4211811ed7ef6250300a9cd8614a39d5281fef6661519d915a29980a8347368b50bcf7961cfb5a676b6b6d196f16a48cafb
|
7
|
+
data.tar.gz: 1ca5a7a3ffc81adc74679524ad715d4833e665867041e7c2c25eace44e98d9612a330dad433e0db4c9e85d95e5fbc5209fc5c46705c1510e91280a011a122c11
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,12 +2,30 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
## [0.10.
|
5
|
+
## [0.10.15] - 2025-08-xx
|
6
6
|
|
7
7
|
### Added
|
8
8
|
|
9
9
|
### Changed
|
10
10
|
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
## [0.10.14] - 2025-08-15
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- `Person#phone_number`
|
18
|
+
|
19
|
+
## [0.10.12] - 2025-05-30
|
20
|
+
|
21
|
+
### Added
|
22
|
+
|
23
|
+
- `Client#post` **added** named argument `params` (for the **url** arguments)
|
24
|
+
|
25
|
+
## [0.10.11] - 2025-05-15
|
26
|
+
|
27
|
+
### Changed
|
28
|
+
|
11
29
|
- `MAX_START_DELAY` to be `120` (it was `60`).
|
12
30
|
|
13
31
|
### Fixed
|
@@ -27,7 +27,8 @@ module Ecoportal
|
|
27
27
|
include WithRetry
|
28
28
|
include RateThrottling
|
29
29
|
|
30
|
-
DEFAULT_HOST
|
30
|
+
DEFAULT_HOST = 'live.ecoportal.com'.freeze
|
31
|
+
MAIN_END_POINT = 'api'.freeze
|
31
32
|
|
32
33
|
attr_accessor :logger
|
33
34
|
attr_reader :host
|
@@ -47,9 +48,9 @@ module Ecoportal
|
|
47
48
|
@deep_logging = deep_logging
|
48
49
|
|
49
50
|
if host.match(/^localhost|^127\.0\.0\.1/)
|
50
|
-
@base_uri = "http://#{host}/
|
51
|
+
@base_uri = "http://#{host}/#{main_end_point}/"
|
51
52
|
else
|
52
|
-
@base_uri = "https://#{host}/
|
53
|
+
@base_uri = "https://#{host}/#{main_end_point}/"
|
53
54
|
end
|
54
55
|
|
55
56
|
if deep_logging?
|
@@ -58,7 +59,7 @@ module Ecoportal
|
|
58
59
|
}
|
59
60
|
end
|
60
61
|
|
61
|
-
return unless
|
62
|
+
return unless api_key.nil? || api_key.match(/\A\W*\z/)
|
62
63
|
return unless version
|
63
64
|
|
64
65
|
log(:error) { 'Api-key missing!' }
|
@@ -85,11 +86,17 @@ module Ecoportal
|
|
85
86
|
# @note it automatically adds the http header param `Content-Type` as `application/json`
|
86
87
|
# @param path [String] the tail that completes the url of the request.
|
87
88
|
# @param data [String] the body of the query in json format.
|
89
|
+
# @param params [Hash] the header paramters of the http request (not including the api key).
|
90
|
+
# @option params [String] URL params; will depend on he API being used.
|
88
91
|
# @return [Common::Reponse] the basic custom response object.
|
89
|
-
def post(path, data:)
|
90
|
-
instrument('POST', path,
|
92
|
+
def post(path, data:, params: {})
|
93
|
+
instrument('POST', path, params) do
|
91
94
|
request do |http|
|
92
|
-
http.post(
|
95
|
+
http.post(
|
96
|
+
url_for(path),
|
97
|
+
json: data,
|
98
|
+
params: params
|
99
|
+
)
|
93
100
|
end
|
94
101
|
end
|
95
102
|
end
|
@@ -144,9 +151,9 @@ module Ecoportal
|
|
144
151
|
@base_request ||=
|
145
152
|
case @version
|
146
153
|
when 'v2'
|
147
|
-
HTTP.headers('X-ECOPORTAL-API-KEY' =>
|
154
|
+
HTTP.headers('X-ECOPORTAL-API-KEY' => api_key).accept(:json)
|
148
155
|
else
|
149
|
-
HTTP.headers('X-ApiKey' =>
|
156
|
+
HTTP.headers('X-ApiKey' => api_key).accept(:json)
|
150
157
|
end
|
151
158
|
end
|
152
159
|
|
@@ -159,6 +166,8 @@ module Ecoportal
|
|
159
166
|
|
160
167
|
private
|
161
168
|
|
169
|
+
attr_reader :api_key
|
170
|
+
|
162
171
|
def instrument(method, path, data = nil, &block)
|
163
172
|
raise 'Expected block' unless block_given?
|
164
173
|
|
@@ -203,6 +212,10 @@ module Ecoportal
|
|
203
212
|
puts "(#{level}) #{yield}"
|
204
213
|
logger&.send(level, &block)
|
205
214
|
end
|
215
|
+
|
216
|
+
def main_end_point
|
217
|
+
self.class::MAIN_END_POINT
|
218
|
+
end
|
206
219
|
end
|
207
220
|
end
|
208
221
|
end
|
@@ -13,6 +13,8 @@ module Ecoportal
|
|
13
13
|
alias_method :archived?, :archived
|
14
14
|
|
15
15
|
passthrough :supervisor_id, :contractor_organization_id
|
16
|
+
|
17
|
+
passthrough :phone_number
|
16
18
|
passthrough :brand_id
|
17
19
|
passthrough :freemium
|
18
20
|
|
@@ -22,6 +24,7 @@ module Ecoportal
|
|
22
24
|
|
23
25
|
VALID_TAG_REGEX = /^[A-Za-z0-9 &_'\/.-]+$/
|
24
26
|
VALID_EMAIL_REGEX = /^[^@\s]+@[^@\s]+\.[^@\s]+$/
|
27
|
+
NON_PHONE_REGEX = /[^+0-9]/
|
25
28
|
|
26
29
|
def unarchive!
|
27
30
|
self.archived = false
|
@@ -65,6 +68,15 @@ module Ecoportal
|
|
65
68
|
doc['email'] = value&.downcase
|
66
69
|
end
|
67
70
|
|
71
|
+
# @note this property is read-only in the APIv0.
|
72
|
+
# Sets the **primary** phone number of a person.
|
73
|
+
# @param value [String, nil] the phone number of this person.
|
74
|
+
def phone_number=(value)
|
75
|
+
return
|
76
|
+
|
77
|
+
doc['phone_number'] = parse_number(value)
|
78
|
+
end
|
79
|
+
|
68
80
|
# Validates the string tags of the array, and sets the `filter_tags` property of the account.
|
69
81
|
# @note all is set in upper case and preserves the original order.
|
70
82
|
# @raise [Exception] if there was any invalid string tag.
|
@@ -146,6 +158,19 @@ module Ecoportal
|
|
146
158
|
}
|
147
159
|
end
|
148
160
|
end
|
161
|
+
|
162
|
+
private
|
163
|
+
|
164
|
+
def parse_number(value)
|
165
|
+
value = value.to_s.strip
|
166
|
+
return if value.empty?
|
167
|
+
|
168
|
+
value.gsub(NON_PHONE_REGEX, '').then do |str|
|
169
|
+
next str if str.start_with?('+')
|
170
|
+
|
171
|
+
"+#{str}"
|
172
|
+
end
|
173
|
+
end
|
149
174
|
end
|
150
175
|
end
|
151
176
|
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.10.
|
4
|
+
version: 0.10.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tapio Saarinen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|