go_import 3.0.30 → 3.0.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/go_import/can_become_immutable.rb +29 -0
- data/lib/go_import/errors.rb +3 -0
- data/lib/go_import/model/coworker.rb +9 -3
- data/lib/go_import/model/deal.rb +14 -3
- data/lib/go_import/model/note.rb +10 -2
- data/lib/go_import/model/organization.rb +32 -7
- data/lib/go_import/model/person.rb +15 -4
- data/lib/go_import/model/rootmodel.rb +8 -2
- data/lib/go_import/model_helpers.rb +24 -0
- data/lib/go_import.rb +1 -0
- data/sources/lime-easy/.go_import/runner.rb +1 -1
- data/spec/helpers/xsd_validate_spec.rb +4 -5
- data/spec/person_spec.rb +15 -0
- data/spec/rootmodel_spec.rb +52 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTVkMWQ0NTA0ZWFlZGVlYTQ3NWMwODA4YmJhNzNkYjRiN2MxNTZiYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDIzYTJlZmZmMzMwNzQzZmMwZGRmYTE4ODZhMjEyNGUzYTg4M2I3ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWVkNDJmMmIwNDA2NTNjMjE4MDUzYjgxODE5YjFkZDFlMjk1MmJlMjUwODU5
|
10
|
+
Yjc0NDA2ZDlkMjc3MGRiNzdhOWJmZjkzYTBmNzkyN2JlMTY2NjE4ZjUyMTM0
|
11
|
+
ZmVhYWFjZTVlZjc0NmY0ODlkMGUxZTZjM2U4MDk0ZDQwZGM2NTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGQ3MTNjODdlNjc1YjQ0MTlmY2ZjOThjNzU0OWQwZjA2YTAzYTQ3N2RhODEw
|
14
|
+
M2UzMmY5NTFiNjIyMmMwNThmMThhODhiMDZlMjI1ZTJhNmExZTJmMDIxN2I3
|
15
|
+
YjM0OTM3NjAzMGFhNmQyOGVmZTViZWQ5NmZlMzc5M2E1MzliOTE=
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
module GoImport
|
3
|
+
class CanBecomeImmutable
|
4
|
+
def self.immutable_accessor(name)
|
5
|
+
define_method(name) do
|
6
|
+
return instance_variable_get("@#{name}")
|
7
|
+
end
|
8
|
+
|
9
|
+
define_method("#{name}=") do |value|
|
10
|
+
raise_if_immutable
|
11
|
+
instance_variable_set("@#{name}", value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def raise_if_immutable
|
16
|
+
if @is_immutable
|
17
|
+
raise ObjectIsImmutableError
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_is_immutable()
|
22
|
+
@is_immutable = true
|
23
|
+
end
|
24
|
+
|
25
|
+
def is_immutable()
|
26
|
+
@is_immutable
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/go_import/errors.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module GoImport
|
3
|
-
class Coworker
|
3
|
+
class Coworker < CanBecomeImmutable
|
4
4
|
include SerializeHelper
|
5
|
-
|
6
|
-
|
5
|
+
immutable_accessor :id
|
6
|
+
immutable_accessor :integration_id
|
7
|
+
immutable_accessor :email
|
8
|
+
immutable_accessor :first_name
|
9
|
+
immutable_accessor :last_name
|
10
|
+
immutable_accessor :direct_phone_number
|
11
|
+
immutable_accessor :mobile_phone_number
|
12
|
+
immutable_accessor :home_phone_number
|
7
13
|
|
8
14
|
def initialize(opt = nil)
|
9
15
|
if opt != nil
|
data/lib/go_import/model/deal.rb
CHANGED
@@ -34,14 +34,19 @@ module GoImport
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
class Deal
|
37
|
+
class Deal < CanBecomeImmutable
|
38
38
|
include SerializeHelper, ModelHasCustomFields, ModelHasTags
|
39
39
|
|
40
40
|
# Get/set the deal's status. Statuses must be configured in
|
41
41
|
# LIME Go before the import.
|
42
|
-
|
42
|
+
immutable_accessor :status
|
43
43
|
|
44
|
-
|
44
|
+
immutable_accessor :id
|
45
|
+
immutable_accessor :integration_id
|
46
|
+
immutable_accessor :name
|
47
|
+
immutable_accessor :description
|
48
|
+
immutable_accessor :probability
|
49
|
+
immutable_accessor :order_date
|
45
50
|
|
46
51
|
# you add custom values by using {#set_custom_value}
|
47
52
|
attr_reader :custom_values
|
@@ -132,12 +137,14 @@ module GoImport
|
|
132
137
|
# already exists in the application use the status label
|
133
138
|
# (String) or integration id (Integer) here.
|
134
139
|
def status=(status)
|
140
|
+
raise_if_immutable
|
135
141
|
@status = DealStatus.new if @status.nil?
|
136
142
|
|
137
143
|
@status.status_reference = DealStatusReference.from_deal_status(status)
|
138
144
|
end
|
139
145
|
|
140
146
|
def customer=(customer)
|
147
|
+
raise_if_immutable
|
141
148
|
@customer_reference = OrganizationReference.from_organization(customer)
|
142
149
|
|
143
150
|
if customer.is_a?(Organization)
|
@@ -151,6 +158,7 @@ module GoImport
|
|
151
158
|
end
|
152
159
|
|
153
160
|
def responsible_coworker=(coworker)
|
161
|
+
raise_if_immutable
|
154
162
|
@responsible_coworker_reference = CoworkerReference.from_coworker(coworker)
|
155
163
|
|
156
164
|
if coworker.is_a?(Coworker)
|
@@ -159,6 +167,7 @@ module GoImport
|
|
159
167
|
end
|
160
168
|
|
161
169
|
def customer_contact=(person)
|
170
|
+
raise_if_immutable
|
162
171
|
@customer_contact_reference = PersonReference.from_person(person)
|
163
172
|
|
164
173
|
if person.is_a?(Person)
|
@@ -171,6 +180,8 @@ module GoImport
|
|
171
180
|
# ignored. This makes it easier for us to convert a string
|
172
181
|
# into an integer value.
|
173
182
|
def value=(value)
|
183
|
+
raise_if_immutable
|
184
|
+
|
174
185
|
if value.nil?
|
175
186
|
@value = "0"
|
176
187
|
elsif value.respond_to?(:empty?) && value.empty?
|
data/lib/go_import/model/note.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module GoImport
|
2
|
-
class Note
|
2
|
+
class Note < CanBecomeImmutable
|
3
3
|
include SerializeHelper
|
4
|
-
|
4
|
+
immutable_accessor :id
|
5
|
+
immutable_accessor :integration_id
|
6
|
+
immutable_accessor :date
|
5
7
|
|
6
8
|
attr_reader :text
|
7
9
|
attr_reader :organization, :created_by, :person, :deal
|
@@ -51,6 +53,7 @@ module GoImport
|
|
51
53
|
end
|
52
54
|
|
53
55
|
def organization=(org)
|
56
|
+
raise_if_immutable
|
54
57
|
@organization_reference = OrganizationReference.from_organization(org)
|
55
58
|
|
56
59
|
if org.is_a?(Organization)
|
@@ -59,6 +62,7 @@ module GoImport
|
|
59
62
|
end
|
60
63
|
|
61
64
|
def created_by=(coworker)
|
65
|
+
raise_if_immutable
|
62
66
|
@created_by_reference = CoworkerReference.from_coworker(coworker)
|
63
67
|
|
64
68
|
if coworker.is_a?(Coworker)
|
@@ -67,6 +71,7 @@ module GoImport
|
|
67
71
|
end
|
68
72
|
|
69
73
|
def person=(person)
|
74
|
+
raise_if_immutable
|
70
75
|
@person_reference = PersonReference.from_person(person)
|
71
76
|
|
72
77
|
if person.is_a?(Person)
|
@@ -75,6 +80,7 @@ module GoImport
|
|
75
80
|
end
|
76
81
|
|
77
82
|
def deal=(deal)
|
83
|
+
raise_if_immutable
|
78
84
|
@deal_reference = DealReference.from_deal(deal)
|
79
85
|
|
80
86
|
if deal.is_a?(Deal)
|
@@ -83,6 +89,7 @@ module GoImport
|
|
83
89
|
end
|
84
90
|
|
85
91
|
def classification=(classification)
|
92
|
+
raise_if_immutable
|
86
93
|
if classification == NoteClassification::Comment || classification == NoteClassification::SalesCall ||
|
87
94
|
classification == NoteClassification::TalkedTo || classification == NoteClassification::TriedToReach ||
|
88
95
|
classification == NoteClassification::ClientVisit
|
@@ -93,6 +100,7 @@ module GoImport
|
|
93
100
|
end
|
94
101
|
|
95
102
|
def text=(text)
|
103
|
+
raise_if_immutable
|
96
104
|
@text = text
|
97
105
|
|
98
106
|
if @text.nil?
|
@@ -37,12 +37,20 @@ module GoImport
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
41
|
-
class Organization
|
40
|
+
|
41
|
+
class Organization < CanBecomeImmutable
|
42
42
|
include SerializeHelper, ModelHasCustomFields, ModelHasTags
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
|
44
|
+
immutable_accessor :id
|
45
|
+
immutable_accessor :integration_id
|
46
|
+
immutable_accessor :name
|
47
|
+
immutable_accessor :organization_number
|
48
|
+
immutable_accessor :email
|
49
|
+
immutable_accessor :web_site
|
50
|
+
immutable_accessor :postal_address
|
51
|
+
immutable_accessor :visit_address
|
52
|
+
immutable_accessor :central_phone_number
|
53
|
+
immutable_accessor :source_data
|
46
54
|
|
47
55
|
# Sets/gets the date when this organization's relation was
|
48
56
|
# changed. Default is Now.
|
@@ -127,10 +135,23 @@ module GoImport
|
|
127
135
|
@employees = [] if @employees == nil
|
128
136
|
person = if val.is_a? Person then val else Person.new(val) end
|
129
137
|
@employees.push(person)
|
130
|
-
|
138
|
+
|
139
|
+
# *** TODO:
|
140
|
+
#
|
141
|
+
# The person should be immutable after it has been added
|
142
|
+
# to the organization. However most sources (LIME Easy,
|
143
|
+
# LIME Pro, Excel, SalesForce, etc) are updating the
|
144
|
+
# person after is has been added to the organization. We
|
145
|
+
# must update the sources before we can set the person
|
146
|
+
# immutable here.
|
147
|
+
|
148
|
+
#person.set_is_immutable
|
149
|
+
|
150
|
+
return person
|
131
151
|
end
|
132
152
|
|
133
153
|
def responsible_coworker=(coworker)
|
154
|
+
raise_if_immutable
|
134
155
|
@responsible_coworker_reference = CoworkerReference.from_coworker(coworker)
|
135
156
|
|
136
157
|
if coworker.is_a?(Coworker)
|
@@ -142,6 +163,8 @@ module GoImport
|
|
142
163
|
# relation must be a valid value from the Relation module
|
143
164
|
# otherwise an InvalidRelationError error will be thrown.
|
144
165
|
def relation=(relation)
|
166
|
+
raise_if_immutable
|
167
|
+
|
145
168
|
if relation == Relation::NoRelation || relation == Relation::WorkingOnIt ||
|
146
169
|
relation == Relation::IsACustomer || relation == Relation::WasACustomer || relation == Relation::BeenInTouch
|
147
170
|
@relation = relation
|
@@ -151,8 +174,10 @@ module GoImport
|
|
151
174
|
raise InvalidRelationError
|
152
175
|
end
|
153
176
|
end
|
154
|
-
|
177
|
+
|
155
178
|
def relation_last_modified=(date)
|
179
|
+
raise_if_immutable
|
180
|
+
|
156
181
|
begin
|
157
182
|
@relation_last_modified = @relation != Relation::NoRelation ? Date.parse(date).strftime("%Y-%m-%d") : nil
|
158
183
|
rescue
|
@@ -28,11 +28,22 @@ module GoImport
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
class Person <
|
31
|
+
class Person < CanBecomeImmutable
|
32
32
|
include SerializeHelper, ModelHasCustomFields, ModelHasTags
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
|
34
|
+
immutable_accessor :id
|
35
|
+
immutable_accessor :integration_id
|
36
|
+
immutable_accessor :first_name
|
37
|
+
immutable_accessor :last_name
|
38
|
+
immutable_accessor :direct_phone_number
|
39
|
+
immutable_accessor :fax_phone_number
|
40
|
+
immutable_accessor :mobile_phone_number
|
41
|
+
immutable_accessor :home_phone_number
|
42
|
+
immutable_accessor :position
|
43
|
+
immutable_accessor :email
|
44
|
+
immutable_accessor :alternative_email
|
45
|
+
immutable_accessor :postal_address
|
46
|
+
immutable_accessor :currently_employed
|
36
47
|
|
37
48
|
# you add custom values by using {#set_custom_value}
|
38
49
|
attr_reader :custom_values, :organization
|
@@ -72,6 +72,7 @@ module GoImport
|
|
72
72
|
end
|
73
73
|
|
74
74
|
@coworkers[coworker.integration_id] = coworker
|
75
|
+
coworker.set_is_immutable
|
75
76
|
|
76
77
|
return coworker
|
77
78
|
end
|
@@ -100,6 +101,7 @@ module GoImport
|
|
100
101
|
end
|
101
102
|
|
102
103
|
@organizations[organization.integration_id] = organization
|
104
|
+
organization.set_is_immutable
|
103
105
|
|
104
106
|
return organization
|
105
107
|
end
|
@@ -132,6 +134,7 @@ module GoImport
|
|
132
134
|
end
|
133
135
|
|
134
136
|
@deals[deal.integration_id] = deal
|
137
|
+
deal.set_is_immutable
|
135
138
|
|
136
139
|
return deal
|
137
140
|
end
|
@@ -168,6 +171,7 @@ module GoImport
|
|
168
171
|
end
|
169
172
|
|
170
173
|
@notes[note.integration_id] = note
|
174
|
+
note.set_is_immutable
|
171
175
|
|
172
176
|
return note
|
173
177
|
end
|
@@ -288,7 +292,8 @@ module GoImport
|
|
288
292
|
end
|
289
293
|
|
290
294
|
converter_deal_statuses = @settings.deal.statuses.map {|status| status.label} if @settings.deal != nil
|
291
|
-
@deals.each do |deal|
|
295
|
+
@deals.each do |key, deal|
|
296
|
+
#@deals.each do |deal|
|
292
297
|
error, warning = deal.validate converter_deal_statuses
|
293
298
|
|
294
299
|
if !error.empty?
|
@@ -299,7 +304,8 @@ module GoImport
|
|
299
304
|
end
|
300
305
|
end
|
301
306
|
|
302
|
-
|
307
|
+
#@notes.each do |note|
|
308
|
+
@notes.each do |key, note|
|
303
309
|
validation_message = note.validate
|
304
310
|
|
305
311
|
if !validation_message.empty?
|
@@ -33,6 +33,30 @@ module GoImport
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
module ImmutableModel
|
37
|
+
@is_immutable = false
|
38
|
+
def self.immutable_accessor(name)
|
39
|
+
define_method(name) do
|
40
|
+
return instance_variable_get("@#{name}")
|
41
|
+
end
|
42
|
+
|
43
|
+
define_method("#{name}=") do |value|
|
44
|
+
raise_if_immutable
|
45
|
+
instance_variable_set("@#{name}", value)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def raise_if_immutable
|
50
|
+
if @is_immutable
|
51
|
+
raise ObjectIsImmutableError
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def is_immutable()
|
56
|
+
@is_immutable = true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
36
60
|
module ModelWithIntegrationIdSameAs
|
37
61
|
# check if other is same as regarding integration_id or id
|
38
62
|
def same_as?(other)
|
data/lib/go_import.rb
CHANGED
@@ -7,6 +7,7 @@ module GoImport
|
|
7
7
|
require 'go_import/errors'
|
8
8
|
require 'go_import/serialize_helper'
|
9
9
|
require 'go_import/model_helpers'
|
10
|
+
require 'go_import/can_become_immutable'
|
10
11
|
GoImport::require_all_in 'go_import/model/*.rb'
|
11
12
|
require 'go_import/csv_helper'
|
12
13
|
require 'go_import/roo_helper'
|
@@ -78,7 +78,7 @@ def convert_source
|
|
78
78
|
end
|
79
79
|
|
80
80
|
# deal notes
|
81
|
-
process_rows(" - Reading Deal
|
81
|
+
process_rows(" - Reading Deal Notes '#{DEAL_NOTE_FILE}'", DEAL_NOTE_FILE) do |row|
|
82
82
|
# adds itself if applicable
|
83
83
|
rootmodel.add_note(to_deal_note(converter, row, rootmodel))
|
84
84
|
end
|
@@ -36,11 +36,10 @@ describe GoImport::SerializeHelper do
|
|
36
36
|
coworker = GoImport::Coworker.new({:integration_id => "1", :first_name => "Vincent", :last_name => "Vega"})
|
37
37
|
organization.responsible_coworker = coworker
|
38
38
|
|
39
|
-
emp =
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
})
|
39
|
+
emp = GoImport::Person.new
|
40
|
+
emp.integration_id = "1"
|
41
|
+
emp.first_name = "Kalle"
|
42
|
+
emp.last_name = "Anka"
|
44
43
|
emp.direct_phone_number = '234234234'
|
45
44
|
emp.currently_employed = true
|
46
45
|
rootmodel.add_organization organization
|
data/spec/person_spec.rb
CHANGED
@@ -84,6 +84,21 @@ describe "Person" do
|
|
84
84
|
person.organization.is_a?(GoImport::OrganizationReference).should eq true
|
85
85
|
end
|
86
86
|
|
87
|
+
# *** TODO:
|
88
|
+
# Enable this when sources are fixed, see comment in organization.add_employee
|
89
|
+
|
90
|
+
# it "should be immutable when added to an organization" do
|
91
|
+
# # given
|
92
|
+
# org = GoImport::Organization.new({:integration_id => "123", :name => "Lundalogik"})
|
93
|
+
# person = GoImport::Person.new({:integration_id => "456", :first_name => "vincent"})
|
94
|
+
|
95
|
+
# # when
|
96
|
+
# org.add_employee person
|
97
|
+
|
98
|
+
# # then
|
99
|
+
# person.is_immutable.should eq true
|
100
|
+
# end
|
101
|
+
|
87
102
|
describe "parse_name_to_firstname_lastname_se" do
|
88
103
|
it "can parse 'Kalle Nilsson' into firstname 'Kalle' and lastname 'Nilsson'" do
|
89
104
|
person.parse_name_to_firstname_lastname_se 'Kalle Nilsson'
|
data/spec/rootmodel_spec.rb
CHANGED
@@ -27,6 +27,20 @@ describe "RootModel" do
|
|
27
27
|
rootmodel.coworkers.length.should eq 2
|
28
28
|
end
|
29
29
|
|
30
|
+
it "will make coworkers immutable after it has been added" do
|
31
|
+
# given
|
32
|
+
coworker = GoImport::Coworker.new
|
33
|
+
coworker.integration_id = "123key"
|
34
|
+
coworker.first_name = "vincent"
|
35
|
+
|
36
|
+
# when
|
37
|
+
rootmodel.add_coworker(coworker)
|
38
|
+
|
39
|
+
# then
|
40
|
+
coworker.is_immutable.should eq true
|
41
|
+
end
|
42
|
+
|
43
|
+
|
30
44
|
it "will only add coworkers" do
|
31
45
|
# given
|
32
46
|
not_a_coworker = { :integration_id => "123", :first_name => "Vincent" }
|
@@ -78,6 +92,19 @@ describe "RootModel" do
|
|
78
92
|
rootmodel.organizations.length.should eq 1
|
79
93
|
end
|
80
94
|
|
95
|
+
it "will make organizations immutable after it has been added" do
|
96
|
+
# given
|
97
|
+
organization = GoImport::Organization.new
|
98
|
+
organization.integration_id = "123key"
|
99
|
+
organization.name = "Beagle Boys"
|
100
|
+
|
101
|
+
# when
|
102
|
+
rootmodel.add_organization(organization)
|
103
|
+
|
104
|
+
# then
|
105
|
+
organization.is_immutable.should eq true
|
106
|
+
end
|
107
|
+
|
81
108
|
it "will only add organizations" do
|
82
109
|
# given
|
83
110
|
not_an_organization = { :integration_id => "123", :name => "This is not a note"}
|
@@ -149,6 +176,19 @@ describe "RootModel" do
|
|
149
176
|
rootmodel.deals.length.should eq 1
|
150
177
|
end
|
151
178
|
|
179
|
+
it "will make deal immutable after it has been added" do
|
180
|
+
# given
|
181
|
+
deal = GoImport::Deal.new
|
182
|
+
deal.integration_id = "123key"
|
183
|
+
deal.name = "Big deal"
|
184
|
+
|
185
|
+
# when
|
186
|
+
rootmodel.add_deal(deal)
|
187
|
+
|
188
|
+
# then
|
189
|
+
deal.is_immutable.should eq true
|
190
|
+
end
|
191
|
+
|
152
192
|
it "will only add deals" do
|
153
193
|
# given
|
154
194
|
not_a_deal = { :integration_id => "123", :name => "This is not a deal" }
|
@@ -245,6 +285,18 @@ describe "RootModel" do
|
|
245
285
|
}.to raise_error(ArgumentError)
|
246
286
|
rootmodel.notes.length.should eq 0
|
247
287
|
end
|
288
|
+
|
289
|
+
it "will make note immutable after it has been added" do
|
290
|
+
# given
|
291
|
+
note = GoImport::Note.new
|
292
|
+
note.text = "this is a note"
|
293
|
+
|
294
|
+
# when
|
295
|
+
rootmodel.add_note(note)
|
296
|
+
|
297
|
+
# then
|
298
|
+
note.is_immutable.should eq true
|
299
|
+
end
|
248
300
|
|
249
301
|
it "can add a note from a new note" do
|
250
302
|
# given
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petter Sandholdt
|
@@ -179,6 +179,7 @@ executables:
|
|
179
179
|
extensions: []
|
180
180
|
extra_rdoc_files: []
|
181
181
|
files:
|
182
|
+
- lib/go_import/can_become_immutable.rb
|
182
183
|
- lib/go_import/csv_helper.rb
|
183
184
|
- lib/go_import/email_helper.rb
|
184
185
|
- lib/go_import/errors.rb
|