sendgrid4r 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +1 -0
- data/lib/client.rb +1 -0
- data/lib/sendgrid4r/factory/campaign_factory.rb +25 -0
- data/lib/sendgrid4r/factory/segment_factory.rb +8 -4
- data/lib/sendgrid4r/rest/api.rb +2 -0
- data/lib/sendgrid4r/rest/campaigns/campaigns.rb +128 -0
- data/lib/sendgrid4r/rest/contacts/lists.rb +7 -5
- data/lib/sendgrid4r/rest/contacts/recipients.rb +25 -31
- data/lib/sendgrid4r/rest/contacts/segments.rb +4 -9
- data/lib/sendgrid4r/rest/request.rb +3 -0
- data/lib/sendgrid4r/version.rb +1 -1
- data/spec/client_spec.rb +21 -8
- data/spec/factory/campaign_factory_spec.rb +38 -0
- data/spec/factory/segment_factory_spec.rb +0 -2
- data/spec/rest/campaigns/campaigns_spec.rb +454 -0
- data/spec/rest/contacts/lists_spec.rb +10 -12
- data/spec/rest/contacts/recipients_spec.rb +80 -133
- data/spec/rest/contacts/segments_spec.rb +24 -109
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d7f4961aa315c9383c28064b91f827b5649cca5
|
4
|
+
data.tar.gz: 97bcf08a8000e314ac46d0641078112bb83eeb2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 764e730d5f55c68eb2b1d9269b16b50419040f023ffc1e316842fa83607ea4f9f2333a72027318b136f8c0571a741b544a7d3840b6ced14c38172658b30b3c8d
|
7
|
+
data.tar.gz: ccf33b5cb94663a33d54b49cf21b5fed12f4a180ce208b6f78c2938a227907518d57770c7c4da73fcc9a6e0a46ad33341127f41c14180f9de6beb1b65455446f
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/lib/client.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
3
|
+
|
4
|
+
module SendGrid4r
|
5
|
+
module Factory
|
6
|
+
#
|
7
|
+
# SendGrid Web API v3 Campaign Factory Class implementation
|
8
|
+
#
|
9
|
+
class CampaignFactory
|
10
|
+
def create(title: nil, subject: nil, sender_id: nil, list_ids: nil,
|
11
|
+
segment_ids: nil, categories: nil, suppression_group_id: nil,
|
12
|
+
html_content: nil, plain_content: nil)
|
13
|
+
segment = SendGrid4r::REST::Campaigns::Campaigns::Campaign.new(
|
14
|
+
nil, title, subject, sender_id, list_ids, segment_ids, categories,
|
15
|
+
suppression_group_id, html_content, plain_content, nil, nil
|
16
|
+
)
|
17
|
+
hash = segment.to_h
|
18
|
+
segment.to_h.each do |key, value|
|
19
|
+
hash.delete(key) if value.nil?
|
20
|
+
end
|
21
|
+
hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -7,14 +7,18 @@ module SendGrid4r
|
|
7
7
|
# SendGrid Web API v3 Segment Factory Class implementation
|
8
8
|
#
|
9
9
|
class SegmentFactory
|
10
|
-
def create(name
|
11
|
-
SendGrid4r::REST::Contacts::Segments::Segment.new(
|
10
|
+
def create(name: nil, list_id: nil, conditions:)
|
11
|
+
segment = SendGrid4r::REST::Contacts::Segments::Segment.new(
|
12
12
|
nil,
|
13
13
|
name,
|
14
|
-
|
14
|
+
list_id,
|
15
15
|
conditions,
|
16
16
|
nil
|
17
|
-
)
|
17
|
+
)
|
18
|
+
hash = segment.to_h
|
19
|
+
hash.delete(:id)
|
20
|
+
hash.delete(:list_id) if list_id.nil?
|
21
|
+
hash
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
data/lib/sendgrid4r/rest/api.rb
CHANGED
@@ -27,6 +27,7 @@ require 'sendgrid4r/rest/contacts/lists'
|
|
27
27
|
require 'sendgrid4r/rest/contacts/recipients'
|
28
28
|
require 'sendgrid4r/rest/contacts/reserved_fields'
|
29
29
|
require 'sendgrid4r/rest/contacts/segments'
|
30
|
+
require 'sendgrid4r/rest/campaigns/campaigns'
|
30
31
|
require 'sendgrid4r/rest/api_keys/api_keys'
|
31
32
|
require 'sendgrid4r/rest/subusers/subusers'
|
32
33
|
require 'sendgrid4r/rest/email_activity/email_activity'
|
@@ -66,6 +67,7 @@ module SendGrid4r
|
|
66
67
|
include SendGrid4r::REST::Contacts::Recipients
|
67
68
|
include SendGrid4r::REST::Contacts::ReservedFields
|
68
69
|
include SendGrid4r::REST::Contacts::Segments
|
70
|
+
include SendGrid4r::REST::Campaigns::Campaigns
|
69
71
|
include SendGrid4r::REST::ApiKeys
|
70
72
|
include SendGrid4r::REST::Subusers
|
71
73
|
include SendGrid4r::REST::EmailActivity
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'sendgrid4r/rest/request'
|
5
|
+
|
6
|
+
module SendGrid4r
|
7
|
+
module REST
|
8
|
+
module Campaigns
|
9
|
+
#
|
10
|
+
# SendGrid Web API v3 Campaigns - Campaigns
|
11
|
+
#
|
12
|
+
module Campaigns
|
13
|
+
include SendGrid4r::REST::Request
|
14
|
+
|
15
|
+
Campaign = Struct.new(
|
16
|
+
:id, :title, :subject, :sender_id, :list_ids, :segment_ids,
|
17
|
+
:categories, :suppression_group_id, :html_content,
|
18
|
+
:plain_content, :send_at, :status
|
19
|
+
)
|
20
|
+
|
21
|
+
Campaigns = Struct.new(:result)
|
22
|
+
|
23
|
+
def self.create_campaign(resp)
|
24
|
+
return resp if resp.nil?
|
25
|
+
send_at = Time.at(resp['send_at']) unless resp['send_at'].nil?
|
26
|
+
Campaign.new(
|
27
|
+
resp['id'], resp['title'], resp['subject'], resp['sender_id'],
|
28
|
+
resp['list_ids'], resp['segment_ids'], resp['categories'],
|
29
|
+
resp['suppression_group_id'], resp['html_content'],
|
30
|
+
resp['plain_content'], send_at, resp['status']
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.create_campaigns(resp)
|
35
|
+
return resp if resp.nil?
|
36
|
+
result = []
|
37
|
+
resp['result'].each do |campaign|
|
38
|
+
result.push(
|
39
|
+
SendGrid4r::REST::Campaigns::Campaigns.create_campaign(campaign)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
Campaigns.new(result)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.url(campaign_id = nil)
|
46
|
+
url = "#{BASE_URL}/campaigns"
|
47
|
+
url = "#{url}/#{campaign_id}" unless campaign_id.nil?
|
48
|
+
url
|
49
|
+
end
|
50
|
+
|
51
|
+
def post_campaign(params:, &block)
|
52
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url
|
53
|
+
resp = post(@auth, endpoint, params, &block)
|
54
|
+
SendGrid4r::REST::Campaigns::Campaigns.create_campaign(resp)
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_campaigns(&block)
|
58
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url
|
59
|
+
resp = get(@auth, endpoint, &block)
|
60
|
+
SendGrid4r::REST::Campaigns::Campaigns.create_campaigns(resp)
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_campaign(campaign_id:, &block)
|
64
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url(campaign_id)
|
65
|
+
resp = get(@auth, endpoint, &block)
|
66
|
+
SendGrid4r::REST::Campaigns::Campaigns.create_campaign(resp)
|
67
|
+
end
|
68
|
+
|
69
|
+
def delete_campaign(campaign_id:, &block)
|
70
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url(campaign_id)
|
71
|
+
delete(@auth, endpoint, &block)
|
72
|
+
end
|
73
|
+
|
74
|
+
def patch_campaign(campaign_id:, params:, &block)
|
75
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url(campaign_id)
|
76
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
77
|
+
SendGrid4r::REST::Campaigns::Campaigns.create_campaign(resp)
|
78
|
+
end
|
79
|
+
|
80
|
+
def send_campaign(campaign_id:, &block)
|
81
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url(campaign_id)
|
82
|
+
endpoint = "#{endpoint}/schedules/now"
|
83
|
+
resp = post(@auth, endpoint, nil, &block)
|
84
|
+
SendGrid4r::REST::Campaigns::Campaigns.create_campaign(resp)
|
85
|
+
end
|
86
|
+
|
87
|
+
def schedule_campaign(campaign_id:, send_at:, &block)
|
88
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url(campaign_id)
|
89
|
+
endpoint = "#{endpoint}/schedules"
|
90
|
+
payload = {}
|
91
|
+
payload['send_at'] = send_at.to_i
|
92
|
+
resp = post(@auth, endpoint, payload, &block)
|
93
|
+
SendGrid4r::REST::Campaigns::Campaigns.create_campaign(resp)
|
94
|
+
end
|
95
|
+
|
96
|
+
def reschedule_campaign(campaign_id:, send_at:, &block)
|
97
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url(campaign_id)
|
98
|
+
endpoint = "#{endpoint}/schedules"
|
99
|
+
payload = {}
|
100
|
+
payload['send_at'] = send_at.to_i
|
101
|
+
resp = patch(@auth, endpoint, payload, &block)
|
102
|
+
SendGrid4r::REST::Campaigns::Campaigns.create_campaign(resp)
|
103
|
+
end
|
104
|
+
|
105
|
+
def get_schedule_time_campaign(campaign_id:, &block)
|
106
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url(campaign_id)
|
107
|
+
endpoint = "#{endpoint}/schedules"
|
108
|
+
resp = get(@auth, endpoint, &block)
|
109
|
+
SendGrid4r::REST::Campaigns::Campaigns.create_campaign(resp)
|
110
|
+
end
|
111
|
+
|
112
|
+
def unschedule_campaign(campaign_id:, &block)
|
113
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url(campaign_id)
|
114
|
+
endpoint = "#{endpoint}/schedules"
|
115
|
+
delete(@auth, endpoint, &block)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_campaign(campaign_id:, to:, &block)
|
119
|
+
endpoint = SendGrid4r::REST::Campaigns::Campaigns.url(campaign_id)
|
120
|
+
endpoint = "#{endpoint}/schedules/test"
|
121
|
+
payload = {}
|
122
|
+
payload['to'] = to
|
123
|
+
post(@auth, endpoint, payload, &block)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -77,14 +77,16 @@ module SendGrid4r
|
|
77
77
|
# no bodies returned
|
78
78
|
def post_recipients_to_list(list_id:, recipients:, &block)
|
79
79
|
url = SendGrid4r::REST::Contacts::Lists.url(list_id)
|
80
|
-
endpoint = "#{url}/
|
80
|
+
endpoint = "#{url}/recipients"
|
81
81
|
post(@auth, endpoint, recipients, &block)
|
82
82
|
end
|
83
83
|
|
84
|
-
def get_recipients_from_list(
|
84
|
+
def get_recipients_from_list(
|
85
|
+
list_id:, page: nil, page_size: nil, &block
|
86
|
+
)
|
85
87
|
params = {}
|
86
|
-
params['
|
87
|
-
params['
|
88
|
+
params['page'] = page unless page.nil?
|
89
|
+
params['page_size'] = page_size unless page_size.nil?
|
88
90
|
endpoint = SendGrid4r::REST::Contacts::Lists.recipients_url(list_id)
|
89
91
|
resp = get(@auth, endpoint, params, &block)
|
90
92
|
SendGrid4r::REST::Contacts::Recipients.create_recipients(resp)
|
@@ -105,7 +107,7 @@ module SendGrid4r
|
|
105
107
|
end
|
106
108
|
|
107
109
|
def delete_lists(list_ids:, &block)
|
108
|
-
endpoint = "#{BASE_URL}/contactdb/
|
110
|
+
endpoint = "#{BASE_URL}/contactdb/lists"
|
109
111
|
delete(@auth, endpoint, nil, list_ids, &block)
|
110
112
|
end
|
111
113
|
end
|
@@ -44,7 +44,7 @@ module SendGrid4r
|
|
44
44
|
resp['last_clicked'],
|
45
45
|
resp['last_emailed'],
|
46
46
|
resp['last_name'],
|
47
|
-
resp['
|
47
|
+
resp['last_opened'],
|
48
48
|
Time.at(resp['updated_at'])
|
49
49
|
)
|
50
50
|
end
|
@@ -66,40 +66,28 @@ module SendGrid4r
|
|
66
66
|
url
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def post_recipients(params:, &block)
|
70
70
|
endpoint = SendGrid4r::REST::Contacts::Recipients.url
|
71
71
|
resp = post(@auth, endpoint, params, &block)
|
72
|
-
SendGrid4r::REST::Contacts::Recipients.
|
72
|
+
SendGrid4r::REST::Contacts::Recipients.create_result(resp)
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
75
|
+
def patch_recipients(params:, &block)
|
76
76
|
endpoint = SendGrid4r::REST::Contacts::Recipients.url
|
77
|
-
|
77
|
+
resp = patch(@auth, endpoint, params, &block)
|
78
|
+
SendGrid4r::REST::Contacts::Recipients.create_result(resp)
|
78
79
|
end
|
79
80
|
|
80
|
-
def
|
81
|
-
params = {}
|
82
|
-
params['limit'] = limit unless limit.nil?
|
83
|
-
params['offset'] = offset unless offset.nil?
|
81
|
+
def delete_recipients(recipient_ids:, &block)
|
84
82
|
endpoint = SendGrid4r::REST::Contacts::Recipients.url
|
85
|
-
|
86
|
-
SendGrid4r::REST::Contacts::Recipients.create_recipients(resp)
|
87
|
-
end
|
88
|
-
|
89
|
-
def get_recipients_by_id(recipient_ids:, &block)
|
90
|
-
endpoint = "#{SendGrid4r::REST::Contacts::Recipients.url}/batch"
|
91
|
-
resp = get(@auth, endpoint, nil, recipient_ids, &block)
|
92
|
-
SendGrid4r::REST::Contacts::Recipients.create_recipients(resp)
|
93
|
-
end
|
94
|
-
|
95
|
-
def get_recipients_count(&block)
|
96
|
-
endpoint = "#{SendGrid4r::REST::Contacts::Recipients.url}/count"
|
97
|
-
resp = get(@auth, endpoint, &block)
|
98
|
-
resp['recipient_count'] unless resp.nil?
|
83
|
+
delete(@auth, endpoint, nil, recipient_ids, &block)
|
99
84
|
end
|
100
85
|
|
101
|
-
def
|
102
|
-
|
86
|
+
def get_recipients(page: nil, page_size: nil, &block)
|
87
|
+
params = {}
|
88
|
+
params['page_size'] = page_size unless page_size.nil?
|
89
|
+
params['page'] = page unless page.nil?
|
90
|
+
endpoint = SendGrid4r::REST::Contacts::Recipients.url
|
103
91
|
resp = get(@auth, endpoint, params, &block)
|
104
92
|
SendGrid4r::REST::Contacts::Recipients.create_recipients(resp)
|
105
93
|
end
|
@@ -124,13 +112,19 @@ module SendGrid4r
|
|
124
112
|
SendGrid4r::REST::Contacts::Lists.create_lists(resp)
|
125
113
|
end
|
126
114
|
|
127
|
-
def
|
128
|
-
endpoint = "#{
|
129
|
-
resp =
|
130
|
-
|
115
|
+
def get_recipients_count(&block)
|
116
|
+
endpoint = "#{SendGrid4r::REST::Contacts::Recipients.url}/count"
|
117
|
+
resp = get(@auth, endpoint, &block)
|
118
|
+
resp['recipient_count'] unless resp.nil?
|
119
|
+
end
|
120
|
+
|
121
|
+
def search_recipients(params:, &block)
|
122
|
+
endpoint = "#{SendGrid4r::REST::Contacts::Recipients.url}/search"
|
123
|
+
resp = get(@auth, endpoint, params, &block)
|
124
|
+
SendGrid4r::REST::Contacts::Recipients.create_recipients(resp)
|
131
125
|
end
|
132
126
|
|
133
|
-
|
127
|
+
Result = Struct.new(
|
134
128
|
:error_count,
|
135
129
|
:error_indices,
|
136
130
|
:new_count,
|
@@ -148,7 +142,7 @@ module SendGrid4r
|
|
148
142
|
resp['persisted_recipients'].each do |value|
|
149
143
|
persisted_recipients.push(value)
|
150
144
|
end
|
151
|
-
|
145
|
+
Result.new(
|
152
146
|
resp['error_count'],
|
153
147
|
error_indices,
|
154
148
|
resp['new_count'],
|
@@ -78,9 +78,9 @@ module SendGrid4r
|
|
78
78
|
SendGrid4r::REST::Contacts::Segments.create_segment(resp)
|
79
79
|
end
|
80
80
|
|
81
|
-
def
|
81
|
+
def patch_segment(segment_id:, params:, &block)
|
82
82
|
endpoint = SendGrid4r::REST::Contacts::Segments.url(segment_id)
|
83
|
-
resp =
|
83
|
+
resp = patch(@auth, endpoint, params, &block)
|
84
84
|
SendGrid4r::REST::Contacts::Segments.create_segment(resp)
|
85
85
|
end
|
86
86
|
|
@@ -89,14 +89,9 @@ module SendGrid4r
|
|
89
89
|
delete(@auth, endpoint, &block)
|
90
90
|
end
|
91
91
|
|
92
|
-
def
|
93
|
-
segment_id:, limit: nil, offset: nil, &block
|
94
|
-
)
|
95
|
-
params = {}
|
96
|
-
params['limit'] = limit unless limit.nil?
|
97
|
-
params['offset'] = offset unless offset.nil?
|
92
|
+
def get_recipients_on_segment(segment_id:, &block)
|
98
93
|
url = SendGrid4r::REST::Contacts::Segments.url(segment_id)
|
99
|
-
resp = get(@auth, "#{url}/recipients",
|
94
|
+
resp = get(@auth, "#{url}/recipients", nil, &block)
|
100
95
|
SendGrid4r::REST::Contacts::Recipients.create_recipients(resp)
|
101
96
|
end
|
102
97
|
end
|
@@ -53,6 +53,9 @@ module SendGrid4r
|
|
53
53
|
args[:url] = process_url_params(endpoint, params)
|
54
54
|
headers = {}
|
55
55
|
headers[:content_type] = :json
|
56
|
+
# Added for Campaign API
|
57
|
+
headers['Accept-Encoding'] = 'plain'
|
58
|
+
#
|
56
59
|
if !auth.api_key.nil?
|
57
60
|
headers[:authorization] = "Bearer #{auth.api_key}"
|
58
61
|
else
|
data/lib/sendgrid4r/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -183,25 +183,38 @@ describe SendGrid4r::Client do
|
|
183
183
|
expect(@client.respond_to?('delete_recipient_from_list')).to eq(true)
|
184
184
|
expect(@client.respond_to?('delete_lists')).to eq(true)
|
185
185
|
# Recipients
|
186
|
-
expect(@client.respond_to?('
|
186
|
+
expect(@client.respond_to?('post_recipients')).to eq(true)
|
187
|
+
expect(@client.respond_to?('patch_recipients')).to eq(true)
|
187
188
|
expect(@client.respond_to?('delete_recipients')).to eq(true)
|
188
189
|
expect(@client.respond_to?('get_recipients')).to eq(true)
|
189
|
-
expect(@client.respond_to?('get_recipients_by_id')).to eq(true)
|
190
|
-
expect(@client.respond_to?('get_recipients_count')).to eq(true)
|
191
|
-
expect(@client.respond_to?('search_recipients')).to eq(true)
|
192
190
|
expect(@client.respond_to?('get_recipient')).to eq(true)
|
193
191
|
expect(@client.respond_to?('delete_recipient')).to eq(true)
|
194
192
|
expect(@client.respond_to?('get_lists_recipient_belong')).to eq(true)
|
195
|
-
expect(@client.respond_to?('
|
193
|
+
expect(@client.respond_to?('get_recipients_count')).to eq(true)
|
194
|
+
expect(@client.respond_to?('search_recipients')).to eq(true)
|
196
195
|
# ReservedFields
|
197
196
|
expect(@client.respond_to?('get_reserved_fields')).to eq(true)
|
198
197
|
# Segments
|
199
198
|
expect(@client.respond_to?('post_segment')).to eq(true)
|
200
199
|
expect(@client.respond_to?('get_segments')).to eq(true)
|
201
200
|
expect(@client.respond_to?('get_segment')).to eq(true)
|
202
|
-
expect(@client.respond_to?('
|
201
|
+
expect(@client.respond_to?('patch_segment')).to eq(true)
|
203
202
|
expect(@client.respond_to?('delete_segment')).to eq(true)
|
204
|
-
expect(@client.respond_to?('
|
203
|
+
expect(@client.respond_to?('get_recipients_on_segment')).to eq(true)
|
204
|
+
|
205
|
+
# Campaigns
|
206
|
+
expect(@client.respond_to?('post_campaign')).to eq(true)
|
207
|
+
expect(@client.respond_to?('get_campaigns')).to eq(true)
|
208
|
+
expect(@client.respond_to?('get_campaign')).to eq(true)
|
209
|
+
expect(@client.respond_to?('delete_campaign')).to eq(true)
|
210
|
+
expect(@client.respond_to?('patch_campaign')).to eq(true)
|
211
|
+
expect(@client.respond_to?('send_campaign')).to eq(true)
|
212
|
+
expect(@client.respond_to?('schedule_campaign')).to eq(true)
|
213
|
+
expect(@client.respond_to?('schedule_campaign')).to eq(true)
|
214
|
+
expect(@client.respond_to?('reschedule_campaign')).to eq(true)
|
215
|
+
expect(@client.respond_to?('get_schedule_time_campaign')).to eq(true)
|
216
|
+
expect(@client.respond_to?('unschedule_campaign')).to eq(true)
|
217
|
+
expect(@client.respond_to?('test_campaign')).to eq(true)
|
205
218
|
|
206
219
|
# Whitelabel
|
207
220
|
# Domains
|
@@ -245,7 +258,7 @@ describe SendGrid4r::Client do
|
|
245
258
|
|
246
259
|
describe 'VERSION' do
|
247
260
|
it 'returns VERSION value' do
|
248
|
-
expect(SendGrid4r::VERSION).to eq('1.
|
261
|
+
expect(SendGrid4r::VERSION).to eq('1.2.0')
|
249
262
|
end
|
250
263
|
end
|
251
264
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
3
|
+
|
4
|
+
describe SendGrid4r::Factory::CampaignFactory do
|
5
|
+
describe 'unit test', :ut do
|
6
|
+
before do
|
7
|
+
Dotenv.load
|
8
|
+
@campaign_factory = SendGrid4r::Factory::CampaignFactory.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'specify all params' do
|
12
|
+
campaign = @campaign_factory.create(
|
13
|
+
title: 'March Newsletter',
|
14
|
+
subject: 'New Products for Spring!',
|
15
|
+
sender_id: 124451,
|
16
|
+
list_ids: [110, 124],
|
17
|
+
segment_ids: [110],
|
18
|
+
categories: ['spring line'],
|
19
|
+
suppression_group_id: 42,
|
20
|
+
html_content: '<html><head><title></title></head><body>'\
|
21
|
+
'<p>Check out our spring line!</p></body></html>',
|
22
|
+
plain_content: 'Check out our spring line!'
|
23
|
+
)
|
24
|
+
@expect = {}
|
25
|
+
@expect[:title] = 'March Newsletter'
|
26
|
+
@expect[:subject] = 'New Products for Spring!'
|
27
|
+
@expect[:sender_id] = 124451
|
28
|
+
@expect[:list_ids] = [110, 124]
|
29
|
+
@expect[:segment_ids] = [110]
|
30
|
+
@expect[:categories] = ['spring line']
|
31
|
+
@expect[:suppression_group_id] = 42
|
32
|
+
@expect[:html_content] = '<html><head><title></title></head><body>'\
|
33
|
+
'<p>Check out our spring line!</p></body></html>'
|
34
|
+
@expect[:plain_content] = 'Check out our spring line!'
|
35
|
+
expect(campaign).to eq(@expect)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -13,9 +13,7 @@ describe SendGrid4r::Factory::SegmentFactory do
|
|
13
13
|
operator: 'eq',
|
14
14
|
and_or: '')
|
15
15
|
@expect = {}
|
16
|
-
@expect[:id] = nil
|
17
16
|
@expect[:name] = 'Last Name Miller'
|
18
|
-
@expect[:list_id] = nil
|
19
17
|
@expect[:conditions] = [@condition]
|
20
18
|
@expect[:recipient_count] = nil
|
21
19
|
end
|