go_import 3.0.17 → 3.0.18
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 +8 -8
- data/lib/go_import/errors.rb +3 -0
- data/lib/go_import/model/note.rb +1 -1
- data/lib/go_import/model/rootmodel.rb +2 -1
- data/sources/easy/.go_import/runner.rb +44 -6
- data/sources/easy/converter.rb +46 -1
- data/sources/salesforce/.gitignore +14 -0
- data/sources/salesforce/.go_import/readme.txt +1 -0
- data/sources/salesforce/.go_import/runner.rb +72 -0
- data/sources/salesforce/Gemfile +5 -0
- data/sources/salesforce/Gemfile.lock +47 -0
- data/sources/salesforce/converter.rb +204 -0
- data/sources/salesforce/data/contacts.csv +4 -0
- data/sources/salesforce/go.zip +0 -0
- data/spec/rootmodel_spec.rb +17 -2
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2U3MjU1NzIwYzUyZDZjODA2ZDg2ZjQ1YmRjNDI2ZTE4ZGMzNGVjNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWM4ZDMyYjVjOTdlYTE5ODcwNGQ0MjdkYjQ0OTViNjZhMzkxMGFmZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDlkMGNmMTBkOWM2ZmE0ZWY5NGNlMDZlOTU4YTBkM2NlY2FiYjYxYWZjNjdl
|
10
|
+
NzEwMjBiMWQ4ZDkxY2QxOGZjNGY1NTc5ZWNiZDVkNjRmOWI3N2YyM2IzMmE0
|
11
|
+
NDBkNmE5M2M4MDI4YmE4NzZhNTBiYzkyZTY4M2Y5NWNiOGQxZGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzdlMjZkYWMxYWJiMTdjMzJkOTk5MTRjNzZjNjZlNjI3MjRmMjY0Nzc5OTVj
|
14
|
+
ZGQ0OWE4NWE3ZGYwYTYyYjNjODQ4ZmVmMDA5OGYxYmMwZjY5NzdlYjNhZmE0
|
15
|
+
MzQxMWEzYTliNmM5NTVlNDQ0ZjAzMjYyNWU4Y2Q2ODczZjM1NzE=
|
data/lib/go_import/errors.rb
CHANGED
data/lib/go_import/model/note.rb
CHANGED
@@ -117,7 +117,8 @@ module GoImport
|
|
117
117
|
|
118
118
|
organization = Organization.new(organization) if !organization.is_a?(Organization)
|
119
119
|
|
120
|
-
if
|
120
|
+
if (!organization.integration_id.nil? && organization.integration_id.length > 0) &&
|
121
|
+
find_organization_by_integration_id(organization.integration_id) != nil
|
121
122
|
raise AlreadyAddedError, "Already added an organization with integration_id #{organization.integration_id}"
|
122
123
|
end
|
123
124
|
|
@@ -56,7 +56,7 @@ def convert_source
|
|
56
56
|
# organization notes
|
57
57
|
process_rows ORGANIZATION_NOTE_FILE do |row|
|
58
58
|
# adds itself if applicable
|
59
|
-
rootmodel.add_note(to_organization_note(row, rootmodel))
|
59
|
+
rootmodel.add_note(to_organization_note(converter, row, rootmodel))
|
60
60
|
end
|
61
61
|
|
62
62
|
# Organization - Deal connection
|
@@ -77,7 +77,7 @@ def convert_source
|
|
77
77
|
# deal notes
|
78
78
|
process_rows DEAL_NOTE_FILE do |row|
|
79
79
|
# adds itself if applicable
|
80
|
-
rootmodel.add_note(to_deal_note(row, rootmodel))
|
80
|
+
rootmodel.add_note(to_deal_note(converter, row, rootmodel))
|
81
81
|
end
|
82
82
|
|
83
83
|
# documents
|
@@ -148,7 +148,7 @@ end
|
|
148
148
|
|
149
149
|
# Turns a row from the Easy exported Company-History.txt file into
|
150
150
|
# a go_import model that is used to generate xml.
|
151
|
-
def to_organization_note(row, rootmodel)
|
151
|
+
def to_organization_note(converter, row, rootmodel)
|
152
152
|
organization = rootmodel.find_organization_by_integration_id(row['idCompany'])
|
153
153
|
coworker = rootmodel.find_coworker_by_integration_id(row['idUser'])
|
154
154
|
|
@@ -158,8 +158,26 @@ def to_organization_note(row, rootmodel)
|
|
158
158
|
note.created_by = coworker
|
159
159
|
note.person = organization.find_employee_by_integration_id(row['idPerson'])
|
160
160
|
note.date = row['Date']
|
161
|
-
|
162
|
-
|
161
|
+
|
162
|
+
if converter.respond_to?(:get_note_classification_for_activity_on_company)
|
163
|
+
# we will get an InvalidNoteClassificationError if we are
|
164
|
+
# setting and invalid classification. So no need to verify
|
165
|
+
# return value from converter.
|
166
|
+
classification =
|
167
|
+
converter.get_note_classification_for_activity_on_company(row['Category'])
|
168
|
+
|
169
|
+
if classification.nil?
|
170
|
+
classification = GoImport::NoteClassification::Comment
|
171
|
+
end
|
172
|
+
|
173
|
+
note.classification = classification
|
174
|
+
|
175
|
+
note.text = row['History']
|
176
|
+
else
|
177
|
+
note.classification = GoImport::NoteClassification::Comment
|
178
|
+
note.text = "#{row['Category']}: #{row['History']}"
|
179
|
+
end
|
180
|
+
|
163
181
|
return note.text.empty? ? nil : note
|
164
182
|
end
|
165
183
|
|
@@ -235,7 +253,7 @@ end
|
|
235
253
|
|
236
254
|
# Turns a row from the Easy exported Project-History.txt file into
|
237
255
|
# a go_import model that is used to generate xml
|
238
|
-
def to_deal_note(row, rootmodel)
|
256
|
+
def to_deal_note(converter, row, rootmodel)
|
239
257
|
# TODO: This could be improved to read a person from an
|
240
258
|
# organization connected to this deal if any, but since it is
|
241
259
|
# a many to many connection between organizations and deals
|
@@ -251,6 +269,26 @@ def to_deal_note(row, rootmodel)
|
|
251
269
|
# Raw history looks like this <category>: <person>: <text>
|
252
270
|
note.text = row['RawHistory']
|
253
271
|
|
272
|
+
if converter.respond_to?(:get_note_classification_for_activity_on_project)
|
273
|
+
# we will get an InvalidNoteClassificationError if we are
|
274
|
+
# setting and invalid classification. So no need to verify
|
275
|
+
# return value from converter.
|
276
|
+
|
277
|
+
classification =
|
278
|
+
converter.get_note_classification_for_activity_on_project(row['Category'])
|
279
|
+
|
280
|
+
if classification.nil?
|
281
|
+
classification = GoImport::NoteClassification::Comment
|
282
|
+
end
|
283
|
+
|
284
|
+
note.classification = classification
|
285
|
+
note.text = row['RawHistory'].to_s.sub("#{row['Category']}:", "")
|
286
|
+
else
|
287
|
+
note.classification = GoImport::NoteClassification::Comment
|
288
|
+
note.text = row['RawHistory']
|
289
|
+
end
|
290
|
+
|
291
|
+
|
254
292
|
return note.text.empty? ? nil : note
|
255
293
|
end
|
256
294
|
|
data/sources/easy/converter.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding:
|
1
|
+
# encoding: iso-8859-1
|
2
2
|
require 'go_import'
|
3
3
|
|
4
4
|
# Customize this file to suit your input files.
|
@@ -220,6 +220,7 @@ class Converter
|
|
220
220
|
## LIME Go custom fields.
|
221
221
|
# This is how you populate a LIME Go custom field that was created in
|
222
222
|
# the configure method.
|
223
|
+
|
223
224
|
# person.set_custom_value("shoe_size", row['shoe size'])
|
224
225
|
end
|
225
226
|
|
@@ -268,6 +269,50 @@ class Converter
|
|
268
269
|
return deal
|
269
270
|
end
|
270
271
|
|
272
|
+
def get_note_classification_for_activity_on_company(activity)
|
273
|
+
# When notes are added to LIME Go this method is called for
|
274
|
+
# every note that is connected to a company in LIME Easy. The
|
275
|
+
# note's activity from LIME Easy is supplied as an argument
|
276
|
+
# and this method should return a classification for the note
|
277
|
+
# in LIME Go. The return value must be a value from the
|
278
|
+
# GoImport::NoteClassification enum. If no classification is
|
279
|
+
# return the note will get the default classification 'Comment'
|
280
|
+
|
281
|
+
# case activity
|
282
|
+
# when 'SalesCall'
|
283
|
+
# classification = GoImport::NoteClassification::SalesCall
|
284
|
+
# when 'Customer Visit'
|
285
|
+
# classification = GoImport::NoteClassification::ClientVisit
|
286
|
+
# when 'No answer'
|
287
|
+
# classification = GoImport::NoteClassification::TriedToReach
|
288
|
+
# else
|
289
|
+
# classification = GoImport::NoteClassification::Comment
|
290
|
+
# end
|
291
|
+
|
292
|
+
# return classification
|
293
|
+
end
|
294
|
+
|
295
|
+
def get_note_classification_for_activity_on_project(activity)
|
296
|
+
# When notes are added to LIME Go this method is called for
|
297
|
+
# every note that is connected to a project in LIME Easy. The
|
298
|
+
# note's activity from LIME Easy is supplied as an argument
|
299
|
+
# and this method should return a classification for the note
|
300
|
+
# in LIME Go. The return value must be a value from the
|
301
|
+
# GoImport::NoteClassification enum. If no classification is
|
302
|
+
# return the note will get the default classification 'Comment'
|
303
|
+
|
304
|
+
# case activity
|
305
|
+
# when 'Installation'
|
306
|
+
# classification = GoImport::NoteClassification::ClientVisit
|
307
|
+
# when 'No answer'
|
308
|
+
# classification = GoImport::NoteClassification::TriedToReach
|
309
|
+
# else
|
310
|
+
# classification = GoImport::NoteClassification::Comment
|
311
|
+
# end
|
312
|
+
|
313
|
+
# return classification
|
314
|
+
end
|
315
|
+
|
271
316
|
def configure(rootmodel)
|
272
317
|
#####################################################################
|
273
318
|
## LIME Go custom fields.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler config
|
8
|
+
/.bundle
|
9
|
+
# Ignore built gems
|
10
|
+
/*.gem
|
11
|
+
# Ignore all logfiles and tempfiles.
|
12
|
+
/tmp
|
13
|
+
/spec/tmp
|
14
|
+
pkg
|
@@ -0,0 +1 @@
|
|
1
|
+
This source converts a csv file to LIME Go.
|
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
require 'go_import'
|
3
|
+
require_relative("../converter")
|
4
|
+
|
5
|
+
# COWORKER_FILE and other file names should be defined ../converter.rb
|
6
|
+
|
7
|
+
def process_rows(file_name)
|
8
|
+
data = File.open(file_name, 'r').read.encode('UTF-8',"ISO-8859-1")
|
9
|
+
rows = GoImport::CsvHelper::text_to_hashes(data)
|
10
|
+
rows.each do |row|
|
11
|
+
yield row
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def convert_source
|
16
|
+
puts "Trying to convert Salesforce CSV export to LIME Go..."
|
17
|
+
|
18
|
+
converter = Converter.new
|
19
|
+
|
20
|
+
# A rootmodel is used to represent all entitite/models that is
|
21
|
+
# exported
|
22
|
+
rootmodel = GoImport::RootModel.new
|
23
|
+
|
24
|
+
if converter.respond_to?(:configure)
|
25
|
+
converter.configure(rootmodel)
|
26
|
+
end
|
27
|
+
|
28
|
+
contacts_file = ::File.expand_path('data/contacts.csv', Dir.pwd)
|
29
|
+
process_rows contacts_file do |row|
|
30
|
+
rootmodel.add_organization(converter.to_organization(row, rootmodel))
|
31
|
+
end
|
32
|
+
|
33
|
+
return rootmodel
|
34
|
+
|
35
|
+
# coworkers
|
36
|
+
# start with these since they are referenced
|
37
|
+
# from everywhere....
|
38
|
+
if defined?(COWORKER_FILE) && !COWORKER_FILE.nil? && !COWORKER_FILE.empty?
|
39
|
+
process_rows COWORKER_FILE do |row|
|
40
|
+
rootmodel.add_coworker(converter.to_coworker(row))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# organizations
|
45
|
+
if defined?(ORGANIZATION_FILE) && !ORGANIZATION_FILE.nil? && !ORGANIZATION_FILE.empty?
|
46
|
+
process_rows ORGANIZATION_FILE do |row|
|
47
|
+
organization = converter.to_organization(row, rootmodel)
|
48
|
+
rootmodel.add_organization(organization)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# persons
|
53
|
+
# depends on organizations
|
54
|
+
if defined?(PERSON_FILE) && !PERSON_FILE.nil? && !PERSON_FILE.empty?
|
55
|
+
process_rows PERSON_FILE do |row|
|
56
|
+
# adds it self to the employer
|
57
|
+
converter.to_person(row, rootmodel)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# deals
|
62
|
+
# deals can reference coworkers (responsible), organizations
|
63
|
+
# and persons (contact)
|
64
|
+
if defined?(DEAL_FILE) && !DEAL_FILE.nil? && !DEAL_FILE.empty?
|
65
|
+
process_rows DEAL_FILE do |row|
|
66
|
+
rootmodel.add_deal(converter.to_deal(row, rootmodel))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
return rootmodel
|
71
|
+
end
|
72
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.2.5)
|
5
|
+
global_phone (1.0.1)
|
6
|
+
go_import (3.0.17)
|
7
|
+
bundler
|
8
|
+
global_phone
|
9
|
+
iso_country_codes
|
10
|
+
nokogiri
|
11
|
+
roo
|
12
|
+
sixarm_ruby_email_address_validation
|
13
|
+
thor
|
14
|
+
iso_country_codes (0.6.1)
|
15
|
+
mini_portile (0.6.1)
|
16
|
+
nokogiri (1.6.4.1-x86-mingw32)
|
17
|
+
mini_portile (~> 0.6.0)
|
18
|
+
roo (1.13.2)
|
19
|
+
nokogiri
|
20
|
+
rubyzip
|
21
|
+
spreadsheet (> 0.6.4)
|
22
|
+
rspec (3.1.0)
|
23
|
+
rspec-core (~> 3.1.0)
|
24
|
+
rspec-expectations (~> 3.1.0)
|
25
|
+
rspec-mocks (~> 3.1.0)
|
26
|
+
rspec-core (3.1.7)
|
27
|
+
rspec-support (~> 3.1.0)
|
28
|
+
rspec-expectations (3.1.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.1.0)
|
31
|
+
rspec-mocks (3.1.3)
|
32
|
+
rspec-support (~> 3.1.0)
|
33
|
+
rspec-support (3.1.2)
|
34
|
+
ruby-ole (1.2.11.7)
|
35
|
+
rubyzip (1.1.6)
|
36
|
+
sixarm_ruby_email_address_validation (2.0.0)
|
37
|
+
spreadsheet (1.0.0)
|
38
|
+
ruby-ole (>= 1.0)
|
39
|
+
thor (0.19.1)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
x86-mingw32
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
go_import
|
46
|
+
rspec
|
47
|
+
thor
|
@@ -0,0 +1,204 @@
|
|
1
|
+
|
2
|
+
require 'go_import'
|
3
|
+
|
4
|
+
# This converter will convert one or more CVS files into a LIME Go XML
|
5
|
+
# file.
|
6
|
+
|
7
|
+
# You need to customize this script to suit your CVS file(s).
|
8
|
+
|
9
|
+
# First we set the file names of your CVS files. If you dont need to
|
10
|
+
# import all kind of objects, just leave the filename empty or remove
|
11
|
+
# the line.
|
12
|
+
DATA_FOLDER = "data"
|
13
|
+
|
14
|
+
#COWORKER_FILE = "data/coworkers.csv"
|
15
|
+
#ORGANIZATION_FILE = "data/organizations.csv"
|
16
|
+
#PERSON_FILE = "data/persons.csv"
|
17
|
+
#DEAL_FILE = "data/deals.csv"
|
18
|
+
|
19
|
+
# Ie if you dont want to import deals, set DEAL_FILE = ""
|
20
|
+
|
21
|
+
# If you are importing files then you must set the FILES_FOLDER
|
22
|
+
# constant. FILES_FOLDER should point to the folder where the files
|
23
|
+
# are stored. FILES_FOLDER can be relative to the project directory
|
24
|
+
# or absolute. Note that you need to escape \ with a \ so in order to
|
25
|
+
# write \ use \\.
|
26
|
+
FILES_FOLDER = "./files"
|
27
|
+
|
28
|
+
# If you are importing files with an absolute path (eg
|
29
|
+
# m:\documents\readme.doc) then you probably wont have files at that
|
30
|
+
# location on the computer where "go-import run" is executed. Set
|
31
|
+
# FILES_FOLDER_AT_CUSTOMER to the folder where documents are stored at
|
32
|
+
# the customers site. Ie, in this example m:\documents.
|
33
|
+
# Note that you need to escape \ with a \ so in order to write \ use
|
34
|
+
# \\.
|
35
|
+
FILES_FOLDER_AT_CUSTOMER = "m:\\documents\\"
|
36
|
+
|
37
|
+
class Converter
|
38
|
+
# Configure your root model, add custom fields and deal statuses.
|
39
|
+
def configure(rootmodel)
|
40
|
+
# add custom field to your model here. Custom fields can be
|
41
|
+
# added to organization, deal and person. Valid types are
|
42
|
+
# :String and :Link. If no type is specified :String is used
|
43
|
+
# as default.
|
44
|
+
# rootmodel.settings.with_organization do |organization|
|
45
|
+
# organization.set_custom_field( { :integrationid => 'external_url', :title => 'Link to external system', :type => :Link } )
|
46
|
+
# end
|
47
|
+
|
48
|
+
# rootmodel.settings.with_deal do |deal|
|
49
|
+
# deal.add_status({:label => "1. Kvalificering", :integration_id => "qualification"})
|
50
|
+
# deal.add_status({:label => "Vunnen", :integration_id => "won",
|
51
|
+
# :assessment => GoImport::DealState::PositiveEndState })
|
52
|
+
# deal.add_status({:label => "Lost", :integration_id => "Lost",
|
53
|
+
# :assessment => GoImport::DealState::NegativeEndState })
|
54
|
+
# end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Turns a row from the organization csv file into a
|
58
|
+
# GoImport::Organization.
|
59
|
+
# Use rootmodel to locate other related stuff such coworker
|
60
|
+
def to_organization(row, rootmodel)
|
61
|
+
organization = GoImport::Organization.new
|
62
|
+
|
63
|
+
puts "Trying to create org '#{row}'"
|
64
|
+
|
65
|
+
return organization
|
66
|
+
|
67
|
+
|
68
|
+
# Integrationid is typically the id in the system that
|
69
|
+
# we are getting the csv from. Must be set to be able
|
70
|
+
# to import the same file more than once without
|
71
|
+
# creating duplicates
|
72
|
+
organization.integration_id = row['id']
|
73
|
+
organization.name = row['name']
|
74
|
+
|
75
|
+
# Just setting all basic properties to show whats available
|
76
|
+
# Remove or fix...
|
77
|
+
organization.organization_number = 'a number' # needs clean up, should have helpers for that in lib. Swedish format.
|
78
|
+
organization.email = 'email to organizaiton, not the person'
|
79
|
+
organization.web_site = 'www.whatever.com'
|
80
|
+
organization.central_phone_number = '0000' # needs clean up, should have helpers for that in lib. Default swedish format, convert to global format
|
81
|
+
|
82
|
+
# Addresses consists of several parts in Go.
|
83
|
+
# Lots of other systems have the address all in one
|
84
|
+
# line, to be able to match when importing it is
|
85
|
+
# way better to split the addresses
|
86
|
+
organization.with_visit_address do |address|
|
87
|
+
address.street = 'visit street'
|
88
|
+
address.zip_code = 'visit zip'
|
89
|
+
address.city = 'visit city'
|
90
|
+
end
|
91
|
+
|
92
|
+
# Another example of setting address using
|
93
|
+
# helper to split '226 48 LUND' into zip and city
|
94
|
+
organization.with_postal_address do |address|
|
95
|
+
address.street = 'postal street'
|
96
|
+
address.parse_zip_and_address_se '226 48 LUND'
|
97
|
+
end
|
98
|
+
|
99
|
+
# Responsible coworker is set by first locating
|
100
|
+
# it in the root model and then setting a reference
|
101
|
+
# to him/her
|
102
|
+
# We need to be able handle missing coworkers here
|
103
|
+
coworker = rootmodel.find_coworker_by_integration_id row['responsible_id']
|
104
|
+
organization.responsible_coworker = coworker.to_reference
|
105
|
+
|
106
|
+
# Set tags for the organization. All organizations will get
|
107
|
+
# the tag "import" automagically
|
108
|
+
organization.set_tag("Guldkund")
|
109
|
+
|
110
|
+
# When imported from web based ERP or similair that
|
111
|
+
# client will continue to use it can be useful to be
|
112
|
+
# able to link from Go to the same record in the ERP
|
113
|
+
# FOr instance Lime links
|
114
|
+
organization.set_custom_value("external_url", "http://something.com?key=#{row['id']}")
|
115
|
+
|
116
|
+
return organization
|
117
|
+
end
|
118
|
+
|
119
|
+
# Turns a row from the coworker csv file into a GoImport::Coworker.
|
120
|
+
def to_coworker(row)
|
121
|
+
coworker = GoImport::Coworker.new
|
122
|
+
coworker.integration_id = row['id']
|
123
|
+
coworker.first_name = row['first_name']
|
124
|
+
coworker.last_name = row['last_name']
|
125
|
+
|
126
|
+
# Other optional attributes
|
127
|
+
coworker.email = 't@e.com'
|
128
|
+
coworker.direct_phone_number = '+46121212'
|
129
|
+
coworker.mobile_phone_number = '+46324234'
|
130
|
+
coworker.home_phone_number = '+46234234'
|
131
|
+
|
132
|
+
# Tags and custom fields are set the same
|
133
|
+
# way as on organizations
|
134
|
+
|
135
|
+
return coworker
|
136
|
+
end
|
137
|
+
|
138
|
+
# Turns a row from the person csv file into a GoImport::Person.
|
139
|
+
#
|
140
|
+
# You MUST add the new person to an existing organization. Use the
|
141
|
+
# rootmodel to find the organization and then add the person with
|
142
|
+
# organization.add_employee
|
143
|
+
def to_person(row, rootmodel)
|
144
|
+
person = GoImport::Person.new
|
145
|
+
person.integration_id = row['id']
|
146
|
+
# Note that Go has separate first and last names
|
147
|
+
# Some splitting might be necessary
|
148
|
+
person.first_name = row['first_name']
|
149
|
+
person.last_name = row['last_name']
|
150
|
+
# other optional attributes
|
151
|
+
person.direct_phone_number = '+4611111'
|
152
|
+
person.fax_phone_number = '+4623234234234'
|
153
|
+
person.mobile_phone_number = '+462321212'
|
154
|
+
person.email = 'x@y.com'
|
155
|
+
person.alternative_email = 'y@x.com'
|
156
|
+
person.with_postal_address do |address|
|
157
|
+
address.street = 'postal street'
|
158
|
+
address.parse_zip_and_address_se '226 48 LUND'
|
159
|
+
end
|
160
|
+
|
161
|
+
# Tags and custom fields are set the same
|
162
|
+
# way as on organizations
|
163
|
+
|
164
|
+
# set employer connection
|
165
|
+
employer_id = row['employer_id']
|
166
|
+
employer = rootmodel.find_organization_by_integration_id employer_id
|
167
|
+
employer.add_employee person
|
168
|
+
end
|
169
|
+
|
170
|
+
# Turns a row form the deal csv file into a GoImport::Deal. Use
|
171
|
+
# the rootmodel to find objects that should be linked to the new
|
172
|
+
# deal.
|
173
|
+
def to_deal(row, rootmodel)
|
174
|
+
deal = GoImport::Deal.new
|
175
|
+
deal.integration_id = row['id']
|
176
|
+
deal.name = row['name']
|
177
|
+
# should be integer, same currency should be used in
|
178
|
+
# the system
|
179
|
+
deal.value = row['value']
|
180
|
+
|
181
|
+
# find stuff connected to deal
|
182
|
+
responsible = rootmodel.find_coworker_by_integration_id row['responsible_id']
|
183
|
+
organization = rootmodel.find_organization_by_integration_id row['customer_id']
|
184
|
+
person = organization.find_employee_by_integration_id row['customer_contact_id']
|
185
|
+
# connect the deal by references
|
186
|
+
deal.responsible_coworker = responsible.to_reference
|
187
|
+
deal.customer = organization.to_reference
|
188
|
+
deal.customer_contact = person.to_reference
|
189
|
+
|
190
|
+
# other optional attributes
|
191
|
+
deal.probability = 50 # should be between 0 - 100
|
192
|
+
deal.order_date = '2014-01-05' # Format ?
|
193
|
+
|
194
|
+
# status, set this by either label, id or integration_id (use
|
195
|
+
# appropriate method to find status)
|
196
|
+
deal.status = rootmodel.settings.deal.find_status_by_label row['status']
|
197
|
+
|
198
|
+
# or set by existing status, search by label, integration_id
|
199
|
+
# (if string) or id (if integer).
|
200
|
+
# deal.status = "Won"
|
201
|
+
|
202
|
+
return deal
|
203
|
+
end
|
204
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
FirstName,LastName,Title,ReportsTo.Email,Birthdate,Description
|
2
|
+
Tom,Jones,Senior Director,buyer@salesforcesample.com,1940-06-07Z,"Self-described as ""the top"" branding guru on the West Coast"
|
3
|
+
Ian,Dury,Chief Imagineer,cto@salesforcesample.com,,"World-renowned expert in fuzzy logic design.
|
4
|
+
Influential in technology purchases."
|
Binary file
|
data/spec/rootmodel_spec.rb
CHANGED
@@ -96,10 +96,25 @@ describe "RootModel" do
|
|
96
96
|
rootmodel.organizations.length.should eq 1
|
97
97
|
end
|
98
98
|
|
99
|
+
it "will add two organizations without integration id" do
|
100
|
+
# given
|
101
|
+
org1 = GoImport::Organization.new
|
102
|
+
org1.name = "Beagle Boys"
|
103
|
+
org2 = GoImport::Organization.new
|
104
|
+
org2.name = "The Corporation"
|
105
|
+
|
106
|
+
# when
|
107
|
+
rootmodel.add_organization(org1)
|
108
|
+
rootmodel.add_organization(org2)
|
109
|
+
|
110
|
+
# then
|
111
|
+
rootmodel.organizations.length.should eq 2
|
112
|
+
end
|
113
|
+
|
99
114
|
it "can add a deal from hash" do
|
100
115
|
rootmodel.add_deal({
|
101
|
-
|
102
|
-
|
116
|
+
:integration_id => "123key",
|
117
|
+
:name => "Big deal"
|
103
118
|
})
|
104
119
|
rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
|
105
120
|
rootmodel.deals.length.should eq 1
|
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.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oskar Gewalli
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-11-
|
14
|
+
date: 2014-11-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: iso_country_codes
|
@@ -227,6 +227,14 @@ files:
|
|
227
227
|
- sources/excel-basic/files/offert-2.docx
|
228
228
|
- sources/excel-basic/files/offert.docx
|
229
229
|
- sources/excel-basic/Gemfile
|
230
|
+
- sources/salesforce/.gitignore
|
231
|
+
- sources/salesforce/.go_import/readme.txt
|
232
|
+
- sources/salesforce/.go_import/runner.rb
|
233
|
+
- sources/salesforce/converter.rb
|
234
|
+
- sources/salesforce/data/contacts.csv
|
235
|
+
- sources/salesforce/Gemfile
|
236
|
+
- sources/salesforce/Gemfile.lock
|
237
|
+
- sources/salesforce/go.zip
|
230
238
|
- sources/VISMA/.gitignore
|
231
239
|
- sources/VISMA/.go_import/readme.txt
|
232
240
|
- sources/VISMA/.go_import/runner.rb
|