leap_salesforce 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/exe/leap_salesforce +7 -2
- data/lib/leap_salesforce/generator/soql_objects.rb +14 -12
- data/lib/leap_salesforce/generator/templates/soql_object_field_names.Java.erb +5 -2
- data/lib/leap_salesforce/parameters.rb +3 -3
- data/lib/leap_salesforce/session.rb +3 -2
- data/lib/leap_salesforce/soql_data/soql.rb +6 -6
- data/lib/leap_salesforce/soql_data/soql_data.rb +1 -1
- data/lib/leap_salesforce/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b60fb84b150303c1dc91eb621c40d5c155f439ecd7047911a321d65129259943
|
4
|
+
data.tar.gz: '0966f9cb9274d9f5d7f3d9f2cc85391bf57b909eb6c2d63792452a70e5f690f3'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc9ae149d641d926b3d165c28356a39655b5bc1376488db5526b4b61dffe351d7212a05b800b0e932796fcb40296f39face2cd68e67347987925d74c6eae56b6
|
7
|
+
data.tar.gz: 8a7de04ea12fa03beaf419a756f4a9bc5acdba392b9162d7e920aa29652c882034488e69ee2d569b095e0e57f9266ca8002a5b95544be7e2c716ffdfbdb094f4
|
data/ChangeLog
CHANGED
data/exe/leap_salesforce
CHANGED
@@ -62,15 +62,20 @@ Please ignore "config/credentials/" and "logs/"'.colorize :red
|
|
62
62
|
end
|
63
63
|
|
64
64
|
desc 'create_soql_objects', 'Creates SOQL objects from metadata based on .leap_salesforce.yml'
|
65
|
-
option :language
|
65
|
+
option :language
|
66
66
|
def create_soql_objects
|
67
|
-
LeapSalesforce.language = options[:language]
|
67
|
+
LeapSalesforce.language = options[:language] if options[:language]
|
68
68
|
require 'leap_salesforce/generator/soql_objects'
|
69
69
|
LeapSalesforce.oauth_working?
|
70
70
|
LeapSalesforce::Users.execute_as_if_present key: :admin do
|
71
71
|
LeapSalesforce::Generator::SoqlObjects.new.create_all
|
72
72
|
end
|
73
73
|
end
|
74
|
+
|
75
|
+
desc 'version', 'Version this library'
|
76
|
+
def version
|
77
|
+
puts LeapSalesforce::VERSION
|
78
|
+
end
|
74
79
|
end
|
75
80
|
end
|
76
81
|
|
@@ -12,7 +12,7 @@ module LeapSalesforce
|
|
12
12
|
class SoqlObjects
|
13
13
|
include Generator
|
14
14
|
|
15
|
-
SOQL_DATA_FOLDER = LeapSalesforce.language ==
|
15
|
+
SOQL_DATA_FOLDER = LeapSalesforce.language == 'java' ? 'SoqlObjects' : 'soql_data'
|
16
16
|
SOQL_OBJECT_FOLDER = File.join(LeapSalesforce.lib_folder, SOQL_DATA_FOLDER).freeze
|
17
17
|
FACTORY_FOLDER = File.join(LeapSalesforce.lib_folder, 'factories').freeze
|
18
18
|
|
@@ -32,7 +32,8 @@ module LeapSalesforce
|
|
32
32
|
raise LeapSalesforce::SetupError, "Error producing Soql data for '#{@soql_class}', soql table " \
|
33
33
|
" '#{@soql_object.backend_name}'. Error message: '#{desc.error_message}'"
|
34
34
|
end
|
35
|
-
return unless LeapSalesforce.language ==
|
35
|
+
return unless LeapSalesforce.language == 'ruby'
|
36
|
+
|
36
37
|
content = read_template 'soql_object.rb.erb', binding
|
37
38
|
file = File.join(SOQL_OBJECT_FOLDER, "#{@soql_object.reference}.rb")
|
38
39
|
generate_file file, content, overwrite: false
|
@@ -40,21 +41,22 @@ module LeapSalesforce
|
|
40
41
|
|
41
42
|
# Generate module with fields for Soql Object
|
42
43
|
def generate_field_module
|
43
|
-
if LeapSalesforce.language ==
|
44
|
+
if LeapSalesforce.language == 'ruby'
|
44
45
|
field_content = read_template 'soql_object_field_names.rb.erb', binding
|
45
46
|
field_file = File.join(SOQL_OBJECT_FOLDER, "#{@field_name_file}.rb")
|
46
47
|
elsif LeapSalesforce.language == "java"
|
47
|
-
field_content = read_template 'soql_object_field_names.
|
48
|
-
field_file = File.join(SOQL_OBJECT_FOLDER, "#{@soql_object.class_name}.
|
48
|
+
field_content = read_template 'soql_object_field_names.java.erb', binding
|
49
|
+
field_file = File.join(SOQL_OBJECT_FOLDER, "#{@soql_object.class_name}.java")
|
49
50
|
else
|
50
51
|
raise LeapSalesforce::SetupError, "Unsupported language '#{LeapSalesforce.language}'"
|
51
|
-
end
|
52
|
-
generate_file field_file, field_content
|
52
|
+
end
|
53
|
+
generate_file field_file, field_content
|
53
54
|
end
|
54
55
|
|
55
56
|
# Generate factory for mass generating objects using FactoryBot
|
56
57
|
def generate_factory
|
57
|
-
return unless LeapSalesforce.language ==
|
58
|
+
return unless LeapSalesforce.language == 'ruby'
|
59
|
+
|
58
60
|
@default_fields, @other_fields = filter_fields
|
59
61
|
content = read_template 'factory.rb.erb', binding
|
60
62
|
file = File.join(FACTORY_FOLDER, "#{@soql_object.reference}.rb")
|
@@ -72,10 +74,10 @@ module LeapSalesforce
|
|
72
74
|
generate_field_module
|
73
75
|
generate_factory
|
74
76
|
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
return unless LeapSalesforce.language == 'ruby'
|
78
|
+
|
79
|
+
`rubocop -A #{SOQL_OBJECT_FOLDER} --enable-pending-cops`
|
80
|
+
`rubocop -A #{FACTORY_FOLDER} --enable-pending-cops`
|
79
81
|
end
|
80
82
|
|
81
83
|
private
|
@@ -15,8 +15,11 @@ public class <%= @soql_object.class_name %> {
|
|
15
15
|
<% end %>
|
16
16
|
|
17
17
|
<% @soql_class.fields.each do |field| %>
|
18
|
-
public String get<%= field['
|
19
|
-
|
18
|
+
public String get<%= field['name'].camelize(:upper) %>() { return <%= field['name'].camelize(:lower) %>; }
|
19
|
+
/**
|
20
|
+
* Label: '<%= field['label'] %>', Type: <%= field['type'] %><%= ", Relationship:" + field['relationshipName'] if field['relationshipName'] %>
|
21
|
+
*/
|
22
|
+
public void set<%= field['name'].camelize(:upper) %>(String <%= field['name'].camelize(:lower) %>) { this.<%= field['name'].camelize(:lower) %> = <%= field['name'].camelize(:lower) %>; }
|
20
23
|
<% end %>
|
21
24
|
}
|
22
25
|
|
@@ -16,8 +16,8 @@ module LeapSalesforce
|
|
16
16
|
@client_id = ENV['client_id']
|
17
17
|
@client_secret = ENV['client_secret']
|
18
18
|
@password = ENV['password']
|
19
|
-
@language =
|
20
|
-
@soql_field_start_text =
|
19
|
+
@language = 'ruby'
|
20
|
+
@soql_field_start_text = ''
|
21
21
|
@environment = nil
|
22
22
|
@logger = Logger.new $stdout
|
23
23
|
@sfdx = false
|
@@ -135,7 +135,7 @@ module LeapSalesforce
|
|
135
135
|
# @return [Symbol] Name of the language used
|
136
136
|
attr_accessor :language
|
137
137
|
|
138
|
-
# @return [String] Text to be added as start of auto generated Soql field names
|
138
|
+
# @return [String] Text to be added as start of auto generated Soql field names
|
139
139
|
# classes in the Salesforce object
|
140
140
|
attr_accessor :soql_field_start_text
|
141
141
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'auth'
|
2
4
|
require 'savon'
|
3
5
|
require 'json'
|
@@ -21,12 +23,11 @@ module LeapSalesforce
|
|
21
23
|
end
|
22
24
|
|
23
25
|
class << self
|
24
|
-
|
25
26
|
# Login via SOAP API
|
26
27
|
def soap_login(username, password, security_token)
|
27
28
|
client = Savon.client do
|
28
29
|
endpoint "#{SoqlHandler.instance_url}/services/Soap/u/51.0"
|
29
|
-
namespace
|
30
|
+
namespace 'urn:partner.soap.sforce.com'
|
30
31
|
log true # See request and response. (Put this in traffic file)
|
31
32
|
log_level :debug
|
32
33
|
logger Soaspec::SpecLogger.create
|
@@ -120,7 +120,7 @@ module LeapSalesforce
|
|
120
120
|
value = value.nil? ? 'null' : value.to_s
|
121
121
|
operator, value = case value[0]
|
122
122
|
when '>', '<', '!', 'I' then extract_comparator(value)
|
123
|
-
when '~' then ['LIKE', value[1
|
123
|
+
when '~' then ['LIKE', value[1..]]
|
124
124
|
else ['=', value]
|
125
125
|
end
|
126
126
|
case soql_table.type_for(field_name)
|
@@ -142,18 +142,18 @@ module LeapSalesforce
|
|
142
142
|
# @return [Array] Extract of operator, value, taking >, >, >= from string and rest of string
|
143
143
|
def extract_comparator(value)
|
144
144
|
if value[1] == '='
|
145
|
-
[value[0..1], value[2
|
145
|
+
[value[0..1], value[2..]]
|
146
146
|
elsif value[0..2] == '!IN'
|
147
|
-
['NOT IN', value[3
|
147
|
+
['NOT IN', value[3..].to_soql_array]
|
148
148
|
elsif value[0..1] == 'IN'
|
149
|
-
['IN', value[2
|
149
|
+
['IN', value[2..].to_soql_array]
|
150
150
|
elsif value[0] == 'I' # 'N' not 2nd character
|
151
151
|
['=', value]
|
152
152
|
elsif value[0] == '!'
|
153
|
-
remaining = value[1
|
153
|
+
remaining = value[1..] == 'nil' ? 'null' : value[1..]
|
154
154
|
['!=', remaining]
|
155
155
|
else
|
156
|
-
[value[0], value[1
|
156
|
+
[value[0], value[1..]]
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
@@ -49,7 +49,7 @@ class SoqlData < Exchange
|
|
49
49
|
if @override_parameters && @override_parameters[:suburl]
|
50
50
|
suburl_passed = @override_parameters[:suburl]
|
51
51
|
@override_parameters[:suburl] = if suburl_passed.include?('sobjects')
|
52
|
-
suburl_passed[suburl_passed.index('sobjects')
|
52
|
+
suburl_passed[suburl_passed.index('sobjects')..]
|
53
53
|
else
|
54
54
|
suburl_passed
|
55
55
|
end
|