send_with_us 1.13.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE +28 -0
- data/CHANGELOG.md +1 -0
- data/README.md +38 -33
- data/lib/send_with_us/api.rb +1 -44
- data/lib/send_with_us/version.rb +1 -1
- data/test/lib/send_with_us/api_request_test.rb +3 -48
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c84fc4a3e66e9b6695c0a3511271dc310216955
|
4
|
+
data.tar.gz: 1708ead51ac8402101d7109cab68b2b98fa9687f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de2168223aa09f4b9f3229946262a44ffb288c94263936115910c131849f54f1700f7bbd537a54617047e73046e6c8d09b20a9f8dfa2d272a0f669ce5d80bdc4
|
7
|
+
data.tar.gz: 67d28bd38f57e27ea39b92dd99959798517ed1159f7714ec00a2e814cf93fe19b5a835ab9e6832e34afe34f302f13bff49baab78d31e5a1dfd78be6943beb5b6
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<!--- Provide a general summary of your changes in the Title above -->
|
2
|
+
|
3
|
+
## Description
|
4
|
+
<!--- Describe your changes in detail if necessary -->
|
5
|
+
|
6
|
+
## Motivation and Context
|
7
|
+
<!--- Why is this change required? What problem does it solve? -->
|
8
|
+
<!--- If it fixes an open issue, please link to the issue here. -->
|
9
|
+
|
10
|
+
## How Has This Been Tested?
|
11
|
+
<!--- Please describe in detail how you tested your changes. -->
|
12
|
+
<!--- Include details of your testing environment, and the tests you ran to -->
|
13
|
+
<!--- see how your change affects other areas of the code, etc. -->
|
14
|
+
|
15
|
+
## Types of changes
|
16
|
+
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
17
|
+
- [ ] Bug fix (non-breaking change which fixes an issue)
|
18
|
+
- [ ] New feature (non-breaking change which adds functionality)
|
19
|
+
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
20
|
+
|
21
|
+
## Checklist:
|
22
|
+
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
23
|
+
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
24
|
+
- [ ] My code follows the code style of this project.
|
25
|
+
- [ ] My change requires a change to the documentation.
|
26
|
+
- [ ] I have updated the documentation accordingly.
|
27
|
+
- [ ] I have added tests to cover my changes.
|
28
|
+
- [ ] All new and existing tests passed.
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -283,18 +283,6 @@ result = obj.customer_create("visha@example.com", customer_data)
|
|
283
283
|
result = obj.customer_delete("visha@example.com")
|
284
284
|
```
|
285
285
|
|
286
|
-
### Add customer to group
|
287
|
-
|
288
|
-
```ruby
|
289
|
-
obj.customer_add_to_group(email_address, group_id)
|
290
|
-
```
|
291
|
-
|
292
|
-
### Remove customer from group
|
293
|
-
|
294
|
-
```ruby
|
295
|
-
obj.customer_remove_from_group(email_address, group_id)
|
296
|
-
```
|
297
|
-
|
298
286
|
### Get logs for customer
|
299
287
|
This will retrieve email logs for a customer.
|
300
288
|
|
@@ -346,26 +334,6 @@ obj.create_template_version(template_id, name, subject, html, text)
|
|
346
334
|
```
|
347
335
|
|
348
336
|
|
349
|
-
## Groups
|
350
|
-
|
351
|
-
Groups are another way to "tag" customers in sendwithus. They can be thought of as lists.
|
352
|
-
|
353
|
-
|
354
|
-
```ruby
|
355
|
-
# List groups
|
356
|
-
obj.get_groups()
|
357
|
-
|
358
|
-
# Create group
|
359
|
-
obj.create_customer_group(name, description)
|
360
|
-
|
361
|
-
# Update group
|
362
|
-
obj.update_customer_group(group_id, new_name, new_description)
|
363
|
-
|
364
|
-
# Delete group
|
365
|
-
obj.delete_customer_group(group_id)
|
366
|
-
|
367
|
-
```
|
368
|
-
|
369
337
|
## Rails
|
370
338
|
|
371
339
|
For a Rails app, create `send_with_us.rb` in `/config/initializers/`
|
@@ -389,7 +357,7 @@ rescue => e
|
|
389
357
|
end
|
390
358
|
```
|
391
359
|
|
392
|
-
Take a look at our Mailer that you can use to
|
360
|
+
Take a look at our Mailer that you can use similarly to ActionMailer
|
393
361
|
|
394
362
|
[sendwithus_ruby_action_mailer](https://github.com/sendwithus/sendwithus_ruby_action_mailer)
|
395
363
|
|
@@ -420,6 +388,43 @@ SendWithUs::ApiConnectionRefused - the target URI is probably incorrect
|
|
420
388
|
SendWithUs::ApiUnknownError - an unhandled HTTP error occurred
|
421
389
|
```
|
422
390
|
|
391
|
+
## Running tests
|
392
|
+
Use [rake](https://github.com/ruby/rake) to run the tests:
|
393
|
+
|
394
|
+
```sh
|
395
|
+
$: rake
|
396
|
+
```
|
397
|
+
|
398
|
+
## Troubleshooting
|
399
|
+
|
400
|
+
### General Troubleshooting
|
401
|
+
|
402
|
+
- Enable debug mode
|
403
|
+
- Make sure you're using the latest Ruby client
|
404
|
+
- Capture the response data and check your logs — often this will have the exact error
|
405
|
+
|
406
|
+
### Enable Debug Mode
|
407
|
+
|
408
|
+
Debug mode prints out the underlying request information as well as the data payload that gets sent to sendwithus. You will most likely find this information in your logs. To enable it, simply put `debug: true` as a parameter when instantiating the API object. Use the debug mode to compare the data payload getting sent to [sendwithus' API docs](https://www.sendwithus.com/docs/api "Official Sendwithus API Docs").
|
409
|
+
|
410
|
+
```php
|
411
|
+
obj = SendWithUs::Api.new( api_key: 'YOUR API KEY', debug: true )
|
412
|
+
```
|
413
|
+
|
414
|
+
### Response Ranges
|
415
|
+
|
416
|
+
Sendwithus' API typically sends responses back in these ranges:
|
417
|
+
|
418
|
+
- 2xx – Successful Request
|
419
|
+
- 4xx – Failed Request (Client error)
|
420
|
+
- 5xx – Failed Request (Server error)
|
421
|
+
|
422
|
+
If you're receiving an error in the 400 response range follow these steps:
|
423
|
+
|
424
|
+
- Double check the data and ID's getting passed to Sendwithus
|
425
|
+
- Ensure your API key is correct
|
426
|
+
- Log and check the body of the response
|
427
|
+
|
423
428
|
|
424
429
|
## Internal
|
425
430
|
Build gem with
|
data/lib/send_with_us/api.rb
CHANGED
@@ -252,12 +252,11 @@ module SendWithUs
|
|
252
252
|
SendWithUs::ApiRequest.new(@configuration).get("customers/#{email}")
|
253
253
|
end
|
254
254
|
|
255
|
-
def customer_create(email, data = {}, locale = nil
|
255
|
+
def customer_create(email, data = {}, locale = nil)
|
256
256
|
payload = {email: email}
|
257
257
|
|
258
258
|
payload[:data] = data if data && data.any?
|
259
259
|
payload[:locale] = locale if locale
|
260
|
-
payload[:groups] = groups if groups && groups.any?
|
261
260
|
|
262
261
|
payload = payload.to_json
|
263
262
|
endpoint = "customers"
|
@@ -269,18 +268,6 @@ module SendWithUs
|
|
269
268
|
SendWithUs::ApiRequest.new(@configuration).delete(endpoint)
|
270
269
|
end
|
271
270
|
|
272
|
-
def customer_add_to_group(email_address, group_id)
|
273
|
-
payload = nil
|
274
|
-
|
275
|
-
endpoint = "customers/#{email_address}/groups/#{group_id}"
|
276
|
-
SendWithUs::ApiRequest.new(@configuration).post(endpoint, payload)
|
277
|
-
end
|
278
|
-
|
279
|
-
def customer_remove_from_group(email_address, group_id)
|
280
|
-
endpoint = "customers/#{email_address}/groups/#{group_id}"
|
281
|
-
SendWithUs::ApiRequest.new(@configuration).delete(endpoint)
|
282
|
-
end
|
283
|
-
|
284
271
|
def customer_email_log(email_address, options = {})
|
285
272
|
endpoint = "customers/#{email_address}/logs"
|
286
273
|
params = {}
|
@@ -360,35 +347,5 @@ module SendWithUs
|
|
360
347
|
endpoint = "templates/#{template_id}/versions"
|
361
348
|
SendWithUs::ApiRequest.new(@configuration).post(endpoint, payload.to_json)
|
362
349
|
end
|
363
|
-
|
364
|
-
def get_groups()
|
365
|
-
endpoint = "groups"
|
366
|
-
SendWithUs::ApiRequest.new(@configuration).get(endpoint)
|
367
|
-
end
|
368
|
-
|
369
|
-
def create_customer_group(name, description = '')
|
370
|
-
payload = {
|
371
|
-
name: name,
|
372
|
-
description: description
|
373
|
-
}
|
374
|
-
|
375
|
-
endpoint = "groups"
|
376
|
-
SendWithUs::ApiRequest.new(@configuration).post(endpoint, payload.to_json)
|
377
|
-
end
|
378
|
-
|
379
|
-
def update_customer_group(group_id, name = '', description = '')
|
380
|
-
payload = {
|
381
|
-
name: name,
|
382
|
-
description: description
|
383
|
-
}
|
384
|
-
|
385
|
-
endpoint = "groups/#{group_id}"
|
386
|
-
SendWithUs::ApiRequest.new(@configuration).put(endpoint, payload.to_json)
|
387
|
-
end
|
388
|
-
|
389
|
-
def delete_customer_group(group_id)
|
390
|
-
endpoint = "groups/#{group_id}"
|
391
|
-
SendWithUs::ApiRequest.new(@configuration).delete(endpoint)
|
392
|
-
end
|
393
350
|
end
|
394
351
|
end
|
data/lib/send_with_us/version.rb
CHANGED
@@ -11,9 +11,9 @@ class TestApiRequest < Minitest::Test
|
|
11
11
|
:drip_campaign_id => 'dc_Rmd7y5oUJ3tn86sPJ8ESCk',
|
12
12
|
:drip_campaign_step_id => 'dcs_yaAMiZNWCLAEGw7GLjBuGY'
|
13
13
|
}
|
14
|
-
@customer = {
|
15
|
-
|
16
|
-
|
14
|
+
@customer = {
|
15
|
+
:email => 'steve@sendwithus.com'
|
16
|
+
}
|
17
17
|
@template = {
|
18
18
|
:html => '<html><head></head><body>TEST</body></html>',
|
19
19
|
:subject => 'A test template',
|
@@ -325,54 +325,9 @@ class TestApiRequest < Minitest::Test
|
|
325
325
|
assert_instance_of( Net::HTTPSuccess, @request.delete(:'customers/#{@customer[:email]}'))
|
326
326
|
end
|
327
327
|
|
328
|
-
def test_customer_add_to_group
|
329
|
-
build_objects
|
330
|
-
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
|
331
|
-
assert_instance_of( Net::HTTPSuccess, @request.post(:"customers/#{@customer[:email]})/groups/#{@customer[:email][0]}", @customer))
|
332
|
-
end
|
333
|
-
|
334
|
-
def test_customer_remove_from_group
|
335
|
-
build_objects
|
336
|
-
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
|
337
|
-
assert_instance_of( Net::HTTPSuccess, @request.delete(:"customers/#{@customer[:email]})/groups/#{@customer[:email][0]}"))
|
338
|
-
end
|
339
|
-
|
340
328
|
def test_logs_with_options
|
341
329
|
build_objects
|
342
330
|
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
|
343
331
|
assert_instance_of( Net::HTTPSuccess, @request.get(:'logs?count=2&offset=10'))
|
344
332
|
end
|
345
|
-
|
346
|
-
def test_get_groups
|
347
|
-
build_objects
|
348
|
-
result = @api.get_groups()
|
349
|
-
|
350
|
-
assert_instance_of( Net::HTTPOK, result )
|
351
|
-
end
|
352
|
-
|
353
|
-
def test_create_customer_group
|
354
|
-
build_objects
|
355
|
-
result = @api.create_customer_group('testing')
|
356
|
-
result_id = JSON.parse(result.body)["group"]["id"]
|
357
|
-
|
358
|
-
# clean up
|
359
|
-
@api.delete_customer_group(result_id)
|
360
|
-
|
361
|
-
assert_instance_of( Net::HTTPOK, result )
|
362
|
-
end
|
363
|
-
|
364
|
-
def test_update_customer_group
|
365
|
-
build_objects
|
366
|
-
result = @api.update_customer_group(@customer[:groups][0], 'test')
|
367
|
-
assert_instance_of( Net::HTTPOK, result )
|
368
|
-
end
|
369
|
-
|
370
|
-
def delete_customer_group
|
371
|
-
build_objects
|
372
|
-
new_group = @api.create_customer_group('deleteme')
|
373
|
-
new_group_id = JSON.parse(new_group.body)["group"]["id"]
|
374
|
-
result = @api.delete_customer_group(new_group_id)
|
375
|
-
|
376
|
-
assert_instance_of( Net::HTTPOK, result )
|
377
|
-
end
|
378
333
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: send_with_us
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Harris
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2017-03-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|
@@ -64,6 +64,7 @@ extensions: []
|
|
64
64
|
extra_rdoc_files: []
|
65
65
|
files:
|
66
66
|
- ".github/ISSUE_TEMPLATE"
|
67
|
+
- ".github/PULL_REQUEST_TEMPLATE"
|
67
68
|
- ".gitignore"
|
68
69
|
- ".travis.yml"
|
69
70
|
- CHANGELOG.md
|