sailthru-client 4.0.3 → 4.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b45d35c5d3292ac571513438e6d96a938c493f21
4
- data.tar.gz: fa8db0b98ba41d0aa3a7878ba9b7bad7c6c5bb34
3
+ metadata.gz: 0761242226c7a009220ba1b1f7f5510e4549465c
4
+ data.tar.gz: 5da88ae0c079cf3e7cd06ad694e11d599750a30e
5
5
  SHA512:
6
- metadata.gz: 82a15ccc9c4775a6751a69335c07f617aa849a402a8ea6c299a722c4a946d5583e9d4e318913ee7f6d905d0c812698521bd778a5c5ebd417a0c3dafe4add845c
7
- data.tar.gz: 48fbcd89d152026fde063f9b8034bd830a4a8de0715c7a0dcd8892f432c02edf594f43404fec2ec489a8bf93c2122b36862b6d78e86b405d8e8c7baa0110a74a
6
+ metadata.gz: 6f8baac4566faa4b74317dc75d7bd9139b864af1f99cea7a8e5958ff207c4f998b07de0f06866a2779f1774446ef3d3b461f3b324893820587836ed7a6a7ecc6
7
+ data.tar.gz: 6640ca3ca033a94d6428eb160c7f68c705654ea550e4a922d72c65abe57c6876daec9f35a310dc0396935ee49e474d5cc1f7b2db27a474d31d13d1181ef0657e
@@ -0,0 +1 @@
1
+ require 'sailthru'
@@ -1,4 +1,5 @@
1
1
  require 'sailthru/helpers'
2
+ require 'sailthru/version'
2
3
 
3
4
  require 'net/http'
4
5
  require 'net/http/post/multipart'
@@ -306,13 +307,35 @@ module Sailthru
306
307
 
307
308
  sig = params.delete(:sig)
308
309
  params.delete(:controller)
309
- return false unless sig == get_signature_hash(params, @secret)
310
- return true
310
+ sig == get_signature_hash(params, @secret)
311
311
  else
312
- return false
312
+ false
313
+ end
314
+ end
315
+
316
+ # List Postbacks must be enabled by Sailthru
317
+ # Contact your account manager or contact support to have this enabled
318
+ #
319
+ # params:
320
+ # params, Hash
321
+ # request, String
322
+ # returns:
323
+ # TrueClass or FalseClass, Returns true if the incoming request is an authenticated list post.
324
+ def receive_list_post(params, request)
325
+ if request.post?
326
+ [:action, :email, :sig].each { |key| return false unless params.has_key?(key) }
327
+
328
+ return false unless params[:action] == 'update'
329
+
330
+ sig = params.delete(:sig)
331
+ params.delete(:controller)
332
+ sig == get_signature_hash(params, @secret)
333
+ else
334
+ false
313
335
  end
314
336
  end
315
337
 
338
+
316
339
  # params:
317
340
  # params, Hash
318
341
  # request, String
@@ -326,10 +349,9 @@ module Sailthru
326
349
 
327
350
  sig = params.delete(:sig)
328
351
  params.delete(:controller)
329
- return false unless sig == get_signature_hash(params, @secret)
330
- return true
352
+ sig == get_signature_hash(params, @secret)
331
353
  else
332
- return false
354
+ false
333
355
  end
334
356
  end
335
357
 
@@ -583,6 +605,13 @@ module Sailthru
583
605
  process_job(:update, data, report_email, postback_url, 'file')
584
606
  end
585
607
 
608
+ # implementation for purchase import job using file upload
609
+ def process_purchase_import_job_from_file(file_path, report_email = nil, postback_url = nil, options = {})
610
+ data = options
611
+ data['file'] = file_path
612
+ process_job(:purchase_import, data, report_email, postback_url, 'file')
613
+ end
614
+
586
615
  # implementation for snapshot job
587
616
  def process_snapshot_job(query = {}, report_email = nil, postback_url = nil, options = {})
588
617
  data = options
@@ -1,3 +1,3 @@
1
1
  module Sailthru
2
- VERSION = '4.0.3'
2
+ VERSION = '4.0.6'
3
3
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.homepage = "http://docs.sailthru.com"
16
16
  s.rdoc_options = ["--main", "README.md"]
17
17
  s.require_paths = ["lib"]
18
- s.summary = "A simple client library to remotely access the Sailthru REST API."
18
+ s.summary = "A simple client library to remotely access the Sailthru REST API. "
19
19
  s.license = "MIT"
20
20
 
21
21
  s.add_dependency(%q<json>, [">= 0"])
@@ -0,0 +1,18 @@
1
+ {
2
+ "name":"my-template-test-vars",
3
+ "sample":"",
4
+ "verify_post_url":"",
5
+ "is_google_analytics":false,
6
+ "is_unviewable":false,
7
+ "error_url":"",
8
+ "subject":"Hello world",
9
+ "content_html":"Hi {firstName}<p/>{beacon}<p><small>If you believe this has been sent to you in error, please safely <a href=\"{optout_confirm_url}\">unsubscribe</a>.</small></p>",
10
+ "is_disabled":false,
11
+ "replyto_email":"",
12
+ "is_link_tracking":true,
13
+ "is_invite":false,
14
+ "success_url":"",
15
+ "content_sms":"",
16
+ "content_text":"",
17
+ "test_vars" : "{\"firstName\":\"Lindsay\"}"
18
+ }
@@ -39,6 +39,19 @@ class ReceivePostCallbackTest < Minitest::Test
39
39
  assert @sailthru_client.receive_optout_post(params, mock(:post? => true))
40
40
  end
41
41
 
42
+ it "can validate a list callback" do
43
+ params = {
44
+ :email => 'ian@sailthru.com',
45
+ :page => 'optout',
46
+ :optout_email => 'none',
47
+ :lists => {'All Users' => '0'},
48
+ :action => 'update',
49
+ :api_key => @api_key
50
+ }
51
+ params[:sig] = get_signature_hash(params, @secret)
52
+ assert @sailthru_client.receive_list_post(params, mock(:post? => true))
53
+ end
54
+
42
55
  it "can validate a hardbounce callback" do
43
56
  params = {
44
57
  :email => 'ian@sailthru.com',
@@ -15,21 +15,11 @@ class StatsTest < Minitest::Test
15
15
  params = {'stat' => stat_field}
16
16
  query_string = create_json_payload(@api_key, @secret, params)
17
17
  stub_get(@api_call_url + '?' + query_string, 'stat_get_valid.json')
18
- response = @sailthru_client.get_stats(stat_field)
18
+ response = @sailthru_client.stats_list()
19
19
  assert_nil response['error']
20
20
  assert_nil response['errormsg']
21
21
  end
22
22
 
23
- it "cannot get information about given field when it's invalid" do
24
- stat_field = 'invalid_field'
25
- params = {'stat' => stat_field}
26
- query_string = create_json_payload(@api_key, @secret, params)
27
- stub_get(@api_call_url + '?' + query_string, 'stat_get_invalid.json')
28
- response = @sailthru_client.get_stats(stat_field)
29
- refute_nil response['error']
30
- refute_nil response['errormsg']
31
- end
32
-
33
23
  it "can get stats list data when list and date are not null" do
34
24
  params = {'stat' => 'list'}
35
25
  query_string = create_json_payload(@api_key, @secret, params)
@@ -39,6 +39,15 @@ class TemplateTest < Minitest::Test
39
39
  assert_equal from_name, response['from_name']
40
40
  end
41
41
 
42
+ it "can save template with test_vars" do
43
+ valid_template_name = 'my-template-test-vars'
44
+ valid_test_vars = "{\"firstName\":\"Lindsay\"}"
45
+ stub_post(@api_call_url, 'template_save_test_vars.json')
46
+ response = @sailthru_client.save_template(valid_template_name, {'test_vars'=> valid_test_vars})
47
+ assert_equal valid_template_name, response['name']
48
+ assert_equal valid_test_vars, response['test_vars']
49
+ end
50
+
42
51
  it "can delete a template with valid template name" do
43
52
  template_name = 'my-template'
44
53
  params = {'template' => template_name}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sailthru-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Prajwal Tuladhar
@@ -10,90 +10,90 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-05-08 00:00:00.000000000 Z
13
+ date: 2015-12-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - '>='
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - '>='
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: multipart-post
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - '>='
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: '0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - '>='
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rake
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - '>='
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: fakeweb
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - '>='
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - '>='
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: minitest
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - '>='
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: '5'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - '>='
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: '5'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: mocha
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - '>='
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  description:
@@ -103,12 +103,13 @@ extensions: []
103
103
  extra_rdoc_files:
104
104
  - README.md
105
105
  files:
106
- - .gitignore
106
+ - ".gitignore"
107
107
  - CHANGELOG.md
108
108
  - Gemfile
109
109
  - MIT-LICENSE
110
110
  - README.md
111
111
  - Rakefile
112
+ - lib/sailthru-client.rb
112
113
  - lib/sailthru.rb
113
114
  - lib/sailthru/client.rb
114
115
  - lib/sailthru/helpers.rb
@@ -150,6 +151,7 @@ files:
150
151
  - test/fixtures/template_delete_valid.json
151
152
  - test/fixtures/template_invalid_get.json
152
153
  - test/fixtures/template_save.json
154
+ - test/fixtures/template_save_test_vars.json
153
155
  - test/fixtures/template_valid_get.json
154
156
  - test/fixtures/user_update_post_valid.json
155
157
  - test/fixtures/user_update_valid.json
@@ -172,23 +174,23 @@ licenses:
172
174
  metadata: {}
173
175
  post_install_message:
174
176
  rdoc_options:
175
- - --main
177
+ - "--main"
176
178
  - README.md
177
179
  require_paths:
178
180
  - lib
179
181
  required_ruby_version: !ruby/object:Gem::Requirement
180
182
  requirements:
181
- - - '>='
183
+ - - ">="
182
184
  - !ruby/object:Gem::Version
183
185
  version: '0'
184
186
  required_rubygems_version: !ruby/object:Gem::Requirement
185
187
  requirements:
186
- - - '>='
188
+ - - ">="
187
189
  - !ruby/object:Gem::Version
188
190
  version: '0'
189
191
  requirements: []
190
192
  rubyforge_project:
191
- rubygems_version: 2.0.14
193
+ rubygems_version: 2.4.6
192
194
  signing_key:
193
195
  specification_version: 4
194
196
  summary: A simple client library to remotely access the Sailthru REST API.
@@ -229,6 +231,7 @@ test_files:
229
231
  - test/fixtures/template_delete_valid.json
230
232
  - test/fixtures/template_invalid_get.json
231
233
  - test/fixtures/template_save.json
234
+ - test/fixtures/template_save_test_vars.json
232
235
  - test/fixtures/template_valid_get.json
233
236
  - test/fixtures/user_update_post_valid.json
234
237
  - test/fixtures/user_update_valid.json