eco-helpers 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eco/api/common/people/default_parsers.rb +4 -0
- data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +29 -0
- data/lib/eco/api/common/people/entries.rb +11 -0
- data/lib/eco/api/common/people/person_entry.rb +1 -1
- data/lib/eco/api/common/people/person_parser.rb +2 -2
- data/lib/eco/api/common/session/environment.rb +10 -0
- data/lib/eco/api/session.rb +4 -6
- data/lib/eco/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3d434c6d214ef71d15aa9c2d334b9e5545c057f8fd9cb702f27080ad7b96a57
|
4
|
+
data.tar.gz: 35d9e89911c0aee5f0550eaabcaa6aecdcfd5a6bf97f6d8a53db416fcc957535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24eb7ad2d08a96c2a171e1b5bd41d988f561bbafc764f91df3152a36dec887c456600356fab112d7b95f476eccd742f187a9f3adca19fc05464a85cf34e95a74
|
7
|
+
data.tar.gz: 05a8af94fcf4e966868c447d0e907424c9e615ad942126fc50e6ed53abb7025098edbaea922c060b2e87cadde1e0296dc54f51ed6d71a1198fece5e1753c0766
|
@@ -27,6 +27,9 @@ module Eco
|
|
27
27
|
DateParser.new(self).process
|
28
28
|
MultiParser.new(self).process
|
29
29
|
|
30
|
+
# ALWAYS PRESENT FIELDS
|
31
|
+
SendInvitesParser.new(self).process
|
32
|
+
|
30
33
|
# FORMAT PARSER
|
31
34
|
CSVParser.new(self).process
|
32
35
|
end
|
@@ -42,4 +45,5 @@ require_relative 'default_parsers/boolean_parser'
|
|
42
45
|
require_relative 'default_parsers/numeric_parser'
|
43
46
|
require_relative 'default_parsers/date_parser'
|
44
47
|
require_relative 'default_parsers/multi_parser'
|
48
|
+
require_relative 'default_parsers/send_invites_parser'
|
45
49
|
require_relative 'default_parsers/csv_parser'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Eco
|
2
|
+
module API
|
3
|
+
module Common
|
4
|
+
module People
|
5
|
+
class DefaultParsers
|
6
|
+
class SendInvitesParser < People::BaseParser
|
7
|
+
|
8
|
+
def process
|
9
|
+
@parsers.define_attribute("send_invites") do |parser|
|
10
|
+
parser.def_parser do |hash|
|
11
|
+
value = hash["send_invites"]
|
12
|
+
value.is_a?(Array) ? value.map { |v| truthy(v) } : truthy(value)
|
13
|
+
end.def_serializer do |person|
|
14
|
+
person.account && person.account.send_invites&.to_s
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def truthy (value)
|
22
|
+
%w[true y yes x].include?(value.to_s&.downcase)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -27,6 +27,17 @@ module Eco
|
|
27
27
|
attr('external_id', *args).first
|
28
28
|
end
|
29
29
|
|
30
|
+
def export(filename)
|
31
|
+
CSV.open(filename, "w") do |csv|
|
32
|
+
entry = self.first
|
33
|
+
header = entry.internal_entry.keys
|
34
|
+
csv << header
|
35
|
+
self.each do |entry|
|
36
|
+
csv << entry.internal_entry.values
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
30
41
|
def entry(id: nil, external_id: nil, email: nil)
|
31
42
|
init_caches
|
32
43
|
pers = nil
|
@@ -234,7 +234,7 @@ module Eco
|
|
234
234
|
|
235
235
|
def _set_to_account(person, attr, value)
|
236
236
|
return if !person.account
|
237
|
-
multiple = ["policy_group_ids"].include?(attr)
|
237
|
+
multiple = ["policy_group_ids", "login_provider_ids"].include?(attr)
|
238
238
|
if multiple
|
239
239
|
value = @person_parser.parse(:multiple, value)
|
240
240
|
# preserve previous order
|
@@ -10,7 +10,7 @@ module Eco
|
|
10
10
|
# @attr_reader all_attrs [Array<String>] all the internal name attributes, including _core_, _account_ and _details_.
|
11
11
|
class PersonParser
|
12
12
|
CORE_ATTRS = ["id", "external_id", "email", "name", "supervisor_id", "filter_tags"]
|
13
|
-
ACCOUNT_ATTRS = ["policy_group_ids", "default_tag"]
|
13
|
+
ACCOUNT_ATTRS = ["policy_group_ids", "default_tag", "send_invites", "landing_page_id", "login_provider_ids"]
|
14
14
|
TYPE = [:select, :text, :date, :number, :phone_number, :boolean, :multiple]
|
15
15
|
FORMAT = [:csv, :xml, :json]
|
16
16
|
|
@@ -18,7 +18,7 @@ module Eco
|
|
18
18
|
attr_reader :details_attrs, :all_attrs
|
19
19
|
attr_reader :defined_attrs
|
20
20
|
attr_reader :patch_version
|
21
|
-
|
21
|
+
|
22
22
|
# @example Example of usage:
|
23
23
|
# person_parser = PersonParser.new(schema: schema)
|
24
24
|
# person_parser.define_attribute("example") do |parser|
|
@@ -9,6 +9,7 @@ module Eco
|
|
9
9
|
attr_reader :config, :session
|
10
10
|
attr_reader :api #, :host, :version
|
11
11
|
attr_reader :file_manager, :logger
|
12
|
+
attr_reader :mailer, :s3uploader
|
12
13
|
|
13
14
|
alias_method :fm, :file_manager
|
14
15
|
|
@@ -22,9 +23,18 @@ module Eco
|
|
22
23
|
@session = session
|
23
24
|
@file_manager = Eco::API::Common::Session::FileManager.new(enviro: self)
|
24
25
|
@logger = Eco::API::Common::Session::Logger.new(enviro: self)
|
26
|
+
|
25
27
|
new_api
|
26
28
|
end
|
27
29
|
|
30
|
+
def mailer
|
31
|
+
@mailer ||= Eco::API::Common::Session::Mailer.new(enviro: self)
|
32
|
+
end
|
33
|
+
|
34
|
+
def s3upoader
|
35
|
+
@s3uploader ||= Eco::API::Common::Session::S3Uploader.new(enviro: self)
|
36
|
+
end
|
37
|
+
|
28
38
|
def new_api
|
29
39
|
return nil unless config.apis.active_api
|
30
40
|
|
data/lib/eco/api/session.rb
CHANGED
@@ -40,18 +40,16 @@ module Eco
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def mail_to(**kargs)
|
43
|
-
|
44
|
-
@mailer.mail(**kargs)
|
43
|
+
mail.mail(**kargs)
|
45
44
|
end
|
46
45
|
|
47
46
|
def s3upload(content: nil, file: nil, directory: nil)
|
48
|
-
@s3uploader ||= Eco::API::Common::Session::S3Uploader.new(enviro: enviro)
|
49
47
|
if content && file
|
50
|
-
|
48
|
+
s3uploader.upload(file, content)
|
51
49
|
elsif file
|
52
|
-
|
50
|
+
s3uploader.upload_file(file)
|
53
51
|
elsif directory
|
54
|
-
|
52
|
+
s3uploader.upload_directory(directory)
|
55
53
|
else
|
56
54
|
logger.error("To use Session.s3upload, you must specify either directory, file or content and file name")
|
57
55
|
end
|
data/lib/eco/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eco-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -245,6 +245,7 @@ files:
|
|
245
245
|
- lib/eco/api/common/people/default_parsers/multi_parser.rb
|
246
246
|
- lib/eco/api/common/people/default_parsers/numeric_parser.rb
|
247
247
|
- lib/eco/api/common/people/default_parsers/select_parser.rb
|
248
|
+
- lib/eco/api/common/people/default_parsers/send_invites_parser.rb
|
248
249
|
- lib/eco/api/common/people/entries.rb
|
249
250
|
- lib/eco/api/common/people/entry_factory.rb
|
250
251
|
- lib/eco/api/common/people/person_attribute_parser.rb
|