salesforce_http_client 0.0.1 → 0.1.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 +4 -4
- data/lib/salesforce_http_client/client.rb +1 -1
- data/lib/salesforce_http_client/configuration.rb +11 -0
- data/lib/salesforce_http_client/version.rb +1 -1
- data/spec/salesforce_http_client/client_spec.rb +30 -23
- data/spec/salesforce_http_client/configuration_spec.rb +29 -1
- data/spec/salesforce_http_client_spec.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 085a5800ae9e26a705adfa5aa2764749d4687025
|
4
|
+
data.tar.gz: 377da12139ead8327f4cc7237df9796f4d78d914
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0dd27bb06bfd0e92320b91f33eccd9464aa4694e8567b305fcc1e90e0a4706a7dd6b5e8251395d479d740f1fa82d310f6d87e2e06562d4b92bae9473d7c4a93
|
7
|
+
data.tar.gz: c21977b8fbabfa7e5ed6a67a610ed3da4e6754b69855422bd15f38f63b4e5850b0017d427e42c9979e0c874bcc86f6453640a91c902c28d6098af3abbd90c768
|
@@ -1,7 +1,14 @@
|
|
1
1
|
require 'logger'
|
2
|
+
require 'singleton'
|
2
3
|
|
3
4
|
module SalesforceHttpClient
|
5
|
+
def self.configure(&block)
|
6
|
+
SalesforceHttpClient::Configuration.configure(&block)
|
7
|
+
end
|
8
|
+
|
4
9
|
class Configuration
|
10
|
+
include Singleton
|
11
|
+
|
5
12
|
attr_accessor :salesforce_login_url
|
6
13
|
attr_accessor :salesforce_logout_url
|
7
14
|
|
@@ -17,6 +24,10 @@ module SalesforceHttpClient
|
|
17
24
|
attr_accessor :logger
|
18
25
|
attr_accessor :log_level
|
19
26
|
|
27
|
+
def self.configure
|
28
|
+
yield instance
|
29
|
+
end
|
30
|
+
|
20
31
|
def initialize
|
21
32
|
@salesforce_login_url = "https://login.salesforce.com/"
|
22
33
|
@salesforce_logout_url = "https://ap.salesforce.com/secur/logout.jsp"
|
@@ -2,37 +2,44 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module SalesforceHttpClient
|
4
4
|
describe Client do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
describe 'basic' do
|
6
|
+
it 'can be init' do
|
7
|
+
client = SalesforceHttpClient::Client.new
|
8
|
+
expect(client).to_not be_nil
|
9
|
+
end
|
8
10
|
end
|
9
|
-
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
describe '#download_report' do
|
13
|
+
before do
|
14
|
+
stub_request(:get, "https://login.salesforce.com/")
|
15
|
+
.to_return(status: 200, body: "", headers: {})
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
stub_request(:post, "https://login.salesforce.com/")
|
18
|
+
.with(body: { "pw" => "test_password", "un" => "test_login_id" })
|
19
|
+
.to_return(status: 302, body: "", headers: { 'Location' => 'https://ap.salesforce.com/secur/frontdoor.jsp?sid=00D10000000ZIju%21ARkAQBU5ixFxxAzNvQTreC6rOQ9QSt_cMxFbwmVoVNbWtl.xxHasjFO8v100wa6b0kv.c9Q9RzYuwss9F5TodikF.ELZAHwq&apv=1&cshc=0000001shFs0000000ZIju&display=page' })
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
stub_request(:get, "https://ap.salesforce.com/secur/frontdoor.jsp?apv=1&cshc=0000001shFs0000000ZIju&display=page&sid=00D10000000ZIju!ARkAQBU5ixFxxAzNvQTreC6rOQ9QSt_cMxFbwmVoVNbWtl.xxHasjFO8v100wa6b0kv.c9Q9RzYuwss9F5TodikF.ELZAHwq")
|
22
|
+
.to_return(status: 200, body: "", headers: {})
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
stub_request(:get, "https://ap.salesforce.com/a?enc=UTF-8&export=1&xf=csv")
|
25
|
+
.to_return(status: 200, body: "", headers: {})
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
stub_request(:get, "https://ap.salesforce.com/secur/logout.jsp")
|
28
|
+
.to_return(status: 200, body: "", headers: {})
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'can download report' do
|
32
|
+
Configuration.configure do |config|
|
33
|
+
config.salesforce_login_id = 'test_login_id'
|
34
|
+
config.salesforce_password = 'test_password'
|
35
|
+
end
|
29
36
|
|
30
|
-
|
31
|
-
|
32
|
-
File.delete(output_file) if File.exist?(output_file)
|
37
|
+
output_file = "tmp/report_a.csv"
|
38
|
+
File.delete(output_file) if File.exist?(output_file)
|
33
39
|
|
34
|
-
|
35
|
-
|
40
|
+
client = SalesforceHttpClient::Client.new
|
41
|
+
client.download_report("a", output_file)
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
38
45
|
end
|
@@ -1,10 +1,38 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module SalesforceHttpClient
|
4
|
+
describe '.configure' do
|
5
|
+
it 'can set config value.' do
|
6
|
+
SalesforceHttpClient.configure do |config|
|
7
|
+
config.salesforce_login_id = 'login_id'
|
8
|
+
config.salesforce_password = 'password'
|
9
|
+
end
|
10
|
+
|
11
|
+
config = Configuration.instance
|
12
|
+
|
13
|
+
expect(config.salesforce_login_id).to eq 'login_id'
|
14
|
+
expect(config.salesforce_password).to eq 'password'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
4
18
|
describe Configuration do
|
5
19
|
it 'can be init' do
|
6
|
-
client =
|
20
|
+
client = Configuration.instance
|
7
21
|
expect(client).to_not be_nil
|
8
22
|
end
|
23
|
+
|
24
|
+
describe '.configure' do
|
25
|
+
it 'can set config value.' do
|
26
|
+
Configuration.configure do |config|
|
27
|
+
config.salesforce_login_id = 'login_id'
|
28
|
+
config.salesforce_password = 'password'
|
29
|
+
end
|
30
|
+
|
31
|
+
config = Configuration.instance
|
32
|
+
|
33
|
+
expect(config.salesforce_login_id).to eq 'login_id'
|
34
|
+
expect(config.salesforce_password).to eq 'password'
|
35
|
+
end
|
36
|
+
end
|
9
37
|
end
|
10
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salesforce_http_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Apuruni
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- spec/salesforce_http_client/client_spec.rb
|
189
189
|
- spec/salesforce_http_client/configuration_spec.rb
|
190
190
|
- spec/salesforce_http_client/version_spec.rb
|
191
|
+
- spec/salesforce_http_client_spec.rb
|
191
192
|
- spec/spec_helper.rb
|
192
193
|
homepage: https://github.com/apuruni/salesforce_http_client
|
193
194
|
licenses:
|
@@ -217,4 +218,5 @@ test_files:
|
|
217
218
|
- spec/salesforce_http_client/client_spec.rb
|
218
219
|
- spec/salesforce_http_client/configuration_spec.rb
|
219
220
|
- spec/salesforce_http_client/version_spec.rb
|
221
|
+
- spec/salesforce_http_client_spec.rb
|
220
222
|
- spec/spec_helper.rb
|