leap_salesforce 0.1.15 → 0.1.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9ac3a7c96d31655ef2684afb14ba1088656bfba4bdba621d1c282163783b6a4
4
- data.tar.gz: 5aad78509c4ef1844c58bd0dbe600f81248126e4570eec154ef0a35abe1091a4
3
+ metadata.gz: 0fe3d1e7b89c6a0185c21a67a0b9b96a151a09a18c313bd81d27675911d7922e
4
+ data.tar.gz: c3542d891c596f1b5f40d53362ef4184bbb1d774bc5839b8d508a8bf09646ef5
5
5
  SHA512:
6
- metadata.gz: 1efdda645ee1103bce00418fd65f75badfc570191a60f7f6d5b44dca2eda1d38a395c3b9f164ec4a10a8a7f980401e1a88d031663fa76ef3d1c752626d2fca10
7
- data.tar.gz: 917b74365cc67fe2d4ec7d9ab6bb3e723c8a7a4b3cdcf2cfcdfa7f42d901d37807c689d940f7be933f764117160016e8595a54e348eb8053dc9b4bb872791f1d
6
+ metadata.gz: 82c5fdb6d8841ad1472a42462cd316ee9db718a9bd7fdd0696506ebc751ba55fa58648f596d938fb4f19c300c2d01ab94b1cc711a2613641ce749964f0865355
7
+ data.tar.gz: 8f4ab171180697bd999dc7b159ddbde298be59977d904ef4d33e7df3b84aa8b1610706ad871a3210ff33d565617e5fd89d0b17a5f691c9f3c90f316a555d1f47
data/.idea/.rakeTasks CHANGED
@@ -4,4 +4,4 @@ You are allowed to:
4
4
  1. Remove rake task
5
5
  2. Add existing rake tasks
6
6
  To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build leap_salesforce-0.1.14.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Check Salesforce OAuth2 authentication is working" fullCmd="check_oauth" taksId="check_oauth" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install leap_salesforce-0.1.14.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install leap_salesforce-0.1.14.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeGroup description="" fullCmd="" taksId="leaps"><RakeTask description="Create objects, fields, enums" fullCmd="leaps:create_all" taksId="create_all" /><RakeTask description="Create Enumeration objects for picklists from Salesforce Metadata" fullCmd="leaps:create_enums" taksId="create_enums" /><RakeTask description="Create Soql Data objects" fullCmd="leaps:create_soql_objects" taksId="create_soql_objects" /></RakeGroup><RakeTask description="Create tag v0.1.14 and build and push leap_salesforce-0.1.14.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="Create stubs for dynamic methods so they're picked up by the IDE" fullCmd="stub" taksId="stub" /><RakeGroup description="" fullCmd="" taksId="yard"><RakeTask description="Run YARD doctests" fullCmd="yard:doctest" taksId="doctest" /></RakeGroup><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build leap_salesforce-0.1.16.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Check Salesforce OAuth2 authentication is working" fullCmd="check_oauth" taksId="check_oauth" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install leap_salesforce-0.1.16.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install leap_salesforce-0.1.16.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeGroup description="" fullCmd="" taksId="leaps"><RakeTask description="Create objects, fields, enums" fullCmd="leaps:create_all" taksId="create_all" /><RakeTask description="Create Enumeration objects for picklists from Salesforce Metadata" fullCmd="leaps:create_enums" taksId="create_enums" /><RakeTask description="Create Soql Data objects" fullCmd="leaps:create_soql_objects" taksId="create_soql_objects" /></RakeGroup><RakeTask description="Create tag v0.1.16 and build and push leap_salesforce-0.1.16.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="Create stubs for dynamic methods so they're picked up by the IDE" fullCmd="stub" taksId="stub" /><RakeGroup description="" fullCmd="" taksId="yard"><RakeTask description="Run YARD doctests" fullCmd="yard:doctest" taksId="doctest" /></RakeGroup><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
@@ -60,7 +60,7 @@
60
60
  <orderEntry type="library" scope="PROVIDED" name="rspec-its (v1.3.0, RVM: ruby-2.6.0) [gem]" level="application" />
61
61
  <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.8.0, RVM: ruby-2.6.0) [gem]" level="application" />
62
62
  <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.8.0, RVM: ruby-2.6.0) [gem]" level="application" />
63
- <orderEntry type="library" scope="PROVIDED" name="rubocop (v0.73.0, RVM: ruby-2.6.0) [gem]" level="application" />
63
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v0.74.0, RVM: ruby-2.6.0) [gem]" level="application" />
64
64
  <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.10.0, RVM: ruby-2.6.0) [gem]" level="application" />
65
65
  <orderEntry type="library" scope="PROVIDED" name="rubykeyword (v0.0.4, RVM: ruby-2.6.0) [gem]" level="application" />
66
66
  <orderEntry type="library" scope="PROVIDED" name="savon (v2.12.0, RVM: ruby-2.6.0) [gem]" level="application" />
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.1.16
2
+ * Bug Fix
3
+ * Fixed where ERB was not being used to interpret user on init script
4
+ * Map keys representing elements passed to `find` and `update` to use snakecase version as defined by soql_element
5
+
1
6
  Version 0.1.15
2
7
  * Enhancements
3
8
  * Handle greater than/less than equal comparator in query
data/README.md CHANGED
@@ -180,7 +180,7 @@ If we had the following `factory` for Contact
180
180
  ```ruby
181
181
  FactoryBot.define do
182
182
  factory :contact do
183
- first_name { 'Test Person' }
183
+ last_name { 'Test Person' }
184
184
  end
185
185
  end
186
186
  ```
@@ -203,7 +203,12 @@ example:
203
203
 
204
204
  ##### Reading entities
205
205
 
206
+ To retrieve an entity, the `find` method can be called on the class for the object required. For example
207
+ to obtain an object representing a contact with a last name of 'Test Person' we could do:
206
208
 
209
+ ```ruby
210
+ @contact = Contact.find last_name: 'Test Person'
211
+ ```
207
212
 
208
213
  ## Structure
209
214
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/clean'
6
6
  require 'yard'
7
7
  require 'yard/doctest/rake'
8
8
 
9
- require 'leap_salesforce/rake'
9
+ require 'leap_salesforce/rake' # TODO: Append this line to existing repo
10
10
 
11
11
  CLEAN.include 'tmp/*'
12
12
 
@@ -38,9 +38,9 @@ module LeapSalesforce
38
38
  def verify_oauth
39
39
  LeapSalesforce.client_id = options[:client_id] || input_for('Client id (Customer Id)')
40
40
  LeapSalesforce.client_secret = options[:client_secret] || STDIN.getpass('Client secret (Consumer Secret)')
41
- LeapSalesforce.api_user = options[:username] || input_for('Salesforce username. It is ideal to start with a System admin' \
41
+ LeapSalesforce.api_user = ERB.new(options[:username] || input_for('Salesforce username. It is ideal to start with a System admin' \
42
42
  ' so that any necessary metadata can be read. More users can be added later. You can use ERB to make name' \
43
- ' vary according to environment (e.g., test.user@<%= LeapSalesforce.environment %>.my.company.com)')
43
+ ' vary according to environment (e.g., test.user@<%= LeapSalesforce.environment %>.my.company.com)')).result(binding)
44
44
  LeapSalesforce.password = options[:password] || STDIN.getpass('Password (Recommendation is that 1 password' \
45
45
  ' be shared across all test users to be easier to manage):')
46
46
  LeapSalesforce.oauth_working?
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'fileutils'
4
+ require 'leap_salesforce'
4
5
  require_relative 'default'
5
6
  require_relative 'generator'
6
7
 
@@ -1,5 +1,4 @@
1
1
  require 'rspec/core/rake_task'
2
- require 'leap_salesforce/rake'
3
2
 
4
3
  RSpec::Core::RakeTask.new(:spec)
5
4
 
@@ -10,4 +9,5 @@ end
10
9
 
11
10
  task default: %i[check_oauth spec]
12
11
 
13
- require 'leap_salesforce'
12
+ require 'leap_salesforce/rake' # Load LeapSalesforce tasks
13
+ require 'leap_salesforce' # Require basic leap salesforce files
@@ -11,7 +11,7 @@ RSpec.describe 'Contact CRUD' do
11
11
  end
12
12
  it 'Read contact by name' do
13
13
  FactoryBot.create(:contact, first_name: uniq_value)
14
- @contact = Contact.find(FirstName: uniq_value)
14
+ @contact = Contact.find(first_name: uniq_value)
15
15
  retrieved_first_name = @contact.first_name
16
16
  expect(retrieved_first_name).to eq uniq_value
17
17
  end
@@ -27,7 +27,7 @@ module SoqlGlobalObjectData
27
27
  # @example Find an account with test organisation name
28
28
  # my_query = "SELECT Name from Account WHERE Name = 'TEST Org 001'"
29
29
  # query my_query # => "SELECT+Name+from+Account+WHERE+Name+=+'TEST+Org+001'"
30
- # @return [Exchange] Exchange object from which JSON response can be obtained (i.e, with exchange.response)
30
+ # @return [self] Exchange object from which JSON response can be obtained (i.e, with exchange.response)
31
31
  def query(soql_query, wait: false)
32
32
  rest_query = soql_query.gsub('%', '%25').gsub('+', '%2B').tr(' ', '+')
33
33
  if wait
@@ -39,7 +39,7 @@ module SoqlGlobalObjectData
39
39
  end
40
40
  end
41
41
 
42
- # @param [Symbol, String] lookup Hash representing look up performed
42
+ # @param [Hash] lookup Hash representing look up performed
43
43
  # @param [String] url Url to get
44
44
  def data_from_url(url, lookup)
45
45
  new("Id at #{url}", method: :get, suburl: url.split("v#{SoqlHandler.api_version}/").last)
@@ -55,11 +55,8 @@ module SoqlGlobalObjectData
55
55
  conditional = ''
56
56
  lookup.each do |key, value|
57
57
  conditional_term = conditional.empty? ? 'WHERE' : 'AND'
58
- unless field_names.include? key.to_s
59
- raise LeapSalesforce::RequestError, "#{key} not in #{self}. " \
60
- " Must be one of #{field_names}"
61
- end
62
- conditional += "#{conditional_term} #{key} #{condition_for(value)} "
58
+ key_used = map_key key
59
+ conditional += "#{conditional_term} #{key_used} #{condition_for(value)} "
63
60
  end
64
61
  query = conditional + 'ORDER BY CreatedDate DESC NULLS FIRST'
65
62
  query += " LIMIT #{limit}" if limit
@@ -92,7 +89,7 @@ module SoqlGlobalObjectData
92
89
  instance_to_get
93
90
  end
94
91
 
95
- # @return [Exchange] Result of looking up id based on lookup criteria
92
+ # @return [self] SoqlData object that is the result of looking up id based on lookup criteria
96
93
  def lookup_id(lookup)
97
94
  teardown = lookup.delete(:teardown)
98
95
  SoqlHandler.new("Query on #{self}").use
@@ -144,18 +141,18 @@ module SoqlGlobalObjectData
144
141
  # Remove object from Salesforce with provided id
145
142
  # @param [String] id Id of element to update
146
143
  # @param [Hash] data Key value pairs with data to update
147
- # @return [Exchange] Exchange object for object
144
+ # @return [self] SoqlData object representing result of API update call
148
145
  def update(id, data)
149
146
  must_pass = data.delete(:must_pass)
150
147
  data = data.transform_values do |value|
151
148
  value.is_a?(Time) ? value.salesforce_format : value
152
149
  end
150
+ data.transform_keys! { |key| map_key(key) } # Map keys to valid field names
153
151
  SoqlHandler.new("Update #{id}").use
154
152
 
155
153
  update = new("Update #{self}, #{id} with '#{data}'", method: :patch,
156
154
  suburl: "sobjects/#{soql_object_name}/#{id}", body: data)
157
155
  update.call
158
-
159
156
  return update unless must_pass
160
157
 
161
158
  successful?
@@ -209,6 +206,21 @@ module SoqlGlobalObjectData
209
206
  # rubocop:enable Metrics/MethodLength
210
207
  # rubocop:enable Metrics/AbcSize
211
208
 
209
+ # Map key to a field name if used directly or field defined through 'soql_element'
210
+ # @param [Symbol, String] key Key to map to Table field name
211
+ # @return [String] Field name of Salesforce entity to use
212
+ def map_key(key)
213
+ if field_names.include? key.to_s
214
+ key.to_s
215
+ else
216
+ return new.send("#{key}_element") if new.respond_to?("#{key}_element")
217
+
218
+ raise LeapSalesforce::RequestError, "#{key} not in #{self}. " \
219
+ " Must be one of #{field_names} or a field name described in" \
220
+ " #{self}::FieldNames"
221
+ end
222
+ end
223
+
212
224
  # Returns SOQL condition for value passed to be used in SOQL query
213
225
  # @example Greater than or equal to yesterday's date
214
226
  # condition_for("<=#{Time.mktime(2019,1,1)}") # => '<= 2019-01-01T00:00:00.000Z'
@@ -2,5 +2,5 @@
2
2
 
3
3
  module LeapSalesforce
4
4
  # @return [String] Version of leap salesforce
5
- VERSION = '0.1.15'
5
+ VERSION = '0.1.16'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leap_salesforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - IQA