send_with_us 1.3.3 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,4 @@
1
+ 1.4.3 - Add customer add/deletion support
1
2
  1.1.4 - Add Drips v2.0 support
2
3
  1.0.5 - Add attachment support
3
4
  1.0.4 - Add drip campaign unsubscribe support
@@ -9,4 +10,4 @@
9
10
  - Test coverage
10
11
  0.0.3 - No idea
11
12
  0.0.2 - Full json post body
12
- 0.0.1 - First Version
13
+ 0.0.1 - First Version
data/README.md CHANGED
@@ -146,20 +146,35 @@ rescue => e
146
146
  end
147
147
  ```
148
148
 
149
- ### Customer conversion event
149
+ ## Customers
150
+
151
+ ### Create/Update a Customer
152
+
153
+ ```ruby
154
+ customer_data = {:FirstName => "Visha"}
155
+ result = obj.customer_create("visha@example.com", customer_data)
156
+ ```
157
+
158
+ ### Delete a Customer
159
+
160
+ ```ruby
161
+ result = obj.customer_delete("visha@example.com")
162
+ ```
163
+
164
+ ### Customer Conversion Event
150
165
  You can use the Conversion API to track conversion and revenue data events against your sent emails
151
166
 
152
167
  **NOTE:** Revenue is in cents (eg. $100.50 = 10050)
153
168
 
154
169
  ```ruby
155
170
  # With Revenue
156
- obj.conversion_event('customer@example.com', 10050)
171
+ obj.customer_conversion('customer@example.com', 10050)
157
172
 
158
173
  # Without Revenue
159
- obj.conversion_event('customer@example.com')
174
+ obj.customer_conversion('customer@example.com')
160
175
  ```
161
176
 
162
- ### Rails
177
+ ## Rails
163
178
 
164
179
  For a Rails app, create `send_with_us.rb` in `/config/initializers/`
165
180
  with the following:
@@ -153,5 +153,20 @@ module SendWithUs
153
153
  endpoint = "customers/#{customer}/conversions"
154
154
  SendWithUs::ApiRequest.new(@configuration).post(endpoint, payload)
155
155
  end
156
+
157
+ def customer_create(email, data = {})
158
+ payload = {email: email}
159
+
160
+ if data.any?
161
+ payload[:data] = data
162
+ end
163
+
164
+ payload = payload.to_json
165
+ SendWithUs::ApiRequest.new(@configuration).post("customers", payload)
166
+ end
167
+
168
+ def customer_delete(email)
169
+ SendWithUs::ApiRequest.new(@configuration).delete("customers/#{email}")
170
+ end
156
171
  end
157
172
  end
@@ -1,3 +1,3 @@
1
1
  module SendWithUs
2
- VERSION = '1.3.3'
2
+ VERSION = '1.4.3'
3
3
  end
@@ -8,6 +8,7 @@ class TestApiRequest < MiniTest::Unit::TestCase
8
8
  @config = SendWithUs::Config.new( api_version: '1_0', api_key: 'THIS_IS_A_TEST_API_KEY', debug: false )
9
9
  @request = SendWithUs::ApiRequest.new(@config)
10
10
  @drip_campaign = { :drip_campaign_id => 'dc_Rmd7y5oUJ3tn86sPJ8ESCk', :drip_campaign_step_id => 'dcs_yaAMiZNWCLAEGw7GLjBuGY' }
11
+ @customer = { :email => "steve@sendwithus.com" }
11
12
  end
12
13
 
13
14
  def test_payload
@@ -143,4 +144,16 @@ class TestApiRequest < MiniTest::Unit::TestCase
143
144
  assert_instance_of( Net::HTTPSuccess, @request.post(:'customers/test@sendwithus.com/conversions', @payload))
144
145
  end
145
146
 
147
+ def test_customer_create()
148
+ build_objects
149
+ Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
150
+ assert_instance_of( Net::HTTPSuccess, @request.post(:'customers', @customer))
151
+ end
152
+
153
+ def test_customer_delete()
154
+ build_objects
155
+ Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
156
+ assert_instance_of( Net::HTTPSuccess, @request.delete(:'customers/#{@customer[:email]}'))
157
+ end
158
+
146
159
  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: 1.3.3
4
+ version: 1.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-11-12 00:00:00.000000000 Z
14
+ date: 2014-11-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake