leap_salesforce 0.1.17 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 455d4ec9852a5afd9bf82cbe504b755fee025025ff3a7ad35d958ca944ea89cd
4
- data.tar.gz: 304a5f93081a5e65fff63b34ce61a8cb0f4a8ed90e71d4ef9947a57eb8155562
3
+ metadata.gz: 467199374ed9914ed99da0b95b4c9fbe7105eed96b1456ea469d55c1cfadc0f9
4
+ data.tar.gz: 1aca36e08dca7f60197fc8809d2fa69a1468087c0114c0fc70964cb0b46c80c6
5
5
  SHA512:
6
- metadata.gz: bfa00811dd445829c140a9980353c32b8568feb47c3caa37a8e950426b7b31c1ac00bb333ac1707861271b21684d770892263061c7cddc7f0c2d3cf22b553c8a
7
- data.tar.gz: b48b467b870cf0b239d39ce648d2ed7b7cc5d4762c9c9bb6668f89a92b4a5a298535e6a08d12e8c3baedc1de13717952b886926a8eb2df35d0052e971aace28c
6
+ metadata.gz: 18f11ad55eee275cad36b44ba80eef5a34ba1de1cdba00d2c40541bf2449dedf29234f3854a1629e174d6353916ee40e834ea2ec0f4bc351a1142e0e60613a1e
7
+ data.tar.gz: ed67318c6a72655e8053d02f945ed133e6bf8461a89fc00ea7dd7684402d30291375c046b418f3465a2edcf33f45ddac1345027557cfc9a75623be041ea3d2a2
@@ -3,6 +3,7 @@
3
3
  <words>
4
4
  <w>rubocop</w>
5
5
  <w>salesforce</w>
6
+ <w>sfdx</w>
6
7
  <w>soql</w>
7
8
  <w>topoisomerase</w>
8
9
  </words>
@@ -7,12 +7,11 @@
7
7
  <content url="file://$MODULE_DIR$" />
8
8
  <orderEntry type="jdk" jdkName="RVM: ruby-2.6.0" jdkType="RUBY_SDK" />
9
9
  <orderEntry type="sourceFolder" forTests="false" />
10
- <orderEntry type="library" scope="PROVIDED" name="activemodel (v5.2.3, RVM: ruby-2.6.0) [gem]" level="application" />
11
- <orderEntry type="library" scope="PROVIDED" name="activerecord (v5.2.3, RVM: ruby-2.6.0) [gem]" level="application" />
12
- <orderEntry type="library" scope="PROVIDED" name="activesupport (v5.2.3, RVM: ruby-2.6.0) [gem]" level="application" />
10
+ <orderEntry type="library" scope="PROVIDED" name="activemodel (v6.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="activerecord (v6.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v6.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
13
13
  <orderEntry type="library" scope="PROVIDED" name="addressable (v2.6.0, RVM: ruby-2.6.0) [gem]" level="application" />
14
14
  <orderEntry type="library" scope="PROVIDED" name="akami (v1.3.1, RVM: ruby-2.6.0) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="arel (v9.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
16
15
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.0, RVM: ruby-2.6.0) [gem]" level="application" />
17
16
  <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.3, RVM: ruby-2.6.0) [gem]" level="application" />
18
17
  <orderEntry type="library" scope="PROVIDED" name="bundler (v2.0.2, RVM: ruby-2.6.0) [gem]" level="application" />
@@ -25,6 +24,7 @@
25
24
  <orderEntry type="library" scope="PROVIDED" name="faker (v2.1.2, RVM: ruby-2.6.0) [gem]" level="application" />
26
25
  <orderEntry type="library" scope="PROVIDED" name="gyoku (v1.3.1, RVM: ruby-2.6.0) [gem]" level="application" />
27
26
  <orderEntry type="library" scope="PROVIDED" name="hashie (v3.6.0, RVM: ruby-2.6.0) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="http-accept (v1.7.0, RVM: ruby-2.6.0) [gem]" level="application" />
28
28
  <orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.3, RVM: ruby-2.6.0) [gem]" level="application" />
29
29
  <orderEntry type="library" scope="PROVIDED" name="httpi (v2.4.4, RVM: ruby-2.6.0) [gem]" level="application" />
30
30
  <orderEntry type="library" scope="PROVIDED" name="humanize (v2.1.1, RVM: ruby-2.6.0) [gem]" level="application" />
@@ -51,9 +51,9 @@
51
51
  <orderEntry type="library" scope="PROVIDED" name="rack-protection (v2.0.4, RVM: ruby-2.6.0) [gem]" level="application" />
52
52
  <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
53
53
  <orderEntry type="library" scope="PROVIDED" name="rake (v12.3.3, RVM: ruby-2.6.0) [gem]" level="application" />
54
- <orderEntry type="library" scope="PROVIDED" name="random-port (v0.3.2, RVM: ruby-2.6.0) [gem]" level="application" />
54
+ <orderEntry type="library" scope="PROVIDED" name="random-port (v0.4.1, RVM: ruby-2.6.0) [gem]" level="application" />
55
55
  <orderEntry type="library" scope="PROVIDED" name="require_all (v2.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
56
- <orderEntry type="library" scope="PROVIDED" name="rest-client (v2.0.2, RVM: ruby-2.6.0) [gem]" level="application" />
56
+ <orderEntry type="library" scope="PROVIDED" name="rest-client (v2.1.0, RVM: ruby-2.6.0) [gem]" level="application" />
57
57
  <orderEntry type="library" scope="PROVIDED" name="rspec (v3.8.0, RVM: ruby-2.6.0) [gem]" level="application" />
58
58
  <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.8.0, RVM: ruby-2.6.0) [gem]" level="application" />
59
59
  <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.8.3, RVM: ruby-2.6.0) [gem]" level="application" />
@@ -67,13 +67,13 @@
67
67
  <orderEntry type="library" scope="PROVIDED" name="sinatra (v2.0.4, RVM: ruby-2.6.0) [gem]" level="application" />
68
68
  <orderEntry type="library" scope="PROVIDED" name="sinatra-basic-auth (v0.1.0, RVM: ruby-2.6.0) [gem]" level="application" />
69
69
  <orderEntry type="library" scope="PROVIDED" name="sinatra-docdsl (v0.8.6, RVM: ruby-2.6.0) [gem]" level="application" />
70
- <orderEntry type="library" scope="PROVIDED" name="soaspec (v0.2.30, RVM: ruby-2.6.0) [gem]" level="application" />
70
+ <orderEntry type="library" scope="PROVIDED" name="soaspec (v0.2.31, RVM: ruby-2.6.0) [gem]" level="application" />
71
71
  <orderEntry type="library" scope="PROVIDED" name="socksify (v1.7.1, RVM: ruby-2.6.0) [gem]" level="application" />
72
72
  <orderEntry type="library" scope="PROVIDED" name="thor (v0.20.3, RVM: ruby-2.6.0) [gem]" level="application" />
73
73
  <orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.6, RVM: ruby-2.6.0) [gem]" level="application" />
74
74
  <orderEntry type="library" scope="PROVIDED" name="tilt (v2.0.9, RVM: ruby-2.6.0) [gem]" level="application" />
75
75
  <orderEntry type="library" scope="PROVIDED" name="to_regexp (v0.2.1, RVM: ruby-2.6.0) [gem]" level="application" />
76
- <orderEntry type="library" scope="PROVIDED" name="topoisomerase (v0.1.3, RVM: ruby-2.6.0) [gem]" level="application" />
76
+ <orderEntry type="library" scope="PROVIDED" name="topoisomerase (v0.1.5, RVM: ruby-2.6.0) [gem]" level="application" />
77
77
  <orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.5, RVM: ruby-2.6.0) [gem]" level="application" />
78
78
  <orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, RVM: ruby-2.6.0) [gem]" level="application" />
79
79
  <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.7.6, RVM: ruby-2.6.0) [gem]" level="application" />
@@ -82,5 +82,6 @@
82
82
  <orderEntry type="library" scope="PROVIDED" name="xml-simple (v1.1.5, RVM: ruby-2.6.0) [gem]" level="application" />
83
83
  <orderEntry type="library" scope="PROVIDED" name="yard (v0.9.19, RVM: ruby-2.6.0) [gem]" level="application" />
84
84
  <orderEntry type="library" scope="PROVIDED" name="yard-doctest (v0.1.16, RVM: ruby-2.6.0) [gem]" level="application" />
85
+ <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.1.9, RVM: ruby-2.6.0) [gem]" level="application" />
85
86
  </component>
86
87
  </module>
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.1.18
2
+ * Enhancements
3
+ * `LeapSalesforce.logger` can be used to configure logger
4
+ * Cater for deprecated `get` method with deprecation warning
5
+
1
6
  Version 0.1.17
2
7
  * Enhancements
3
8
  * Retry if a Server breaks connection intermittently raises an error
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative 'users/users'
4
4
  require_relative 'soql_object'
5
+ require 'logger'
5
6
 
6
7
  # Adding parameters to set for authentication, environment and other common settings
7
8
  module LeapSalesforce
@@ -13,6 +14,8 @@ module LeapSalesforce
13
14
  @client_secret = ENV['client_secret']
14
15
  @password = ENV['password']
15
16
  @environment = nil
17
+ @logger = Logger.new STDOUT
18
+ @sfdx = false
16
19
  class << self
17
20
  # @return [String] Environment to use for tests. This can be accessed to change the username used to login
18
21
  # to test.salesforce with. This can be set on the command line with 'LEAP_ENV'
@@ -86,12 +89,17 @@ module LeapSalesforce
86
89
  attr_accessor :objects_to_verify
87
90
  # @return [Array] List of Soql Objects identified for Leap Salesforce to maintain
88
91
  attr_reader :soql_objects
89
-
92
+ # @return [Logger] Logger used by LeapSalesforce
93
+ attr_accessor :logger
90
94
  # @return [Array] list_of_soql_objects Array describing Soql objects taken from .leap_salesforce.yml
91
95
  def soql_objects=(list_of_soql_objects)
92
96
  @soql_objects = list_of_soql_objects.collect do |soql_object_desc|
93
97
  SoqlObject.new(soql_object_desc)
94
98
  end
95
99
  end
100
+ # Setting this variable uses sfdx for authentication and other actions such
101
+ # as opening an organisation link
102
+ # @return [Boolean] Whether Salesforce sfdx is being used
103
+ attr_accessor :sfdx
96
104
  end
97
105
  end
@@ -100,6 +100,16 @@ class SoqlData < Exchange
100
100
  self
101
101
  end
102
102
 
103
+ # @deprecated
104
+ # Get details of itself by searching for it's id
105
+ # Store response within itself
106
+ # @return [Exchange] Exchange with details of data
107
+ def get
108
+ LeapSalesforce.logger.warn "Method 'get' called when it is deprecated" \
109
+ " from #{caller_locations[0]}"
110
+ find
111
+ end
112
+
103
113
  # Update current record with data provided
104
114
  # @param [Hash] data Data to update exchange with
105
115
  def update(data)
@@ -89,6 +89,16 @@ module SoqlGlobalObjectData
89
89
  instance_to_get
90
90
  end
91
91
 
92
+ # @deprecated
93
+ # Get details of itself by searching for it's id
94
+ # Store response within itself
95
+ # @return [Exchange] Exchange with details of data
96
+ def get(lookup)
97
+ LeapSalesforce.logger.warn "Method 'get' called when it is deprecated" \
98
+ " from #{caller_locations[0]}"
99
+ find(lookup)
100
+ end
101
+
92
102
  # @return [self] SoqlData object that is the result of looking up id based on lookup criteria
93
103
  def lookup_id(lookup)
94
104
  teardown = lookup.delete(:teardown)
@@ -183,6 +193,7 @@ module SoqlGlobalObjectData
183
193
  # rubocop:disable Metrics/AbcSize
184
194
  def soql_element(name, backend_name)
185
195
  # Either set the element (if creating a new record) or update the object
196
+ # @todo: ensure next time an element is retrieved it's not from a cached value
186
197
  # @param [String] new_value Value to update record to
187
198
  define_method("#{name}=") do |new_value|
188
199
  if @response
@@ -199,6 +210,7 @@ module SoqlGlobalObjectData
199
210
  rescue NoElementAtPath
200
211
  raise diagnose_error if error_message?
201
212
 
213
+ # TODO: Response here should not be necessary. Only find is
202
214
  @response = find.response
203
215
  self[backend_name]
204
216
  end
@@ -7,7 +7,13 @@ require 'soaspec'
7
7
  # Credentials are stored either in 'config/credentials' folder or via environment variables
8
8
  # To check out SOQL SCHEMA go to workbench.developerforce.com. Use Sandbox and login
9
9
  class SoqlHandler < Soaspec::RestHandler
10
- oauth2 LeapSalesforce.oauth_settings
10
+ oauth2 LeapSalesforce.oauth_settings unless LeapSalesforce.sfdx
11
+ if LeapSalesforce.sfdx
12
+ # @return [String]
13
+ def instance_url
14
+ # TODO: Get this
15
+ end
16
+ end
11
17
  base_url '<%= instance_url %>/services/data/v<%= api_version %>/'
12
18
 
13
19
  pascal_keys true
@@ -10,7 +10,7 @@ module LeapSalesforce
10
10
  # @return [Array] List of test users
11
11
  attr_accessor :list
12
12
 
13
- # @param [LeapSalesforce::User] user Test user to add to leap salesforce
13
+ # @param [LeapSalesforce::User, Array] user Test user to add to leap salesforce
14
14
  def add(user)
15
15
  return @list << user if user.is_a? LeapSalesforce::User
16
16
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module LeapSalesforce
4
4
  # @return [String] Version of leap salesforce
5
- VERSION = '0.1.17'
5
+ VERSION = '0.1.18'
6
6
  end
@@ -3,13 +3,13 @@
3
3
  require 'leap_salesforce/version'
4
4
 
5
5
  require 'soaspec'
6
- Soaspec::OAuth2.refresh_token = :once # Save access token and reuse it
7
- Soaspec.log_warnings = false # Log any API warnings
8
- Soaspec::SpecLogger.progname = 'Leaps'
9
- Soaspec::OAuth2.request_message = false
6
+ Soaspec::OAuth2.refresh_token = :once # Save access token and reuse it
7
+ Soaspec.log_warnings = false # Log any API warnings
8
+ Soaspec::SpecLogger.progname = 'Leaps' # Program name shown in logs
9
+ Soaspec::OAuth2.request_message = false # Don't display message explaining OAuth request
10
10
  Soaspec::OAuth2.retry_limit = 1 # Retrying for OAuth token too many times results in user locked out
11
11
  require 'active_support/core_ext/integer/time' # Creating time objects
12
- require 'leap_salesforce/parameters'
12
+ require 'leap_salesforce/parameters' # Important to load this first
13
13
  require 'leap_salesforce/ext/string'
14
14
  require 'leap_salesforce/ext/time'
15
15
  require 'require_all'
@@ -21,7 +21,7 @@ require 'leap_salesforce/error'
21
21
  LEAP_CONFIG_FILE = '.leap_salesforce.yml'
22
22
  CREDENTIAL_FILE = File.join('config', 'credentials', 'salesforce_oauth2.yml')
23
23
 
24
- leap_logger = Logger.new STDOUT
24
+ leap_logger = LeapSalesforce.logger
25
25
  leap_logger.level = Logger::DEBUG
26
26
  leap_logger.datetime_format = '%Y-%m-%d %H:%M:%S'
27
27
 
@@ -41,7 +41,15 @@ end
41
41
 
42
42
  raise LeapSalesforce::SetupError, 'LeapSalesforce.environment not set' if LeapSalesforce.environment.nil?
43
43
 
44
- if File.exist? CREDENTIAL_FILE
44
+ if LeapSalesforce.sfdx
45
+ # Assume authentication already made through 'sfdx force:auth:jwt:grant'
46
+ unless ENV['SF_USERNAME'] && ENV['SF_CONSUMER_KEY']
47
+ raise LeapSalesforce::SetupError,
48
+ 'Please set SF_USERNAME and SF_CONSUMER_KEY environment variables'
49
+ end
50
+ `sfdx force:user:display -u #{ENV['SF_USERNAME']}`
51
+ elsif File.exist? CREDENTIAL_FILE
52
+ # Set credentials from credentials file for ConnectedApp
45
53
  YAML.load_file(CREDENTIAL_FILE).each do |key, value|
46
54
  LeapSalesforce.send("#{key}=", value)
47
55
  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.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - IQA
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-08-20 00:00:00.000000000 Z
12
+ date: 2019-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler