expresspigeon-ruby 0.0.8 → 0.0.9

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: 1091b71d05e2b52d8834c3e156b4a7abb1a7d581
4
- data.tar.gz: 0c6c20dfb96132e211cc05090d51f83170da212c
3
+ metadata.gz: 294edf79278fdc87552d25a9ea25245f0c77d760
4
+ data.tar.gz: f7ed25d8e26eb73b7e66044352c724a51e488472
5
5
  SHA512:
6
- metadata.gz: 63fbab303fa8bed86310e7c50208090e3466546d7f4fe782ac8dd66ac9acb89fad1d4b82dbad2e42846387316b66d6a59226752ce968d09166d5bb2c9e066d9f
7
- data.tar.gz: b3da497b86385ec668d652dc543b48ddbc7937ddf8e93866f83ec1b02ee24cd34b1cf239487ac5f170641f47597c7fd27c2a5e5b844a760cf10cb29578587855
6
+ metadata.gz: 02494b9f8a07d6ea1f16fd437a5aa0982d0ceb2e2fc839254c795aa899d377b514511b96bd67ee7fe8171a05680e0ccc6dd4e6590b1b29813802c6deb22de7ca
7
+ data.tar.gz: de2c151ea4f6903598beebd48070c45d2f065922862e02fae85db9b630e21e9499c47220107a3ff3203fb55427baa4fb32ec91fab54d50ee6bc23f9d2657d94f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- expresspigeon-ruby (0.0.6)
4
+ expresspigeon-ruby (0.0.8)
5
5
  rest-client (~> 1.8)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -53,7 +53,7 @@ puts MESSAGES.report message_response.id
53
53
  'jane@doe.com', #reply_to
54
54
  "Jane Doe", #from_name
55
55
  "Want to get out for a dinner?", #subject
56
- {first_name: 'Igor', eye_color: 'blue'}, #merge_fields
56
+ {first_name: 'John', main_course: 'stake'}, #merge_fields
57
57
  false, #view_online
58
58
  true, #click_tracking
59
59
  true, #suppress_address
@@ -58,11 +58,16 @@ module ExpressPigeon
58
58
  resp = Net::HTTP.start(uri.host, uri.port, :use_ssl => USE_SSL) do |http|
59
59
  http.request req
60
60
  end
61
- parsed = JSON.parse(resp.body)
62
- if parsed.kind_of? Hash
63
- MetaResponse.new parsed
61
+
62
+ if resp.content_type == 'application/json'
63
+ parsed = JSON.parse(resp.body)
64
+ if parsed.kind_of? Hash
65
+ MetaResponse.new parsed
66
+ else
67
+ parsed
68
+ end
64
69
  else
65
- parsed
70
+ resp.body
66
71
  end
67
72
  end
68
73
  end
@@ -103,7 +108,7 @@ module ExpressPigeon
103
108
  Messages.new
104
109
  end
105
110
 
106
- def self.auto_responders
111
+ def self.autoresponders
107
112
  AutoResponders.new
108
113
  end
109
114
 
@@ -12,10 +12,8 @@ module ExpressPigeon
12
12
  #
13
13
  # Returns an array of autoresponders.
14
14
  #
15
- # Docs: https://expresspigeon.com/api#auto_responders_get_all
16
- #
17
15
  def all
18
- get endpoint
16
+ get @endpoint
19
17
  end
20
18
 
21
19
  # Start for a contact
@@ -25,10 +23,9 @@ module ExpressPigeon
25
23
  # :param auto_responder_id: autoresponder id to be started for a contact
26
24
  # :param email: contact email
27
25
  #
28
- # Docs: https://expresspigeon.com/api#auto_responders_start
29
26
  #
30
27
  def start(auto_responder_id, email)
31
- post "#{endpoint}/#{auto_responder_id}/start", email: email
28
+ post "#{@endpoint}/#{auto_responder_id}/start", email: email
32
29
  end
33
30
 
34
31
  # Stop for a contact
@@ -41,7 +38,45 @@ module ExpressPigeon
41
38
  # Docs: https://expresspigeon.com/api#auto_responders_stop
42
39
  #
43
40
  def stop(auto_responder_id, email)
44
- post "#{endpoint}/#{auto_responder_id}/stop", email: email
41
+ post "#{@endpoint}/#{auto_responder_id}/stop", email: email
42
+ end
43
+
44
+ # Reports for a single responder
45
+ #
46
+ # :param auto_responder_id: autoresponder id to be stopped for a contact
47
+ # :param email: contact email
48
+ #
49
+ def report(auto_responder_id)
50
+ get "#{@endpoint}/#{auto_responder_id}"
51
+ end
52
+
53
+
54
+ # Reports bounces for autoresponder part
55
+ #
56
+ # :param auto_responder_id: autoresponder id to be stopped for a contact
57
+ # :param auto_responder_part_id: id of the autoresponder part in questions
58
+ #
59
+ def bounced(auto_responder_id, autoresponder_part_id)
60
+ get "#{@endpoint}/#{auto_responder_id}/#{autoresponder_part_id}/bounced"
61
+ end
62
+
63
+ # Reports unsubscribed for autoresponder part
64
+ #
65
+ # :param auto_responder_id: autoresponder id to be stopped for a contact
66
+ # :param auto_responder_part_id: id of the autoresponder part in questions
67
+ #
68
+ def unsubscribed(auto_responder_id, autoresponder_part_id)
69
+ get "#{@endpoint}/#{auto_responder_id}/#{autoresponder_part_id}/unsubscribed"
70
+ end
71
+
72
+
73
+ # Get spam reports for autoresponder part
74
+ #
75
+ # :param auto_responder_id: autoresponder id to be stopped for a contact
76
+ # :param auto_responder_part_id: id of the autoresponder part in questions
77
+ #
78
+ def spam(auto_responder_id, autoresponder_part_id)
79
+ get "#{@endpoint}/#{auto_responder_id}/#{autoresponder_part_id}/spam"
45
80
  end
46
81
  end
47
82
  end
@@ -14,6 +14,14 @@ module ExpressPigeon
14
14
  get "#{@endpoint}/#{campaign_id}"
15
15
  end
16
16
 
17
+ def opened(campaign_id)
18
+ get "#{@endpoint}/#{campaign_id}/opened"
19
+ end
20
+
21
+ def clicked(campaign_id)
22
+ get "#{@endpoint}/#{campaign_id}/clicked"
23
+ end
24
+
17
25
  def bounced(campaign_id)
18
26
  get "#{@endpoint}/#{campaign_id}/bounced"
19
27
  end
@@ -11,6 +11,7 @@ module ExpressPigeon
11
11
  end
12
12
 
13
13
 
14
+
14
15
  # JSON document represents a contact to be created or updated.
15
16
  # The email field is required.
16
17
  # When updating a contact, list_id is optional,
@@ -33,6 +33,13 @@ module ExpressPigeon
33
33
  end
34
34
 
35
35
 
36
+ #
37
+ #:returns: status of upload
38
+ #
39
+ def upload_status(list_id)
40
+ get "#{@endpoint}/upload_status/#{list_id}"
41
+ end
42
+
36
43
  ##
37
44
  # Removes a list with a given id. A list must be enabled and has no dependent subscriptions and/or scheduled campaigns.
38
45
  #
@@ -19,18 +19,20 @@ module ExpressPigeon
19
19
  # * +click_tracking+ - enable/disable click tracking (and URL rewriting)
20
20
  # * +suppress_address+ - enable/disable display of physical address at the bottom of newsletter.
21
21
  # * +attachments+ - array of file paths to attach to email. Size limit: 1k per attachment, maximum 3 attachments.
22
+ # * +headers+ - hash with headers to include into the message. The header 'Sender' will override a standard behavior of the platform.
22
23
  def send_message(template_id, to, reply_to, from_name, subject, merge_fields = nil, view_online = false,
23
- click_tracking = true, suppress_address = false, attachments = nil)
24
+ click_tracking = true, suppress_address = false, attachments = nil, headers = nil)
24
25
  if attachments
25
26
  upload(template_id, to, reply_to, from_name, subject, merge_fields, view_online, click_tracking,
26
- suppress_address, attachments)
27
+ suppress_address, attachments, headers)
27
28
  else
28
29
  post @endpoint, params = {template_id: template_id, to: to, reply_to: reply_to, from: from_name,
29
30
  subject: subject, merge_fields: merge_fields, view_online: view_online,
30
- click_tracking: click_tracking, suppress_address: suppress_address}
31
+ click_tracking: click_tracking, suppress_address: suppress_address, headers: headers}
31
32
  end
32
33
  end
33
34
 
35
+
34
36
  # Retrieve report for a single message.
35
37
  #
36
38
  # * +message_id+ - ID of a message sent previously
@@ -84,10 +86,10 @@ module ExpressPigeon
84
86
  # * +click_tracking+ - enable/disable click tracking (and URL rewriting)
85
87
  # * +suppress_address+ - enable/disable display of physical address at the bottom of newsletter.
86
88
  # * +attachments+ - array of file paths to attach to email. Size limit: 1k per attachment, maximum 3 attachments.
87
- def upload(template_id, to, reply_to, from_name, subject, merge_fields, view_online, click_tracking, suppress_address, attachments)
89
+ def upload(template_id, to, reply_to, from_name, subject, merge_fields, view_online, click_tracking, suppress_address, attachments, headers)
88
90
  path = "#{@root ? @root : ROOT}/#{@endpoint}"
89
91
  begin
90
- payload = prepare_payload(template_id, to, reply_to, from_name, subject, merge_fields, view_online, click_tracking, suppress_address, attachments)
92
+ payload = prepare_payload(template_id, to, reply_to, from_name, subject, merge_fields, view_online, click_tracking, suppress_address, attachments, headers)
91
93
  request = RestClient::Request.new(
92
94
  :method => :post,
93
95
  :headers => {:'X-auth-key' => get_auth_key},
@@ -108,7 +110,7 @@ module ExpressPigeon
108
110
  end
109
111
 
110
112
 
111
- def prepare_payload(template_id, to, reply_to, from, subject, merge_fields, view_online, click_tracking, suppress_address, attachments)
113
+ def prepare_payload(template_id, to, reply_to, from, subject, merge_fields, view_online, click_tracking, suppress_address, attachments, headers)
112
114
  payload = { multipart: true }
113
115
  payload[:template_id] = template_id
114
116
  payload[:to] = to
@@ -116,6 +118,7 @@ module ExpressPigeon
116
118
  payload[:subject] = subject
117
119
  payload[:from] = from
118
120
  payload[:merge_fields] = merge_fields.to_json
121
+ payload[:headers] = headers.to_json
119
122
  payload[:view_online] = view_online
120
123
  payload[:click_tracking] = click_tracking
121
124
  payload[:suppress_address] = suppress_address
@@ -1,5 +1,5 @@
1
1
  module Expresspigeon
2
2
  module API
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
@@ -0,0 +1,46 @@
1
+ require './lib/expresspigeon-ruby'
2
+ require 'pigeon_helper'
3
+
4
+ describe 'autoresponders integration test' do
5
+
6
+ include PigeonSpecHelper
7
+
8
+ it 'should return all autoresponders' do
9
+ res = ExpressPigeon::API.autoresponders.all
10
+ res.class.should == Array
11
+ res.size.should > 0
12
+ puts res
13
+ end
14
+
15
+ it 'should start autoresponder by id' do
16
+ res = ExpressPigeon::API.autoresponders.start 672, 'igor@polevoy.org'
17
+ puts res
18
+ end
19
+
20
+ it 'should stop autoresponder by id' do
21
+ res = ExpressPigeon::API.autoresponders.stop 672, 'igor@polevoy.org'
22
+ puts res
23
+ end
24
+
25
+ it 'should get single report' do
26
+ res = ExpressPigeon::API.autoresponders.report 672
27
+ puts res
28
+ end
29
+
30
+ it 'should get bounces for autoresponder part' do
31
+ res = ExpressPigeon::API.autoresponders.bounced 672, 746
32
+ puts res
33
+ end
34
+
35
+ it 'should get spam for autoresponder part' do
36
+ res = ExpressPigeon::API.autoresponders.spam 672, 746
37
+ puts res
38
+ end
39
+
40
+ it 'should get unsubscribed for autoresponder part' do
41
+ res = ExpressPigeon::API.autoresponders.unsubscribed 672, 746
42
+ puts res
43
+ end
44
+
45
+ end
46
+
@@ -6,55 +6,55 @@ describe 'campaigns integration test' do
6
6
  include PigeonSpecHelper
7
7
 
8
8
  it 'should return more than 0 campaign ids' do
9
- res = PIGEON.campaigns.all
9
+ res = ExpressPigeon::API.campaigns.all
10
10
  res.class.should == Array
11
11
  res.size.should > 0
12
12
  end
13
13
 
14
14
  it 'cannot send with missing parameters' do
15
- res = PIGEON.campaigns.send(:template_id => 15233, :name => 'API Test campaign',
16
- :from_name => 'Igor Polevoy', :reply_to => 'igor@polevoy.org',
17
- :subject => 'API test', :google_analytics => true)
15
+ res = ExpressPigeon::API.campaigns.send(:template_id => 15233, :name => 'API Test campaign',
16
+ :from_name => 'Igor Polevoy', :reply_to => 'igor@polevoy.org',
17
+ :subject => 'API test', :google_analytics => true)
18
18
  validate_response res, 400, 'error', /required parameters: list_id, template_id, name, from_name, reply_to, subject, google_analytics/
19
19
  end
20
20
 
21
21
  it 'cannot send with bad reply_to' do
22
- res = PIGEON.campaigns.send(:list_id => -1, :template_id => -1, :name => 'My Campaign', :from_name => 'John', :reply_to => 'j',
23
- :subject => 'Hi', :google_analytics => false)
22
+ res = ExpressPigeon::API.campaigns.send(:list_id => -1, :template_id => -1, :name => 'My Campaign', :from_name => 'John', :reply_to => 'j',
23
+ :subject => 'Hi', :google_analytics => false)
24
24
  validate_response res, 400, 'error', /reply_to should be valid email address/
25
25
  end
26
26
 
27
27
  it 'cannot send with non-existing template' do
28
- res = PIGEON.campaigns.send(:list_id => -1, :template_id => -1, :name => 'My Campaign', :from_name => 'John',
29
- :reply_to => 'j@j.j',
30
- :subject => 'Hi', :google_analytics => false)
28
+ res = ExpressPigeon::API.campaigns.send(:list_id => -1, :template_id => -1, :name => 'My Campaign', :from_name => 'John',
29
+ :reply_to => 'j@j.j',
30
+ :subject => 'Hi', :google_analytics => false)
31
31
  validate_response res, 400, 'error', /template=-1 is not found/
32
32
  end
33
33
 
34
34
  it 'cannot send to non-existing list' do
35
- res = PIGEON.campaigns.send(:list_id => -1, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
36
- :reply_to => 'j@j.j',
37
- :subject => 'Hi', :google_analytics => false)
35
+ res = ExpressPigeon::API.campaigns.send(:list_id => -1, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
36
+ :reply_to => 'j@j.j',
37
+ :subject => 'Hi', :google_analytics => false)
38
38
  validate_response res, 400, 'error', /list=-1 is not found/
39
39
  end
40
40
 
41
41
  it 'cannot send to disabled list' do
42
- res = PIGEON.campaigns.send(:list_id => LIST_ID, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
43
- :reply_to => 'j@j.j',
44
- :subject => 'Hi', :google_analytics => false)
42
+ res = ExpressPigeon::API.campaigns.send(:list_id => LIST_ID, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
43
+ :reply_to => 'j@j.j',
44
+ :subject => 'Hi', :google_analytics => false)
45
45
  validate_response res, 400, 'error', /list=#{DISABLED_LIST} is disabled/
46
46
  end
47
47
 
48
48
  it 'should create new list, add contact and send successful campaign' do
49
49
 
50
- list_resp = PIGEON.lists.create('My list', 'John', API_USER)
50
+ list_resp = ExpressPigeon::API.lists.create('My list', 'John', API_USER)
51
51
  list_id = list_resp.list.id
52
- PIGEON.contacts.upsert(list_id, {:email => API_USER})
53
- resp = PIGEON.campaigns.send(:list_id => list_id, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
54
- :reply_to => API_USER,
55
- :subject => 'Hi', :google_analytics => false)
52
+ ExpressPigeon::API.contacts.upsert(list_id, {:email => API_USER})
53
+ resp = ExpressPigeon::API.campaigns.send(:list_id => list_id, :template_id => TEMPLATE_ID, :name => 'My Campaign', :from_name => 'John',
54
+ :reply_to => API_USER,
55
+ :subject => 'Hi', :google_analytics => false)
56
56
  validate_response resp, 200, 'success', /new campaign created successfully/
57
- report = PIGEON.campaigns.report(resp.campaign_id)
57
+ report = ExpressPigeon::API.campaigns.report(resp.campaign_id)
58
58
  (report.delivered == 0 or report.delivered == 1).should be_true
59
59
  report.clicked.should eq 0
60
60
  report.opened.should eq 0
@@ -62,45 +62,45 @@ describe 'campaigns integration test' do
62
62
  (report.in_transit == 0 or report.in_transit == 1).should be_true
63
63
  report.unsubscribed.should eq 0
64
64
  report.bounced.should eq 0
65
- bounced = PIGEON.campaigns.bounced(resp.campaign_id)
66
- unsubscribed = PIGEON.campaigns.unsubscribed(resp.campaign_id)
67
- spam = PIGEON.campaigns.spam(resp.campaign_id)
65
+ bounced = ExpressPigeon::API.campaigns.bounced(resp.campaign_id)
66
+ unsubscribed = ExpressPigeon::API.campaigns.unsubscribed(resp.campaign_id)
67
+ spam = ExpressPigeon::API.campaigns.spam(resp.campaign_id)
68
68
 
69
69
  bounced.size.should eq 0
70
70
  unsubscribed.size.should eq 0
71
71
  spam.size.should eq 0
72
72
 
73
- resp = PIGEON.contacts.delete(API_USER)
73
+ resp = ExpressPigeon::API.contacts.delete(API_USER)
74
74
  validate_response resp, 200, 'success', /contact=non@non.non deleted successfully/
75
75
 
76
- resp = PIGEON.contacts.find_by_email(API_USER)
76
+ resp = ExpressPigeon::API.contacts.find_by_email(API_USER)
77
77
  validate_response resp, 404, 'error', /contact=non@non.non not found/
78
78
 
79
- resp = PIGEON.lists.delete(list_id)
79
+ resp = ExpressPigeon::API.lists.delete(list_id)
80
80
  validate_response resp, 200, 'success', /deleted successfully/
81
81
  end
82
82
 
83
83
 
84
84
  it 'cannot send campaign if scheduling with bad date' do
85
85
 
86
- list_resp = PIGEON.lists.create "My list", "John", API_USER
87
- resp = PIGEON.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
86
+ list_resp = ExpressPigeon::API.lists.create "My list", "John", API_USER
87
+ resp = ExpressPigeon::API.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
88
88
 
89
- :from_name => 'John',
90
- :reply_to => API_USER, :subject => 'Hi',
91
- :google_analytics => false, :schedule_for => "2013-05-28"
89
+ :from_name => 'John',
90
+ :reply_to => API_USER, :subject => 'Hi',
91
+ :google_analytics => false, :schedule_for => "2013-05-28"
92
92
 
93
93
  validate_response resp, 400, 'error', /schedule_for is not in ISO date format, example: 2013-05-28T17:19:50.779/
94
- resp = PIGEON.lists.delete(list_resp.list.id)
94
+ resp = ExpressPigeon::API.lists.delete(list_resp.list.id)
95
95
  validate_response resp, 200, 'success', /deleted successfully/
96
96
  end
97
97
 
98
98
  it 'should not schedule campaign with date in the past' do
99
- list_resp = PIGEON.lists.create('My list', 'John', API_USER)
100
- resp = PIGEON.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
101
- :from_name => 'John',
102
- :reply_to => API_USER, :subject => 'Hi',
103
- :google_analytics => false, :schedule_for => '2010-05-28T17:19:50.779+0300'
99
+ list_resp = ExpressPigeon::API.lists.create('My list', 'John', API_USER)
100
+ resp = ExpressPigeon::API.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
101
+ :from_name => 'John',
102
+ :reply_to => API_USER, :subject => 'Hi',
103
+ :google_analytics => false, :schedule_for => '2010-05-28T17:19:50.779+0300'
104
104
 
105
105
  validate_response resp, 400, 'error', /schedule_for should be in the future/
106
106
  end
@@ -108,26 +108,48 @@ describe 'campaigns integration test' do
108
108
 
109
109
 
110
110
  it 'should delete scheduled campaign' do
111
- list_resp = PIGEON.lists.create('My list', 'John', API_USER)
112
- resp = PIGEON.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
113
- :from_name => 'John',
114
- :reply_to => API_USER, :subject => 'Hi',
115
- :google_analytics => false, :schedule_for => '2030-05-28T17:19:50.779+0300'
111
+ list_resp = ExpressPigeon::API.lists.create('My list', 'John', API_USER)
112
+ resp = ExpressPigeon::API.campaigns.schedule :list_id => list_resp.list.id, :template_id => TEMPLATE_ID, :name => 'My Campaign',
113
+ :from_name => 'John',
114
+ :reply_to => API_USER, :subject => 'Hi',
115
+ :google_analytics => false, :schedule_for => '2030-05-28T17:19:50.779+0300'
116
116
 
117
117
  validate_response resp, 200, 'success', /new campaign created successfully/
118
118
  campaign_id = resp.campaign_id
119
- resp = PIGEON.campaigns.delete campaign_id
119
+ resp = ExpressPigeon::API.campaigns.delete campaign_id
120
120
  resp.message.should eq "campaign #{campaign_id} was deleted"
121
121
  end
122
122
 
123
123
 
124
124
  # This test uses account ep.api.tester@expresspigeon.com and expects two specific campaign there.
125
125
  it 'should list campaigns from account' do
126
- campaigns = PIGEON.campaigns.all
126
+ campaigns = ExpressPigeon::API.campaigns.all
127
127
  campaigns.size.should eq 4
128
- campaigns = PIGEON.campaigns.all from_id: 53853
128
+ campaigns = ExpressPigeon::API.campaigns.all from_id: 53853
129
129
  campaigns.size.should eq 3
130
130
  end
131
131
 
132
+
133
+ it 'should get opened from campaign' do
134
+ opened = ExpressPigeon::API.campaigns.opened 441663
135
+
136
+ puts opened
137
+
138
+ end
139
+
140
+ it 'should get clicked from campaign' do
141
+ clicked = ExpressPigeon::API.campaigns.clicked 441663
142
+
143
+ puts clicked
144
+
145
+ end
146
+
147
+ it 'should get unsubs from campaign' do
148
+ unsubscribed = ExpressPigeon::API.campaigns.unsubscribed 441663
149
+
150
+ puts unsubscribed
151
+
152
+ end
153
+
132
154
  end
133
155
 
@@ -6,24 +6,24 @@ describe 'contacts integration test' do
6
6
  include PigeonSpecHelper
7
7
 
8
8
  it 'should not create contact without contact data' do
9
- resp = PIGEON.contacts.upsert(-1, {})
9
+ resp = ExpressPigeon::API.contacts.upsert(-1, {})
10
10
  validate_response resp, 400, 'error', /email is required/
11
11
  end
12
12
 
13
13
  it 'should not create contact without email' do
14
- resp = PIGEON.contacts.upsert -1, :email => '', :first_name => 'Marylin', :last_name => 'Monroe'
14
+ resp = ExpressPigeon::API.contacts.upsert -1, :email => '', :first_name => 'Marylin', :last_name => 'Monroe'
15
15
  validate_response resp, 400, 'error', /email is required/
16
16
  end
17
17
 
18
18
  it 'should not add contact with too many custom fields' do
19
19
  custom_fields = {}
20
20
  (1..25).each { |n| custom_fields["custom_field_#{n}"] = n }
21
- resp = PIGEON.contacts.upsert -1, :email => "mary@e.e", :custom_fields => custom_fields
21
+ resp = ExpressPigeon::API.contacts.upsert -1, :email => "mary@e.e", :custom_fields => custom_fields
22
22
  validate_response resp, 400, 'error', /You cannot create more than 20 custom fields. Use one of the 'custom_fields'./
23
23
  end
24
24
 
25
25
  it 'should not create new contact without list_id' do
26
- resp = PIGEON.contacts.upsert '', :email => 'ee@e.e', :first_name => 'Marylin', :last_name => 'Monroe'
26
+ resp = ExpressPigeon::API.contacts.upsert '', :email => 'ee@e.e', :first_name => 'Marylin', :last_name => 'Monroe'
27
27
  # TODO: this is a pretty crappy message from API https://redmine.expresspigeon.com/issues/5479
28
28
  validate_response resp, 400, 'error', /failed to convert: '' to Long/
29
29
  end
@@ -34,21 +34,21 @@ describe 'contacts integration test' do
34
34
  # end
35
35
 
36
36
  it 'cannot upsert into non-existent_list' do
37
- resp = PIGEON.contacts.upsert -123, :email => "e@e.e"
37
+ resp = ExpressPigeon::API.contacts.upsert -123, :email => "e@e.e"
38
38
  # TODO: uncomment after: https://redmine.expresspigeon.com/issues/5478
39
39
  validate_response resp, 404, 'error', /contact=e@e.e not found/
40
40
  end
41
41
 
42
42
  it 'creates list with contacts' do
43
- list_response = PIGEON.lists.create 'My List', 'John Doe', 'john@doe.com'
43
+ list_response = ExpressPigeon::API.lists.create 'My List', 'John Doe', 'john@doe.com'
44
44
  list_id = list_response.list.id
45
- resp = PIGEON.contacts.upsert list_id, email: "mary@e.e",
46
- :custom_fields => {:custom_field_1 => "custom_value_1", }
45
+ resp = ExpressPigeon::API.contacts.upsert list_id, email: "mary@e.e",
46
+ :custom_fields => {:custom_field_1 => "custom_value_1", }
47
47
  validate_response resp, 200, 'success', /contacts created\/updated successfully/
48
48
 
49
- resp = PIGEON.contacts.find_by_email "mary@e.e"
49
+ resp = ExpressPigeon::API.contacts.find_by_email "mary@e.e"
50
50
 
51
- PIGEON.lists.delete(list_id)
51
+ ExpressPigeon::API.lists.delete(list_id)
52
52
 
53
53
  resp.custom_fields.custom_field_1 eq "custom_value_1"
54
54
  resp.email.should eq 'mary@e.e'
@@ -56,16 +56,16 @@ describe 'contacts integration test' do
56
56
  end
57
57
 
58
58
  it 'creates list non-existent custom field' do
59
- list_response = PIGEON.lists.create 'My List', 'John Doe', 'a@a.a'
59
+ list_response = ExpressPigeon::API.lists.create 'My List', 'John Doe', 'a@a.a'
60
60
  list_id = list_response.list.id
61
- resp = PIGEON.contacts.upsert(list_id, {:email => "mary@e.e", :custom_fields => {:c => "c", }})
62
- PIGEON.lists.delete(list_id)
61
+ resp = ExpressPigeon::API.contacts.upsert(list_id, {:email => "mary@e.e", :custom_fields => {:c => "c", }})
62
+ ExpressPigeon::API.lists.delete(list_id)
63
63
  validate_response resp, 200, 'success', nil
64
64
  end
65
65
 
66
66
  it 'cannot export contacts from list without list_id' do
67
67
  content = ''
68
- PIGEON.lists.csv "-1" do |c|
68
+ ExpressPigeon::API.lists.csv "-1" do |c|
69
69
  content << c
70
70
  end
71
71
  resp = JSON.parse(content)
@@ -76,7 +76,7 @@ describe 'contacts integration test' do
76
76
 
77
77
  it 'should get contacts from suppressed list' do
78
78
  content =''
79
- PIGEON.lists.csv "suppress_list" do |c|
79
+ ExpressPigeon::API.lists.csv "suppress_list" do |c|
80
80
  content += c
81
81
  end
82
82
  resp = content.split /\n/
@@ -87,13 +87,13 @@ describe 'contacts integration test' do
87
87
  end
88
88
 
89
89
  it 'should get single contact' do
90
- resp = PIGEON.contacts.find_by_email 'suppressed@e.e'
90
+ resp = ExpressPigeon::API.contacts.find_by_email 'suppressed@e.e'
91
91
  # TODO: have these on account before checking.
92
92
  # resp.email.should eq 'suppressed@e.e'
93
93
  end
94
94
 
95
95
  it 'should not find non existent contact' do
96
- resp = PIGEON.contacts.find_by_email 'a@a.a'
96
+ resp = ExpressPigeon::API.contacts.find_by_email 'a@a.a'
97
97
  # TODO: have these on account before checking.
98
98
 
99
99
  # validate_response resp, 404, 'error', /contact=a@a.a not found/
@@ -103,56 +103,56 @@ describe 'contacts integration test' do
103
103
 
104
104
 
105
105
 
106
- list_response = PIGEON.lists.create('My List', 'John Doe', "a@a.a")
106
+ list_response = ExpressPigeon::API.lists.create('My List', 'John Doe', "a@a.a")
107
107
 
108
108
  # PIGEON.contacts.find_by_email("mary@e.e").last_name.should eq 'Doe'
109
109
 
110
- resp = PIGEON.contacts.upsert list_response.list.id,
111
- :email => 'mary@e.e', :first_name => 'Mary', :last_name => 'Johns'
110
+ resp = ExpressPigeon::API.contacts.upsert list_response.list.id,
111
+ :email => 'mary@e.e', :first_name => 'Mary', :last_name => 'Johns'
112
112
  validate_response resp, 200, 'success', /contacts created\/updated successfully/
113
- PIGEON.contacts.find_by_email("mary@e.e").last_name.should eq 'Johns'
114
- PIGEON.lists.delete list_response.list.id
113
+ ExpressPigeon::API.contacts.find_by_email("mary@e.e").last_name.should eq 'Johns'
114
+ ExpressPigeon::API.lists.delete list_response.list.id
115
115
  end
116
116
 
117
117
  it 'cannot delete contact with non-existent email' do
118
- res = PIGEON.contacts.delete("g@g.g")
118
+ res = ExpressPigeon::API.contacts.delete("g@g.g")
119
119
  validate_response res, 404, 'error', /contact=g@g.g not found/
120
120
  end
121
121
 
122
122
  it 'should not delete suppressed contact' do
123
- res = PIGEON.contacts.delete("suppressed@e.e")
123
+ res = ExpressPigeon::API.contacts.delete("suppressed@e.e")
124
124
 
125
125
  # TODO: add this to the account at setup.
126
126
  # validate_response res, 400, 'error', /contact=suppressed@e.e is in suppress list/
127
127
  end
128
128
 
129
129
  it 'should delete single contact from all lists' do
130
- list_response = PIGEON.lists.create 'My List', 'Jane Doe', 'a@a.a'
131
- PIGEON.contacts.upsert list_response.list.id, :email => 'mary@e.e'
132
- res = PIGEON.contacts.delete 'mary@e.e'
130
+ list_response = ExpressPigeon::API.lists.create 'My List', 'Jane Doe', 'a@a.a'
131
+ ExpressPigeon::API.contacts.upsert list_response.list.id, :email => 'mary@e.e'
132
+ res = ExpressPigeon::API.contacts.delete 'mary@e.e'
133
133
  validate_response res, 200, 'success', /contact=mary@e.e deleted successfully/
134
- PIGEON.lists.delete list_response.list.id
134
+ ExpressPigeon::API.lists.delete list_response.list.id
135
135
  end
136
136
 
137
137
  it 'deletes single contact from single list' do
138
- list_response = PIGEON.lists.create 'My List', 'John D.', 'a@a.a'
139
- list_response_2 = PIGEON.lists.create('My List2', "Jane D.", 'a@a.a')
140
- PIGEON.contacts.upsert(list_response.list.id, {:email => 'mary@e.e'})
141
- PIGEON.contacts.upsert(list_response_2.list.id, {:email => 'mary@e.e'})
138
+ list_response = ExpressPigeon::API.lists.create 'My List', 'John D.', 'a@a.a'
139
+ list_response_2 = ExpressPigeon::API.lists.create('My List2', "Jane D.", 'a@a.a')
140
+ ExpressPigeon::API.contacts.upsert(list_response.list.id, {:email => 'mary@e.e'})
141
+ ExpressPigeon::API.contacts.upsert(list_response_2.list.id, {:email => 'mary@e.e'})
142
142
 
143
- res = PIGEON.contacts.delete 'mary@e.e', list_response.list.id
143
+ res = ExpressPigeon::API.contacts.delete 'mary@e.e', list_response.list.id
144
144
 
145
145
  validate_response res, 200, 'success', /contact=mary@e.e deleted successfully/
146
146
 
147
147
  contacts_exported = ''
148
- PIGEON.lists.csv list_response.list.id do |c|
148
+ ExpressPigeon::API.lists.csv list_response.list.id do |c|
149
149
  contacts_exported << c
150
150
  end
151
151
  contacts_exported = contacts_exported.split /\n/
152
152
  contacts_exported.size.should eq 1
153
153
 
154
154
  contacts_exported_2 = ''
155
- PIGEON.lists.csv list_response_2.list.id do |c|
155
+ ExpressPigeon::API.lists.csv list_response_2.list.id do |c|
156
156
  contacts_exported_2 << c
157
157
  end
158
158
 
@@ -160,9 +160,9 @@ describe 'contacts integration test' do
160
160
  contacts_exported_2.size.should eq 2
161
161
  contacts_exported_2[1].should =~ /"mary@e.e"/
162
162
 
163
- PIGEON.lists.delete(list_response.list.id)
164
- PIGEON.lists.delete(list_response_2.list.id)
165
- PIGEON.contacts.delete('mary@e.e')
163
+ ExpressPigeon::API.lists.delete(list_response.list.id)
164
+ ExpressPigeon::API.lists.delete(list_response_2.list.id)
165
+ ExpressPigeon::API.contacts.delete('mary@e.e')
166
166
  end
167
167
  end
168
168
 
@@ -6,39 +6,39 @@ describe 'lists integration test' do
6
6
  include PigeonSpecHelper
7
7
 
8
8
  it 'test_create_and_delete_new_list(self):' do
9
- contact_list = PIGEON.lists.create 'Active customers', 'Bob', 'bob@acmetools.com'
9
+ contact_list = ExpressPigeon::API.lists.create 'Active customers', 'Bob', 'bob@acmetools.com'
10
10
  validate_response contact_list, 200, 'success', /list=#{contact_list.list.id} created\/updated successfully/
11
11
  contact_list.list.name.should eq "Active customers"
12
12
  contact_list.list.from_name.should eq "Bob"
13
13
  contact_list.list.reply_to.should eq "bob@acmetools.com"
14
14
  contact_list.list.contact_count.should eq 0
15
- res = PIGEON.lists.delete contact_list.list.id
15
+ res = ExpressPigeon::API.lists.delete contact_list.list.id
16
16
  validate_response res, 200, 'success', /list=#{contact_list.list.id} deleted successfully/
17
17
  end
18
18
 
19
19
  it 'should update existing list' do
20
- contact_list = PIGEON.lists.create("Update", "Bob", "bob@acmetools.com")
21
- res = PIGEON.lists.update contact_list.list.id, :name => 'Updated Name', :from_name => 'Bob', :reply_to => 'Frank@zappa.com'
20
+ contact_list = ExpressPigeon::API.lists.create("Update", "Bob", "bob@acmetools.com")
21
+ res = ExpressPigeon::API.lists.update contact_list.list.id, :name => 'Updated Name', :from_name => 'Bob', :reply_to => 'Frank@zappa.com'
22
22
  validate_response res, 200, 'success', /list=#{res.list.id} created\/updated successfully/
23
23
  res.list.name.should eq "Updated Name"
24
24
  res.list.from_name.should eq 'Bob'
25
- res = PIGEON.lists.delete(contact_list.list.id)
25
+ res = ExpressPigeon::API.lists.delete(contact_list.list.id)
26
26
  validate_response res, 200, 'success', /list=#{contact_list.list.id} deleted successfully/
27
27
  end
28
28
 
29
29
 
30
30
  it 'should upload contacts as CSV file' do
31
31
  list_name = "Upload_#{Kernel.rand(9999).to_s}"
32
- list_resp = PIGEON.lists.create(list_name, 'Bob', 'bob@acmetools.com')
32
+ list_resp = ExpressPigeon::API.lists.create(list_name, 'Bob', 'bob@acmetools.com')
33
33
  begin
34
- resp = PIGEON.lists.upload(list_resp.list.id, 'spec/resources/upload.csv')
34
+ resp = ExpressPigeon::API.lists.upload(list_resp.list.id, 'spec/resources/upload.csv')
35
35
  validate_response resp, 200, 'success', /file uploaded successfully/
36
- res = PIGEON.contacts.find_by_email 'x@x.x'
36
+ res = ExpressPigeon::API.contacts.find_by_email 'x@x.x'
37
37
  res.lists[0]['id'].should eq list_resp.list.id
38
38
  ensure
39
- res = PIGEON.lists.delete(list_resp.list.id)
39
+ res = ExpressPigeon::API.lists.delete(list_resp.list.id)
40
40
  validate_response res, 200, 'success', /list=#{list_resp.list.id} deleted successfully/
41
- PIGEON.contacts.find_by_email('x@x.x').message.should eq 'contact=x@x.x not found'
41
+ ExpressPigeon::API.contacts.find_by_email('x@x.x').message.should eq 'contact=x@x.x not found'
42
42
  end
43
43
  end
44
44
 
@@ -72,11 +72,19 @@ describe 'lists integration test' do
72
72
  # self.assertEqual(res.code, 404)
73
73
  # self.assertEqual(res.message, "list=-1 not found")
74
74
  #
75
- # def test_upload_status_without_upload_id(self):
76
- # res = self.api.lists.upload_status("")
77
- # self.assertEqual(res.code, 400)
78
- # self.assertEqual(res.status, "error")
79
- # self.assertEqual(res.message, "you must provide upload id")
75
+ it 'should check upload status' do
76
+ list_response = ExpressPigeon::API.lists.create("My List", "a@a.a", "a@a.a")
77
+ resp = ExpressPigeon::API.lists.upload(list_response.list.id, 'spec/resources/upload.csv')
78
+
79
+ sleep 20
80
+
81
+ begin
82
+ puts ExpressPigeon::API.lists.upload_status list_response.list.id
83
+ ensure
84
+ ExpressPigeon::API.lists.delete list_response.list.id
85
+ end
86
+
87
+ end
80
88
  #
81
89
  # def test_enabled_list_removal(self):
82
90
  # list_resp = self.api.lists.create("My list", "John", os.environ['EXPRESSPIGEON_API_USER'])
@@ -102,22 +110,32 @@ describe 'lists integration test' do
102
110
  # "could not delete list={0}, it has dependent subscriptions and/or scheduled campaigns".format(
103
111
  # list_resp.list.id))
104
112
  #
105
- # def test_export_csv(self):
106
- # list_response = self.api.lists.create("My List", "a@a.a", "a@a.a")
107
- # self.api.contacts.upsert(list_response.list.id, {"email": "mary@a.a"})
108
- #
109
- # res = self.api.lists.csv(list_response.list.id).split("\n")
110
- # self.assertEquals(len(res), 2)
111
- # headers = '"Email", "First name", "Last name", "City", "Phone", "Company", "Title", "Address 1", "Address 2", ' \
112
- # '"State", "Zip", "Country", "Date of birth", "custom_field_1", "custom_field_10", "custom_field_11", ' \
113
- # '"custom_field_12", "custom_field_13", "custom_field_18", "custom_field_19", "custom_field_2", ' \
114
- # '"custom_field_20", "custom_field_21", "custom_field_22", "custom_field_23", "custom_field_24", ' \
115
- # '"custom_field_3", "custom_field_4", "custom_field_5", "custom_field_6", "custom_field_7", ' \
116
- # '"custom_field_8", "custom_field_9"'
117
- # self.assertEquals(res[0], headers)
118
- # self.assertEquals(res[1], '"mary@a.a",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,')
119
- #
120
- # self.api.lists.delete(list_response.list.id)
121
- # self.api.contacts.delete("mary@a.a")
113
+ it 'should upload and download CSV' do
114
+ list_response = ExpressPigeon::API.lists.create("My List", "a@a.a", "a@a.a")
115
+ resp = ExpressPigeon::API.lists.upload(list_response.list.id, 'spec/resources/upload.csv')
116
+ res = ExpressPigeon::API.lists.csv(list_response.list.id)
117
+ ExpressPigeon::API.lists.delete list_response.list.id
118
+
119
+ count = 0
120
+ res.each_line do |line|
121
+ count = count + 1
122
+ end
123
+ count.should eq 4
124
+
125
+
126
+
127
+ # self.assertEquals(len(res), 2)
128
+ # headers = '"Email", "First name", "Last name", "City", "Phone", "Company", "Title", "Address 1", "Address 2", ' \
129
+ # '"State", "Zip", "Country", "Date of birth", "custom_field_1", "custom_field_10", "custom_field_11", ' \
130
+ # '"custom_field_12", "custom_field_13", "custom_field_18", "custom_field_19", "custom_field_2", ' \
131
+ # '"custom_field_20", "custom_field_21", "custom_field_22", "custom_field_23", "custom_field_24", ' \
132
+ # '"custom_field_3", "custom_field_4", "custom_field_5", "custom_field_6", "custom_field_7", ' \
133
+ # '"custom_field_8", "custom_field_9"'
134
+ # self.assertEquals(res[0], headers)
135
+ # self.assertEquals(res[1], '"mary@a.a",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,')
136
+ #
137
+ # self.api.lists.delete(list_response.list.id)
138
+ # self.api.contacts.delete("mary@a.a")
139
+ end
122
140
 
123
141
  end
@@ -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 = PIGEON.messages.send_message 115, ENV['TARGET_EMAIL'], ENV['TARGET_EMAIL'], "Team ExpressPigeon", "Hi there!",
36
- :first_name => "Igor"
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 = PIGEON.messages.report(message_response.id)
38
+ report = ExpressPigeon::API.messages.report(message_response.id)
39
39
  report.id.should eq message_response.id
40
40
  end
41
41
 
@@ -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 'test_sending_multiple_messages_and_get_reports_for_today(self):' do
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 = PIGEON.messages.send_message 4905, ENV['TARGET_EMAIL'], ENV['TARGET_EMAIL'],
98
- 'Team EP', "Hi, there!", :first_name => "Bob"
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 = PIGEON.messages.send_message 4905, ENV['TARGET_EMAIL'], ENV['TARGET_EMAIL'],
104
- 'Team EP', "Hi, there!", :first_name => "Bob"
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 = PIGEON.messages.reports (message_response.id - 1), start, finish
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,16 +126,16 @@ describe 'transactional messages integration test' do
124
126
  # return report[0]
125
127
 
126
128
 
127
- it 'should from payload hash' do
129
+ it 'should prepare payload hash' do
128
130
 
129
- payload = PIGEON.messages.prepare_payload(123, #template_id
130
- 'john@doe.com',
131
- 'jane@doe.com',
132
- 'Jane Doe',
133
- 'Hello, Dolly!',
134
- {eye_color: 'blue', body_shape:'pear'},
135
- false, true, false,
136
- %w(spec/resources/attachment1.txt spec/resources/attachment2.txt))
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), {})
137
139
 
138
140
  payload[:multipart].should eq true
139
141
  payload[:template_id].should eq 123
@@ -1,5 +1,3 @@
1
- PIGEON = ExpressPigeon::API
2
-
3
1
 
4
2
  TEMPLATE_ID = ENV['TEMPLATE_ID']
5
3
  LIST_ID = ENV['LIST_ID']
@@ -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 = PIGEON.templates.copy 34830, "new template", :content => "Hello Template World!"
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 = PIGEON.templates.delete template_id
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
@@ -0,0 +1,19 @@
1
+
2
+ require_relative '../lib/expresspigeon-ruby.rb'
3
+
4
+ MESSAGES = ExpressPigeon::API.messages.auth_key(ENV['AUTH_KEY'])
5
+
6
+
7
+ puts MESSAGES.send_message(
8
+ 390243, # template_id
9
+ 'igor@polevoy.org', #to
10
+ 'igor@polevoy.org', #reply_to
11
+ "Igor Polevoy", #from_name
12
+ "Hi there! Sending with a heades", #subject
13
+ {first_name: 'Igor', eye_color: 'brown'}, #merge_fields
14
+ false, #view_online
15
+ true, #click_tracking
16
+ true, #suppress_address
17
+ {}, #file paths to upload as attachments
18
+ {Sender: 'Vasya Pupkin <vasya@polevoy.org>'}
19
+ )
@@ -3,17 +3,20 @@ require_relative '../lib/expresspigeon-ruby.rb'
3
3
 
4
4
  MESSAGES = ExpressPigeon::API.messages.auth_key(ENV['AUTH_KEY'])
5
5
 
6
- attachments = %W{attachments/attachment1.txt attachments/smile.pdf attachments/example.ics}
6
+ #attachments = %W{attachments/attachment1.txt attachments/smile.pdf attachments/example.ics}
7
+ #attachments = %W{/home/igor/tmp/The-Definitive-Guide-To-Mobile-Marketing-Marketo.pdf}
8
+ attachments = %W{/home/igor/tmp/Express-Pigeon-PropertyRadar-MSA-12-13-15.pdf}
7
9
 
8
10
  puts MESSAGES.send_message(
9
- 1527, # template_id
10
- 'igor@expresspigeon.com', #to
11
+ 390243, # template_id
12
+ 'igor@polevoy.org', #to
11
13
  'igor@polevoy.org', #reply_to
12
14
  "Igor Polevoy", #from_name
13
- "Hi there! Two attachments and a calendar - Ruby", #subject
15
+ "Hi there! Attachments and header", #subject
14
16
  {first_name: 'Igor', eye_color: 'blue'}, #merge_fields
15
17
  false, #view_online
16
18
  true, #click_tracking
17
19
  true, #suppress_address
18
- attachments #file paths to upload as attachments
20
+ attachments, #file paths to upload as attachments
21
+ {Sender: 'Vasya Pupkin <vasya@polevoy.org>'}
19
22
  )
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.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ipolevoy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-14 00:00:00.000000000 Z
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -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
@@ -73,6 +74,7 @@ files:
73
74
  - test/README
74
75
  - test/attachments/example.ics
75
76
  - test/attachments/smile.pdf
77
+ - test/send.rb
76
78
  - test/send_with_attachments.rb
77
79
  homepage: https://github.com/expresspigeon/expresspigeon-ruby
78
80
  licenses:
@@ -99,6 +101,7 @@ signing_key:
99
101
  specification_version: 4
100
102
  summary: ExpressPigeon API Ruby Wrapper
101
103
  test_files:
104
+ - spec/autoresponders_spec.rb
102
105
  - spec/campaigns_spec.rb
103
106
  - spec/contacts_spec.rb
104
107
  - spec/lists_spec.rb
@@ -109,4 +112,5 @@ test_files:
109
112
  - test/README
110
113
  - test/attachments/example.ics
111
114
  - test/attachments/smile.pdf
115
+ - test/send.rb
112
116
  - test/send_with_attachments.rb