salesforce_ar_sync 1.1.1 → 1.1.2

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/README.md CHANGED
@@ -110,6 +110,7 @@ The options available to configure are
110
110
 
111
111
  * __organization_id__: the 18 character organization id of your Salesforce instance
112
112
  * __sync_enabled__: a global sync enabled flag which is a boolean true/false
113
+ * __namespace_prefix__: Namespace prefix of your Salesforce app in case you specified one
113
114
 
114
115
  To generate a YAML file
115
116
 
@@ -123,6 +124,7 @@ which will create a template salesforce_ar_sync.yml in /config that looks like t
123
124
 
124
125
  organization_id: <organization id> #18 character organization_id
125
126
  sync_enabled: true
127
+ namespace_prefix:
126
128
 
127
129
 
128
130
  To use the ENV variable you must pass environemnt variables to rails via the _export_ command in bash or before the
@@ -130,7 +132,8 @@ initializer loads the ENV settings.
130
132
 
131
133
  $ export SALESFORCE_AR_SYNC_ORGANIZATION_ID=123456789123456789
132
134
  $ export SALESFORCE_AR_SYNC_SYNC_ENABLED=true
133
-
135
+ $ export SALESFORCE_AR_NAMESPACE_PREFIX=my_prefix
136
+
134
137
  ### Model Options
135
138
  The model can have several options set:
136
139
 
@@ -3,15 +3,18 @@ production:
3
3
  sync_enabled: true
4
4
  # Salesforce owned IPs from: https://help.salesforce.com/apex/HTViewSolution?language=en_US&id=000003652
5
5
  ip_ranges: "204.14.232.0/23,204.14.237.0/24,96.43.144.0/22,96.43.148.0/22,204.14.234.0/23,204.14.238.0/23,182.50.76.0/22"
6
+ namespace_prefix:
6
7
 
7
8
  development:
8
9
  organization_id: <%= @organization_id %>
9
10
  sync_enabled: false
10
11
  # Salesforce owned IPs from: https://help.salesforce.com/apex/HTViewSolution?language=en_US&id=000003652
11
12
  ip_ranges: "204.14.232.0/23,204.14.237.0/24,96.43.144.0/22,96.43.148.0/22,204.14.234.0/23,204.14.238.0/23,182.50.76.0/22"
13
+ namespace_prefix:
12
14
 
13
15
  test:
14
16
  organization_id: <%= @organization_id %>
15
17
  sync_enabled: false
16
18
  # Salesforce owned IPs from: https://help.salesforce.com/apex/HTViewSolution?language=en_US&id=000003652
17
- ip_ranges: "204.14.232.0/23,204.14.237.0/24,96.43.144.0/22,96.43.148.0/22,204.14.234.0/23,204.14.238.0/23,182.50.76.0/22"
19
+ ip_ranges: "204.14.232.0/23,204.14.237.0/24,96.43.144.0/22,96.43.148.0/22,204.14.234.0/23,204.14.238.0/23,182.50.76.0/22"
20
+ namespace_prefix:
@@ -12,12 +12,14 @@ module SalesforceArSync
12
12
  SalesforceArSync.config["ORGANIZATION_ID"] = config['organization_id']
13
13
  SalesforceArSync.config["SYNC_ENABLED"] = config['sync_enabled']
14
14
  SalesforceArSync.config["IP_RANGES"] = config['ip_ranges'].split(',').map{ |ip| ip.strip }
15
+ SalesforceArSync.config["NAMESPACE_PREFIX"] = config['namespace_prefix']
15
16
  end
16
17
 
17
18
  #if we have ENV flags prefer them
18
19
  SalesforceArSync.config["ORGANIZATION_ID"] = ENV["SALESFORCE_AR_SYNC_ORGANIZATION_ID"] if ENV["SALESFORCE_AR_SYNC_ORGANIZATION_ID"]
19
20
  SalesforceArSync.config["SYNC_ENABLED"] = ENV["SALESFORCE_AR_SYNC_SYNC_ENABLED"] if ENV.include? "SALESFORCE_AR_SYNC_SYNC_ENABLED"
20
21
  SalesforceArSync.config["IP_RANGES"] = ENV["SALESFORCE_AR_SYNC_IP_RANGES"].split(',').map{ |ip| ip.strip } if ENV["SALESFORCE_AR_SYNC_IP_RANGES"]
22
+ SalesforceArSync.config["NAMESPACE_PREFIX"] = ENV["SALESFORCE_AR_NAMESPACE_PREFIX"] if ENV["SALESFORCE_AR_NAMESPACE_PREFIX"]
21
23
 
22
24
  #do we have valid config options now?
23
25
  if !SalesforceArSync.config["ORGANIZATION_ID"].present? || SalesforceArSync.config["ORGANIZATION_ID"].length != 18
@@ -41,6 +41,10 @@ module SalesforceArSync
41
41
  end
42
42
  return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><notificationsResponse>#{response}</notificationsResponse></soapenv:Body></soapenv:Envelope>"
43
43
  end
44
+
45
+ def self.namespaced(field)
46
+ SalesforceArSync.config["NAMESPACE_PREFIX"].present? ? :"#{SalesforceArSync.config["NAMESPACE_PREFIX"]}__#{field}" : :"#{field}"
47
+ end
44
48
 
45
49
  private
46
50
 
@@ -8,12 +8,12 @@ module SalesforceArSync
8
8
  end
9
9
 
10
10
  def self.delete_object(hash = {})
11
- raise ArgumentError, "Object_Id__c parameter required" if hash[:Object_Id__c].blank?
12
- raise ArgumentError, "Object_Type__c parameter required" if hash[:Object_Type__c].blank?
11
+ raise ArgumentError, "Object_Id__c parameter required" if hash[namespaced(:Object_Id__c)].blank?
12
+ raise ArgumentError, "Object_Type__c parameter required" if hash[namespaced(:Object_Type__c)].blank?
13
13
 
14
- object = hash[:Object_Type__c].constantize.find_by_salesforce_id(hash[:Object_Id__c])
14
+ object = hash[namespaced(:Object_Type__c)].constantize.find_by_salesforce_id(hash[namespaced(:Object_Id__c)])
15
15
  object.destroy if object
16
16
  end
17
- end
17
+ end
18
18
  end
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module SalesforceArSync
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salesforce_ar_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-04-24 00:00:00.000000000 Z
16
+ date: 2013-04-26 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails