fruit_to_lime 2.5.5 → 2.5.6
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.
- data/lib/fruit_to_lime.rb +17 -17
- data/lib/fruit_to_lime/csv_helper.rb +47 -47
- data/lib/fruit_to_lime/email_helper.rb +10 -10
- data/lib/fruit_to_lime/errors.rb +16 -16
- data/lib/fruit_to_lime/excel_helper.rb +10 -10
- data/lib/fruit_to_lime/global_phone.json +6571 -6571
- data/lib/fruit_to_lime/model/address.rb +60 -60
- data/lib/fruit_to_lime/model/class_settings.rb +50 -50
- data/lib/fruit_to_lime/model/coworker.rb +76 -76
- data/lib/fruit_to_lime/model/coworker_reference.rb +33 -33
- data/lib/fruit_to_lime/model/customfield.rb +87 -87
- data/lib/fruit_to_lime/model/deal.rb +141 -141
- data/lib/fruit_to_lime/model/deal_status.rb +12 -12
- data/lib/fruit_to_lime/model/note.rb +80 -79
- data/lib/fruit_to_lime/model/organization.rb +203 -203
- data/lib/fruit_to_lime/model/person.rb +151 -151
- data/lib/fruit_to_lime/model/referencetosource.rb +45 -45
- data/lib/fruit_to_lime/model/relation.rb +23 -23
- data/lib/fruit_to_lime/model/rootmodel.rb +342 -338
- data/lib/fruit_to_lime/model/settings.rb +60 -60
- data/lib/fruit_to_lime/model/tag.rb +35 -35
- data/lib/fruit_to_lime/model_helpers.rb +54 -54
- data/lib/fruit_to_lime/phone_helper.rb +74 -74
- data/lib/fruit_to_lime/roo_helper.rb +72 -72
- data/lib/fruit_to_lime/serialize_helper.rb +186 -186
- data/lib/fruit_to_lime/templating.rb +52 -52
- data/spec/address_spec.rb +48 -48
- data/spec/class_settings_spec.rb +37 -37
- data/spec/coworker_spec.rb +94 -94
- data/spec/custom_field_spec.rb +22 -22
- data/spec/deal_spec.rb +101 -101
- data/spec/helpers/csv_helper_spec.rb +29 -29
- data/spec/helpers/email_helper_spec.rb +32 -32
- data/spec/helpers/phone_helper_spec.rb +97 -97
- data/spec/helpers/serialize_helper_spec.rb +249 -249
- data/spec/helpers/xsd_validate_spec.rb +58 -58
- data/spec/note_spec.rb +98 -98
- data/spec/organization_spec.rb +103 -103
- data/spec/person_spec.rb +134 -134
- data/spec/rootmodel_spec.rb +306 -277
- data/spec/templating_spec.rb +11 -11
- data/templates/csv/lib/tomodel.rb +230 -230
- data/templates/csv/spec/exporter_spec.rb +17 -17
- data/templates/csv/spec/sample_data/coworkers.csv +2 -2
- data/templates/csv/spec/sample_data/deals.csv +2 -2
- data/templates/csv/spec/sample_data/organizations.csv +2 -2
- data/templates/csv/spec/sample_data/persons.csv +2 -2
- data/templates/easy/Gemfile +5 -5
- data/templates/easy/Rakefile.rb +7 -7
- data/templates/easy/convert.rb +2 -2
- data/templates/easy/spec/exporter_spec.rb +10 -10
- data/templates/easy/spec/spec_helper.rb +24 -24
- data/templates/excel/lib/tomodel.rb +207 -207
- data/templates/sqlserver/lib/tomodel.rb +79 -79
- metadata +3 -3
@@ -1,61 +1,61 @@
|
|
1
|
-
require 'iso_country_codes'
|
2
|
-
module FruitToLime
|
3
|
-
class Address
|
4
|
-
attr_accessor :street, :zip_code, :city, :country_code, :location
|
5
|
-
def serialize_variables
|
6
|
-
[ :street, :zip_code, :city, :country_code, :location].map {|p| {:id=>p,:type=>:string} }
|
7
|
-
end
|
8
|
-
include SerializeHelper
|
9
|
-
def initialize()
|
10
|
-
end
|
11
|
-
|
12
|
-
# What fields/rows on the class is supposed to be used by the Gem to generate the xml
|
13
|
-
# This method uses {#serialize_variables}. It also adds {#country_name} to be serialized
|
14
|
-
def get_import_rows
|
15
|
-
(serialize_variables+[{:id=>:country_name, :type=>:string}]).map do |p|
|
16
|
-
map_to_row p
|
17
|
-
end
|
18
|
-
end
|
19
|
-
# Used as a convenience in order to get country code from internally used {#country_code}
|
20
|
-
def country_name
|
21
|
-
if @country_code
|
22
|
-
IsoCountryCodes.find(@country_code).name
|
23
|
-
else
|
24
|
-
nil
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Used as a convenience in order to map country name to the internal {#country_code}
|
29
|
-
def country_name=(name)
|
30
|
-
@country_code = case name
|
31
|
-
when nil
|
32
|
-
nil
|
33
|
-
when 'Sverige'
|
34
|
-
'SE'
|
35
|
-
else
|
36
|
-
IsoCountryCodes.search_by_name(name).first.alpha2
|
37
|
-
end
|
38
|
-
end
|
39
|
-
# parses a line like "226 48 LUND" into its corresponding
|
40
|
-
# zipcode and city properties on the address
|
41
|
-
def parse_zip_and_address_se(line)
|
42
|
-
Address.parse_line_to_zip_and_address_se(line, self)
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
def self.parse_line_to_zip_and_address_se(line, address)
|
47
|
-
matched_zipcode = /^\d{3}\s?\d{2}/.match(line)
|
48
|
-
if matched_zipcode && matched_zipcode.length == 1
|
49
|
-
address.zip_code = matched_zipcode[0].strip()
|
50
|
-
matched_city = /\D*$/.match(line)
|
51
|
-
if matched_city && matched_city.length == 1
|
52
|
-
address.city = matched_city[0].strip()
|
53
|
-
return address
|
54
|
-
end
|
55
|
-
end
|
56
|
-
return nil
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
end
|
1
|
+
require 'iso_country_codes'
|
2
|
+
module FruitToLime
|
3
|
+
class Address
|
4
|
+
attr_accessor :street, :zip_code, :city, :country_code, :location
|
5
|
+
def serialize_variables
|
6
|
+
[ :street, :zip_code, :city, :country_code, :location].map {|p| {:id=>p,:type=>:string} }
|
7
|
+
end
|
8
|
+
include SerializeHelper
|
9
|
+
def initialize()
|
10
|
+
end
|
11
|
+
|
12
|
+
# What fields/rows on the class is supposed to be used by the Gem to generate the xml
|
13
|
+
# This method uses {#serialize_variables}. It also adds {#country_name} to be serialized
|
14
|
+
def get_import_rows
|
15
|
+
(serialize_variables+[{:id=>:country_name, :type=>:string}]).map do |p|
|
16
|
+
map_to_row p
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# Used as a convenience in order to get country code from internally used {#country_code}
|
20
|
+
def country_name
|
21
|
+
if @country_code
|
22
|
+
IsoCountryCodes.find(@country_code).name
|
23
|
+
else
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Used as a convenience in order to map country name to the internal {#country_code}
|
29
|
+
def country_name=(name)
|
30
|
+
@country_code = case name
|
31
|
+
when nil
|
32
|
+
nil
|
33
|
+
when 'Sverige'
|
34
|
+
'SE'
|
35
|
+
else
|
36
|
+
IsoCountryCodes.search_by_name(name).first.alpha2
|
37
|
+
end
|
38
|
+
end
|
39
|
+
# parses a line like "226 48 LUND" into its corresponding
|
40
|
+
# zipcode and city properties on the address
|
41
|
+
def parse_zip_and_address_se(line)
|
42
|
+
Address.parse_line_to_zip_and_address_se(line, self)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
def self.parse_line_to_zip_and_address_se(line, address)
|
47
|
+
matched_zipcode = /^\d{3}\s?\d{2}/.match(line)
|
48
|
+
if matched_zipcode && matched_zipcode.length == 1
|
49
|
+
address.zip_code = matched_zipcode[0].strip()
|
50
|
+
matched_city = /\D*$/.match(line)
|
51
|
+
if matched_city && matched_city.length == 1
|
52
|
+
address.city = matched_city[0].strip()
|
53
|
+
return address
|
54
|
+
end
|
55
|
+
end
|
56
|
+
return nil
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
end
|
61
61
|
end
|
@@ -1,50 +1,50 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module FruitToLime
|
3
|
-
class ClassSettings
|
4
|
-
include SerializeHelper
|
5
|
-
attr_reader :custom_fields
|
6
|
-
|
7
|
-
def initialize(opt = nil)
|
8
|
-
if opt != nil
|
9
|
-
serialize_variables.each do |myattr|
|
10
|
-
val = opt[myattr[:id]]
|
11
|
-
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def serialize_variables
|
17
|
-
[{:id => :custom_fields, :type => :custom_fields} ]
|
18
|
-
end
|
19
|
-
|
20
|
-
def serialize_name
|
21
|
-
"ClassSettings"
|
22
|
-
end
|
23
|
-
|
24
|
-
# Set custom field. If there is already an existing custom field, then it is overwritten.
|
25
|
-
def set_custom_field(obj)
|
26
|
-
@custom_fields = [] if @custom_fields == nil
|
27
|
-
|
28
|
-
if obj.is_a?(CustomField)
|
29
|
-
field = obj
|
30
|
-
else
|
31
|
-
field = CustomField.new(obj)
|
32
|
-
end
|
33
|
-
|
34
|
-
if field.integration_id == "" && field.id == ""
|
35
|
-
raise InvalidCustomFieldError, "Custom field must have either id or integration_id"
|
36
|
-
end
|
37
|
-
|
38
|
-
index = @custom_fields.find_index do |custom_field|
|
39
|
-
custom_field.same_as?(field)
|
40
|
-
end
|
41
|
-
if index
|
42
|
-
@custom_fields.delete_at index
|
43
|
-
end
|
44
|
-
|
45
|
-
@custom_fields.push field
|
46
|
-
|
47
|
-
return field
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
module FruitToLime
|
3
|
+
class ClassSettings
|
4
|
+
include SerializeHelper
|
5
|
+
attr_reader :custom_fields
|
6
|
+
|
7
|
+
def initialize(opt = nil)
|
8
|
+
if opt != nil
|
9
|
+
serialize_variables.each do |myattr|
|
10
|
+
val = opt[myattr[:id]]
|
11
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def serialize_variables
|
17
|
+
[{:id => :custom_fields, :type => :custom_fields} ]
|
18
|
+
end
|
19
|
+
|
20
|
+
def serialize_name
|
21
|
+
"ClassSettings"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Set custom field. If there is already an existing custom field, then it is overwritten.
|
25
|
+
def set_custom_field(obj)
|
26
|
+
@custom_fields = [] if @custom_fields == nil
|
27
|
+
|
28
|
+
if obj.is_a?(CustomField)
|
29
|
+
field = obj
|
30
|
+
else
|
31
|
+
field = CustomField.new(obj)
|
32
|
+
end
|
33
|
+
|
34
|
+
if field.integration_id == "" && field.id == ""
|
35
|
+
raise InvalidCustomFieldError, "Custom field must have either id or integration_id"
|
36
|
+
end
|
37
|
+
|
38
|
+
index = @custom_fields.find_index do |custom_field|
|
39
|
+
custom_field.same_as?(field)
|
40
|
+
end
|
41
|
+
if index
|
42
|
+
@custom_fields.delete_at index
|
43
|
+
end
|
44
|
+
|
45
|
+
@custom_fields.push field
|
46
|
+
|
47
|
+
return field
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,76 +1,76 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module FruitToLime
|
3
|
-
class Coworker
|
4
|
-
include SerializeHelper
|
5
|
-
attr_accessor :id, :integration_id, :email, :first_name, :last_name, :direct_phone_number,
|
6
|
-
:mobile_phone_number, :home_phone_number
|
7
|
-
|
8
|
-
def initialize(opt = nil)
|
9
|
-
if opt != nil
|
10
|
-
serialize_variables.each do |myattr|
|
11
|
-
val = opt[myattr[:id]]
|
12
|
-
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def serialize_variables
|
18
|
-
[
|
19
|
-
:id, :integration_id, :email, :first_name, :last_name,
|
20
|
-
:direct_phone_number, :mobile_phone_number, :home_phone_number
|
21
|
-
].map {|p| { :id => p, :type => :string } }
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_reference
|
25
|
-
reference = CoworkerReference.new
|
26
|
-
reference.id = @id
|
27
|
-
reference.integration_id = @integration_id
|
28
|
-
reference.heading = "#{@first_name} #{@last_name}".strip
|
29
|
-
|
30
|
-
return reference
|
31
|
-
end
|
32
|
-
|
33
|
-
def serialize_name
|
34
|
-
"Coworker"
|
35
|
-
end
|
36
|
-
|
37
|
-
def ==(that)
|
38
|
-
if that.nil?
|
39
|
-
return false
|
40
|
-
end
|
41
|
-
|
42
|
-
if that.is_a? Coworker
|
43
|
-
return @integration_id == that.integration_id
|
44
|
-
end
|
45
|
-
|
46
|
-
return false
|
47
|
-
end
|
48
|
-
|
49
|
-
def parse_name_to_firstname_lastname_se(name, when_missing = '')
|
50
|
-
if name.nil? or name.empty?
|
51
|
-
@first_name = when_missing
|
52
|
-
return
|
53
|
-
end
|
54
|
-
|
55
|
-
splitted = name.split(' ')
|
56
|
-
@first_name = splitted[0]
|
57
|
-
if splitted.length > 1
|
58
|
-
@last_name = splitted.drop(1).join(' ')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def to_email_chars(s)
|
63
|
-
s.tr " åäöèé", "-aaoee"
|
64
|
-
end
|
65
|
-
|
66
|
-
def guess_email(domain)
|
67
|
-
return '' if @last_name.nil? || @last_name.empty?
|
68
|
-
return '' if @first_name.nil? || @first_name.empty?
|
69
|
-
|
70
|
-
firstname = to_email_chars @first_name.downcase
|
71
|
-
lastname = to_email_chars @last_name.downcase
|
72
|
-
return "#{firstname}.#{lastname}@#{domain}"
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
module FruitToLime
|
3
|
+
class Coworker
|
4
|
+
include SerializeHelper
|
5
|
+
attr_accessor :id, :integration_id, :email, :first_name, :last_name, :direct_phone_number,
|
6
|
+
:mobile_phone_number, :home_phone_number
|
7
|
+
|
8
|
+
def initialize(opt = nil)
|
9
|
+
if opt != nil
|
10
|
+
serialize_variables.each do |myattr|
|
11
|
+
val = opt[myattr[:id]]
|
12
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def serialize_variables
|
18
|
+
[
|
19
|
+
:id, :integration_id, :email, :first_name, :last_name,
|
20
|
+
:direct_phone_number, :mobile_phone_number, :home_phone_number
|
21
|
+
].map {|p| { :id => p, :type => :string } }
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_reference
|
25
|
+
reference = CoworkerReference.new
|
26
|
+
reference.id = @id
|
27
|
+
reference.integration_id = @integration_id
|
28
|
+
reference.heading = "#{@first_name} #{@last_name}".strip
|
29
|
+
|
30
|
+
return reference
|
31
|
+
end
|
32
|
+
|
33
|
+
def serialize_name
|
34
|
+
"Coworker"
|
35
|
+
end
|
36
|
+
|
37
|
+
def ==(that)
|
38
|
+
if that.nil?
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
|
42
|
+
if that.is_a? Coworker
|
43
|
+
return @integration_id == that.integration_id
|
44
|
+
end
|
45
|
+
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
|
49
|
+
def parse_name_to_firstname_lastname_se(name, when_missing = '')
|
50
|
+
if name.nil? or name.empty?
|
51
|
+
@first_name = when_missing
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
55
|
+
splitted = name.split(' ')
|
56
|
+
@first_name = splitted[0]
|
57
|
+
if splitted.length > 1
|
58
|
+
@last_name = splitted.drop(1).join(' ')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_email_chars(s)
|
63
|
+
s.tr " åäöèé", "-aaoee"
|
64
|
+
end
|
65
|
+
|
66
|
+
def guess_email(domain)
|
67
|
+
return '' if @last_name.nil? || @last_name.empty?
|
68
|
+
return '' if @first_name.nil? || @first_name.empty?
|
69
|
+
|
70
|
+
firstname = to_email_chars @first_name.downcase
|
71
|
+
lastname = to_email_chars @last_name.downcase
|
72
|
+
return "#{firstname}.#{lastname}@#{domain}"
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
@@ -1,33 +1,33 @@
|
|
1
|
-
module FruitToLime
|
2
|
-
class CoworkerReference
|
3
|
-
include SerializeHelper
|
4
|
-
attr_accessor :id, :heading, :integration_id
|
5
|
-
|
6
|
-
def initialize(opt = nil)
|
7
|
-
if opt != nil
|
8
|
-
serialize_variables.each do |myattr|
|
9
|
-
val = opt[myattr[:id]]
|
10
|
-
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def serialize_variables
|
16
|
-
[:id, :integration_id, :heading].map {|p| {:id => p, :type => :string} }
|
17
|
-
end
|
18
|
-
|
19
|
-
def serialize_name
|
20
|
-
"CoworkerReference"
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.from_coworker(coworker)
|
24
|
-
if coworker.nil?
|
25
|
-
return nil
|
26
|
-
elsif coworker.is_a?(Coworker)
|
27
|
-
return coworker.to_reference
|
28
|
-
elsif coworker.is_a?(CoworkerReference)
|
29
|
-
return coworker
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
1
|
+
module FruitToLime
|
2
|
+
class CoworkerReference
|
3
|
+
include SerializeHelper
|
4
|
+
attr_accessor :id, :heading, :integration_id
|
5
|
+
|
6
|
+
def initialize(opt = nil)
|
7
|
+
if opt != nil
|
8
|
+
serialize_variables.each do |myattr|
|
9
|
+
val = opt[myattr[:id]]
|
10
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def serialize_variables
|
16
|
+
[:id, :integration_id, :heading].map {|p| {:id => p, :type => :string} }
|
17
|
+
end
|
18
|
+
|
19
|
+
def serialize_name
|
20
|
+
"CoworkerReference"
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.from_coworker(coworker)
|
24
|
+
if coworker.nil?
|
25
|
+
return nil
|
26
|
+
elsif coworker.is_a?(Coworker)
|
27
|
+
return coworker.to_reference
|
28
|
+
elsif coworker.is_a?(CoworkerReference)
|
29
|
+
return coworker
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,87 +1,87 @@
|
|
1
|
-
module FruitToLime
|
2
|
-
class CustomFieldReference
|
3
|
-
include SerializeHelper, ModelWithIntegrationIdSameAs
|
4
|
-
|
5
|
-
attr_accessor :id, :integration_id
|
6
|
-
|
7
|
-
def initialize(opt=nil)
|
8
|
-
if opt != nil
|
9
|
-
serialize_variables.each do |myattr|
|
10
|
-
val = opt[myattr[:id]]
|
11
|
-
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def serialize_variables
|
17
|
-
[:id, :integration_id].map {|p| { :id => p, :type => :string } }
|
18
|
-
end
|
19
|
-
|
20
|
-
def get_import_rows
|
21
|
-
serialize_variables.map do |p|
|
22
|
-
map_to_row p
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def serialize_name
|
27
|
-
"CustomFieldReference"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
class CustomField
|
32
|
-
include SerializeHelper, ModelWithIntegrationIdSameAs
|
33
|
-
attr_accessor :id, :integration_id, :title, :type
|
34
|
-
|
35
|
-
def initialize(opt=nil)
|
36
|
-
if opt != nil
|
37
|
-
serialize_variables.each do |myattr|
|
38
|
-
val = opt[myattr[:id]]
|
39
|
-
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def serialize_variables
|
45
|
-
[:id, :integration_id, :title, :type].map {|p| { :id => p, :type => :string } }
|
46
|
-
end
|
47
|
-
|
48
|
-
def get_import_rows
|
49
|
-
serialize_variables.map do |p|
|
50
|
-
map_to_row p
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def serialize_name
|
55
|
-
"CustomField"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class CustomValue
|
60
|
-
include SerializeHelper
|
61
|
-
attr_accessor :field, :value
|
62
|
-
|
63
|
-
def initialize(opt=nil)
|
64
|
-
if opt != nil
|
65
|
-
serialize_variables.each do |myattr|
|
66
|
-
val = opt[myattr[:id]]
|
67
|
-
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def serialize_variables
|
73
|
-
[ { :id =>:field, :type => :custom_field_reference },
|
74
|
-
{ :id =>:value, :type => :string }]
|
75
|
-
end
|
76
|
-
|
77
|
-
def get_import_rows
|
78
|
-
serialize_variables.map do |p|
|
79
|
-
map_to_row p
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def serialize_name
|
84
|
-
"CustomValue"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
1
|
+
module FruitToLime
|
2
|
+
class CustomFieldReference
|
3
|
+
include SerializeHelper, ModelWithIntegrationIdSameAs
|
4
|
+
|
5
|
+
attr_accessor :id, :integration_id
|
6
|
+
|
7
|
+
def initialize(opt=nil)
|
8
|
+
if opt != nil
|
9
|
+
serialize_variables.each do |myattr|
|
10
|
+
val = opt[myattr[:id]]
|
11
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def serialize_variables
|
17
|
+
[:id, :integration_id].map {|p| { :id => p, :type => :string } }
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_import_rows
|
21
|
+
serialize_variables.map do |p|
|
22
|
+
map_to_row p
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def serialize_name
|
27
|
+
"CustomFieldReference"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class CustomField
|
32
|
+
include SerializeHelper, ModelWithIntegrationIdSameAs
|
33
|
+
attr_accessor :id, :integration_id, :title, :type
|
34
|
+
|
35
|
+
def initialize(opt=nil)
|
36
|
+
if opt != nil
|
37
|
+
serialize_variables.each do |myattr|
|
38
|
+
val = opt[myattr[:id]]
|
39
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def serialize_variables
|
45
|
+
[:id, :integration_id, :title, :type].map {|p| { :id => p, :type => :string } }
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_import_rows
|
49
|
+
serialize_variables.map do |p|
|
50
|
+
map_to_row p
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def serialize_name
|
55
|
+
"CustomField"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class CustomValue
|
60
|
+
include SerializeHelper
|
61
|
+
attr_accessor :field, :value
|
62
|
+
|
63
|
+
def initialize(opt=nil)
|
64
|
+
if opt != nil
|
65
|
+
serialize_variables.each do |myattr|
|
66
|
+
val = opt[myattr[:id]]
|
67
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def serialize_variables
|
73
|
+
[ { :id =>:field, :type => :custom_field_reference },
|
74
|
+
{ :id =>:value, :type => :string }]
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_import_rows
|
78
|
+
serialize_variables.map do |p|
|
79
|
+
map_to_row p
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def serialize_name
|
84
|
+
"CustomValue"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|