restforce 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of restforce might be problematic. Click here for more details.

data/README.md CHANGED
@@ -13,6 +13,8 @@ It attempts to solve a couple of key issues that the databasedotcom gem has been
13
13
  * Support for blob data types.
14
14
  * A clean and modular architecture using [Faraday middleware](https://github.com/technoweenie/faraday)
15
15
 
16
+ [Documentation](http://rubydoc.info/gems/restforce/frames)
17
+
16
18
  ## Installation
17
19
 
18
20
  Add this line to your application's Gemfile:
@@ -94,7 +96,12 @@ Restforce.configure do |config|
94
96
  end
95
97
  ```
96
98
 
97
- ### Query
99
+ * * *
100
+
101
+ ### query(soql)
102
+
103
+ Performs a soql query and returns the result. The result will be a
104
+ [Restforce::Collection][], which can be iterated over.
98
105
 
99
106
  ```ruby
100
107
  accounts = client.query("select Id, Something__c from Account where Id = 'someid'")
@@ -114,7 +121,14 @@ account.destroy
114
121
  # => true
115
122
  ```
116
123
 
117
- ### Search
124
+ _See also: http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_query.htm_
125
+
126
+ * * *
127
+
128
+ ### search(sosl)
129
+
130
+ Performs a sosl query and returns the result. The result will be a
131
+ [Restforce::Collection][].
118
132
 
119
133
  ```ruby
120
134
  # Find all occurrences of 'bar'
@@ -126,7 +140,14 @@ client.search('FIND {genepoint} RETURNING Account (Name)').map(&:Name)
126
140
  # => ['GenePoint']
127
141
  ```
128
142
 
129
- ### Create
143
+ _See also: http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_search.htm_
144
+
145
+ * * *
146
+
147
+ ### create(sobject, attrs)
148
+
149
+ Takes an sobject name and a hash of attributes to create a record. Returns the
150
+ Id of the newly created reocrd if the record was successfully created.
130
151
 
131
152
  ```ruby
132
153
  # Add a new account
@@ -134,7 +155,15 @@ client.create('Account', Name: 'Foobar Inc.')
134
155
  # => '0016000000MRatd'
135
156
  ```
136
157
 
137
- ### Update
158
+ _See also: http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_create.htm_
159
+
160
+ * * *
161
+
162
+ ### update(sobject, attrs)
163
+
164
+ Takes an sobject name and a hash of attributes to update a record. The
165
+ 'Id' field is required to update. Returns true if the record was successfully
166
+ updated.
138
167
 
139
168
  ```ruby
140
169
  # Update the Account with Id '0016000000MRatd'
@@ -142,15 +171,28 @@ client.update('Account', Id: '0016000000MRatd', Name: 'Whizbang Corp')
142
171
  # => true
143
172
  ```
144
173
 
174
+ _See also: http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_update_fields.htm_
175
+
176
+ * * *
177
+
178
+ ### upsert(sobject, field, attrs)
145
179
 
146
- ### Upsert
180
+ Takes an sobject name, an external id field, and a hash of attributes and
181
+ either inserts or updates the record depending on the existince of the record.
182
+ Returns true if the record was updated or the Id of the record if the record was
183
+ created.
147
184
 
148
185
  ```ruby
149
186
  # Update the record with external ID of 12
150
187
  client.upsert('Account', 'External__c', External__c: 12, Name: 'Foobar')
151
188
  ```
152
189
 
153
- ### Destroy
190
+ _See also: http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_upsert.htm_
191
+
192
+ ### destroy(sobject, id)
193
+
194
+ Takes an sobject name and an Id and deletes the record. Returns true if the
195
+ record was successfully deleted.
154
196
 
155
197
  ```ruby
156
198
  # Delete the Account with Id '0016000000MRatd'
@@ -158,6 +200,10 @@ client.destroy('Account', '0016000000MRatd')
158
200
  # => true
159
201
  ```
160
202
 
203
+ _See also: http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_delete_record.htm_
204
+
205
+ * * *
206
+
161
207
  ### File Uploads
162
208
 
163
209
  Using the new [Blob Data](http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_insert_update_blob.htm) api feature (500mb limit):
@@ -178,6 +224,10 @@ client.create 'Document', FolderId: '00lE0000000FJ6H',
178
224
  Body: Base64::encode64(File.read('image.jpg'))
179
225
  ```
180
226
 
227
+ _See also: http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_insert_update_blob.htm_
228
+
229
+ * * *
230
+
181
231
  ### Streaming
182
232
 
183
233
  Restforce supports the [Streaming API](http://wiki.developerforce.com/page/Getting_Started_with_the_Force.com_Streaming_API), and makes implementing
@@ -201,24 +251,26 @@ EM.run {
201
251
  Boom, you're now receiving push notifications when Accounts are
202
252
  created/updated.
203
253
 
254
+ _See also: http://www.salesforce.com/us/developer/docs/api_streaming/index.htm_
255
+
256
+ * * *
257
+
204
258
  ### Caching
205
259
 
206
260
  The gem supports easy caching of GET requests (e.g. queries):
207
261
 
208
262
  ```ruby
209
- # Memcached example:
210
-
211
- cache = Dalli::Client.new
212
-
213
- client = Restforce.new cache: cache
263
+ # rails example:
264
+ client = Restforce.new cache: Rails.cache
214
265
 
215
266
  # or
216
-
217
267
  Restforce.configure do |config|
218
- config.cache = cache
268
+ config.cache = Rails.cache
219
269
  end
220
270
  ```
221
271
 
272
+ * * *
273
+
222
274
  ### Logging/Debugging
223
275
 
224
276
  You can easily inspect what Restforce is sending/receiving by setting
@@ -255,3 +307,5 @@ client = Restforce.new.query('select Id, Name from Account')
255
307
  3. Commit your changes (`git commit -am 'Added some feature'`)
256
308
  4. Push to the branch (`git push origin my-new-feature`)
257
309
  5. Create new Pull Request
310
+
311
+ [Restforce::Collection]: https://github.com/ejholmes/restforce/blob/master/lib/restforce/collection.rb "Restforce::Collection"
@@ -8,12 +8,14 @@ module Restforce
8
8
 
9
9
  def call(env)
10
10
  request_body = env[:body]
11
+ request = env[:request]
11
12
  begin
12
13
  return authenticate! if force_authenticate?(env)
13
14
  @app.call(env)
14
15
  rescue Restforce::UnauthorizedError
15
16
  authenticate!
16
17
  env[:body] = request_body
18
+ env[:request] = request
17
19
  @app.call(env)
18
20
  end
19
21
  end
@@ -1,3 +1,3 @@
1
1
  module Restforce
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -28,12 +28,13 @@ describe Restforce::Middleware::Authentication do
28
28
  context 'when an exception is thrown' do
29
29
  before do
30
30
  env[:body] = 'foo'
31
+ env[:request] = {proxy: nil}
31
32
  end
32
33
 
33
34
  it 'attempts to authenticate' do
34
- app.should_receive(:call).once { |env| env[:body] = 'bar'; raise Restforce::UnauthorizedError.new('something bad') }
35
+ app.should_receive(:call).once { |env| env[:body] = 'bar'; env[:request] = 'foo'; raise Restforce::UnauthorizedError.new('something bad') }
35
36
  middleware.should_receive(:authenticate!)
36
- app.should_receive(:call).with(:body => 'foo').once
37
+ app.should_receive(:call).with(body: 'foo', request: { proxy: nil }).once
37
38
  middleware.call(env)
38
39
  end
39
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-17 00:00:00.000000000 Z
12
+ date: 2012-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake