express_pigeon 1.0.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.example +1 -0
- data/.gitignore +19 -16
- data/.rspec +1 -0
- data/.rubocop.yml +17 -0
- data/.rubocop_todo.yml +15 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CONTRIBUTING.md +21 -0
- data/Gemfile +13 -8
- data/Guardfile +56 -0
- data/LICENSE +9 -2
- data/README.md +4 -124
- data/Rakefile +1 -2
- data/express_pigeon.gemspec +31 -16
- data/lib/express_pigeon/api/campaigns.rb +62 -0
- data/lib/express_pigeon/api/contacts.rb +42 -0
- data/lib/express_pigeon/api/lists.rb +49 -0
- data/lib/express_pigeon/api/messages.rb +56 -0
- data/lib/express_pigeon/api.rb +66 -0
- data/lib/express_pigeon/autoresponders.rb +0 -0
- data/lib/express_pigeon/contacts.rb +71 -0
- data/lib/express_pigeon/lists.rb +111 -0
- data/lib/express_pigeon/meta_hash.rb +20 -0
- data/lib/express_pigeon/templates.rb +4 -0
- data/lib/express_pigeon/transactional_emails.rb +4 -0
- data/lib/express_pigeon/version.rb +1 -1
- data/lib/express_pigeon.rb +16 -442
- data/spec/express_pigeon/api/campaigns_spec.rb +100 -0
- data/spec/express_pigeon/api/contacts_spec.rb +146 -0
- data/spec/express_pigeon/api/lists_spec.rb +23 -0
- data/spec/express_pigeon/api/messages_spec.rb +36 -0
- data/spec/express_pigeon/contacts_spec.rb +111 -0
- data/spec/express_pigeon/lists_spec.rb +131 -0
- data/spec/fixtures/contacts.csv +2 -0
- data/spec/fixtures/contacts.csv.zip +0 -0
- data/spec/spec_helper.rb +100 -12
- data/vendor/cache/ast-2.0.0.gem +0 -0
- data/vendor/cache/astrolabe-1.3.0.gem +0 -0
- data/vendor/cache/awesome_print-1.2.0.gem +0 -0
- data/vendor/cache/byebug-3.5.1.gem +0 -0
- data/vendor/cache/celluloid-0.16.0.gem +0 -0
- data/vendor/cache/coderay-1.1.0.gem +0 -0
- data/vendor/cache/colorize-0.7.5.gem +0 -0
- data/vendor/cache/columnize-0.9.0.gem +0 -0
- data/vendor/cache/debugger-linecache-1.2.0.gem +0 -0
- data/vendor/cache/diff-lcs-1.2.5.gem +0 -0
- data/vendor/cache/docile-1.1.5.gem +0 -0
- data/vendor/cache/dotenv-1.0.2.gem +0 -0
- data/vendor/cache/ffi-1.9.6.gem +0 -0
- data/vendor/cache/formatador-0.2.5.gem +0 -0
- data/vendor/cache/guard-2.10.5.gem +0 -0
- data/vendor/cache/guard-compat-1.2.0.gem +0 -0
- data/vendor/cache/guard-rspec-4.5.0.gem +0 -0
- data/vendor/cache/hitimes-1.2.2.gem +0 -0
- data/vendor/cache/httmultiparty-0.3.16.gem +0 -0
- data/vendor/cache/httparty-0.13.3.gem +0 -0
- data/vendor/cache/json-1.8.1.gem +0 -0
- data/vendor/cache/listen-2.8.4.gem +0 -0
- data/vendor/cache/lumberjack-1.0.9.gem +0 -0
- data/vendor/cache/method_source-0.8.2.gem +0 -0
- data/vendor/cache/mimemagic-0.2.1.gem +0 -0
- data/vendor/cache/multi_json-1.10.1.gem +0 -0
- data/vendor/cache/multi_xml-0.5.5.gem +0 -0
- data/vendor/cache/multipart-post-2.0.0.gem +0 -0
- data/vendor/cache/nenv-0.1.1.gem +0 -0
- data/vendor/cache/parser-2.2.0.pre.8.gem +0 -0
- data/vendor/cache/powerpack-0.0.9.gem +0 -0
- data/vendor/cache/pry-0.10.1.gem +0 -0
- data/vendor/cache/pry-byebug-2.0.0.gem +0 -0
- data/vendor/cache/rainbow-2.0.0.gem +0 -0
- data/vendor/cache/rake-10.4.2.gem +0 -0
- data/vendor/cache/rb-fsevent-0.9.4.gem +0 -0
- data/vendor/cache/rb-inotify-0.9.5.gem +0 -0
- data/vendor/cache/rspec-3.1.0.gem +0 -0
- data/vendor/cache/rspec-core-3.1.7.gem +0 -0
- data/vendor/cache/rspec-expectations-3.1.2.gem +0 -0
- data/vendor/cache/rspec-mocks-3.1.3.gem +0 -0
- data/vendor/cache/rspec-support-3.1.2.gem +0 -0
- data/vendor/cache/rubocop-0.28.0.gem +0 -0
- data/vendor/cache/ruby-progressbar-1.7.1.gem +0 -0
- data/vendor/cache/simplecov-0.9.1.gem +0 -0
- data/vendor/cache/simplecov-html-0.8.0.gem +0 -0
- data/vendor/cache/slop-3.6.0.gem +0 -0
- data/vendor/cache/thor-0.19.1.gem +0 -0
- data/vendor/cache/timers-4.0.1.gem +0 -0
- metadata +183 -53
- data/.rvmrc +0 -52
- data/.travis.yml +0 -8
- data/CHANGELOG +0 -6
- data/bin/console +0 -12
- data/express_pigeon-rb.yml +0 -10
- data/lib/active_model/validations/date_format_validator.rb +0 -20
- data/script/lint +0 -6
- data/script/multispec +0 -23
- data/spec/web_forms_spec.rb +0 -164
data/lib/express_pigeon.rb
CHANGED
@@ -1,449 +1,23 @@
|
|
1
|
-
|
1
|
+
require 'awesome_print'
|
2
2
|
|
3
|
-
require
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require 'active_model/validations/date_format_validator'
|
3
|
+
# require 'net/http'
|
4
|
+
require 'json'
|
5
|
+
# require 'uri'
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
def express_pigeon_states
|
11
|
-
{
|
12
|
-
"Alaska" => "AK",
|
13
|
-
"Alabama" => "AL",
|
14
|
-
"Arkansas" => "AR",
|
15
|
-
"Arizona" => "AZ",
|
16
|
-
"California" => "CA",
|
17
|
-
"Colorado" => "CO",
|
18
|
-
"Connecticut" => "CT",
|
19
|
-
"Delaware" => "DE",
|
20
|
-
"Florida" => "FL",
|
21
|
-
"Georgia" => "GA",
|
22
|
-
"Hawaii" => "HI",
|
23
|
-
"Iowa" => "IA",
|
24
|
-
"Idaho" => "ID",
|
25
|
-
"Illinois" => "IL",
|
26
|
-
"Indiana" => "IN",
|
27
|
-
"Kansas" => "KS",
|
28
|
-
"Kentucky" => "KY",
|
29
|
-
"Louisiana" => "LA",
|
30
|
-
"Massachusetts" => "MA",
|
31
|
-
"Maryland" => "MD",
|
32
|
-
"Maine" => "ME",
|
33
|
-
"Michigan" => "MI",
|
34
|
-
"Minnesota" => "MN",
|
35
|
-
"Missouri" => "MO",
|
36
|
-
"Mississippi" => "MS",
|
37
|
-
"Montana" => "MT",
|
38
|
-
"North Carolina" => "NC",
|
39
|
-
"North Dakota" => "ND",
|
40
|
-
"Nebraska" => "NE",
|
41
|
-
"New Hampshire" => "NH",
|
42
|
-
"New Jersey" => "NJ",
|
43
|
-
"New Mexico" => "NM",
|
44
|
-
"Nevada" => "NV",
|
45
|
-
"New York" => "NY",
|
46
|
-
"Ohio" => "OH",
|
47
|
-
"Oklahoma" => "OK",
|
48
|
-
"Oregon" => "OR",
|
49
|
-
"Pennsylvania" => "PA",
|
50
|
-
"Rhode Island" => "RI",
|
51
|
-
"South Carolina" => "SC",
|
52
|
-
"South Dakota" => "SD",
|
53
|
-
"Tennessee" => "TN",
|
54
|
-
"Texas" => "TX",
|
55
|
-
"Utah" => "UT",
|
56
|
-
"Virginia" => "VA",
|
57
|
-
"Vermont" => "VT",
|
58
|
-
"Washington" => "WA",
|
59
|
-
"Wisconsin" => "WI",
|
60
|
-
"West Virginia" => "WV",
|
61
|
-
"Wyoming" => "WY",
|
62
|
-
}
|
63
|
-
end
|
64
|
-
|
65
|
-
def express_pigeon_countries
|
66
|
-
{
|
67
|
-
"Afghanistan" => "Afghanistan",
|
68
|
-
"Albania" => "Albania",
|
69
|
-
"Algeria" => "Algeria",
|
70
|
-
"American Samoa" => "American Samoa",
|
71
|
-
"Andorra" => "Andorra",
|
72
|
-
"Angola" => "Angola",
|
73
|
-
"Anguilla" => "Anguilla",
|
74
|
-
"Antarctica" => "Antarctica",
|
75
|
-
"Antigua and Barbuda" => "Antigua and Barbuda",
|
76
|
-
"Argentina" => "Argentina",
|
77
|
-
"Armenia" => "Armenia",
|
78
|
-
"Aruba" => "Aruba",
|
79
|
-
"Australia" => "Australia",
|
80
|
-
"Austria" => "Austria",
|
81
|
-
"Azerbaijan" => "Azerbaijan",
|
82
|
-
"Bahamas" => "Bahamas",
|
83
|
-
"Bahrain" => "Bahrain",
|
84
|
-
"Bangladesh" => "Bangladesh",
|
85
|
-
"Barbados" => "Barbados",
|
86
|
-
"Belarus" => "Belarus",
|
87
|
-
"Belgium" => "Belgium",
|
88
|
-
"Belize" => "Belize",
|
89
|
-
"Benin" => "Benin",
|
90
|
-
"Bermuda" => "Bermuda",
|
91
|
-
"Bhutan" => "Bhutan",
|
92
|
-
"Bolivia" => "Bolivia",
|
93
|
-
"Bosnia and Herzegovina" => "Bosnia and Herzegovina",
|
94
|
-
"Botswana" => "Botswana",
|
95
|
-
"Brazil" => "Brazil",
|
96
|
-
"British Indian Ocean Territory" => "British Indian Ocean Territory",
|
97
|
-
"Brunei" => "Brunei",
|
98
|
-
"Bulgaria" => "Bulgaria",
|
99
|
-
"Burkina Faso" => "Burkina Faso",
|
100
|
-
"Burundi" => "Burundi",
|
101
|
-
"Cambodia" => "Cambodia",
|
102
|
-
"Cameroon" => "Cameroon",
|
103
|
-
"Canada" => "Canada",
|
104
|
-
"Cape Verde" => "Cape Verde",
|
105
|
-
"Cayman Islands" => "Cayman Islands",
|
106
|
-
"Central African Republic" => "Central African Republic",
|
107
|
-
"Chad" => "Chad",
|
108
|
-
"Chile" => "Chile",
|
109
|
-
"China" => "China",
|
110
|
-
"Christmas Island" => "Christmas Island",
|
111
|
-
"Cocos Islands" => "Cocos Islands",
|
112
|
-
"Colombia" => "Colombia",
|
113
|
-
"Comoros" => "Comoros",
|
114
|
-
"Congo" => "Congo",
|
115
|
-
"Congo, Democratic Republic of the" => "Congo, Democratic Republic of the",
|
116
|
-
"Cook Islands" => "Cook Islands",
|
117
|
-
"Costa Rica" => "Costa Rica",
|
118
|
-
"Croatia" => "Croatia",
|
119
|
-
"Cuba" => "Cuba",
|
120
|
-
"Cyprus" => "Cyprus",
|
121
|
-
"Czech Republic" => "Czech Republic",
|
122
|
-
"Côte d'Ivoire" => "Côte d'Ivoire",
|
123
|
-
"Denmark" => "Denmark",
|
124
|
-
"Djibouti" => "Djibouti",
|
125
|
-
"Dominica" => "Dominica",
|
126
|
-
"Dominican Republic" => "Dominican Republic",
|
127
|
-
"Ecuador" => "Ecuador",
|
128
|
-
"Egypt" => "Egypt",
|
129
|
-
"El Salvador" => "El Salvador",
|
130
|
-
"Equatorial Guinea (Guinea Ecuatorial)" => "Equatorial Guinea (Guinea Ecuatorial)",
|
131
|
-
"Eritrea" => "Eritrea",
|
132
|
-
"Estonia" => "Estonia",
|
133
|
-
"Ethiopia" => "Ethiopia",
|
134
|
-
"Falkland Islands" => "Falkland Islands",
|
135
|
-
"Faroe Islands" => "Faroe Islands",
|
136
|
-
"Fiji" => "Fiji",
|
137
|
-
"Finland" => "Finland",
|
138
|
-
"France" => "France",
|
139
|
-
"French Guiana" => "French Guiana",
|
140
|
-
"French Polynesia" => "French Polynesia",
|
141
|
-
"French Southern Territories" => "French Southern Territories",
|
142
|
-
"Gabon" => "Gabon",
|
143
|
-
"Gambia" => "Gambia",
|
144
|
-
"Georgia" => "Georgia",
|
145
|
-
"Germany" => "Germany",
|
146
|
-
"Ghana" => "Ghana",
|
147
|
-
"Gibraltar" => "Gibraltar",
|
148
|
-
"Greece" => "Greece",
|
149
|
-
"Greenland" => "Greenland",
|
150
|
-
"Grenada" => "Grenada",
|
151
|
-
"Guadeloupe" => "Guadeloupe",
|
152
|
-
"Guam" => "Guam",
|
153
|
-
"Guatemala" => "Guatemala",
|
154
|
-
"Guinea" => "Guinea",
|
155
|
-
"Guinea-Bissau" => "Guinea-Bissau",
|
156
|
-
"Guyana" => "Guyana",
|
157
|
-
"Haiti" => "Haiti",
|
158
|
-
"Honduras" => "Honduras",
|
159
|
-
"Hong Kong" => "Hong Kong",
|
160
|
-
"Hungary" => "Hungary",
|
161
|
-
"Iceland" => "Iceland",
|
162
|
-
"India" => "India",
|
163
|
-
"Indonesia" => "Indonesia",
|
164
|
-
"Iran" => "Iran",
|
165
|
-
"Iraq" => "Iraq",
|
166
|
-
"Ireland" => "Ireland",
|
167
|
-
"Israel" => "Israel",
|
168
|
-
"Italy" => "Italy",
|
169
|
-
"Jamaica" => "Jamaica",
|
170
|
-
"Japan" => "Japan",
|
171
|
-
"Jordan" => "Jordan",
|
172
|
-
"Kazakhstan" => "Kazakhstan",
|
173
|
-
"Kenya" => "Kenya",
|
174
|
-
"Kiribati" => "Kiribati",
|
175
|
-
"Kuwait" => "Kuwait",
|
176
|
-
"Kyrgyzstan" => "Kyrgyzstan",
|
177
|
-
"Laos" => "Laos",
|
178
|
-
"Latvia" => "Latvia",
|
179
|
-
"Lebanon" => "Lebanon",
|
180
|
-
"Lesotho" => "Lesotho",
|
181
|
-
"Liberia" => "Liberia",
|
182
|
-
"Libya" => "Libya",
|
183
|
-
"Liechtenstein" => "Liechtenstein",
|
184
|
-
"Lithuania" => "Lithuania",
|
185
|
-
"Luxembourg" => "Luxembourg",
|
186
|
-
"Macao" => "Macao",
|
187
|
-
"Macedonia" => "Macedonia",
|
188
|
-
"Madagascar" => "Madagascar",
|
189
|
-
"Malawi" => "Malawi",
|
190
|
-
"Malaysia" => "Malaysia",
|
191
|
-
"Maldives" => "Maldives",
|
192
|
-
"Mali" => "Mali",
|
193
|
-
"Malta" => "Malta",
|
194
|
-
"Marshall Islands" => "Marshall Islands",
|
195
|
-
"Martinique" => "Martinique",
|
196
|
-
"Mauritania" => "Mauritania",
|
197
|
-
"Mauritius" => "Mauritius",
|
198
|
-
"Mayotte" => "Mayotte",
|
199
|
-
"Mexico" => "Mexico",
|
200
|
-
"Micronesia" => "Micronesia",
|
201
|
-
"Moldova" => "Moldova",
|
202
|
-
"Monaco" => "Monaco",
|
203
|
-
"Mongolia" => "Mongolia",
|
204
|
-
"Montenegro" => "Montenegro",
|
205
|
-
"Montserrat" => "Montserrat",
|
206
|
-
"Morocco" => "Morocco",
|
207
|
-
"Mozambique" => "Mozambique",
|
208
|
-
"Myanmar" => "Myanmar",
|
209
|
-
"Namibia" => "Namibia",
|
210
|
-
"Nauru" => "Nauru",
|
211
|
-
"Nepal" => "Nepal",
|
212
|
-
"Netherlands Antilles" => "Netherlands Antilles",
|
213
|
-
"Netherlands" => "Netherlands",
|
214
|
-
"New Caledonia" => "New Caledonia",
|
215
|
-
"New Zealand" => "New Zealand",
|
216
|
-
"Nicaragua" => "Nicaragua",
|
217
|
-
"Niger" => "Niger",
|
218
|
-
"Nigeria" => "Nigeria",
|
219
|
-
"Niue" => "Niue",
|
220
|
-
"Norfolk Island" => "Norfolk Island",
|
221
|
-
"North Korea" => "North Korea",
|
222
|
-
"Northern Mariana Islands" => "Northern Mariana Islands",
|
223
|
-
"Norway" => "Norway",
|
224
|
-
"Oman" => "Oman",
|
225
|
-
"Pakistan" => "Pakistan",
|
226
|
-
"Palau" => "Palau",
|
227
|
-
"Palestinian Territories" => "Palestinian Territories",
|
228
|
-
"Panama" => "Panama",
|
229
|
-
"Papua New Guinea" => "Papua New Guinea",
|
230
|
-
"Paraguay" => "Paraguay",
|
231
|
-
"Peru" => "Peru",
|
232
|
-
"Philippines" => "Philippines",
|
233
|
-
"Pitcairn" => "Pitcairn",
|
234
|
-
"Poland" => "Poland",
|
235
|
-
"Portugal" => "Portugal",
|
236
|
-
"Puerto Rico" => "Puerto Rico",
|
237
|
-
"Qatar" => "Qatar",
|
238
|
-
"Reunion" => "Reunion",
|
239
|
-
"Romania" => "Romania",
|
240
|
-
"Russia" => "Russia",
|
241
|
-
"Rwanda" => "Rwanda",
|
242
|
-
"Saint Helena" => "Saint Helena",
|
243
|
-
"Saint Kitts and Nevis" => "Saint Kitts and Nevis",
|
244
|
-
"Saint Lucia" => "Saint Lucia",
|
245
|
-
"Saint Pierre and Miquelon" => "Saint Pierre and Miquelon",
|
246
|
-
"Saint Vincent and the Grenadines" => "Saint Vincent and the Grenadines",
|
247
|
-
"Samoa" => "Samoa",
|
248
|
-
"San Marino" => "San Marino",
|
249
|
-
"Saudi Arabia" => "Saudi Arabia",
|
250
|
-
"Senegal" => "Senegal",
|
251
|
-
"Serbia" => "Serbia",
|
252
|
-
"Seychelles" => "Seychelles",
|
253
|
-
"Sierra Leone" => "Sierra Leone",
|
254
|
-
"Singapore" => "Singapore",
|
255
|
-
"Slovakia" => "Slovakia",
|
256
|
-
"Slovenia" => "Slovenia",
|
257
|
-
"Solomon Islands" => "Solomon Islands",
|
258
|
-
"Somalia" => "Somalia",
|
259
|
-
"South Africa" => "South Africa",
|
260
|
-
"South Georgia and the South Sandwich Islands" => "South Georgia and the South Sandwich Islands",
|
261
|
-
"South Korea" => "South Korea",
|
262
|
-
"Spain" => "Spain",
|
263
|
-
"Sri Lanka" => "Sri Lanka",
|
264
|
-
"Sudan" => "Sudan",
|
265
|
-
"Suriname" => "Suriname",
|
266
|
-
"Svalbard and Jan Mayen" => "Svalbard and Jan Mayen",
|
267
|
-
"Swaziland" => "Swaziland",
|
268
|
-
"Sweden" => "Sweden",
|
269
|
-
"Switzerland" => "Switzerland",
|
270
|
-
"Syria" => "Syria",
|
271
|
-
"São Tomé and Príncipe" => "São Tomé and Príncipe",
|
272
|
-
"Taiwan" => "Taiwan",
|
273
|
-
"Tajikistan" => "Tajikistan",
|
274
|
-
"Tanzania" => "Tanzania",
|
275
|
-
"Thailand" => "Thailand",
|
276
|
-
"Timor-Leste" => "Timor-Leste",
|
277
|
-
"Togo" => "Togo",
|
278
|
-
"Tokelau" => "Tokelau",
|
279
|
-
"Tonga" => "Tonga",
|
280
|
-
"Trinidad and Tobago" => "Trinidad and Tobago",
|
281
|
-
"Tunisia" => "Tunisia",
|
282
|
-
"Turkey" => "Turkey",
|
283
|
-
"Turkmenistan" => "Turkmenistan",
|
284
|
-
"Turks and Caicos Islands" => "Turks and Caicos Islands",
|
285
|
-
"Tuvalu" => "Tuvalu",
|
286
|
-
"Uganda" => "Uganda",
|
287
|
-
"Ukraine" => "Ukraine",
|
288
|
-
"United Arab Emirates" => "United Arab Emirates",
|
289
|
-
"United Kingdom" => "United Kingdom",
|
290
|
-
"United States minor outlying islands" => "United States minor outlying islands",
|
291
|
-
"United States" => "United States",
|
292
|
-
"Uruguay" => "Uruguay",
|
293
|
-
"Uzbekistan" => "Uzbekistan",
|
294
|
-
"Vanuatu" => "Vanuatu",
|
295
|
-
"Vatican City" => "Vatican City",
|
296
|
-
"Venezuela" => "Venezuela",
|
297
|
-
"Vietnam" => "Vietnam",
|
298
|
-
"Virgin Islands,
|
299
|
-
British" => "Virgin Islands,
|
300
|
-
British",
|
301
|
-
"Virgin Islands,
|
302
|
-
U.S." => "Virgin Islands,
|
303
|
-
U.S.",
|
304
|
-
"Wallis and Futuna" => "Wallis and Futuna",
|
305
|
-
"Western Sahara" => "Western Sahara",
|
306
|
-
"Yemen" => "Yemen",
|
307
|
-
"Zambia" => "Zambia",
|
308
|
-
"Zimbabwe" => "Zimbabwe",
|
309
|
-
}
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
module WebFormValidations
|
314
|
-
def self.included(base)
|
315
|
-
|
316
|
-
base.validates :guid, :presence => true
|
317
|
-
base.validates :email, :presence => true, :length => 3..50, :allow_blank => false
|
318
|
-
|
319
|
-
# TODO check the actual form to see whether a field is required.
|
320
|
-
#
|
321
|
-
# The functionality to check whether a field is actually required
|
322
|
-
# hasn't been implemented yet. Go ahead and just assume they're not
|
323
|
-
# required and just check bounds.
|
324
|
-
base.validates :address1, :length => 0..255, :allow_blank => true
|
325
|
-
base.validates :address2, :length => 0..255, :allow_blank => true
|
326
|
-
base.validates :city, :length => 0..128, :allow_blank => true
|
327
|
-
base.validates :company, :length => 0..128, :allow_blank => true
|
328
|
-
base.validates :country, :length => 0..128, :allow_blank => true
|
329
|
-
|
330
|
-
# now sure why we can put 255 chars into date of birth but that's what it is.
|
331
|
-
# TODO validate and require date format, submit as MM/DD/YYYY
|
332
|
-
base.validates :date_of_birth, :length => 0..255, :allow_blank => true, :date_format => true
|
333
|
-
|
334
|
-
# will email_form be a submittable field?
|
335
|
-
base.validates :first_name, :length => 0..50, :allow_blank => true
|
336
|
-
base.validates :last_name, :length => 0..50, :allow_blank => true
|
337
|
-
base.validates :phone, :length => 0..30, :allow_blank => true
|
338
|
-
base.validates :state, :length => 0..48, :allow_blank => true # state is 48?
|
339
|
-
base.validates :title, :length => 0..30, :allow_blank => true
|
340
|
-
base.validates :zip, :length => 0..24, :allow_blank => true # zip is 24?
|
341
|
-
|
342
|
-
# TODO validate state
|
343
|
-
# TODO validate field sizes
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
module WebFormPushable
|
348
|
-
def push_to_express_pigeon!
|
349
|
-
def url; "https://expresspigeon.com/subscription/add_contact"; end
|
350
|
-
|
351
|
-
params = {
|
352
|
-
:address1 => self.address1,
|
353
|
-
:address2 => self.address2,
|
354
|
-
:city => self.city,
|
355
|
-
:company => self.company,
|
356
|
-
:country => self.country,
|
357
|
-
:date_of_birth => format_date(self.date_of_birth),
|
358
|
-
:email => self.email,
|
359
|
-
:first_name => self.first_name,
|
360
|
-
:guid => self.guid,
|
361
|
-
:last_name => self.last_name,
|
362
|
-
:phone => self.phone,
|
363
|
-
:state => self.state,
|
364
|
-
:title => self.title,
|
365
|
-
:zip => self.zip,
|
366
|
-
}
|
367
|
-
|
368
|
-
response = CurbFu.post({:url => url}, params)
|
7
|
+
require 'httparty'
|
8
|
+
require 'httmultiparty'
|
369
9
|
|
370
|
-
|
371
|
-
end
|
10
|
+
require 'express_pigeon/version'
|
372
11
|
|
373
|
-
|
374
|
-
|
12
|
+
require 'express_pigeon/lists'
|
13
|
+
require 'express_pigeon/contacts'
|
14
|
+
require 'express_pigeon/transactional_emails'
|
15
|
+
require 'express_pigeon/templates'
|
16
|
+
require 'express_pigeon/autoresponders'
|
375
17
|
|
376
|
-
|
377
|
-
|
378
|
-
|
18
|
+
AUTH_KEY = ENV['EXPRESS_PIGEON_AUTH_KEY']
|
19
|
+
ROOT = 'https://api.expresspigeon.com/'
|
20
|
+
USE_SSL = true
|
379
21
|
|
380
|
-
|
381
|
-
class WebForm
|
382
|
-
include ActiveModel::Validations
|
383
|
-
include WebFormValidations
|
384
|
-
include WebFormPushable
|
385
|
-
|
386
|
-
include ActiveModel::Dirty
|
387
|
-
|
388
|
-
define_attribute_methods [
|
389
|
-
:address1,
|
390
|
-
:address2,
|
391
|
-
:city,
|
392
|
-
:company,
|
393
|
-
:country,
|
394
|
-
:date_of_birth,
|
395
|
-
:email,
|
396
|
-
:first_name,
|
397
|
-
:guid,
|
398
|
-
:last_name,
|
399
|
-
:phone,
|
400
|
-
:state,
|
401
|
-
:title,
|
402
|
-
:zip,
|
403
|
-
]
|
404
|
-
|
405
|
-
# TODO after submitting the form try to capture the response for errors?
|
406
|
-
|
407
|
-
def address1 ; @address1 ; end
|
408
|
-
def address2 ; @address2 ; end
|
409
|
-
def city ; @city ; end
|
410
|
-
def company ; @company ; end
|
411
|
-
def country ; @country ; end
|
412
|
-
def date_of_birth ; @date_of_birth ; end
|
413
|
-
def email ; @email ; end
|
414
|
-
def first_name ; @first_name ; end
|
415
|
-
def guid ; @guid ; end
|
416
|
-
def last_name ; @last_name ; end
|
417
|
-
def phone ; @phone ; end
|
418
|
-
def state ; @state ; end
|
419
|
-
def title ; @title ; end
|
420
|
-
def zip ; @zip ; end
|
421
|
-
|
422
|
-
def address1=(val) ; address1_will_change! unless val == @address1 ; @address1 = val ; end
|
423
|
-
def address2=(val) ; address2_will_change! unless val == @address2 ; @address2 = val ; end
|
424
|
-
def city=(val) ; city_will_change! unless val == @city ; @city = val ; end
|
425
|
-
def company=(val) ; company_will_change! unless val == @company ; @company = val ; end
|
426
|
-
def country=(val) ; country_will_change! unless val == @country ; @country = val ; end
|
427
|
-
def date_of_birth=(val) ; date_of_birth_will_change! unless val == @date_of_birth ; @date_of_birth = val ; end
|
428
|
-
def email=(val) ; email_will_change! unless val == @email ; @email = val ; end
|
429
|
-
def first_name=(val) ; first_name_will_change! unless val == @first_name ; @first_name = val ; end
|
430
|
-
def guid=(val) ; guid_will_change! unless val == @guid ; @guid = val ; end
|
431
|
-
def last_name=(val) ; last_name_will_change! unless val == @last_name ; @last_name = val ; end
|
432
|
-
def phone=(val) ; phone_will_change! unless val == @phone ; @phone = val ; end
|
433
|
-
def state=(val) ; state_will_change! unless val == @state ; @state = val ; end
|
434
|
-
def title=(val) ; title_will_change! unless val == @title ; @title = val ; end
|
435
|
-
def zip=(val) ; zip_will_change! unless val == @zip ; @zip = val ; end
|
436
|
-
|
437
|
-
def save
|
438
|
-
return false unless self.valid?
|
439
|
-
response = push_to_express_pigeon!
|
440
|
-
if response
|
441
|
-
@previously_changed = changes
|
442
|
-
@changed_attributes.clear
|
443
|
-
end
|
444
|
-
end
|
445
|
-
|
446
|
-
private
|
447
|
-
|
448
|
-
end
|
22
|
+
module ExpressPigeon
|
449
23
|
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# RSpec.describe 'campaigns integration test', skip: true do
|
2
|
+
# include PigeonSpecHelper
|
3
|
+
#
|
4
|
+
# it 'should return more than 0 campaign ids' do
|
5
|
+
# res = PIGEON.campaigns.all
|
6
|
+
# res.class.should == Array
|
7
|
+
# res.size.should > 0
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# it 'cannot send with missing parameters' do
|
11
|
+
# res = PIGEON.campaigns.send(template_id: 15_233, name: 'API Test campaign',
|
12
|
+
# from_name: 'Igor Polevoy', reply_to: 'igor@polevoy.org',
|
13
|
+
# subject: 'API test', google_analytics: true)
|
14
|
+
# validate_response res, 400, 'error', /required parameters: list_id, template_id, name, from_name, reply_to, subject, google_analytics/
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# it 'cannot send with bad reply_to' do
|
18
|
+
# res = PIGEON.campaigns.send(list_id: -1, template_id: -1, name: 'My Campaign', from_name: 'John', reply_to: 'j',
|
19
|
+
# subject: 'Hi', google_analytics: false)
|
20
|
+
# validate_response res, 400, 'error', /reply_to should be valid email address/
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# it 'cannot send with non-existing template' do
|
24
|
+
# res = PIGEON.campaigns.send(list_id: -1, template_id: -1, name: 'My Campaign', from_name: 'John',
|
25
|
+
# reply_to: 'j@j.j',
|
26
|
+
# subject: 'Hi', google_analytics: false)
|
27
|
+
# validate_response res, 400, 'error', /template=-1 is not found/
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# it 'cannot send to non-existing list' do
|
31
|
+
# res = PIGEON.campaigns.send(list_id: -1, template_id: TEMPLATE_ID, name: 'My Campaign', from_name: 'John',
|
32
|
+
# reply_to: 'j@j.j',
|
33
|
+
# subject: 'Hi', google_analytics: false)
|
34
|
+
# validate_response res, 400, 'error', /list=-1 is not found/
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# it 'cannot send to disabled list' do
|
38
|
+
# res = PIGEON.campaigns.send(list_id: LIST_ID, template_id: TEMPLATE_ID, name: 'My Campaign', from_name: 'John',
|
39
|
+
# reply_to: 'j@j.j',
|
40
|
+
# subject: 'Hi', google_analytics: false)
|
41
|
+
# validate_response res, 400, 'error', /list=#{DISABLED_LIST} is disabled/
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# it 'should create new list, add contact and send successful campaign' do
|
45
|
+
# list_resp = PIGEON.lists.create('My list', 'John', API_USER)
|
46
|
+
# list_id = list_resp.list.id
|
47
|
+
# PIGEON.contacts.upsert(list_id, email: API_USER)
|
48
|
+
# resp = PIGEON.campaigns.send(list_id: list_id, template_id: TEMPLATE_ID, name: 'My Campaign', from_name: 'John',
|
49
|
+
# reply_to: API_USER,
|
50
|
+
# subject: 'Hi', google_analytics: false)
|
51
|
+
# validate_response resp, 200, 'success', /new campaign created successfully/
|
52
|
+
# report = PIGEON.campaigns.report(resp.campaign_id)
|
53
|
+
# (report.delivered == 0 || report.delivered == 1).should be_true
|
54
|
+
# report.clicked.should eq 0
|
55
|
+
# report.opened.should eq 0
|
56
|
+
# report.spam.should eq 0
|
57
|
+
# (report.in_transit == 0 || report.in_transit == 1).should be_true
|
58
|
+
# report.unsubscribed.should eq 0
|
59
|
+
# report.bounced.should eq 0
|
60
|
+
# bounced = PIGEON.campaigns.bounced(resp.campaign_id)
|
61
|
+
# unsubscribed = PIGEON.campaigns.unsubscribed(resp.campaign_id)
|
62
|
+
# spam = PIGEON.campaigns.spam(resp.campaign_id)
|
63
|
+
#
|
64
|
+
# bounced.size.should eq 0
|
65
|
+
# unsubscribed.size.should eq 0
|
66
|
+
# spam.size.should eq 0
|
67
|
+
#
|
68
|
+
# resp = PIGEON.contacts.delete(API_USER)
|
69
|
+
# validate_response resp, 200, 'success', /contact=non@non.non deleted successfully/
|
70
|
+
#
|
71
|
+
# resp = PIGEON.contacts.find_by_email(API_USER)
|
72
|
+
# validate_response resp, 404, 'error', /contact=non@non.non not found/
|
73
|
+
#
|
74
|
+
# resp = PIGEON.lists.delete(list_id)
|
75
|
+
# validate_response resp, 200, 'success', /deleted successfully/
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# it 'cannot send campaign if scheduling with bad date' do
|
79
|
+
# list_resp = PIGEON.lists.create 'My list', 'John', API_USER
|
80
|
+
# resp = PIGEON.campaigns.schedule list_id: list_resp.list.id, template_id: TEMPLATE_ID, name: 'My Campaign',
|
81
|
+
#
|
82
|
+
# from_name: 'John',
|
83
|
+
# reply_to: API_USER, subject: 'Hi',
|
84
|
+
# google_analytics: false, schedule_for: '2013-05-28'
|
85
|
+
#
|
86
|
+
# validate_response resp, 400, 'error', /schedule_for is not in ISO date format, example: 2013-05-28T17:19:50.779/
|
87
|
+
# resp = PIGEON.lists.delete(list_resp.list.id)
|
88
|
+
# validate_response resp, 200, 'success', /deleted successfully/
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# it 'should not schedule campaign with date in the past' do
|
92
|
+
# list_resp = PIGEON.lists.create('My list', 'John', API_USER)
|
93
|
+
# resp = PIGEON.campaigns.schedule list_id: list_resp.list.id, template_id: TEMPLATE_ID, name: 'My Campaign',
|
94
|
+
# from_name: 'John',
|
95
|
+
# reply_to: API_USER, subject: 'Hi',
|
96
|
+
# google_analytics: false, schedule_for: '2010-05-28T17:19:50.779+0300'
|
97
|
+
#
|
98
|
+
# validate_response resp, 400, 'error', /schedule_for should be in the future/
|
99
|
+
# end
|
100
|
+
# end
|