send_with_us 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 65b92cea546354eac916a6b8ddf032708fb6d781
4
+ data.tar.gz: 45eac263af34f99b56df3cad0dbdcb98fac9c141
5
+ SHA512:
6
+ metadata.gz: 5739066e33b90202e3ba743c4d67cc1a01e72b69b31124f94930367537aeaaf3c0c114f16f76b45973ca9682c2cccebf53af45155835abc08f4556c243e08c9a
7
+ data.tar.gz: c7fc5a00fee215eede59fdfc385dc833a1b762b2dfb70be40459340c8f5b10ecf3b7aa496b741708fb0d12594e6ccf55bc176e050078b00960521d6e33f766d1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,4 @@
1
+ 1.1.4 - Add Drips v2.0 support
1
2
  1.0.5 - Add attachment support
2
3
  1.0.4 - Add drip campaign unsubscribe support
3
4
  1.0.3 - Don't allow nil email_id
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- send_with_us (1.1.3)
4
+ send_with_us (1.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -81,7 +81,7 @@ begin
81
81
  puts result
82
82
 
83
83
  # Set ESP account
84
- # See: https://help.sendwithus.com/support/solutions/articles/1000088976-set-up-and-use-multiple
84
+ # See: https://help.sendwithus.com/support/solutions/articles/1000088976-set-up-and-use-multiple
85
85
  result = obj.send_with(
86
86
  'email_id',
87
87
  { name: 'Matt', address: 'recipient@example.com' },
@@ -115,6 +115,43 @@ rescue => e
115
115
  end
116
116
  ```
117
117
 
118
+ ### Using Drips 2.0
119
+
120
+ ```ruby
121
+ require 'rubygems'
122
+ require 'send_with_us'
123
+
124
+ begin
125
+ obj = SendWithUs::Api.new( api_key: 'YOUR API KEY', debug: true )
126
+
127
+ # List campaigns
128
+ result = obj.list_drip_campaigns()
129
+ puts result
130
+
131
+ # List steps of campaign dc_asdf1234
132
+ result = obj.drip_campaign_details('dc_asdf1234')
133
+ puts result
134
+
135
+ # Add customer@example.com to campaign dc_asdf1234
136
+ result = obj.start_on_drip_campaign('customer@example.com', 'dc_asdf1234', {location: 'Canada', total: '100.00'})
137
+ puts result
138
+
139
+ # Remove customer@example.com from campaign dc_asdf1234
140
+ result = obj.remove_from_drip_campaign('cusomter@example.com', 'dc_asdf1234')
141
+ puts result
142
+
143
+ # List active customers on campaign dc_asdf1234
144
+ result = obj.list_customers_on_campaign('dc_asdf1234')
145
+ puts result
146
+
147
+ # List active customers on campaign step dcs_qwer5678
148
+ result = obj.list_customers_on_campaign_step('dc_asdf1234', 'dcs_qwer5678')
149
+ puts result
150
+ rescue => e
151
+ puts "error - #{e.class.name}: #{e.message}"
152
+ end
153
+ ```
154
+
118
155
  ### Rails
119
156
 
120
157
  For a Rails app, create `send_with_us.rb` in `/config/initializers/`
@@ -86,19 +86,58 @@ module SendWithUs
86
86
  SendWithUs::ApiRequest.new(@configuration).post(:emails, payload)
87
87
  end
88
88
 
89
+ def list_drip_campaigns()
90
+ SendWithUs::ApiRequest.new(@configuration).get(:drip_campaigns)
91
+ end
92
+
93
+ def start_on_drip_campaign(recipient_address, drip_campaign_id, email_data={})
94
+
95
+ if email_data.nil?
96
+ payload = {
97
+ recipient_address: recipient_address
98
+ }.to_json
99
+ else
100
+ payload = {
101
+ recipient_address: recipient_address,
102
+ email_data: email_data
103
+ }.to_json
104
+ end
105
+
106
+ SendWithUs::ApiRequest.new(@configuration).post('drip_campaigns/#{drip_campaign_id}/activate'.to_sym, payload)
107
+ end
108
+
109
+ def remove_from_drip_campaign(recipient_address, drip_campaign_id)
110
+ payload = {
111
+ recipient_address: recipient_address
112
+ }.to_json
113
+
114
+ SendWithUs::ApiRequest.new(@configuration).post('drip_campaigns/#{drip_campaign_id}/deactivate'.to_sym, payload)
115
+ end
116
+
117
+ def drip_campaign_details(drip_campaign_id)
118
+ SendWithUs::ApiRequest.new(@configuration).get('drip_campaigns/#{drip_campaign_id}'.to_sym)
119
+ end
120
+
121
+ def list_customers_on_campaign(drip_campaign_id)
122
+ SendWithUs::ApiRequest.new(@configuration).get('drip_campaigns/#{drip_campaign_id}/customers'.to_sym)
123
+ end
124
+
125
+ def list_customers_on_campaign_step(drip_campaign_id, drip_campaign_step_id)
126
+ SendWithUs::ApiRequest.new(@configuration).get('drip_campaigns/#{drip_campaign_id}/step/#{drip_campaign_step_id}/customers'.to_sym)
127
+ end
128
+
89
129
  def add_customer_event(customer, event_name, revenue=nil)
90
-
91
- if revenue.nil?
130
+
131
+ if revenue.nil?
92
132
  payload = { event_name: event_name }
93
133
  else
94
134
  payload = { event_name: event_name, revenue: revenue}
95
- end
96
-
135
+ end
136
+
97
137
  payload = payload.to_json
98
138
  endpoint = 'customers/' + customer + '/events'
99
139
  SendWithUs::ApiRequest.new(@configuration).post(endpoint, payload)
100
- end
101
-
102
- end
140
+ end
141
+ end
103
142
  end
104
143
 
@@ -1,3 +1,3 @@
1
1
  module SendWithUs
2
- VERSION = '1.1.4'
2
+ VERSION = '1.1.5'
3
3
  end
@@ -72,6 +72,42 @@ class TestApiRequest < MiniTest::Unit::TestCase
72
72
  assert_instance_of( Net::HTTPSuccess, @request.get(:emails) )
73
73
  end
74
74
 
75
+ def test_list_drip_campaigns
76
+ build_objects
77
+ Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
78
+ assert_instance_of( Net::HTTPSuccess, @request.get(:'drip_campaigns') )
79
+ end
80
+
81
+ def test_start_on_drip_campaign
82
+ build_objects
83
+ Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
84
+ assert_instance_of( Net::HTTPSuccess, @request.post('drip_campaigns/#{drip_campaign_id}/activate'.to_sym, @payload) )
85
+ end
86
+
87
+ def test_remove_from_drip_campaign
88
+ build_objects
89
+ Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
90
+ assert_instance_of( Net::HTTPSuccess, @request.post('drip_campaigns/#{drip_campaign_id}/deactivate'.to_sym, @payload) )
91
+ end
92
+
93
+ def test_drip_campaign_details
94
+ build_objects
95
+ Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
96
+ assert_instance_of( Net::HTTPSuccess, @request.get('drip_campaigns/#{drip_campaign_id}'.to_sym) )
97
+ end
98
+
99
+ def test_list_customers_on_campaign
100
+ build_objects
101
+ Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
102
+ assert_instance_of( Net::HTTPSuccess, @request.get('drip_campaigns/#{drip_campaign_id}/customers'.to_sym) )
103
+ end
104
+
105
+ def test_list_customers_on_campaign_step
106
+ build_objects
107
+ Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
108
+ assert_instance_of( Net::HTTPSuccess, @request.get('drip_campaigns/#{drip_campaign_id}/step/#{drip_campaign_step_id}/customers'.to_sym) )
109
+ end
110
+
75
111
  def test_request_path
76
112
  build_objects
77
113
  assert_equal( true, @request.send(:request_path, :send) == '/api/v1_0/send' )
@@ -82,5 +118,5 @@ class TestApiRequest < MiniTest::Unit::TestCase
82
118
  Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
83
119
  assert_instance_of( Net::HTTPSuccess, @request.post(:'customers/test@sendwithus.com/events', @payload))
84
120
  end
85
-
121
+
86
122
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: send_with_us
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
5
- prerelease:
4
+ version: 1.1.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matt Harris
@@ -11,54 +10,48 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2014-08-14 00:00:00.000000000 Z
13
+ date: 2014-09-03 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rake
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
- - - ! '>='
19
+ - - ">="
22
20
  - !ruby/object:Gem::Version
23
21
  version: '0'
24
22
  type: :development
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
- - - ! '>='
26
+ - - ">="
30
27
  - !ruby/object:Gem::Version
31
28
  version: '0'
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: shoulda
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
- - - ! '>='
33
+ - - ">="
38
34
  - !ruby/object:Gem::Version
39
35
  version: '0'
40
36
  type: :development
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
- - - ! '>='
40
+ - - ">="
46
41
  - !ruby/object:Gem::Version
47
42
  version: '0'
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: mocha
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
- - - ! '>='
47
+ - - ">="
54
48
  - !ruby/object:Gem::Version
55
49
  version: '0'
56
50
  type: :development
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
- - - ! '>='
54
+ - - ">="
62
55
  - !ruby/object:Gem::Version
63
56
  version: '0'
64
57
  description: SendWithUs.com Ruby Client
@@ -68,8 +61,8 @@ executables: []
68
61
  extensions: []
69
62
  extra_rdoc_files: []
70
63
  files:
71
- - .gitignore
72
- - .travis.yml
64
+ - ".gitignore"
65
+ - ".travis.yml"
73
66
  - CHANGELOG.md
74
67
  - Gemfile
75
68
  - Gemfile.lock
@@ -90,27 +83,26 @@ files:
90
83
  - test/test_helper.rb
91
84
  homepage: https://github.com/sendwithus/sendwithus_ruby
92
85
  licenses: []
86
+ metadata: {}
93
87
  post_install_message:
94
88
  rdoc_options: []
95
89
  require_paths:
96
90
  - lib
97
91
  required_ruby_version: !ruby/object:Gem::Requirement
98
- none: false
99
92
  requirements:
100
- - - ! '>='
93
+ - - ">="
101
94
  - !ruby/object:Gem::Version
102
95
  version: '0'
103
96
  required_rubygems_version: !ruby/object:Gem::Requirement
104
- none: false
105
97
  requirements:
106
- - - ! '>='
98
+ - - ">="
107
99
  - !ruby/object:Gem::Version
108
100
  version: '0'
109
101
  requirements: []
110
102
  rubyforge_project:
111
- rubygems_version: 1.8.23.2
103
+ rubygems_version: 2.2.2
112
104
  signing_key:
113
- specification_version: 3
105
+ specification_version: 4
114
106
  summary: SendWithUs.com Ruby Client
115
107
  test_files:
116
108
  - test/lib/send_with_us/api_request_test.rb