freshmail_api 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b966404064d4d4c0171650ff3dc29ea880053742
4
+ data.tar.gz: b04fb438224015806d5f0567bef1bae5ed5f54ee
5
+ SHA512:
6
+ metadata.gz: 91f14047d3c3176664eb943d030cf7f9483f65b8d0a0a07bf06dbcaa7d4cad9e82020a24caf9b3d6aa703e19693aba21b77b0d792b956889269f127a322eed6c
7
+ data.tar.gz: de5df6a31945a3e301ca467f6f94b06fb1aaac47f07d9319027b48a9e51f07a031dd2b958dd17de2e7897257471d2d601884a0adc2a6465d0ec5c29d605096ba
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
File without changes
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Damian Śliwecki
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,368 @@
1
+ ## FreshmailApi
2
+ Rails gem for fast Freshmail integration
3
+
4
+ Documentation of Freshmail API http://freshmail.pl/wp-content/uploads/2013/04/REST_API_v1.0.19.pdf
5
+
6
+ ## Do you like it? Give me star ;) Thank you!
7
+
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'freshmail_api'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install freshmail_api
24
+
25
+ ## Usage
26
+
27
+ First, you must set up config (for example in config/initializers/freshmail_api.rb) and add following code:
28
+
29
+ ```ruby
30
+ FreshmailApi.configure do |config|
31
+ config.api_key = 'your api key'
32
+ config.api_secret = 'your secret key'
33
+ end
34
+ ```
35
+
36
+ Next, you should use available methods:
37
+
38
+ 1. Test your connection
39
+ GET:
40
+ ```ruby
41
+ FreshmailApi.get_ping
42
+ ```
43
+ POST:
44
+ ```ruby
45
+ FreshmailApi.post_ping({data: 'some data'})
46
+ ```
47
+
48
+
49
+ 2. Send mail:
50
+ ```ruby
51
+ FreshmailApi.send_mail(subscriber: "subscriber@mail.com", subject: "test", text: "pure text message")
52
+ or
53
+ FreshmailApi.send_mail(subscriber: "subscriber@mail.com", subject: "test", html: "message with html tags")
54
+ ```
55
+ -require options:
56
+ :subscriber,
57
+ :subject,
58
+ :html or :text
59
+ -optional options:
60
+ :from,
61
+ :from_name,
62
+ :reply_to,
63
+ :encoding,
64
+ :attachments,
65
+ :tracking,
66
+ :domain,
67
+ :tag
68
+
69
+ 3. Send sms message (SMS agreement required to send sms):
70
+ ```ruby
71
+ FreshmailApi.send_sms(gsm: "123456789", text: "hello bro! :)")
72
+ ```
73
+ -require options:
74
+ :gsm,
75
+ :text
76
+ -optional options:
77
+ :from,
78
+ :single
79
+
80
+
81
+ 4. Reports:
82
+ 4.1 Campaigns list
83
+ ```ruby
84
+ FreshmailApi.campaigns_list
85
+ or
86
+ FreshmailApi.campaigns_list(69)
87
+ ```
88
+ -optional options:
89
+ :page
90
+
91
+ 4.2 Campaign report
92
+ ```ruby
93
+ FreshmailApi.campaign_report(id_hash)
94
+ ```
95
+ -required options:
96
+ :id_hash
97
+
98
+ 4.3 Campaign time details
99
+ ```ruby
100
+ FreshmailApi.campaign_time_details(id_hash)
101
+ ```
102
+ -required options:
103
+ :id_hash
104
+
105
+
106
+ 5. Campaign:
107
+ 5.1 Create:
108
+ ```ruby
109
+ FreshmailApi.create_campaign({options})
110
+ ```
111
+ -require options:
112
+ :name,
113
+ :list or :group,
114
+ :html or :text
115
+ -optional options:
116
+ :url,
117
+ :subject,
118
+ :from_address,
119
+ :from_name,
120
+ :reply_to,
121
+ :resignlink
122
+
123
+ 5.1 Edit:
124
+ ```ruby
125
+ FreshmailApi.edit_campaig({options})
126
+ ```
127
+ require options:
128
+ :id_hash
129
+ optional options:
130
+ :name,
131
+ :url,
132
+ :html,
133
+ :text,
134
+ :subject,
135
+ :from_name,
136
+ :from_address,
137
+ :reply_to,
138
+ :list,
139
+ :group,
140
+ :resignlink
141
+
142
+ 5.1 Delete:
143
+ ```ruby
144
+ FreshmailApi.delete_campaig({options})
145
+ ```
146
+ require options:
147
+ :hash
148
+
149
+ 5.1 Send test campaign:
150
+ ```ruby
151
+ FreshmailApi.send_test_campaig(hash: '4zcnmd2ski', emails: ['test1@email.com', 'test2@email.com'])
152
+ ```
153
+ require options:
154
+ :hash,
155
+ :emails
156
+ optional options:
157
+ :custom_fields
158
+
159
+ 5.1 Send campaign:
160
+ ```ruby
161
+ FreshmailApi.send_campaig({options})
162
+ ```
163
+ require options:
164
+ :hash
165
+ optional options:
166
+ :time (format: YYYY-MM-DD H:i:s)
167
+
168
+
169
+ 6. Subscriber:
170
+ 6.1 Add:
171
+ ```ruby
172
+ FreshmailApi.add_subscriber({options})
173
+ ```
174
+ -require options:
175
+ :email,
176
+ :list
177
+ -optional options:
178
+ :state,
179
+ :confirm,
180
+ :custom_fields
181
+
182
+ 6.2 Edit:
183
+ ```ruby
184
+ FreshmailApi.edit_subscriber({options})
185
+ ```
186
+ -require options:
187
+ :email,
188
+ :list
189
+ -optional options:
190
+ :state,
191
+ :custom_fields
192
+
193
+ 6.3 Add:
194
+ ```ruby
195
+ FreshmailApi.get_subscriber(email: 'test@email.com', list: '4zcnmd2ski')
196
+ ```
197
+ -require options:
198
+ :email,
199
+ :list
200
+
201
+ 6.4 Delete:
202
+ ```ruby
203
+ FreshmailApi.delete_subscriber({options})
204
+ ```
205
+ -require options:
206
+ :email,
207
+ :list
208
+
209
+ 6.5 History of subscriber:
210
+ ```ruby
211
+ FreshmailApi.get_subscriber_history(email: 'test@email.com', list: '4zcnmd2ski', limit: 30)
212
+ ```
213
+ -require options:
214
+ :email,
215
+ :list
216
+ -optional options:
217
+ :limit (default: 10)
218
+
219
+ 6.6 Add subscribers:
220
+ ```ruby
221
+ FreshmailApi.add_subscribers(subscribers: [{email: 'test@email.com'}, {email: 'test@email.com'}], list: '4zcnmd2ski')
222
+ ```
223
+ -require options:
224
+ :subscribers,
225
+ :list
226
+ -optional options:
227
+ :state,
228
+ :confirm
229
+
230
+ 6.7 Edit subscribers:
231
+ ```ruby
232
+ FreshmailApi.edit_subscribers(subscribers: [{email: 'test@email.com'}, {email: 'test@email.com'}], list: '4zcnmd2ski')
233
+ ```
234
+ -require options:
235
+ :subscribers,
236
+ :list
237
+ -optional options:
238
+ :state,
239
+ :confirm
240
+
241
+ 6.8 Update field value for all subscribers:
242
+ ```ruby
243
+ FreshmailApi.update_subscriber_field({options})
244
+ ```
245
+ -require options:
246
+ :listHash,
247
+ :tag,
248
+ :value,
249
+ :url
250
+
251
+ 6.9 Get data from subscribers:
252
+ ```ruby
253
+ FreshmailApi.get_subscribers({options})
254
+ ```
255
+ -require options:
256
+ :subscribers,
257
+ :list
258
+
259
+ 6.10 Delete subscribers:
260
+ ```ruby
261
+ FreshmailApi.delete_subscribers({options})
262
+ ```
263
+ -require options:
264
+ :subscribers,
265
+ :list
266
+
267
+ 6.11 Block subscribers:
268
+ ```ruby
269
+ FreshmailApi.block_subscribers({options})
270
+ ```
271
+ -require options:
272
+ :emails
273
+
274
+ 6.12 Unblock subscribers:
275
+ ```ruby
276
+ FreshmailApi.unblock_subscribers({options})
277
+ ```
278
+ -require options:
279
+ :emails
280
+
281
+
282
+ 7. Create account:
283
+ ```ruby
284
+ FreshmailApi.create_account({options})
285
+ ```
286
+ -require options:
287
+ :login,
288
+ :password,
289
+ :firstname,
290
+ :lastname,
291
+ :phone
292
+ -optional options:
293
+ :company,
294
+ :activation_email,
295
+ :activation,
296
+ :child_account
297
+
298
+
299
+ 8. Subscribers list:
300
+ 8.1 Create:
301
+ ```ruby
302
+ FreshmailApi.create_subscribers_list({options})
303
+ ```
304
+ -require options:
305
+ :name
306
+ -optional options:
307
+ :description,
308
+ :custom_field
309
+
310
+ 8.2 Update:
311
+ ```ruby
312
+ FreshmailApi.update_subscribers_list({options})
313
+ ```
314
+ -require options:
315
+ :hash,
316
+ :name
317
+ -optional options:
318
+ :description
319
+
320
+ 8.3 Delete:
321
+ ```ruby
322
+ FreshmailApi.delete_subscribers_list({options})
323
+ ```
324
+ -require options:
325
+ :hash
326
+
327
+ 8.4 Get lists:
328
+ ```ruby
329
+ FreshmailApi.get_subscribers_lists
330
+ ```
331
+
332
+ 8.5 Add extra field:
333
+ ```ruby
334
+ FreshmailApi.add_field_to_subscribers_list({options})
335
+ ```
336
+ -require options:
337
+ :hash,
338
+ :name
339
+ -optional options:
340
+ :tag,
341
+ :type
342
+
343
+ 8.6 Get extra fields:
344
+ ```ruby
345
+ FreshmailApi.get_subscribers_list_fields({options})
346
+ ```
347
+ -require options:
348
+ :hash
349
+
350
+ 9. Spam test:
351
+ ```ruby
352
+ FreshmailApi.check_spam_test({options})
353
+ ```
354
+ -require options:
355
+ :subject
356
+ -optional options:
357
+ :from,
358
+ :from_name,
359
+ :html or :text
360
+
361
+
362
+ ## Contributing
363
+
364
+ 1. Fork it ( https://github.com/sliwecki/freshmail_api/fork )
365
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
366
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
367
+ 4. Push to the branch (`git push origin my-new-feature`)
368
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'freshmail_api/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.version = FreshmailApi::VERSION
7
+ spec.name = "freshmail_api"
8
+ spec.authors = ["Damian Śliwecki"]
9
+ spec.email = ["sliwecki@gmail.com"]
10
+ spec.summary = %q{Freshmail REST API v3.0}
11
+ spec.description = %q{Rails gem for fast Freshmail integration}
12
+ spec.homepage = "https://github.com/sliwecki"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "faraday", "~> 0.9.1"
21
+ spec.add_dependency "json"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,8 @@
1
+ module FreshmailApi
2
+ module Account
3
+
4
+ def create_account(data)
5
+ perform(:post, 'account/create', data)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ module FreshmailApi
2
+ module Authorization
3
+
4
+ def authorize(path, data)
5
+ Digest::SHA1.hexdigest([
6
+ configuration.api_key,
7
+ path,
8
+ data,
9
+ configuration.api_secret
10
+ ].join)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ module FreshmailApi
2
+ module Campaign
3
+
4
+ def create_campaign(data)
5
+ perform(:post, 'campaigns/create', data)
6
+ end
7
+
8
+ def edit_campaig(data)
9
+ perform(:post, 'campaigns/edit', data)
10
+ end
11
+
12
+ def delete_campaig(data)
13
+ perform(:post, 'campaigns/delete', data)
14
+ end
15
+
16
+ def send_test_campaig(data)
17
+ perform(:post, 'campaigns/sendTest', data)
18
+ end
19
+
20
+ def send_campaig(data)
21
+ perform(:post, 'campaigns/send', data)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ module FreshmailApi
2
+ module Client
3
+
4
+ ENDPOINT = 'https://api.freshmail.com'
5
+
6
+ def perform(method, path, data={})
7
+ data = parse_data(data)
8
+ path = "/rest/#{path}"
9
+ response = client.send(method, path) do |request|
10
+ request.headers = headers(path, data)
11
+ request.body = data if method == :post
12
+ end
13
+
14
+ JSON.parse(response.body)
15
+ end
16
+
17
+ private
18
+
19
+ def client
20
+ @client ||= Faraday.new(ENDPOINT)
21
+ end
22
+
23
+ def parse_data(data)
24
+ data.empty? ? '' : data.to_json
25
+ end
26
+
27
+ def headers(path, data)
28
+ {
29
+ 'Content-Type' => 'application/json',
30
+ 'X-Rest-ApiKey' => configuration.api_key,
31
+ 'X-Rest-ApiSign' => authorize(path, data)
32
+ }
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,6 @@
1
+ module FreshmailApi
2
+ class Configuration
3
+
4
+ attr_accessor :api_key, :api_secret
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module FreshmailApi
2
+ module Mail
3
+
4
+ def send_mail(data)
5
+ perform(:post, 'mail', data)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ module FreshmailApi
2
+ module Ping
3
+
4
+ def get_ping
5
+ perform(:get, 'ping')
6
+ end
7
+
8
+ def post_ping(data)
9
+ perform(:post, 'ping', data)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ module FreshmailApi
2
+ module Report
3
+
4
+ def campaigns_list(page='')
5
+ perform(:get, "reports/campaignsList/#{page}")
6
+ end
7
+
8
+ def campaign_report(id_hash)
9
+ perform(:get, "reports/campaign/#{id_hash}")
10
+ end
11
+
12
+ def campaign_time_details(id_hash)
13
+ perform(:get, "reports/campaignTimeDetails/#{id_hash}")
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ module FreshmailApi
2
+ module Sms
3
+
4
+ def send_sms(data)
5
+ perform(:post, 'sms', data)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module FreshmailApi
2
+ module SpamTest
3
+
4
+ def check_spam_test(data)
5
+ perform(:post, 'spam_test/check', data)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,52 @@
1
+ module FreshmailApi
2
+ module Subscriber
3
+
4
+ def add_subscriber(data)
5
+ perform(:post, 'subscriber/add', data)
6
+ end
7
+
8
+ def edit_subscriber(data)
9
+ perform(:post, 'subscriber/edit', data)
10
+ end
11
+
12
+ def get_subscriber(data)
13
+ perform(:get, "subscriber/get/#{data[:list]}/#{data[:email]}")
14
+ end
15
+
16
+ def delete_subscriber(data)
17
+ perform(:post, 'subscriber/delete', data)
18
+ end
19
+
20
+ def get_subscriber_history(data)
21
+ perform(:post, 'subscriber/getHistory', data)
22
+ end
23
+
24
+ def add_subscribers(data)
25
+ perform(:post, 'subscriber/addMultiple', data)
26
+ end
27
+
28
+ def edit_subscribers(data)
29
+ perform(:post, 'subscriber/editMultiple', data)
30
+ end
31
+
32
+ def update_subscriber_field(data)
33
+ perform(:post, 'subscriber/updateFieldValue', data)
34
+ end
35
+
36
+ def get_subscribers(data)
37
+ perform(:post, "subscriber/getMultiple", data)
38
+ end
39
+
40
+ def delete_subscribers(data)
41
+ perform(:post, "subscriber/deleteMultiple", data)
42
+ end
43
+
44
+ def block_subscribers(data)
45
+ perform(:post, "subscriber/addBlocks", data)
46
+ end
47
+
48
+ def unblock_subscribers(data)
49
+ perform(:post, "subscriber/removeBlocks", data)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,28 @@
1
+ module FreshmailApi
2
+ module SubscribersList
3
+
4
+ def create_subscribers_list(data)
5
+ perform(:post, "subscribers_list/create", data)
6
+ end
7
+
8
+ def update_subscribers_list(data)
9
+ perform(:post, "subscribers_list/update", data)
10
+ end
11
+
12
+ def delete_subscribers_list(data)
13
+ perform(:post, "subscribers_list/delete", data)
14
+ end
15
+
16
+ def get_subscribers_lists
17
+ perform(:get, "subscribers_list/lists")
18
+ end
19
+
20
+ def add_field_to_subscribers_list(data)
21
+ perform(:post, "subscribers_list/addField", data)
22
+ end
23
+
24
+ def get_subscribers_list_fields(data)
25
+ perform(:post, "subscribers_list/getFields", data)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module FreshmailApi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,40 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'freshmail_api/version'
4
+ require 'freshmail_api/configuration'
5
+ require 'freshmail_api/authorization'
6
+ require 'freshmail_api/client'
7
+ require 'freshmail_api/ping'
8
+ require 'freshmail_api/mail'
9
+ require 'freshmail_api/sms'
10
+ require 'freshmail_api/account'
11
+ require 'freshmail_api/spam_test'
12
+ require 'freshmail_api/report'
13
+ require 'freshmail_api/campaign'
14
+ require 'freshmail_api/subscriber'
15
+ require 'freshmail_api/subscribers_list'
16
+
17
+ module FreshmailApi
18
+ extend Authorization
19
+ extend Client
20
+ extend Ping
21
+ extend Mail
22
+ extend Sms
23
+ extend Subscriber
24
+ extend Account
25
+ extend SpamTest
26
+ extend Report
27
+ extend Campaign
28
+ extend SubscribersList
29
+
30
+ class << self
31
+
32
+ def configure
33
+ yield(configuration) if block_given?
34
+ end
35
+
36
+ def configuration
37
+ @configuration ||= Configuration.new
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,292 @@
1
+ require 'spec_helper'
2
+
3
+ describe FreshmailApi do
4
+ let(:url) { "https://api.freshmail.com/rest/#{path}" }
5
+ let(:stubs) { Faraday::Adapter::Test::Stubs.new }
6
+ let(:client) { Faraday.new { |builder| builder.adapter(:test, stubs) }}
7
+
8
+ before do
9
+ allow(described_class).to receive(:client) { client }
10
+
11
+ described_class.configure do |config|
12
+ config.api_key = 'api_key_1'
13
+ config.api_secret = 'api_secret_1'
14
+ end
15
+ end
16
+
17
+ describe '.configuration' do
18
+ it 'not be nil' do
19
+ expect(described_class.configuration.api_key).not_to be(nil)
20
+ expect(described_class.configuration.api_secret).not_to be(nil)
21
+ end
22
+
23
+ it 'api_key should eq api_key_1' do
24
+ expect(described_class.configuration.api_key).to eq('api_key_1')
25
+ end
26
+
27
+ it 'api_secret should eq api_secret_1' do
28
+ expect(described_class.configuration.api_secret).to eq('api_secret_1')
29
+ end
30
+ end
31
+
32
+ context 'Ping' do
33
+ let(:path) { 'ping' }
34
+ it '.get_ping' do
35
+ stubs.get(url) { |env| [ 200, {}, '{"status": "get_ping OK"}']}
36
+ expect(described_class.get_ping).to eq({ 'status' => 'get_ping OK' })
37
+ end
38
+
39
+ it '.post_ping' do
40
+ stubs.post(url) { |env| [ 200, {}, '{"status": "post_ping OK"}']}
41
+ expect(described_class.post_ping({data: 'data'})).to eq({ 'status' => 'post_ping OK' })
42
+ end
43
+ end
44
+
45
+ context 'Account' do
46
+ let(:path) { 'account/create' }
47
+ it '.create_account' do
48
+ stubs.post(url) { |env| [ 200, {}, '{"status": "create_account OK"}']}
49
+ expect(described_class.create_account({data: 'data'})).to eq({ 'status' => 'create_account OK' })
50
+ end
51
+ end
52
+
53
+ context 'Mail' do
54
+ let(:path) { 'mail' }
55
+ it '.send_mail' do
56
+ stubs.post(url) { |env| [ 200, {}, '{"status": "send_mail OK"}']}
57
+ expect(described_class.send_mail({data: 'data'})).to eq({ 'status' => 'send_mail OK' })
58
+ end
59
+ end
60
+
61
+ context 'Sms' do
62
+ let(:path) { 'sms' }
63
+ it '.send_sms' do
64
+ stubs.post(url) { |env| [ 200, {}, '{"status": "send_sms OK"}']}
65
+ expect(described_class.send_sms({data: 'data'})).to eq({ 'status' => 'send_sms OK' })
66
+ end
67
+ end
68
+
69
+ context 'SpanTest' do
70
+ let(:path) { 'spam_test/check' }
71
+ it '.check_spam_test' do
72
+ stubs.post(url) { |env| [ 200, {}, '{"status": "check_spam_test OK"}']}
73
+ expect(described_class.check_spam_test({data: 'data'})).to eq({ 'status' => 'check_spam_test OK' })
74
+ end
75
+ end
76
+
77
+ context 'Report' do
78
+ describe '.campaigns_list' do
79
+ let(:path) { 'reports/campaignsList/1' }
80
+ it do
81
+ stubs.get(url) { |env| [ 200, {}, '{"status": "campaigns_list OK"}']}
82
+ expect(described_class.campaigns_list(1)).to eq({ 'status' => 'campaigns_list OK' })
83
+ end
84
+ end
85
+
86
+ describe '.campaign_report' do
87
+ let(:path) { 'reports/campaign/1' }
88
+ it do
89
+ stubs.get(url) { |env| [ 200, {}, '{"status": "campaign_report OK"}']}
90
+ expect(described_class.campaign_report(1)).to eq({ 'status' => 'campaign_report OK' })
91
+ end
92
+ end
93
+
94
+ describe '.campaign_time_details' do
95
+ let(:path) { 'reports/campaignTimeDetails/1' }
96
+ it do
97
+ stubs.get(url) { |env| [ 200, {}, '{"status": "campaign_time_details OK"}']}
98
+ expect(described_class.campaign_time_details(1)).to eq({ 'status' => 'campaign_time_details OK' })
99
+ end
100
+ end
101
+ end
102
+
103
+ context 'Campaign' do
104
+ describe '.create_campaign' do
105
+ let(:path) { 'campaigns/create' }
106
+ it do
107
+ stubs.post(url) { |env| [ 200, {}, '{"status": "create_campaign OK"}']}
108
+ expect(described_class.create_campaign({data: 'data'})).to eq({ 'status' => 'create_campaign OK' })
109
+ end
110
+ end
111
+
112
+ describe '.edit_campaig' do
113
+ let(:path) { 'campaigns/edit' }
114
+ it do
115
+ stubs.post(url) { |env| [ 200, {}, '{"status": "edit_campaig OK"}']}
116
+ expect(described_class.edit_campaig({data: 'data'})).to eq({ 'status' => 'edit_campaig OK' })
117
+ end
118
+ end
119
+
120
+ describe '.delete_campaig' do
121
+ let(:path) { 'campaigns/delete' }
122
+ it do
123
+ stubs.post(url) { |env| [ 200, {}, '{"status": "delete_campaig OK"}']}
124
+ expect(described_class.delete_campaig({data: 'data'})).to eq({ 'status' => 'delete_campaig OK' })
125
+ end
126
+ end
127
+
128
+ describe '.send_test_campaig' do
129
+ let(:path) { 'campaigns/sendTest' }
130
+ it do
131
+ stubs.post(url) { |env| [ 200, {}, '{"status": "send_test_campaig OK"}']}
132
+ expect(described_class.send_test_campaig({data: 'data'})).to eq({ 'status' => 'send_test_campaig OK' })
133
+ end
134
+ end
135
+
136
+ describe '.send_campaig' do
137
+ let(:path) { 'campaigns/send' }
138
+ it do
139
+ stubs.post(url) { |env| [ 200, {}, '{"status": "send_campaig OK"}']}
140
+ expect(described_class.send_campaig({data: 'data'})).to eq({ 'status' => 'send_campaig OK' })
141
+ end
142
+ end
143
+ end
144
+
145
+ context 'SubscribersList' do
146
+ describe '.create_subscribers_list' do
147
+ let(:path) { 'subscribers_list/create' }
148
+ it do
149
+ stubs.post(url) { |env| [ 200, {}, '{"status": "create_subscribers_list OK"}']}
150
+ expect(described_class.create_subscribers_list({data: 'data'})).to eq({ 'status' => 'create_subscribers_list OK' })
151
+ end
152
+ end
153
+
154
+ describe '.update_subscribers_list' do
155
+ let(:path) { 'subscribers_list/update' }
156
+ it do
157
+ stubs.post(url) { |env| [ 200, {}, '{"status": "update_subscribers_list OK"}']}
158
+ expect(described_class.update_subscribers_list({data: 'data'})).to eq({ 'status' => 'update_subscribers_list OK' })
159
+ end
160
+ end
161
+
162
+ describe '.delete_subscribers_list' do
163
+ let(:path) { 'subscribers_list/delete' }
164
+ it do
165
+ stubs.post(url) { |env| [ 200, {}, '{"status": "delete_subscribers_list OK"}']}
166
+ expect(described_class.delete_subscribers_list({data: 'data'})).to eq({ 'status' => 'delete_subscribers_list OK' })
167
+ end
168
+ end
169
+
170
+ describe '.get_subscribers_lists' do
171
+ let(:path) { 'subscribers_list/lists' }
172
+ it do
173
+ stubs.get(url) { |env| [ 200, {}, '{"status": "get_subscribers_lists OK"}']}
174
+ expect(described_class.get_subscribers_lists).to eq({ 'status' => 'get_subscribers_lists OK' })
175
+ end
176
+ end
177
+
178
+ describe '.add_field_to_subscribers_list' do
179
+ let(:path) { 'subscribers_list/addField' }
180
+ it do
181
+ stubs.post(url) { |env| [ 200, {}, '{"status": "add_field_to_subscribers_list OK"}']}
182
+ expect(described_class.add_field_to_subscribers_list({data: 'data'})).to eq({ 'status' => 'add_field_to_subscribers_list OK' })
183
+ end
184
+ end
185
+
186
+ describe '.get_subscribers_list_fields' do
187
+ let(:path) { 'subscribers_list/getFields' }
188
+ it do
189
+ stubs.post(url) { |env| [ 200, {}, '{"status": "get_subscribers_list_fields OK"}']}
190
+ expect(described_class.get_subscribers_list_fields({data: 'data'})).to eq({ 'status' => 'get_subscribers_list_fields OK' })
191
+ end
192
+ end
193
+ end
194
+
195
+ context 'Subscriber' do
196
+ describe '.add_subscriber' do
197
+ let(:path) { 'subscriber/add' }
198
+ it do
199
+ stubs.post(url) { |env| [ 200, {}, '{"status": "add_subscriber OK"}']}
200
+ expect(described_class.add_subscriber({data: 'data'})).to eq({ 'status' => 'add_subscriber OK' })
201
+ end
202
+ end
203
+
204
+ describe '.edit_subscriber' do
205
+ let(:path) { 'subscriber/edit' }
206
+ it do
207
+ stubs.post(url) { |env| [ 200, {}, '{"status": "edit_subscriber OK"}']}
208
+ expect(described_class.edit_subscriber({data: 'data'})).to eq({ 'status' => 'edit_subscriber OK' })
209
+ end
210
+ end
211
+
212
+ describe '.get_subscriber' do
213
+ let(:path) { 'subscriber/get/1/some@mail.com' }
214
+ it do
215
+ stubs.get(url) { |env| [ 200, {}, '{"status": "get_subscriber OK"}']}
216
+ expect(described_class.get_subscriber({list: 1, email: 'some@mail.com'})).to eq({ 'status' => 'get_subscriber OK' })
217
+ end
218
+ end
219
+
220
+ describe '.delete_subscriber' do
221
+ let(:path) { 'subscriber/delete' }
222
+ it do
223
+ stubs.post(url) { |env| [ 200, {}, '{"status": "delete_subscriber OK"}']}
224
+ expect(described_class.delete_subscriber({data: 'data'})).to eq({ 'status' => 'delete_subscriber OK' })
225
+ end
226
+ end
227
+
228
+ describe '.get_subscriber_history' do
229
+ let(:path) { 'subscriber/getHistory' }
230
+ it do
231
+ stubs.post(url) { |env| [ 200, {}, '{"status": "get_subscriber_history OK"}']}
232
+ expect(described_class.get_subscriber_history({data: 'data'})).to eq({ 'status' => 'get_subscriber_history OK' })
233
+ end
234
+ end
235
+
236
+ describe '.add_subscribers' do
237
+ let(:path) { 'subscriber/addMultiple' }
238
+ it do
239
+ stubs.post(url) { |env| [ 200, {}, '{"status": "add_subscribers OK"}']}
240
+ expect(described_class.add_subscribers({data: 'data'})).to eq({ 'status' => 'add_subscribers OK' })
241
+ end
242
+ end
243
+
244
+ describe '.edit_subscribers' do
245
+ let(:path) { 'subscriber/editMultiple' }
246
+ it do
247
+ stubs.post(url) { |env| [ 200, {}, '{"status": "edit_subscribers OK"}']}
248
+ expect(described_class.edit_subscribers({data: 'data'})).to eq({ 'status' => 'edit_subscribers OK' })
249
+ end
250
+ end
251
+
252
+ describe '.update_subscriber_field' do
253
+ let(:path) { 'subscriber/updateFieldValue' }
254
+ it do
255
+ stubs.post(url) { |env| [ 200, {}, '{"status": "update_subscriber_field OK"}']}
256
+ expect(described_class.update_subscriber_field({data: 'data'})).to eq({ 'status' => 'update_subscriber_field OK' })
257
+ end
258
+ end
259
+
260
+ describe '.get_subscribers' do
261
+ let(:path) { 'subscriber/getMultiple' }
262
+ it do
263
+ stubs.post(url) { |env| [ 200, {}, '{"status": "get_subscribers OK"}']}
264
+ expect(described_class.get_subscribers({data: 'data'})).to eq({ 'status' => 'get_subscribers OK' })
265
+ end
266
+ end
267
+
268
+ describe '.delete_subscribers' do
269
+ let(:path) { 'subscriber/deleteMultiple' }
270
+ it do
271
+ stubs.post(url) { |env| [ 200, {}, '{"status": "delete_subscribers OK"}']}
272
+ expect(described_class.delete_subscribers({data: 'data'})).to eq({ 'status' => 'delete_subscribers OK' })
273
+ end
274
+ end
275
+
276
+ describe '.block_subscribers' do
277
+ let(:path) { 'subscriber/addBlocks' }
278
+ it do
279
+ stubs.post(url) { |env| [ 200, {}, '{"status": "block_subscribers OK"}']}
280
+ expect(described_class.block_subscribers({data: 'data'})).to eq({ 'status' => 'block_subscribers OK' })
281
+ end
282
+ end
283
+
284
+ describe '.unblock_subscribers' do
285
+ let(:path) { 'subscriber/removeBlocks' }
286
+ it do
287
+ stubs.post(url) { |env| [ 200, {}, '{"status": "unblock_subscribers OK"}']}
288
+ expect(described_class.unblock_subscribers({data: 'data'})).to eq({ 'status' => 'unblock_subscribers OK' })
289
+ end
290
+ end
291
+ end
292
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe FreshmailApi::VERSION do
4
+ it 'has a version number' do
5
+ expect(FreshmailApi::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ require 'freshmail_api'
2
+
3
+ RSpec.configure do |config|
4
+ config.color_enabled = true
5
+ config.formatter = 'documentation'
6
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: freshmail_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Damian Śliwecki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Rails gem for fast Freshmail integration
84
+ email:
85
+ - sliwecki@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - freshmail_api.gemspec
98
+ - lib/freshmail_api.rb
99
+ - lib/freshmail_api/account.rb
100
+ - lib/freshmail_api/authorization.rb
101
+ - lib/freshmail_api/campaign.rb
102
+ - lib/freshmail_api/client.rb
103
+ - lib/freshmail_api/configuration.rb
104
+ - lib/freshmail_api/mail.rb
105
+ - lib/freshmail_api/ping.rb
106
+ - lib/freshmail_api/report.rb
107
+ - lib/freshmail_api/sms.rb
108
+ - lib/freshmail_api/spam_test.rb
109
+ - lib/freshmail_api/subscriber.rb
110
+ - lib/freshmail_api/subscribers_list.rb
111
+ - lib/freshmail_api/version.rb
112
+ - spec/freshmail_api_spec.rb
113
+ - spec/lib/version_spec.rb
114
+ - spec/spec_helper.rb
115
+ homepage: https://github.com/sliwecki
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.4.5
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Freshmail REST API v3.0
139
+ test_files:
140
+ - spec/freshmail_api_spec.rb
141
+ - spec/lib/version_spec.rb
142
+ - spec/spec_helper.rb