SFDO-API 0.1.5 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e4fb8c9db613614f675fc0157594bcb6751911c
4
- data.tar.gz: 22e020c4781a686dab58dae5fe6722ac6a9bb91f
3
+ metadata.gz: be6528c0a458a146c3ae52b5a59b9504d81cd219
4
+ data.tar.gz: 28b4defea23aac1e34fb703d69b3872a9d0aff75
5
5
  SHA512:
6
- metadata.gz: 5e8553ee5611a0ebc8063aca224324a79cef8b75e52bf2b8b83aec93e9d8ee8b829bf254b04114ec18edd7cd5fcc9b8dee4071324b8a76bdea1e87be47a9ec25
7
- data.tar.gz: f473ab15546f20136c93ce91f136e17092fc6e72350dd3ab8afee3bfd9b6dadc798c0fbb9f2012a411b22c748f50ff32047c6e98e0ce077b5aefe1584b8fd3c3
6
+ metadata.gz: f3375dd2d43439605a4ec80155323a0d88651ccf7526808d18fb0babb1c086257e8e732b4f9b6e72d1fdb57f79a1fd80135c1fc85da2d923317fa8d0adafe09f
7
+ data.tar.gz: f5ae2b0277f5fd587ee8a000c9fd326e76a08f9132cf8720c57fb3833dfe55fad9098642425767326c702a9a8d14522eec8355d611bf1df856831c6767775775
data/README.md CHANGED
@@ -34,7 +34,7 @@ To create a simple Account and get the ID for that Account:
34
34
  end
35
35
  ```
36
36
 
37
- You can also address the Restforce API client directly if you want, for example to issue a 'select' query:
37
+ When issuing a SELECT query, use the select_api() method with your query:
38
38
 
39
39
  ```ruby
40
40
  def create_contact_via_api(client_name, street = '', city = '', state = '', country = '', zip = '')
@@ -44,12 +44,17 @@ You can also address the Restforce API client directly if you want, for example
44
44
  MailingState: state,
45
45
  MailingCountry: country,
46
46
  MailingPostalCode: zip
47
- account_object = @api_client.query("select AccountId from Contact where Id = '#{@contact_id}'")
47
+ account_object = select_api "select AccountId from Contact where Id = '#{@contact_id}'"
48
48
  my_account_object = account_object.first
49
49
  @account_id_for_contact = my_account_object.AccountId
50
50
  end
51
51
  ```
52
52
 
53
+ When doing SELECT for a custom object, leave off any namespace value, SFDO-API retrieves the appropriate namespace at run time:
54
+ ```ruby
55
+ gaus = select_api 'select Id from General_Accounting_Unit__c'
56
+ ```
57
+
53
58
  To delete a single instance of an object for which you have the Id value
54
59
  ```ruby
55
60
  def delete_account_via_api
@@ -93,7 +98,7 @@ When using delete_one_foo or delete_all_foo do not use any namespace value, SFDO
93
98
  ```ruby
94
99
  def delete_gaus_via_api
95
100
  api_client do
96
- gaus = @api_client.query("select Id from #{true_object_name('General_Accounting_Unit__c')}")
101
+ gaus = select_api 'select Id from General_Accounting_Unit__c'
97
102
  puts gaus.inspect
98
103
  delete_all_General_Accounting_Unit__c(gaus)
99
104
  end
@@ -21,6 +21,23 @@ module SfdoAPI
21
21
  obj_id
22
22
  end
23
23
 
24
+ def select_api(query)
25
+ if query.match /where/i
26
+ obj_name = query[/(?<=from )(.*)(?= where)|$/i]
27
+ else
28
+ obj_name = query[/(?<=from )(.*)$/i]
29
+ end
30
+
31
+ real_obj_name = true_object_name(obj_name)
32
+
33
+ query = query.gsub(obj_name, real_obj_name)
34
+
35
+ results = api_client do
36
+ @api_client.query query
37
+ end
38
+ results
39
+ end
40
+
24
41
  def is_valid_obj_hash?(object_name, obj_hash, fields_acceptibly_nil)
25
42
  required_fields = get_object_describe(object_name).map(&:fieldName)
26
43
  valid = true
@@ -118,10 +135,10 @@ module SfdoAPI
118
135
  delete obj_type, *args
119
136
  when /^create_/
120
137
  create obj_type, *args
138
+ when /^select_api/
139
+ select_api *args
121
140
  when /^update/
122
141
  #TODO
123
- when /^select/
124
- #TODO
125
142
  else
126
143
  super.method_missing
127
144
  end
@@ -1,5 +1,5 @@
1
1
  module SFDO
2
2
  module API
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SFDO-API
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris McMahon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-09-29 00:00:00.000000000 Z
12
+ date: 2016-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler