restforce 2.3.0 → 2.4.0

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88a93138f74a67b4da1371232281d45950539b18
4
- data.tar.gz: f3603bbb017e9864ce6873524c4206ddf4142b61
3
+ metadata.gz: b601d8c57cda8c40639e2167ff4e887d4ad8764b
4
+ data.tar.gz: abfa4a6ec6a1f098c35f1f83139686d8234bf28d
5
5
  SHA512:
6
- metadata.gz: 14cbc34c3bc5bd7b766cfc71c3ecae01fbb370be79b4c02078493949c21f3ad8df4679422f574b587e15344f9388b09c311214f1a6935d5c0dfe364556dc164f
7
- data.tar.gz: 47fce31a67fe328abe6a992b2c9030dd01b190d719526571f4e7ef98cd4e5a337b28749a1cd460d7ec019cb5ae52c7ffe63c1d228befb4ada31fa16db88d3157
6
+ metadata.gz: bdaacea3ebb0a83ffbd7bf6e3f73635fbb426616074d1fa7164e06312b5dd32caec5fea30a5b598fca6a6e4c4466f556a679c1600dc17f9b01239133af3b229b
7
+ data.tar.gz: 30cedb2942d22e55df574696d6a2d2fc23b5f7a34aa46f333e92dac3857c38093d26edcdfb579012717aa5f68f9961f1a44d1f351ea055fa575979a7931d3b8c
@@ -1,4 +1,8 @@
1
- # 2.3.0 (Jul 15, 2016)
1
+ ## 2.4.0 (Jul 29, 2016)
2
+
3
+ * Added ability to download documents attached to records, behaving like attachments (@jhelbig)
4
+
5
+ ## 2.3.0 (Jul 15, 2016)
2
6
 
3
7
  * Allow the Salesforce API version to be specified with a `SALESFORCE_API_VERSION` environment variable (@jhelbig)
4
8
 
data/README.md CHANGED
@@ -439,14 +439,20 @@ _See also: [Inserting or updating blob data](http://www.salesforce.com/us/develo
439
439
 
440
440
  * * *
441
441
 
442
- ### Downloading Attachments
442
+ ### Downloading Attachments and Documents
443
443
 
444
- Restforce also makes it incredibly easy to download Attachments:
444
+ Restforce also makes it incredibly easy to download Attachments or Documents:
445
445
 
446
+ ##### Attachments
446
447
  ```ruby
447
448
  attachment = client.query('select Id, Name, Body from Attachment').first
448
449
  File.open(attachment.Name, 'wb') { |f| f.write(attachment.Body) }
449
450
  ```
451
+ ##### Documents
452
+ ```ruby
453
+ document = client.query('select Id, Name, Body from Document').first
454
+ File.open(document.Name, 'wb') { |f| f.write(document.Body) }
455
+ ```
450
456
 
451
457
  * * *
452
458
 
@@ -11,6 +11,7 @@ module Restforce
11
11
  autoload :Collection, 'restforce/collection'
12
12
  autoload :Middleware, 'restforce/middleware'
13
13
  autoload :Attachment, 'restforce/attachment'
14
+ autoload :Document, 'restforce/document'
14
15
  autoload :UploadIO, 'restforce/upload_io'
15
16
  autoload :SObject, 'restforce/sobject'
16
17
  autoload :Client, 'restforce/client'
@@ -0,0 +1,21 @@
1
+ module Restforce
2
+ class Document < Restforce::SObject
3
+ # Public: Returns the body of the document.
4
+ #
5
+ # Examples
6
+ #
7
+ # document = client.query('select Id, Name, Body from Document').first
8
+ # File.open(document.Name, 'wb') { |f| f.write(document.Body) }
9
+ def Body
10
+ ensure_id && ensure_body
11
+ @client.get(super).body
12
+ end
13
+
14
+ private
15
+
16
+ def ensure_body
17
+ return true if self.Body?
18
+ raise 'You need to query the Body for the record first.'
19
+ end
20
+ end
21
+ end
@@ -24,8 +24,11 @@ module Restforce
24
24
  # of sobject records.
25
25
  Restforce::Collection
26
26
  elsif val.key? 'attributes'
27
- if val['attributes']['type'] == 'Attachment'
27
+ case (val['attributes']['type'])
28
+ when "Attachment"
28
29
  Restforce::Attachment
30
+ when "Document"
31
+ Restforce::Document
29
32
  else
30
33
  # When the hash contains an attributes key, it should be considered an
31
34
  # sobject record
@@ -1,3 +1,3 @@
1
1
  module Restforce
2
- VERSION = '2.3.0'
2
+ VERSION = '2.4.0'
3
3
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Restforce::Document do
4
+ let(:client) { double(Restforce::AbstractClient) }
5
+ let(:body_url) { '/services/data/v26.0/sobjects/Document/00PG0000006Hll5MAC/Body' }
6
+ let(:hash) { { 'Id' => '1234', 'Body' => body_url } }
7
+ let(:sobject) { described_class.new(hash, client) }
8
+
9
+ describe '.Body' do
10
+ it 'requests the body' do
11
+ client.should_receive(:get).with(body_url).
12
+ and_return(double('response').as_null_object)
13
+ sobject.Body
14
+ end
15
+ end
16
+ end
@@ -26,6 +26,11 @@ describe Restforce::Mash do
26
26
  let(:input) { { 'attributes' => { 'type' => 'Attachment' } } }
27
27
  it { should eq Restforce::Attachment }
28
28
  end
29
+
30
+ context 'when the sobject type is a Document' do
31
+ let(:input) { { 'attributes' => { 'type' => 'Document' } } }
32
+ it { should eq Restforce::Document }
33
+ end
29
34
  end
30
35
 
31
36
  context 'else' do
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: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric J. Holmes
@@ -9,144 +9,144 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-15 00:00:00.000000000 Z
12
+ date: 2016-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.9.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.9.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: faraday_middleware
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: 0.8.8
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: 0.8.8
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: json
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: 1.7.5
49
- - - "<"
49
+ - - <
50
50
  - !ruby/object:Gem::Version
51
51
  version: 1.9.0
52
52
  type: :runtime
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - ">="
56
+ - - '>='
57
57
  - !ruby/object:Gem::Version
58
58
  version: 1.7.5
59
- - - "<"
59
+ - - <
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.9.0
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: hashie
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.2.0
69
- - - "<"
69
+ - - <
70
70
  - !ruby/object:Gem::Version
71
71
  version: '4.0'
72
72
  type: :runtime
73
73
  prerelease: false
74
74
  version_requirements: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - ">="
76
+ - - '>='
77
77
  - !ruby/object:Gem::Version
78
78
  version: 1.2.0
79
- - - "<"
79
+ - - <
80
80
  - !ruby/object:Gem::Version
81
81
  version: '4.0'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: rspec
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ~>
87
87
  - !ruby/object:Gem::Version
88
88
  version: 2.14.0
89
89
  type: :development
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "~>"
93
+ - - ~>
94
94
  - !ruby/object:Gem::Version
95
95
  version: 2.14.0
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: webmock
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - ~>
101
101
  - !ruby/object:Gem::Version
102
102
  version: 1.13.0
103
103
  type: :development
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - "~>"
107
+ - - ~>
108
108
  - !ruby/object:Gem::Version
109
109
  version: 1.13.0
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: simplecov
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - "~>"
114
+ - - ~>
115
115
  - !ruby/object:Gem::Version
116
116
  version: 0.7.1
117
117
  type: :development
118
118
  prerelease: false
119
119
  version_requirements: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - "~>"
121
+ - - ~>
122
122
  - !ruby/object:Gem::Version
123
123
  version: 0.7.1
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: rubocop
126
126
  requirement: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - "~>"
128
+ - - ~>
129
129
  - !ruby/object:Gem::Version
130
130
  version: 0.31.0
131
131
  type: :development
132
132
  prerelease: false
133
133
  version_requirements: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - "~>"
135
+ - - ~>
136
136
  - !ruby/object:Gem::Version
137
137
  version: 0.31.0
138
138
  - !ruby/object:Gem::Dependency
139
139
  name: faye
140
140
  requirement: !ruby/object:Gem::Requirement
141
141
  requirements:
142
- - - ">="
142
+ - - '>='
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  type: :development
146
146
  prerelease: false
147
147
  version_requirements: !ruby/object:Gem::Requirement
148
148
  requirements:
149
- - - ">="
149
+ - - '>='
150
150
  - !ruby/object:Gem::Version
151
151
  version: '0'
152
152
  description: A lightweight ruby client for the Salesforce REST API.
@@ -157,10 +157,10 @@ executables: []
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
- - ".gitignore"
161
- - ".rubocop.yml"
162
- - ".rubocop_todo.yml"
163
- - ".travis.yml"
160
+ - .gitignore
161
+ - .rubocop.yml
162
+ - .rubocop_todo.yml
163
+ - .travis.yml
164
164
  - CHANGELOG.md
165
165
  - CODE_OF_CONDUCT.md
166
166
  - CONTRIBUTING.md
@@ -186,6 +186,7 @@ files:
186
186
  - lib/restforce/concerns/verbs.rb
187
187
  - lib/restforce/config.rb
188
188
  - lib/restforce/data/client.rb
189
+ - lib/restforce/document.rb
189
190
  - lib/restforce/mash.rb
190
191
  - lib/restforce/middleware.rb
191
192
  - lib/restforce/middleware/authentication.rb
@@ -266,6 +267,7 @@ files:
266
267
  - spec/unit/concerns/streaming_spec.rb
267
268
  - spec/unit/config_spec.rb
268
269
  - spec/unit/data/client_spec.rb
270
+ - spec/unit/document_spec.rb
269
271
  - spec/unit/mash_spec.rb
270
272
  - spec/unit/middleware/authentication/password_spec.rb
271
273
  - spec/unit/middleware/authentication/token_spec.rb
@@ -289,17 +291,17 @@ require_paths:
289
291
  - lib
290
292
  required_ruby_version: !ruby/object:Gem::Requirement
291
293
  requirements:
292
- - - ">="
294
+ - - '>='
293
295
  - !ruby/object:Gem::Version
294
296
  version: 1.9.3
295
297
  required_rubygems_version: !ruby/object:Gem::Requirement
296
298
  requirements:
297
- - - ">="
299
+ - - '>='
298
300
  - !ruby/object:Gem::Version
299
301
  version: '0'
300
302
  requirements: []
301
303
  rubyforge_project:
302
- rubygems_version: 2.4.7
304
+ rubygems_version: 2.0.14.1
303
305
  signing_key:
304
306
  specification_version: 4
305
307
  summary: A lightweight ruby client for the Salesforce REST API.
@@ -360,6 +362,7 @@ test_files:
360
362
  - spec/unit/concerns/streaming_spec.rb
361
363
  - spec/unit/config_spec.rb
362
364
  - spec/unit/data/client_spec.rb
365
+ - spec/unit/document_spec.rb
363
366
  - spec/unit/mash_spec.rb
364
367
  - spec/unit/middleware/authentication/password_spec.rb
365
368
  - spec/unit/middleware/authentication/token_spec.rb
@@ -373,4 +376,3 @@ test_files:
373
376
  - spec/unit/signed_request_spec.rb
374
377
  - spec/unit/sobject_spec.rb
375
378
  - spec/unit/tooling/client_spec.rb
376
- has_rdoc: