sendpulse 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf8288c003a2fdf99278dbcbacd388178c55bd3f
4
- data.tar.gz: dd1ece8c1e5162e13791484e1c53eddc2721dcc4
3
+ metadata.gz: 410d39c2cdf278d41fefb97a275d021384be3e62
4
+ data.tar.gz: 9461b6f3da754d3e9939ce69c580aa3fa8554f6e
5
5
  SHA512:
6
- metadata.gz: f9a8b1827b7d949e03babd0c3ca79ff32c87ea5ab925e5a62a664769b3d8e9e7fdef1600d674cb65f2bc0211becf888749172475c8f78e0cae4d4da970a9ea83
7
- data.tar.gz: e9ef3f04b6f063331e97d1bc378f92257ebc0d31226ddbbdf7e567b048f554d61703de162be8b017a797482f65c703e5984b3c6fad63cf25a242b653d2cd2f3d
6
+ metadata.gz: d76f1f3453d8668ea393d63ff599952263966662293c5371693202d5471c672ea8e079390f7817da2efd3c0ddc67683dccad7ac70ea9ceefbd4f442e85725ebf
7
+ data.tar.gz: 5672def6d76dc0832cde50594ffdfe34e6ea3f40789bdf61118a918516436c7b14f9543fdcca63aaafb685de46230c6d6211f55c2a379d447175c6845813f3ed
@@ -1,18 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sendpulse (0.0.1)
4
+ sendpulse (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.3)
10
- docile (1.1.5)
11
10
  dotenv (2.1.1)
12
11
  faker (1.7.3)
13
12
  i18n (~> 0.5)
14
13
  i18n (0.8.1)
15
- json (2.0.3)
16
14
  rake (10.5.0)
17
15
  rspec (3.5.0)
18
16
  rspec-core (~> 3.5.0)
@@ -27,11 +25,6 @@ GEM
27
25
  diff-lcs (>= 1.2.0, < 2.0)
28
26
  rspec-support (~> 3.5.0)
29
27
  rspec-support (3.5.0)
30
- simplecov (0.14.1)
31
- docile (~> 1.1.0)
32
- json (>= 1.8, < 3)
33
- simplecov-html (~> 0.10.0)
34
- simplecov-html (0.10.0)
35
28
 
36
29
  PLATFORMS
37
30
  ruby
@@ -43,7 +36,6 @@ DEPENDENCIES
43
36
  rake (~> 10.0)
44
37
  rspec (~> 3.2)
45
38
  sendpulse!
46
- simplecov (~> 0.14.1)
47
39
 
48
40
  BUNDLED WITH
49
41
  1.14.6
data/README.md CHANGED
@@ -41,6 +41,117 @@ sendpulse_smtp = SendPulse::Smtp.new(your_client_id, your_client_secret, 'https'
41
41
  sendpulse_smtp.retrieve_emails
42
42
  ```
43
43
 
44
+ ### Mailing List
45
+ #### Creating a mailing list
46
+
47
+ ```ruby
48
+ require 'sendpulse/mailing_list'
49
+
50
+ sendpulse_mailinglist = SendPulse::MailingList.new(your_client_id, your_client_secret, 'https', nil)
51
+ sendpulse_mailinglist.create("Mailing List Title")
52
+ ```
53
+
54
+ #### Editing a mailing list
55
+
56
+ ```ruby
57
+ require 'sendpulse/mailing_list'
58
+
59
+ sendpulse_mailinglist = SendPulse::MailingList.new(your_client_id, your_client_secret, 'https', nil)
60
+ sendpulse_mailinglist.update({ id: id, name: "New mailing list name" })
61
+ ```
62
+
63
+ #### Retrieving a list of mailing list
64
+
65
+ ```ruby
66
+ require 'sendpulse/mailing_list'
67
+
68
+ sendpulse_mailinglist = SendPulse::MailingList.new(your_client_id, your_client_secret, 'https', nil)
69
+ sendpulse_mailinglist.list({ limit: 10, offset: 10 })
70
+ ```
71
+
72
+ #### Retrieving mailing list information
73
+
74
+ ```ruby
75
+ require 'sendpulse/mailing_list'
76
+
77
+ sendpulse_mailinglist = SendPulse::MailingList.new(your_client_id, your_client_secret, 'https', nil)
78
+ sendpulse_mailinglist.get(mailinglist_id)
79
+ ```
80
+
81
+ #### Retrieving a list of emails from a mailing list
82
+
83
+ ```ruby
84
+ require 'sendpulse/mailing_list'
85
+
86
+ sendpulse_mailinglist = SendPulse::MailingList.new(your_client_id, your_client_secret, 'https', nil)
87
+ sendpulse_mailinglist.get_emails(mailinglist_id)
88
+ ```
89
+
90
+ #### Adding emails to a mailing list
91
+
92
+ ```ruby
93
+ require 'sendpulse/mailing_list'
94
+
95
+ sendpulse_mailinglist = SendPulse::MailingList.new(your_client_id, your_client_secret, 'https', nil)
96
+ sendpulse_mailinglist.add_emails(
97
+ {
98
+ id: id,
99
+ emails: [
100
+ {
101
+ "email": "test1@gmail.com",
102
+ "variables": {
103
+ "variable1": "value1",
104
+ "variable2": "value2"
105
+ }
106
+ },
107
+ {
108
+ "email": "test1@gmail.com",
109
+ "variables": {
110
+ "variable1": "value1",
111
+ "variable2": "value2"
112
+ }
113
+ }
114
+ ]
115
+ }
116
+ )
117
+ ```
118
+
119
+ #### Deleting emails from a mailing list
120
+
121
+ ```ruby
122
+ require 'sendpulse/mailing_list'
123
+
124
+ sendpulse_mailinglist = SendPulse::MailingList.new(your_client_id, your_client_secret, 'https', nil)
125
+ sendpulse_mailinglist.delete_emails({ id: id, emails: ["test1@gmail.com"] })
126
+ ```
127
+
128
+ #### Retrieving information for specific email address from a mailing list
129
+
130
+ ```ruby
131
+ require 'sendpulse/mailing_list'
132
+
133
+ sendpulse_mailinglist = SendPulse::MailingList.new(your_client_id, your_client_secret, 'https', nil)
134
+ sendpulse_mailinglist.get_email({ id: id, email: "test1@gmail.com" })
135
+ ```
136
+
137
+ #### Erasing a mailing list
138
+
139
+ ```ruby
140
+ require 'sendpulse/mailing_list'
141
+
142
+ sendpulse_mailinglist = SendPulse::MailingList.new(your_client_id, your_client_secret, 'https', nil)
143
+ sendpulse_mailinglist.delete(id)
144
+ ```
145
+
146
+ #### Calculating the cost of a campaign carried out by a mailing list
147
+
148
+ ```ruby
149
+ require 'sendpulse/mailing_list'
150
+
151
+ sendpulse_mailinglist = SendPulse::MailingList.new(your_client_id, your_client_secret, 'https', nil)
152
+ sendpulse_mailinglist.cost(id)
153
+ ```
154
+
44
155
  [Here](https://sendpulse.com/integrations/api) is SendPulse API specification.
45
156
 
46
157
  ## Contributing
@@ -22,6 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'rake', '~> 10.0'
23
23
  spec.add_development_dependency 'rspec', '~> 3.2'
24
24
  spec.add_development_dependency 'dotenv', '~> 2.1.1'
25
- spec.add_development_dependency 'simplecov', '~> 0.14.1'
26
25
  spec.add_development_dependency 'faker', '~> 1.7.3'
27
26
  end
@@ -61,6 +61,9 @@ module SendPulse
61
61
  when 'PUT'
62
62
  request = Net::HTTP::Put.new(uri.request_uri, token)
63
63
  request.set_form_data(data)
64
+ when 'DELETE'
65
+ request = Net::HTTP::Delete.new(uri.request_uri, token)
66
+ request.set_form_data(data)
64
67
  else
65
68
  request = Net::HTTP::Get.new(uri.request_uri, token)
66
69
  end
@@ -0,0 +1,45 @@
1
+ require 'sendpulse/api'
2
+
3
+ module SendPulse
4
+ class MailingList < SendPulse::Api
5
+ def create(list_name)
6
+ send_request('addressbooks', 'POST', { bookName: list_name })
7
+ end
8
+
9
+ def update(params)
10
+ send_request("addressbooks/#{params[:id]}", 'PUT', params)
11
+ end
12
+
13
+ def list(params = {})
14
+ send_request('addressbooks', 'GET', params)
15
+ end
16
+
17
+ def get(id)
18
+ send_request("addressbooks/#{id}", 'GET')
19
+ end
20
+
21
+ def add_emails(params)
22
+ send_request("addressbooks/#{params[:id]}/emails", 'POST', { id: params[:id], emails: serialize(params[:emails]) })
23
+ end
24
+
25
+ def get_emails(params)
26
+ send_request("addressbooks/#{params[:id]}/emails", 'GET', params)
27
+ end
28
+
29
+ def delete_emails(params)
30
+ send_request("addressbooks/#{params[:id]}/emails", 'DELETE', { emails: serialize(params[:emails]) })
31
+ end
32
+
33
+ def get_email(params)
34
+ send_request("addressbooks/#{params[:id]}/emails/#{params[:email]}", 'GET', params)
35
+ end
36
+
37
+ def delete(id)
38
+ send_request("addressbooks/#{id}", 'DELETE')
39
+ end
40
+
41
+ def cost(id)
42
+ send_request("addressbooks/#{id}/cost", 'GET')
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module SendPulse
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,99 @@
1
+ require 'spec_helper'
2
+ require 'faker'
3
+
4
+ describe SendPulse::MailingList do
5
+ before(:each) do
6
+ @client_id = ENV['CLIENT_ID']
7
+ @client_secret = ENV['CLIENT_SECRET']
8
+ end
9
+
10
+ context "Initialize" do
11
+ describe "Mailing List" do
12
+ let(:sendpulse_mailinglist) { described_class.new(@client_id, @client_secret, "https", nil) }
13
+ let(:mailinglist) { sendpulse_mailinglist.create("#{Faker::Book.title} #{Time.now.to_i}") }
14
+
15
+ it do
16
+ expect(mailinglist[:data]).to include("id")
17
+
18
+ id = mailinglist[:data]["id"]
19
+ new_name = "#{Faker::Book.title} #{Time.now.to_i}"
20
+ update_mailing_list = sendpulse_mailinglist.update({ id: id, name: new_name })
21
+ expect(update_mailing_list[:data]).to eql({ "result" => true })
22
+ list = sendpulse_mailinglist.list[:data]
23
+ first_list = list[0]
24
+ expect(first_list).to include("id")
25
+ expect(first_list).to include("name")
26
+ expect(first_list).to include("all_email_qty")
27
+ expect(first_list).to include("active_email_qty")
28
+ expect(first_list).to include("inactive_email_qty")
29
+ expect(first_list).to include("creationdate")
30
+ expect(first_list).to include("status")
31
+ expect(first_list).to include("status_explain")
32
+ single_list = sendpulse_mailinglist.get(id)[:data][0]
33
+ expect(single_list).to include("id")
34
+ expect(single_list).to include("name")
35
+ expect(single_list).to include("all_email_qty")
36
+ expect(single_list).to include("active_email_qty")
37
+ expect(single_list).to include("inactive_email_qty")
38
+ expect(single_list).to include("creationdate")
39
+ expect(single_list).to include("status")
40
+ expect(single_list).to include("status_explain")
41
+ add_emails = sendpulse_mailinglist.add_emails(
42
+ {
43
+ id: id,
44
+ emails: [
45
+ {
46
+ "email": "test1@gmail.com",
47
+ "variables": {
48
+ "variable1": "value1",
49
+ "variable2": "value2"
50
+ }
51
+ },
52
+ {
53
+ "email": "test2@gmail.com",
54
+ "variables": {
55
+ "variable3": "value3",
56
+ "variable4": "value4"
57
+ }
58
+ },
59
+ {
60
+ "email": "test3@gmail.com",
61
+ "variables": {
62
+ "variable5": "value5",
63
+ "variable6": "value6"
64
+ }
65
+ }
66
+ ]
67
+ }
68
+ )
69
+ expect(add_emails[:data]).to eql({ "result" => true })
70
+ get_emails = sendpulse_mailinglist.get_emails({ id: id })[:data]
71
+ get_email = get_emails[0]
72
+ expect(get_email).to include("email")
73
+ expect(get_email).to include("status")
74
+ expect(get_email).to include("phone")
75
+ expect(get_email).to include("status_explain")
76
+ expect(get_email).to include("variables")
77
+ get_email = sendpulse_mailinglist.get_email({ id: id, email: "test1@gmail.com" })[:data]
78
+ expect(get_email).to include("email")
79
+ expect(get_email).to include("abook_id")
80
+ expect(get_email).to include("phone")
81
+ expect(get_email).to include("status")
82
+ expect(get_email).to include("status_explain")
83
+ expect(get_email).to include("variables")
84
+ delete_emails = sendpulse_mailinglist.delete_emails({ id: id, emails: ["test1@gmail.com", "test2@gmail.com"] })
85
+ expect(delete_emails[:data]).to eql({ "result" => true })
86
+ cost = sendpulse_mailinglist.cost(id)[:data]
87
+ expect(cost).to include("cur")
88
+ expect(cost).to include("sent_emails_qty")
89
+ expect(cost).to include("overdraftAllEmailsPrice")
90
+ expect(cost).to include("addressesDeltaFromBalance")
91
+ expect(cost).to include("addressesDeltaFromTariff")
92
+ expect(cost).to include("max_emails_per_task")
93
+ expect(cost).to include("result")
94
+ delete = sendpulse_mailinglist.delete(id)
95
+ expect(delete[:data]).to eql({ "result" => true })
96
+ end
97
+ end
98
+ end
99
+ end
@@ -28,20 +28,22 @@ describe SendPulse::Smtp do
28
28
  let(:send_email) { sendpulse_smtp.send_email(@email) }
29
29
  let(:retrieve_emails) { sendpulse_smtp.retrieve_emails }
30
30
 
31
- it { expect(sendpulse_smtp).to be_a SendPulse::Smtp }
32
- it { expect(send_email[:data]).to eql({ "result" => true }) }
33
- it { expect(retrieve_emails[:data][0]).to include("id") }
34
- it { expect(retrieve_emails[:data][0]).to include("sender") }
35
- it { expect(retrieve_emails[:data][0]).to include("total_size") }
36
- it { expect(retrieve_emails[:data][0]).to include("sender_ip") }
37
- it { expect(retrieve_emails[:data][0]).to include("smtp_answer_code") }
38
- it { expect(retrieve_emails[:data][0]).to include("smtp_answer_code_explain") }
39
- it { expect(retrieve_emails[:data][0]).to include("smtp_answer_subcode") }
40
- it { expect(retrieve_emails[:data][0]).to include("smtp_answer_data") }
41
- it { expect(retrieve_emails[:data][0]).to include("used_ip") }
42
- it { expect(retrieve_emails[:data][0]).to include("recipient") }
43
- it { expect(retrieve_emails[:data][0]).to include("subject") }
44
- it { expect(retrieve_emails[:data][0]).to include("send_date") }
31
+ it do
32
+ expect(sendpulse_smtp).to be_a SendPulse::Smtp
33
+ expect(send_email[:data]).to eql({ "result" => true })
34
+ expect(retrieve_emails[:data][0]).to include("id")
35
+ expect(retrieve_emails[:data][0]).to include("sender")
36
+ expect(retrieve_emails[:data][0]).to include("total_size")
37
+ expect(retrieve_emails[:data][0]).to include("sender_ip")
38
+ expect(retrieve_emails[:data][0]).to include("smtp_answer_code")
39
+ expect(retrieve_emails[:data][0]).to include("smtp_answer_code_explain")
40
+ expect(retrieve_emails[:data][0]).to include("smtp_answer_subcode")
41
+ expect(retrieve_emails[:data][0]).to include("smtp_answer_data")
42
+ expect(retrieve_emails[:data][0]).to include("used_ip")
43
+ expect(retrieve_emails[:data][0]).to include("recipient")
44
+ expect(retrieve_emails[:data][0]).to include("subject")
45
+ expect(retrieve_emails[:data][0]).to include("send_date")
46
+ end
45
47
  end
46
48
  end
47
49
  end
@@ -3,8 +3,6 @@ require 'dotenv'
3
3
  require 'json'
4
4
  Dotenv.load
5
5
 
6
- require 'simplecov'
7
- SimpleCov.start
8
-
9
6
  require 'sendpulse/api'
10
7
  require 'sendpulse/smtp'
8
+ require 'sendpulse/mailing_list'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendpulse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoga Hapriana
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-09 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.1.1
69
- - !ruby/object:Gem::Dependency
70
- name: simplecov
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.14.1
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.14.1
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: faker
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -111,9 +97,11 @@ files:
111
97
  - SendPulse.gemspec
112
98
  - lib/sendpulse/api.rb
113
99
  - lib/sendpulse/host.rb
100
+ - lib/sendpulse/mailing_list.rb
114
101
  - lib/sendpulse/smtp.rb
115
102
  - lib/sendpulse/version.rb
116
103
  - spec/lib/sendpulse/api_spec.rb
104
+ - spec/lib/sendpulse/mailing_list_spec.rb
117
105
  - spec/lib/sendpulse/smtp_spec.rb
118
106
  - spec/spec_helper.rb
119
107
  homepage: https://github.com/yogahp/SendPulse
@@ -142,5 +130,6 @@ specification_version: 4
142
130
  summary: Client to http://sendpulse.com/ API.
143
131
  test_files:
144
132
  - spec/lib/sendpulse/api_spec.rb
133
+ - spec/lib/sendpulse/mailing_list_spec.rb
145
134
  - spec/lib/sendpulse/smtp_spec.rb
146
135
  - spec/spec_helper.rb