salesforce_bulk_api 0.0.4 → 0.0.5

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.rdoc CHANGED
@@ -3,22 +3,25 @@
3
3
  ==Overview
4
4
 
5
5
  Salesforce bulk Api is a simple ruby gem for connecting to and using the Salesforce Bulk API. It is actually a re-written code from salesforce_bulk[https://github.com/jorgevaldivia/salesforce_bulk].Written to suit many more other features as well.
6
-
6
+
7
7
  ==How to use
8
8
 
9
9
  Using this gem is simple and straight forward.
10
10
 
11
11
  To initialize:
12
12
  sudo gem install salesforce_bulk_api
13
- or add
13
+ or add
14
14
  gem salesforce_bulk_api
15
- in your Gemfile
16
-
15
+ in your Gemfile
16
+
17
17
 
18
- Pl do check the entire documentation of the databasedotcom gem and it various ways of authentication
18
+ Please do check the entire documentation of the databasedotcom gem and it various ways of authentication
19
19
  Databasedotcom[https://github.com/heroku/databasedotcom]
20
20
 
21
- You can use username password combo,OmniAuth,Oauth2
21
+ You can use username password combo, OmniAuth, Oauth2
22
+ You can as many records possible in the Array. Governor limits are taken care of inside the gem.
23
+
24
+
22
25
 
23
26
  require 'salesforce_bulk_api'
24
27
  client = Databasedotcom::Client.new :client_id => $SFDC_APP_CONFIG["client_id"], :client_secret => $SFDC_APP_CONFIG["client_secret"] #client_id and client_secret respectively
@@ -58,12 +61,6 @@ Sample operations:
58
61
  ==Installation
59
62
  sudo gem install salesforce_bulk_api
60
63
 
61
- ==TODO
62
- This is a rough early version of the gem. Immediate plans include better error reporting as there currently is none.
63
-
64
64
  == Copyright
65
65
 
66
66
  Copyright (c) 2012 Yatish Mehta
67
-
68
- ===end
69
-
@@ -27,7 +27,7 @@ module SalesforceBulkApi
27
27
  headers = Hash['Content-Type' => 'application/xml; charset=utf-8']
28
28
 
29
29
  response = @@connection.post_xml(nil, path, xml, headers)
30
- response_parsed = XmlSimple.xml_in(response)
30
+ response_parsed = XmlSimple.xml_in(response)
31
31
  puts response
32
32
  @@job_id = response_parsed['id'][0]
33
33
  end
@@ -49,7 +49,7 @@ module SalesforceBulkApi
49
49
  def add_query
50
50
  path = "job/#{@@job_id}/batch/"
51
51
  headers = Hash["Content-Type" => "application/xml; charset=UTF-8"]
52
-
52
+
53
53
  response = @@connection.post_xml(nil, path, @@records, headers)
54
54
  response_parsed = XmlSimple.xml_in(response)
55
55
 
@@ -65,7 +65,7 @@ module SalesforceBulkApi
65
65
  super_records<<@@records_dup.pop(10000)
66
66
  end
67
67
  super_records<<@@records_dup
68
-
68
+
69
69
  super_records.each do|batch|
70
70
  xml = "#{@@XML_HEADER}<sObjects xmlns=\"http://www.force.com/2009/06/asyncapi/dataload\">"
71
71
  batch.each do |r|
@@ -76,13 +76,13 @@ module SalesforceBulkApi
76
76
  xml += "</sObject>"
77
77
  end
78
78
  xml += "</sObjects>"
79
-
79
+
80
80
 
81
81
  path = "job/#{@@job_id}/batch/"
82
82
  headers = Hash["Content-Type" => "application/xml; charset=UTF-8"]
83
83
  response = @@connection.post_xml(nil, path, xml, headers)
84
84
  response_parsed = XmlSimple.xml_in(response)
85
-
85
+
86
86
  @@batch_id = response_parsed['id'][0]
87
87
  puts @@batch_id
88
88
  end
@@ -101,7 +101,6 @@ module SalesforceBulkApi
101
101
  response_parsed['state'][0]
102
102
  rescue Exception => e
103
103
  #puts "check: #{response_parsed.inspect}\n"
104
-
105
104
  nil
106
105
  end
107
106
  end
@@ -1,3 +1,3 @@
1
1
  module SalesforceBulkApi
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -6,6 +6,7 @@ require 'csv'
6
6
  require "salesforce_bulk_api/version"
7
7
  require 'salesforce_bulk_api/job'
8
8
  require 'salesforce_bulk_api/connection'
9
+
9
10
  module SalesforceBulkApi
10
11
  # Your code goes here...
11
12
  class Api
@@ -23,7 +24,7 @@ module SalesforceBulkApi
23
24
  def update(sobject, records)
24
25
  self.do_operation('update', sobject, records, nil)
25
26
  end
26
-
27
+
27
28
  def create(sobject, records)
28
29
  self.do_operation('insert', sobject, records, nil)
29
30
  end
@@ -43,16 +44,11 @@ module SalesforceBulkApi
43
44
 
44
45
  # TODO: put this in one function
45
46
  job_id = job.create_job()
46
- if(operation == "query")
47
- batch_id = job.add_query()
48
- else
49
- batch_id = job.add_batch()
50
- end
47
+ batch_id = operation == "query" ? job.add_query() : job.add_batch()
51
48
  job.close_job()
52
49
 
53
50
  while true
54
51
  state = job.check_batch_status()
55
- #puts "\nstate is #{state}\n"
56
52
  if state != "Queued" && state != "InProgress"
57
53
  break
58
54
  end
@@ -64,10 +60,6 @@ module SalesforceBulkApi
64
60
  else
65
61
  return "error"
66
62
  end
67
-
68
63
  end
69
-
70
64
  end # End class
71
65
  end
72
-
73
-
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.description = %q{Salesforce Bulk API with governor limits taken care of}
13
13
 
14
14
  s.rubyforge_project = "salesforce_bulk_api"
15
- s.add_dependency(%q<oauth2>, ["0.4.1"])
15
+ s.add_dependency(%q<oauth2>, [">= 0.9.1"])
16
16
  s.add_dependency(%q<databasedotcom>, [">= 0"])
17
17
  s.add_dependency(%q<json>, [">= 0"])
18
18
  s.add_dependency(%q<xml-simple>, [">= 0"])
metadata CHANGED
@@ -1,90 +1,87 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: salesforce_bulk_api
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Yatish Mehta
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-05-09 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-03-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: oauth2
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - "="
27
- - !ruby/object:Gem::Version
28
- hash: 13
29
- segments:
30
- - 0
31
- - 4
32
- - 1
33
- version: 0.4.1
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.1
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: databasedotcom
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: databasedotcom
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
48
38
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: json
52
39
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: json
48
+ requirement: !ruby/object:Gem::Requirement
54
49
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
62
54
  type: :runtime
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: xml-simple
66
55
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: xml-simple
64
+ requirement: !ruby/object:Gem::Requirement
68
65
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
76
70
  type: :runtime
77
- version_requirements: *id004
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
78
  description: Salesforce Bulk API with governor limits taken care of
79
- email:
79
+ email:
80
80
  - yatishmehta27@gmail.com
81
81
  executables: []
82
-
83
82
  extensions: []
84
-
85
83
  extra_rdoc_files: []
86
-
87
- files:
84
+ files:
88
85
  - .gitignore
89
86
  - Gemfile
90
87
  - README.rdoc
@@ -96,36 +93,26 @@ files:
96
93
  - salesforce_bulk_api.gemspec
97
94
  homepage: https://github.com/yatishmehta27/salesforce_bulk_api
98
95
  licenses: []
99
-
100
96
  post_install_message:
101
97
  rdoc_options: []
102
-
103
- require_paths:
98
+ require_paths:
104
99
  - lib
105
- required_ruby_version: !ruby/object:Gem::Requirement
100
+ required_ruby_version: !ruby/object:Gem::Requirement
106
101
  none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- hash: 3
111
- segments:
112
- - 0
113
- version: "0"
114
- required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
107
  none: false
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- hash: 3
120
- segments:
121
- - 0
122
- version: "0"
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
123
112
  requirements: []
124
-
125
113
  rubyforge_project: salesforce_bulk_api
126
- rubygems_version: 1.8.10
114
+ rubygems_version: 1.8.24
127
115
  signing_key:
128
116
  specification_version: 3
129
117
  summary: It uses the bulk api of salesforce to communicate with teh salesforce CRM
130
118
  test_files: []
131
-