ebsyc 1.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 +7 -0
- data/README.md +17 -0
- data/bin/ebsyc +2 -0
- data/lib/ebsyc.rb +9 -0
- data/lib/ebsyc/ebsyc.rb +109 -0
- data/lib/ebsyc/service.rb +9 -0
- data/lib/ebsyc/utils.rb +81 -0
- data/lib/ebsyc/version.rb +3 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8ad2a01881316f14e3eaf2761616fb6f05561d89
|
4
|
+
data.tar.gz: b43066a71f1d799fdecc21a41f65aa6109abee71
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e2ee3848c33303c2c166c8224ddc6407c7bc7783affdc63bdef96a78c389403f0c226a2aa8f8011bcd6feeb62c4463a9bb9a42f03680163150ceac05540d0773
|
7
|
+
data.tar.gz: d9698d3e08d592a4762c3ba59ce0b9fc81158f16fe2cd1b2fa0bc55b0c49315fc3684d1cfb26b3dacfebf065dd856f3c0f6230d17f3c3a6abd70bf31a33e83dd
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# ebest sync test
|
2
|
+
|
3
|
+
# params = '{"syncType": "0", "groupNumber": "1"}' #groupNumber, objectNames,eventFlag,deviceId
|
4
|
+
# params = '{"syncType": "0", "objectNames": "ebMobile__Call__c"}' #groupNumber, objectNames,eventFlag,deviceId
|
5
|
+
|
6
|
+
# ebsyc -u 'uname:pwd' -d '{"syncType": "0", "objectNames": "ebMobile__Call__c"}'
|
7
|
+
|
8
|
+
# ebsyc -u 'uname:pwd' -d '{"syncType": "0", "groupNumber": "1"}'
|
9
|
+
|
10
|
+
# ebsyc -u 'uname:pwd' -d '{"syncType": "1", "groupNumber": "1"}'
|
11
|
+
|
12
|
+
# ebsyc -u 'uname:pwd' -b #download database
|
13
|
+
|
14
|
+
# ebsyc -u 'uname:pwd' -c #download config data
|
15
|
+
|
16
|
+
# ebsyc -u 'uname:pwd' -p '{}' #download config data
|
17
|
+
|
data/bin/ebsyc
ADDED
data/lib/ebsyc.rb
ADDED
data/lib/ebsyc/ebsyc.rb
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__))
|
2
|
+
%w(restforce faye json base64 service utils).each do |file|
|
3
|
+
require "#{file}"
|
4
|
+
end
|
5
|
+
|
6
|
+
# Parse arguments
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
op = OptionParser.new do |opts|
|
10
|
+
opts.banner = Ebsyc::HELP_MSG
|
11
|
+
opts.separator ''
|
12
|
+
|
13
|
+
opts.on("-u", "--user username:password", "The user name and password.") do |u|
|
14
|
+
options[:up] = u
|
15
|
+
options[:username] = options[:up].split(':').first
|
16
|
+
options[:password] = options[:up].split(':').last
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("-t", "--token token", "The password security token") do |token|
|
20
|
+
options[:security_token] = token
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("-T", "Change to sandbox environment.") do |test|
|
24
|
+
options[:host] = 'test.salesforce.com'
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on("-b", "Dwonload database") do |r|
|
28
|
+
options[:db] = r
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("-c", "Dwonload config data") do |r|
|
32
|
+
options[:config] = r
|
33
|
+
end
|
34
|
+
|
35
|
+
opts.on("-d", "--download params", "Params are : syncType, groupNumber, objectNames,eventFlag,deviceId") do |data|
|
36
|
+
options[:download] = data
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-p", "--upload jsonData", "The json data {} need to upload") do |data|
|
40
|
+
options[:upload] = data
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on_tail("-h", "--help", "Show help message") do
|
44
|
+
puts op
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
begin
|
50
|
+
op.parse(ARGV)
|
51
|
+
rescue Exception => e
|
52
|
+
abort e.message
|
53
|
+
end
|
54
|
+
|
55
|
+
if ARGV.size < 1
|
56
|
+
puts op
|
57
|
+
exit
|
58
|
+
end
|
59
|
+
|
60
|
+
#Login to Salesforce
|
61
|
+
begin
|
62
|
+
Restforce.configure do |config|
|
63
|
+
config.host = options[:host] #test.salesforce.com
|
64
|
+
config.api_version = '36.0'
|
65
|
+
config.client_id = SFDC_CLIENT_ID
|
66
|
+
config.client_secret = SFDC_CLIENT_SECRET
|
67
|
+
end
|
68
|
+
client = Restforce.new :username => options[:username], :password => options[:password], :security_token => options[:security_token]
|
69
|
+
rescue Exception => e
|
70
|
+
puts e.message
|
71
|
+
abort 'Failed to connect to Salesforce.'
|
72
|
+
end
|
73
|
+
|
74
|
+
###################################### Starts action ##################################################
|
75
|
+
if options[:db]
|
76
|
+
begin
|
77
|
+
puts 'loading......'
|
78
|
+
Ebsyc.download_db(client)
|
79
|
+
rescue Exception => e
|
80
|
+
puts e.message
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
if options[:config]
|
85
|
+
begin
|
86
|
+
puts 'loading......'
|
87
|
+
Ebsyc.download_config_data(client)
|
88
|
+
rescue Exception => e
|
89
|
+
puts e.message
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
if options[:download]
|
94
|
+
begin
|
95
|
+
puts 'loading......'
|
96
|
+
Ebsyc.download_data(client, options[:download])
|
97
|
+
rescue Exception => e
|
98
|
+
puts e.message
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
if options[:upload]
|
103
|
+
begin
|
104
|
+
puts 'uploading......'
|
105
|
+
Ebsyc.upload_data(client,options[:upload])
|
106
|
+
rescue Exception => e
|
107
|
+
puts e.message
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#########################################################
|
2
|
+
|
3
|
+
SFDC_DOWNLOAD = '/services/apexrest/ebMobile/EbestDownloadService2'
|
4
|
+
SFDC_UPLOAD = '/services/apexrest/ebMobile/EbestUploadService'
|
5
|
+
SFDC_DB = '/services/apexrest/ebMobile/EbestDbSchemaService'
|
6
|
+
SFDC_PASSWORD = '/services/apexrest/ebMobile/EbestPasswordService'
|
7
|
+
|
8
|
+
SFDC_CLIENT_ID = '3MVG9sG9Z3Q1Rlbe5gN0RgMaBD27ydIVLLn4tylDVp53lN8x.HxSTZv_cMGYJgr5e91mZW6pAxphsiYHDd_Qs'
|
9
|
+
SFDC_CLIENT_SECRET = '6133896795401857399'
|
data/lib/ebsyc/utils.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__))
|
2
|
+
%w(restforce faye json base64).each do |file|
|
3
|
+
require "#{file}"
|
4
|
+
end
|
5
|
+
|
6
|
+
module Ebsyc
|
7
|
+
extend self
|
8
|
+
|
9
|
+
# help messages
|
10
|
+
HELP_MSG = "eBest Sync Framework for testing sync service"
|
11
|
+
|
12
|
+
def download_db(client)
|
13
|
+
db_schema = client.get SFDC_DB
|
14
|
+
db_schema.body.each do |st|
|
15
|
+
hash_data = JSON.parse(st.to_json)
|
16
|
+
#puts hash_data
|
17
|
+
puts hash_data["ObjName"] #IsDeletable IsCreateable IsAccessible IsUpdateable
|
18
|
+
#{"type" "required" "isUpdateable" "isAccessible""fieldLabel", "fieldApiName", "byteLength"}
|
19
|
+
puts hash_data["FieldInfo"]
|
20
|
+
puts hash_data[""]
|
21
|
+
puts '**************************************************************************************************'
|
22
|
+
end
|
23
|
+
puts db_schema.body.size
|
24
|
+
end
|
25
|
+
|
26
|
+
def download_config_data(client)
|
27
|
+
data = client.get SFDC_DOWNLOAD
|
28
|
+
data.body.each do |st|
|
29
|
+
hash_data = JSON.parse(st.to_json)
|
30
|
+
puts hash_data["values"]
|
31
|
+
puts hash_data["name"]
|
32
|
+
puts hash_data["fields"]
|
33
|
+
puts '=================================================================================================='
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def download_data(client, params)
|
38
|
+
#params = '{"syncType": "0", "groupNumber": "1"}' #'eyJzeW5jVHlwZSI6IjAifQ=='
|
39
|
+
data = client.post SFDC_DOWNLOAD, {:jsonData => Base64.encode64(params)}
|
40
|
+
i = 0
|
41
|
+
#puts Base64.encode64(params)
|
42
|
+
data.body.each do |st|
|
43
|
+
hash_data = JSON.parse(st.to_json)
|
44
|
+
puts hash_data["name"]
|
45
|
+
#puts hash_data["fields"]
|
46
|
+
puts hash_data["values"]
|
47
|
+
object_size = hash_data["values"].to_s.split(', "').size
|
48
|
+
i += object_size
|
49
|
+
puts object_size
|
50
|
+
puts '=================================================================================================='
|
51
|
+
end
|
52
|
+
puts '****************************************************************************************************'
|
53
|
+
puts 'Total Records ' + i.to_s
|
54
|
+
puts 'Total Objects ' + data.body.page_size.to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
#data = '{"records":[{"values":["GUID60c16c7c-9fe6-b6ac-b1e5-40a7a2b3ecb3▏bruceyue▏0019000001c2iJX"],"name":"Contact","fields":"Id,LastName,AccountId"}]}'
|
58
|
+
def upload_data(client, data)
|
59
|
+
upload_result = client.post SFDC_UPLOAD, {:jsonData => Base64.encode64(data)}
|
60
|
+
upload_result.body.each do |dr|
|
61
|
+
puts JSON.parse(dr.to_json)
|
62
|
+
puts '==================================================================================================='
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def change_pwd(client, newPassword)
|
67
|
+
upload_result = client.post SFDC_PASSWORD, {:newPassword => newPassword}
|
68
|
+
upload_result.body.each do |dr|
|
69
|
+
puts JSON.parse(dr.to_json)
|
70
|
+
puts '==================================================================================================='
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_event_log(client)
|
75
|
+
logs = client.query("SELECT Id, EventType, LogDate, LogFileLength, LogFileContentType, ApiVersion, LogFileFieldNames, LogFileFieldTypes, LogFile FROM EventLogFile limit 1000")
|
76
|
+
logs.each do |log|
|
77
|
+
puts log.Id + ' | ' + log.EventType + ' | ' + log.LogDate + ' | ' + log.LogFile
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ebsyc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bruce Yue
|
8
|
+
autorequire:
|
9
|
+
bindir:
|
10
|
+
- bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: restforce
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.2.1
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.2.1
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: eventmachine
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.0.8
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.0.8
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: faye
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.1.2
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.1.2
|
56
|
+
description: eBest Sync Framework
|
57
|
+
email:
|
58
|
+
- bruce.yue@outlook.com
|
59
|
+
executables:
|
60
|
+
- ebsyc
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- README.md
|
65
|
+
- bin/ebsyc
|
66
|
+
- lib/ebsyc.rb
|
67
|
+
- lib/ebsyc/ebsyc.rb
|
68
|
+
- lib/ebsyc/service.rb
|
69
|
+
- lib/ebsyc/utils.rb
|
70
|
+
- lib/ebsyc/version.rb
|
71
|
+
homepage: http://www.ebestmobile.com
|
72
|
+
licenses:
|
73
|
+
- Bruce Yue
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.4.6
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: S3 Salesforce
|
95
|
+
test_files: []
|
96
|
+
has_rdoc:
|