sfdc 2.4.0 → 3.0.0

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: b069e7a4c283823fd8d6c1cb4d91655843aeb825
4
- data.tar.gz: 5f4ee6acdefbea239435a03d000e3ff2f5fbfdb0
3
+ metadata.gz: a4a336e27a5dc02b776c7d3898a80ff1d51c0020
4
+ data.tar.gz: d7c5c2eb05b464a0da43d7d92cd014831446c5b2
5
5
  SHA512:
6
- metadata.gz: 7b8ce424aa1aee8e13e61a8b3d79c90f0db1adde39258ff722492d49bc65afcb884352ec617b95db3245399ad238605d1145aed17f6dda7e5b1ec66379ced844
7
- data.tar.gz: 476893d58baba2e78b4bbfb2ab111ae92fd756cef72115c712dbcdc29baed9844e5156261030085e1a65cbc322601b4ef5d69b004c668dabcfe7fe6c679d874b
6
+ metadata.gz: 3081785e27bc7dbd8d55dd481c179d35bee99f420912fc05178a8ee8e08183d0aebb47ab44507504b0710ebdb0d9b3113c21c8fdc073f3802718b4500ce75567
7
+ data.tar.gz: 27e4897d37ab690d6faa5c82dd1a5c05f83fe1c196de559203f3a1a27ab65d89a734c17aafbad0021d490759b1a80d94bbd133df3afad4f538ddbd9fd5f99d4a
data/README.md CHANGED
@@ -4,16 +4,6 @@ Sfdc is a ruby gem for the [Salesforce REST api](http://www.salesforce.com/us/de
4
4
 
5
5
  Features include:
6
6
 
7
- * Support for interacting with multiple users from different orgs.
8
- * Support for parent-to-child relationships.
9
- * Support for aggregate queries.
10
- * Support for the [Streaming API](#streaming)
11
- * Support for blob data types.
12
- * Support for GZIP compression.
13
- * Support for [custom Apex REST endpoints](#custom-apex-rest-endpoints).
14
- * Support for dependent picklists.
15
- * Support for decoding [Force.com Canvas](http://www.salesforce.com/us/developer/docs/platform_connectpre/canvas_framework.pdf) signed requests. (NEW!)
16
-
17
7
 
18
8
  ## Installation
19
9
 
@@ -22,6 +22,11 @@ module Sfdc
22
22
  end
23
23
  alias_method :length, :size
24
24
 
25
+ # Return array of the elements on the current page
26
+ def current_page
27
+ first(@raw_page['records'].size)
28
+ end
29
+
25
30
  # Return the current and all of the following pages.
26
31
  def pages
27
32
  [self] + (has_next_page? ? next_page.pages : [])
@@ -65,6 +65,30 @@ module Sfdc
65
65
  end
66
66
  end
67
67
 
68
+ # Public: Returns a detailed description of the Page Layout for the
69
+ # specified sobject type, or URIs for layouts if the sobject has
70
+ # multiple Record Types.
71
+ #
72
+ # This resource was introduced in version 28.0.
73
+ #
74
+ # Examples:
75
+ # # get the layouts for the sobject
76
+ # client.describe_layouts('Account')
77
+ # # => { ... }
78
+ #
79
+ # # get the layout for the specified Id for the sobject
80
+ # client.describe_layouts('Account', '012E0000000RHEp')
81
+ # # => { ... }
82
+ #
83
+ # Returns the Hash representation of the describe_layouts result
84
+ def describe_layouts(sobject, layout_id = nil)
85
+ if layout_id
86
+ api_get("sobjects/#{sobject.to_s}/describe/layouts/#{layout_id}").body
87
+ else
88
+ api_get("sobjects/#{sobject.to_s}/describe/layouts").body
89
+ end
90
+ end
91
+
68
92
  # Public: Get the current organization's Id.
69
93
  #
70
94
  # Examples
@@ -275,26 +299,6 @@ module Sfdc
275
299
  def find(sobject, id, field=nil)
276
300
  api_get(field ? "sobjects/#{sobject}/#{field}/#{id}" : "sobjects/#{sobject}/#{id}").body
277
301
  end
278
-
279
- # Public: Get the current user's Id.
280
- # client.user_id
281
- def user_id
282
- response = authenticate!
283
- info = get(response.id).body
284
- user_id = info.user_id
285
- return user_id
286
- end
287
-
288
- #################### Chatter items ############################
289
- # @client.feeds.each do |f|
290
- # puts f.to_hash['id']
291
- # puts f.to_hash['body']['text']
292
- # end
293
- def feeds
294
- api_get("/chatter/feeds/news/me/feed-items").body.items
295
- end
296
-
297
- ###############################################################
298
302
 
299
303
  private
300
304
 
@@ -37,6 +37,9 @@ module Sfdc
37
37
  # :timeout - Faraday connection request read/open timeout. (default: nil).
38
38
  #
39
39
  # :proxy_uri - Proxy URI: 'http://proxy.example.com:port' or 'http://user@pass:proxy.example.com:port'
40
+ #
41
+ # :authentication_callback
42
+ # - A Proc that is called with the response body after a successful authentication.
40
43
  def initialize(opts = {})
41
44
  raise ArgumentError, 'Please specify a hash of options' unless opts.is_a?(Hash)
42
45
  @options = Hash[Sfdc.configuration.options.map { |option| [option, Sfdc.configuration.send(option)] }]
@@ -51,7 +51,7 @@ module Sfdc
51
51
  end
52
52
 
53
53
  def adapter
54
- Sfdc.configuration.adapter
54
+ options[:adapter]
55
55
  end
56
56
 
57
57
  # Internal: Faraday Connection options
data/lib/sfdc/config.rb CHANGED
@@ -125,6 +125,9 @@ module Sfdc
125
125
 
126
126
  option :proxy_uri, :default => lambda { ENV['PROXY_URI'] }
127
127
 
128
+ # A Proc that is called with the response body after a successful authentication.
129
+ option :authentication_callback
130
+
128
131
  def logger
129
132
  @logger ||= ::Logger.new STDOUT
130
133
  end
data/lib/sfdc/mash.rb CHANGED
@@ -46,6 +46,10 @@ module Sfdc
46
46
  deep_update(source_hash) if source_hash
47
47
  default ? super(default) : super(&blk)
48
48
  end
49
+
50
+ def dup
51
+ self.class.new(self, @client, self.default)
52
+ end
49
53
 
50
54
  def convert_value(val, duping=false)
51
55
  case val
@@ -24,6 +24,7 @@ module Sfdc
24
24
  raise Sfdc::AuthenticationError, error_message(response) if response.status != 200
25
25
  @options[:instance_url] = response.body['instance_url']
26
26
  @options[:oauth_token] = response.body['access_token']
27
+ @options[:authentication_callback].call(response.body) if @options[:authentication_callback]
27
28
  response.body
28
29
  end
29
30
 
@@ -34,7 +35,8 @@ module Sfdc
34
35
 
35
36
  # Internal: Faraday connection to use when sending an authentication request.
36
37
  def connection
37
- @connection ||= Faraday.new(:url => "https://#{@options[:host]}") do |builder|
38
+ @connection ||= Faraday.new(faraday_options) do |builder|
39
+ builder.use Faraday::Request::UrlEncoded
38
40
  builder.use Sfdc::Middleware::Mashify, nil, @options
39
41
  builder.response :json
40
42
  builder.use Sfdc::Middleware::Logger, Sfdc.configuration.logger, @options if Sfdc.log?
@@ -59,5 +61,11 @@ module Sfdc
59
61
  end.join('&')
60
62
  end
61
63
  end
64
+
65
+ private
66
+ def faraday_options
67
+ { :url => "https://#{@options[:host]}",
68
+ :proxy => @options[:proxy_uri] }.reject { |k, v| v.nil? }
69
+ end
62
70
  end
63
71
  end
@@ -7,8 +7,10 @@ module Sfdc
7
7
  raise Faraday::Error::ResourceNotFound, message
8
8
  when 401
9
9
  raise Sfdc::UnauthorizedError, message
10
+ when 413
11
+ raise Faraday::Error::ClientError.new("HTTP 413 - Request Entity Too Large", env[:response])
10
12
  when 400...600
11
- raise Faraday::Error::ClientError, message
13
+ raise Faraday::Error::ClientError.new(message, env[:response])
12
14
  end
13
15
  end
14
16
 
data/lib/sfdc/sobject.rb CHANGED
@@ -2,7 +2,7 @@ module Sfdc
2
2
  class SObject < Sfdc::Mash
3
3
 
4
4
  def sobject_type
5
- self.attributes.type
5
+ self.attributes['type']
6
6
  end
7
7
 
8
8
  # Public: Get the describe for this sobject type
@@ -10,6 +10,11 @@ module Sfdc
10
10
  @client.describe(sobject_type)
11
11
  end
12
12
 
13
+ # Public: Describe layouts for this sobject type
14
+ def describe_layouts(layout_id = nil)
15
+ @client.describe_layouts(sobject_type, layout_id)
16
+ end
17
+
13
18
  # Public: Persist the attributes to Salesforce.
14
19
  #
15
20
  # Examples
data/lib/sfdc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sfdc
2
- VERSION = '2.4.0'
2
+ VERSION = '3.0.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sfdc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruce Yue
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir:
10
10
  - bin
11
11
  cert_chain: []
12
- date: 2013-05-21 00:00:00.000000000 Z
12
+ date: 2013-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  version: '0'
172
172
  requirements: []
173
173
  rubyforge_project: sfdc
174
- rubygems_version: 2.0.0
174
+ rubygems_version: 2.0.3
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Salesforce API