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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e0ed38d2c69621d46ecf753ea9f6f992feb42b9
4
- data.tar.gz: 60b4f75c09f351b6b394bb38c00730688acbbe0c
3
+ metadata.gz: 85e9e3a722e8682bc0087cea159614cb2a50cbaa
4
+ data.tar.gz: ba7eba6ef456d232db316b04472fc7e6817ab5ec
5
5
  SHA512:
6
- metadata.gz: 0302239bef00e87f45c74352a617737493cb8b31e1309ae8d8c3ca5ac42f78541f3b4c1d892d7d7f582a6ec40c169cd6e6d0d09d0c09ebb85c6409e00cb4677b
7
- data.tar.gz: 4d89bc238690a0eafd7b561a98b59f9ca00222ee532772c6082ca5fd98e4a3da66cea029aff08ed92bc91e17f6bcb573a3d1f5a98865116c5de280c4bf8cf8a0
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
- # faraday.response :logger
72
+ faraday.response :logger
29
73
  faraday.adapter Faraday.default_adapter
30
74
  end
31
75
 
32
- response = conn.get do |req|
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.params = json_data if json_data
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)
@@ -1,3 +1,3 @@
1
1
  module Freshmail
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1"
3
3
  end
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.0.1
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-08 00:00:00.000000000 Z
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails