expresspigeon-ruby 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -1
- data/.ruby-version +1 -0
- data/Gemfile.lock +5 -5
- data/README.md +46 -3
- data/expresspigeon-ruby.gemspec +2 -2
- data/lib/expresspigeon-ruby.rb +13 -6
- data/lib/expresspigeon-ruby/auto_responders.rb +41 -6
- data/lib/expresspigeon-ruby/campaigns.rb +8 -0
- data/lib/expresspigeon-ruby/contacts.rb +1 -0
- data/lib/expresspigeon-ruby/lists.rb +7 -0
- data/lib/expresspigeon-ruby/messages.rb +112 -6
- data/lib/expresspigeon-ruby/meta_response.rb +1 -1
- data/lib/expresspigeon-ruby/version.rb +1 -1
- data/spec/autoresponders_spec.rb +46 -0
- data/spec/campaigns_spec.rb +68 -46
- data/spec/contacts_spec.rb +38 -38
- data/spec/lists_spec.rb +50 -32
- data/spec/messages_spec.rb +48 -15
- data/spec/pigeon_helper.rb +0 -2
- data/spec/templates_spec.rb +2 -2
- data/test/send.rb +14 -5
- metadata +19 -6
- data/.rvmrc +0 -8
data/spec/messages_spec.rb
CHANGED
@@ -6,25 +6,25 @@ describe 'transactional messages integration test' do
|
|
6
6
|
include PigeonSpecHelper
|
7
7
|
|
8
8
|
#def test_sending_message_and_report_without_params(self):
|
9
|
-
# res = self.api.messages.send_message(template_id=-1, to="", reply_to="",
|
9
|
+
# res = self.api.messages.send_message(template_id=-1, to="", reply_to="", from="", subject="")
|
10
10
|
# self.assertEqual(res.code, 400)
|
11
11
|
# self.assertEqual(res.status, "error")
|
12
12
|
# self.assertEqual(res.message, "Required fields: template_id, reply_to, from, to, and subject")
|
13
13
|
#
|
14
14
|
#def test_sending_message_and_report_with_wrong_email_in_to(self):
|
15
|
-
# res = self.api.messages.send_message(template_id=-1, to="e", reply_to="a@a.a",
|
15
|
+
# res = self.api.messages.send_message(template_id=-1, to="e", reply_to="a@a.a", from="me", subject="Hi")
|
16
16
|
# self.assertEqual(res.code, 400)
|
17
17
|
# self.assertEqual(res.status, "error")
|
18
18
|
# self.assertEqual(res.message, "Email in the 'to' field is not valid")
|
19
19
|
#
|
20
20
|
#def test_sending_message_and_report_with_wrong_email_in_reply_to(self):
|
21
|
-
# res = self.api.messages.send_message(template_id=-1, to="e@e.e", reply_to="a",
|
21
|
+
# res = self.api.messages.send_message(template_id=-1, to="e@e.e", reply_to="a", from="me", subject="Hi")
|
22
22
|
# self.assertEqual(res.code, 400)
|
23
23
|
# self.assertEqual(res.status, "error")
|
24
24
|
# self.assertEqual(res.message, "Email in the 'reply_to' field is not valid")
|
25
25
|
#
|
26
26
|
#def test_sending_message_and_report_with_wrong_template_id(self):
|
27
|
-
# res = self.api.messages.send_message(template_id=-1, to="e@e.e", reply_to="a@a.a",
|
27
|
+
# res = self.api.messages.send_message(template_id=-1, to="e@e.e", reply_to="a@a.a", from="me", subject="Hi")
|
28
28
|
# self.assertEqual(res.code, 400)
|
29
29
|
# self.assertEqual(res.status, "error")
|
30
30
|
# self.assertEqual(res.message, "template=-1 not found")
|
@@ -32,10 +32,10 @@ describe 'transactional messages integration test' do
|
|
32
32
|
|
33
33
|
#TODO: complete the spec
|
34
34
|
it 'sends a single transactional message' do
|
35
|
-
message_response =
|
36
|
-
|
35
|
+
message_response = ExpressPigeon::API.messages.send_message 115, ENV['TARGET_EMAIL'], ENV['TARGET_EMAIL'], "Team ExpressPigeon", "Hi there!",
|
36
|
+
:first_name => "Igor"
|
37
37
|
validate_response message_response, 200, 'success', /email queued/
|
38
|
-
report =
|
38
|
+
report = ExpressPigeon::API.messages.report(message_response.id)
|
39
39
|
report.id.should eq message_response.id
|
40
40
|
end
|
41
41
|
|
@@ -62,7 +62,7 @@ describe 'transactional messages integration test' do
|
|
62
62
|
#def test_sending_multiple_messages_and_get_reports(self):
|
63
63
|
# message_response = self.api.messages.send_message(template_id=self.template_id,
|
64
64
|
# to=os.environ['EXPRESSPIGEON_API_USER'],
|
65
|
-
# reply_to="a@a.a",
|
65
|
+
# reply_to="a@a.a", from="me", subject="Hi",
|
66
66
|
# merge_fields={"first_name": "Gleb"})
|
67
67
|
# self.assertEqual(message_response.code, 200)
|
68
68
|
# self.assertEqual(message_response.status, "success")
|
@@ -71,7 +71,7 @@ describe 'transactional messages integration test' do
|
|
71
71
|
#
|
72
72
|
# message_response_2 = self.api.messages.send_message(template_id=self.template_id,
|
73
73
|
# to=os.environ['EXPRESSPIGEON_API_USER'],
|
74
|
-
# reply_to="a@a.a",
|
74
|
+
# reply_to="a@a.a", from="me", subject="Hi 2",
|
75
75
|
# merge_fields={"first_name": "Gleb"})
|
76
76
|
# self.assertEqual(message_response_2.code, 200)
|
77
77
|
# self.assertEqual(message_response_2.status, "success")
|
@@ -90,23 +90,23 @@ describe 'transactional messages integration test' do
|
|
90
90
|
# self.assertEquals(report2.email, os.environ['EXPRESSPIGEON_API_USER'])
|
91
91
|
# self.assertTrue(report2.in_transit is not None)
|
92
92
|
#
|
93
|
-
it '
|
93
|
+
it 'should send multiple messages and get reports for today' do
|
94
94
|
|
95
95
|
start = Time.now.utc - 60 # one minute ago
|
96
96
|
|
97
|
-
message_response =
|
98
|
-
|
97
|
+
message_response = ExpressPigeon::API.messages.send_message 4905, ENV['TARGET_EMAIL'], ENV['TARGET_EMAIL'],
|
98
|
+
'Team EP', "Hi, there!", :first_name => "Bob"
|
99
99
|
|
100
100
|
validate_response message_response, 200, 'success', /email queued/
|
101
101
|
message_response.id should_not be_nil
|
102
102
|
|
103
|
-
message_response2 =
|
104
|
-
|
103
|
+
message_response2 = ExpressPigeon::API.messages.send_message 4905, ENV['TARGET_EMAIL'], ENV['TARGET_EMAIL'],
|
104
|
+
'Team EP', "Hi, there!", :first_name => "Bob"
|
105
105
|
validate_response message_response2, 200, 'success', /email queued/
|
106
106
|
message_response2.id should_not be_nil
|
107
107
|
|
108
108
|
finish = start + 120 # two minutes after start
|
109
|
-
reports =
|
109
|
+
reports = ExpressPigeon::API.messages.reports (message_response.id - 1), start, finish
|
110
110
|
|
111
111
|
reports.size.should eq 2
|
112
112
|
reports[0]['id'].should eq message_response.id
|
@@ -115,6 +115,8 @@ describe 'transactional messages integration test' do
|
|
115
115
|
reports[0]['email'].should eq ENV['TARGET_EMAIL']
|
116
116
|
reports[1]['email'].should eq ENV['TARGET_EMAIL']
|
117
117
|
end
|
118
|
+
|
119
|
+
|
118
120
|
#
|
119
121
|
#def __get_report_by_id__(self, message_id, start_date=None, end_date=None):
|
120
122
|
# reports = self.api.messages.reports() if start_date is None and end_date is None else \
|
@@ -124,4 +126,35 @@ describe 'transactional messages integration test' do
|
|
124
126
|
# return report[0]
|
125
127
|
|
126
128
|
|
129
|
+
it 'should prepare payload hash' do
|
130
|
+
|
131
|
+
payload = ExpressPigeon::API.messages.prepare_payload(123, #template_id
|
132
|
+
'john@doe.com',
|
133
|
+
'jane@doe.com',
|
134
|
+
'Jane Doe',
|
135
|
+
'Hello, Dolly!',
|
136
|
+
{eye_color: 'blue', body_shape:'pear'},
|
137
|
+
false, true, false,
|
138
|
+
%w(spec/resources/attachment1.txt spec/resources/attachment2.txt), {}, nil, nil)
|
139
|
+
|
140
|
+
payload[:multipart].should eq true
|
141
|
+
payload[:template_id].should eq 123
|
142
|
+
payload[:to].should eq 'john@doe.com'
|
143
|
+
payload[:reply_to].should eq 'jane@doe.com'
|
144
|
+
payload[:from].should eq 'Jane Doe'
|
145
|
+
payload[:subject].should eq 'Hello, Dolly!'
|
146
|
+
payload[:template_id].should eq 123
|
147
|
+
payload[:view_online].should eq false
|
148
|
+
payload[:click_tracking].should eq true
|
149
|
+
payload[:suppress_address].should eq false
|
150
|
+
payload['attachment1.txt'].class.should eq File
|
151
|
+
|
152
|
+
payload[:merge_fields].class.should eq String
|
153
|
+
merge_fields = JSON.parse payload[:merge_fields]
|
154
|
+
merge_fields['eye_color'].should eq "blue"
|
155
|
+
merge_fields['body_shape'].should eq "pear"
|
156
|
+
|
157
|
+
File.basename(payload['attachment1.txt']).should eq 'attachment1.txt'
|
158
|
+
File.basename(payload['attachment2.txt']).should eq 'attachment2.txt'
|
159
|
+
end
|
127
160
|
end
|
data/spec/pigeon_helper.rb
CHANGED
data/spec/templates_spec.rb
CHANGED
@@ -6,10 +6,10 @@ describe 'templates integration test' do
|
|
6
6
|
include PigeonSpecHelper
|
7
7
|
|
8
8
|
it 'should copy template and delete template' do
|
9
|
-
template_response =
|
9
|
+
template_response = ExpressPigeon::API.templates.copy 34830, "new template", :content => "Hello Template World!"
|
10
10
|
template_response.message.should eq 'template copied successfully'
|
11
11
|
template_id = template_response.template_id
|
12
|
-
delete_response =
|
12
|
+
delete_response = ExpressPigeon::API.templates.delete template_id
|
13
13
|
delete_response.message.should eq 'template deleted successfully'
|
14
14
|
end
|
15
15
|
end
|
data/test/send.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
|
-
require '../lib/expresspigeon-ruby.rb'
|
2
1
|
|
2
|
+
require_relative '../lib/expresspigeon-ruby.rb'
|
3
3
|
|
4
|
-
MESSAGES = ExpressPigeon::API.messages
|
5
|
-
MESSAGES.open_timeout = 1000
|
6
|
-
|
7
|
-
puts MESSAGES.send_message 565452, 'igor@expresspigeon.com', 'igor@polevoy.org', "Igor Polevoy", "Transactional message test", {first_name: 'Igor', img1: "https://cdn.pioneer.pgsitecore.com/en-us/-/media/Charmin/Images/Editorials/charmin_tipsarticles_howtopottytrainagirl_image1.jpg"}
|
4
|
+
MESSAGES = ExpressPigeon::API.messages.auth_key(ENV['AUTH_KEY'])
|
8
5
|
|
9
6
|
|
7
|
+
puts MESSAGES.send_message(
|
8
|
+
390243, # template_id
|
9
|
+
'igor@expressxxxx.com', #to
|
10
|
+
'igor@polevoyxxx.org', #reply_to
|
11
|
+
"Igor Polevoy", #from_name
|
12
|
+
"Hi there! A simple send 345!", #subject
|
13
|
+
{first_name: 'Igor', eye_color: 'brown'}, #merge_fields
|
14
|
+
true, #view_online
|
15
|
+
true, #click_tracking
|
16
|
+
true #suppress_address
|
17
|
+
|
18
|
+
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expresspigeon-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ipolevoy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,7 +47,7 @@ extensions: []
|
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
49
|
- ".gitignore"
|
50
|
-
- ".
|
50
|
+
- ".ruby-version"
|
51
51
|
- Gemfile
|
52
52
|
- Gemfile.lock
|
53
53
|
- LICENSE.txt
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/expresspigeon-ruby/meta_response.rb
|
64
64
|
- lib/expresspigeon-ruby/templates.rb
|
65
65
|
- lib/expresspigeon-ruby/version.rb
|
66
|
+
- spec/autoresponders_spec.rb
|
66
67
|
- spec/campaigns_spec.rb
|
67
68
|
- spec/contacts_spec.rb
|
68
69
|
- spec/lists_spec.rb
|
@@ -70,9 +71,15 @@ files:
|
|
70
71
|
- spec/pigeon_helper.rb
|
71
72
|
- spec/resources/upload.csv
|
72
73
|
- spec/templates_spec.rb
|
74
|
+
- test/README
|
75
|
+
- test/attachments/example.ics
|
76
|
+
- test/attachments/smile.pdf
|
73
77
|
- test/send.rb
|
78
|
+
- test/send_with_attachments.rb
|
79
|
+
- test/send_with_headers.rb
|
74
80
|
homepage: https://github.com/expresspigeon/expresspigeon-ruby
|
75
|
-
licenses:
|
81
|
+
licenses:
|
82
|
+
- MIT
|
76
83
|
metadata: {}
|
77
84
|
post_install_message:
|
78
85
|
rdoc_options: []
|
@@ -95,6 +102,7 @@ signing_key:
|
|
95
102
|
specification_version: 4
|
96
103
|
summary: ExpressPigeon API Ruby Wrapper
|
97
104
|
test_files:
|
105
|
+
- spec/autoresponders_spec.rb
|
98
106
|
- spec/campaigns_spec.rb
|
99
107
|
- spec/contacts_spec.rb
|
100
108
|
- spec/lists_spec.rb
|
@@ -102,4 +110,9 @@ test_files:
|
|
102
110
|
- spec/pigeon_helper.rb
|
103
111
|
- spec/resources/upload.csv
|
104
112
|
- spec/templates_spec.rb
|
113
|
+
- test/README
|
114
|
+
- test/attachments/example.ics
|
115
|
+
- test/attachments/smile.pdf
|
105
116
|
- test/send.rb
|
117
|
+
- test/send_with_attachments.rb
|
118
|
+
- test/send_with_headers.rb
|