edm 0.0.2 → 0.0.3
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/lib/edm.rb +55 -1
- data/lib/edm/version.rb +1 -1
- metadata +3 -3
data/lib/edm.rb
CHANGED
@@ -1,15 +1,69 @@
|
|
1
1
|
require "edm/version"
|
2
|
+
require "net/http"
|
2
3
|
|
3
4
|
module Edm
|
4
5
|
def self.batch_create_contacts(key, options = {})
|
6
|
+
unless key.present?
|
7
|
+
raise "access key can not be blank."
|
8
|
+
end
|
9
|
+
unless options[:account_key].present?
|
10
|
+
raise "account key can not be blank."
|
11
|
+
end
|
12
|
+
|
13
|
+
unless options[:data].present?
|
14
|
+
raise "data can not be blank and must be an array."
|
15
|
+
end
|
5
16
|
sign = generate_sign(key, options)
|
6
17
|
options["sign"] = sign
|
18
|
+
|
7
19
|
result = remote_request('post', 'http://0.0.0.0:3000/api/contacts/batch_create.json', options)
|
20
|
+
return result.body
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.create_report(key, options = {})
|
24
|
+
unless options[:title].present?
|
25
|
+
raise "page title can not be blank."
|
26
|
+
end
|
27
|
+
|
28
|
+
unless options[:subject].present?
|
29
|
+
raise "mail subject can not be blank."
|
30
|
+
end
|
31
|
+
|
32
|
+
unless options[:account_key].present?
|
33
|
+
raise "account key can not be blank."
|
34
|
+
end
|
35
|
+
|
36
|
+
unless options[:sender_email].present?
|
37
|
+
raise "sender email can not be blank."
|
38
|
+
end
|
39
|
+
|
40
|
+
unless options[:send_to].present? or !["all", "groups", "contacts"].include?(options[:send_to])
|
41
|
+
raise 'send_to must be "all", "groups" or "contacts".'
|
42
|
+
end
|
43
|
+
|
44
|
+
if options[:send_to] != 'all'
|
45
|
+
unless options[:contacts_info].present?
|
46
|
+
raise "For send_to is #{options[:send_to]}, you must pass contacts_info"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
unless options[:data].present?
|
51
|
+
raise "data can not be blank."
|
52
|
+
end
|
53
|
+
|
54
|
+
unless options[:template_id].present?
|
55
|
+
raise "template_id can not be blank."
|
56
|
+
end
|
57
|
+
sign = generate_sign(key, options)
|
58
|
+
options["sign"] = sign
|
59
|
+
|
60
|
+
result = remote_request('post', 'http://0.0.0.0:3000/api/reports.json', options)
|
61
|
+
return result.body
|
8
62
|
end
|
9
63
|
|
10
64
|
def self.generate_sign(key, options = {})
|
11
65
|
if options.length > 0
|
12
|
-
options.to_a.sort.map { |c| "#{c[0]}=#{c[1]}" }.join('&')
|
66
|
+
str = options.to_a.sort.map { |c| "#{c[0]}=#{c[1]}" }.join('&')
|
13
67
|
sign = Digest::SHA1.hexdigest("#{str}#{key}")
|
14
68
|
end
|
15
69
|
end
|
data/lib/edm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-30 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70287170582780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70287170582780
|
25
25
|
description: demohour edm api
|
26
26
|
email:
|
27
27
|
- lijiping@demohour.com
|