freshmail 0.0.1 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/freshmail/api.rb +53 -5
- data/lib/freshmail/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85e9e3a722e8682bc0087cea159614cb2a50cbaa
|
4
|
+
data.tar.gz: ba7eba6ef456d232db316b04472fc7e6817ab5ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f4db3bcc4196be755f84e667269b056bd6d737713c27d2603f8fde6161afe31d3f5e368ce1a78003b4ca2780d7ba7a2824e3df000f64114a82544a2561a00be
|
7
|
+
data.tar.gz: bd60c515ef0e54580b8c6a12efa9259b2461607b6b635f99123e5b7aa5677b198a6a05284dd74ea88b4193fb7a7961e9e8f4cfb1a19cbeb27c0d91369e9d71ce
|
data/lib/freshmail/api.rb
CHANGED
@@ -15,26 +15,74 @@ module Freshmail
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def ping
|
18
|
-
call_freshmail('ping')
|
18
|
+
call_freshmail(:get, 'ping')
|
19
|
+
end
|
20
|
+
|
21
|
+
def mail(mail_data = {})
|
22
|
+
call_freshmail(:post, 'mail', mail_data)
|
23
|
+
end
|
24
|
+
|
25
|
+
def subscriber(sub_info = {})
|
26
|
+
call_freshmail(:get, 'subscriber/get', sub_info)
|
27
|
+
end
|
28
|
+
|
29
|
+
def subscribers(sub_info = {})
|
30
|
+
call_freshmail(:get, 'subscriber/getMultiple', sub_info)
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_subscriber(sub_info = {})
|
34
|
+
call_freshmail(:post, 'subscriber/add', sub_info)
|
35
|
+
end
|
36
|
+
|
37
|
+
def batch_add_subscriber(sub_info = {})
|
38
|
+
call_freshmail(:post, 'subscriber/addMultiple', sub_info)
|
39
|
+
end
|
40
|
+
|
41
|
+
def delete_subscriber(sub_info = {})
|
42
|
+
call_freshmail(:post, 'subscriber/delete', sub_info)
|
43
|
+
end
|
44
|
+
|
45
|
+
def batch_delete_subscriber(sub_info = {})
|
46
|
+
call_freshmail(:post, 'subscriber/deleteMultiple', sub_info)
|
47
|
+
end
|
48
|
+
|
49
|
+
def lists
|
50
|
+
call_freshmail(:get, 'subscribers_list/lists')
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_list(list_info = {})
|
54
|
+
call_freshmail(:post, 'subscribers_list/create', list_info)
|
55
|
+
end
|
56
|
+
|
57
|
+
def update_list(list_info = {})
|
58
|
+
call_freshmail(:post, 'subscribers_list/update', list_info)
|
59
|
+
end
|
60
|
+
|
61
|
+
def delete_list(list_info = {})
|
62
|
+
call_freshmail(:post, 'subscribers_list/delete', list_info)
|
19
63
|
end
|
20
64
|
|
21
65
|
protected
|
22
|
-
def call_freshmail(get_data, json_data = nil)
|
66
|
+
def call_freshmail(call_type, get_data, json_data = nil)
|
23
67
|
json_data_converted = json_data ? json_data.to_json : ''
|
24
68
|
endpoint = "/rest/#{get_data}"
|
25
69
|
|
26
70
|
conn = Faraday.new(:url => URL) do |faraday|
|
27
71
|
faraday.request :url_encoded
|
28
|
-
|
72
|
+
faraday.response :logger
|
29
73
|
faraday.adapter Faraday.default_adapter
|
30
74
|
end
|
31
75
|
|
32
|
-
response = conn.
|
76
|
+
response = conn.send(call_type) do |req|
|
33
77
|
req.url endpoint
|
34
78
|
req.headers['Content-Type'] = 'application/json'
|
35
79
|
req.headers['X-Rest-ApiKey'] = self.api_key
|
36
80
|
req.headers['X-Rest-ApiSign'] = api_sign(endpoint, json_data_converted)
|
37
|
-
req.
|
81
|
+
if req.method == :get
|
82
|
+
req.params = json_data if json_data
|
83
|
+
else
|
84
|
+
req.body = json_data_converted
|
85
|
+
end
|
38
86
|
end
|
39
87
|
|
40
88
|
JSON.parse(response.body)
|
data/lib/freshmail/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freshmail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Jan Adamczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|