sailthru-client 2.0.0 → 3.0.0

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.
Files changed (62) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +6 -0
  3. data/CHANGELOG.md +31 -0
  4. data/Gemfile +11 -0
  5. data/Gemfile.lock +22 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +11 -4
  8. data/Rakefile +19 -0
  9. data/lib/sailthru.rb +115 -101
  10. data/sailthru-client.gemspec +26 -0
  11. data/test/fixtures/blast_delete_invalid.json +1 -0
  12. data/test/fixtures/blast_delete_valid.json +1 -0
  13. data/test/fixtures/blast_get_invalid.json +1 -0
  14. data/test/fixtures/blast_get_valid.json +1 -0
  15. data/test/fixtures/blast_post_invalid_email.json +1 -0
  16. data/test/fixtures/blast_post_invalid_list.json +1 -0
  17. data/test/fixtures/blast_post_update_valid.json +1 -0
  18. data/test/fixtures/blast_post_valid.json +1 -0
  19. data/test/fixtures/content_valid.json +1 -0
  20. data/test/fixtures/email_get_listed_email.json +1 -0
  21. data/test/fixtures/email_get_not_listed_email.json +1 -0
  22. data/test/fixtures/list_delete_invalid.json +1 -0
  23. data/test/fixtures/list_delete_valid.json +1 -0
  24. data/test/fixtures/list_get_all.json +14 -0
  25. data/test/fixtures/list_get_invalid.json +1 -0
  26. data/test/fixtures/list_get_invalid.txt +4 -0
  27. data/test/fixtures/list_get_valid.json +8 -0
  28. data/test/fixtures/list_get_valid.txt +3 -0
  29. data/test/fixtures/list_save_valid.json +8 -0
  30. data/test/fixtures/purchase_post_invalid_email.json +1 -0
  31. data/test/fixtures/purchase_post_invalid_empty_items.json +1 -0
  32. data/test/fixtures/purchase_post_valid_multiple_items.json +1 -0
  33. data/test/fixtures/purchase_post_valid_single_item.json +1 -0
  34. data/test/fixtures/send_cancel.json +1 -0
  35. data/test/fixtures/send_get_invalid.json +1 -0
  36. data/test/fixtures/send_get_valid.json +1 -0
  37. data/test/fixtures/send_post_invalid.json +1 -0
  38. data/test/fixtures/send_post_multiple_valid.json +1 -0
  39. data/test/fixtures/stat_get_invalid.json +1 -0
  40. data/test/fixtures/stat_get_valid.json +1 -0
  41. data/test/fixtures/stats_lists_invalid.json +1 -0
  42. data/test/fixtures/stats_lists_valid.json +1 -0
  43. data/test/fixtures/template_delete_invalid.json +1 -0
  44. data/test/fixtures/template_delete_valid.json +1 -0
  45. data/test/fixtures/template_invalid_get.json +1 -0
  46. data/test/fixtures/template_save.json +1 -0
  47. data/test/fixtures/template_valid_get.json +1 -0
  48. data/test/fixtures/user_update_post_valid.json +3 -0
  49. data/test/fixtures/user_update_valid.json +1 -0
  50. data/test/sailthru/blast_test.rb +116 -0
  51. data/test/sailthru/content_test.rb +36 -0
  52. data/test/sailthru/email_test.rb +23 -0
  53. data/test/sailthru/error_test.rb +30 -0
  54. data/test/sailthru/file_upload_test.rb +75 -0
  55. data/test/sailthru/helpers_test.rb +23 -0
  56. data/test/sailthru/list_test.rb +69 -0
  57. data/test/sailthru/purchase_test.rb +67 -0
  58. data/test/sailthru/send_test.rb +81 -0
  59. data/test/sailthru/stats_test.rb +53 -0
  60. data/test/sailthru/template_test.rb +61 -0
  61. data/test/test_helper.rb +68 -0
  62. metadata +117 -19
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODBmMmIwZjBhOTdlZTdmZjEzMDFjZmEzYWVmYzM1MTZiZmI2N2FhOA==
5
+ data.tar.gz: !binary |-
6
+ ZjhhMTg5ZDBmNTlhODU1ZmJiZGZlYmExOGM0YWViNDk3ZjBjZDEzNg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MWFkZmE3MzMyNWFlNzk1NTc0ZGViNmNlYzI1YjVkZjdjNTAwYzc0MzRlNmJi
10
+ ZDljM2MxMzQyYjRjOWIzMDQxYjkwZTU4NjdjYWRjZmM0ODVlNjA3OWE5OGRh
11
+ NGUxNDI2NzY0MDBhOWIzMGE4Mjg1OWJmYWI3YjVhNjFkN2ZkZjc=
12
+ data.tar.gz: !binary |-
13
+ NjY4NGRhMDNjMGIwYWE0NmU4MzgwM2QyYzFhNDUwMmIzNDNlZDc3MjNmYWNm
14
+ ZjQ2YjNjNTEzYzZiZjQ5MTg1YzExN2ZjMGM1YjU1OWYxNDAyMjYyYzA2MTk5
15
+ ZjYwOTA2YzUwYjQwMGQyNjhjZDhlMTYyZWUyNjBlZDI0NTg5YzU=
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .*.sw[a-z]
2
+ *.un~
3
+ .rvmrc
4
+ *.gem
5
+ .loadpath
6
+ rdoc
data/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ ## 2.0.0 (Sep 6, 2013)
2
+ - Added triggers and events
3
+ - Changed push_content to handle additional parameters
4
+ - Added verification for postbacks
5
+ - Removed Horizon calls
6
+ - Remvoed create_new_user method
7
+ - Added change_email method
8
+ - Added stats_send method
9
+
10
+ ## 1.14 (Feb 10, 2012)
11
+ - Remove contact API call
12
+ - Update list API call: save_list() cannot be used for saving emails
13
+ - Added get_lists() for retrieving all available lists information
14
+
15
+ ## 1.13 (September 8, 2011)
16
+ - Explicitly convert Exception to string for Ruby 1.9 (Robert Coker)
17
+ - Update purchase() call
18
+
19
+
20
+ ## 1.12 (July 22, 2011)
21
+ - Fix send / multisend api call bug
22
+
23
+ ## 1.11 (June 15, 2011)
24
+ - Job API docs
25
+ - SSL verification disabled
26
+ - Typed variable values can be passed now
27
+
28
+ ## 1.10 (May 14, 2011)
29
+ - Support for Job API call
30
+ - Support for typed parameters
31
+ - By default, make request to https://api.sailthru.com so, default constructor call would be Sailthru::SailthruClient.new("api-key", "api_secret")
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rake'
4
+ gem 'multipart-post'
5
+
6
+ group :test do
7
+ gem 'json'
8
+ gem 'fakeweb'
9
+ gem 'minitest'
10
+ gem 'mocha'
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ fakeweb (1.3.0)
5
+ json (1.8.1)
6
+ metaclass (0.0.4)
7
+ minitest (5.3.4)
8
+ mocha (0.14.0)
9
+ metaclass (~> 0.0.1)
10
+ multipart-post (2.0.0)
11
+ rake (10.3.2)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ fakeweb
18
+ json
19
+ minitest
20
+ mocha
21
+ multipart-post
22
+ rake
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Sailthru, Inc., http://www.sailthru.com/
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,13 +1,20 @@
1
- sailthru-ruby-client
2
- ====================
1
+ # sailthru-ruby-client
3
2
 
4
3
  For installation instructions, documentation, and examples please visit:
5
4
  [http://getstarted.sailthru.com/developers/api-libraries/ruby](http://getstarted.sailthru.com/developers/api-libraries/ruby)
6
5
 
7
6
  A simple client library to remotely access the `Sailthru REST API` as per [http://getstarted.sailthru.com/api](http://getstarted.sailthru.com/developers/api)
8
7
 
9
- By default, it will make request in `JSON` format.
8
+ By default, it will make requests in `JSON` format.
9
+
10
+ ## Installation
10
11
 
11
- ### Installing from rubygems.org (Tested with Ruby 1.8.7)
12
12
  $ gem install sailthru-client
13
13
 
14
+ ## Requirements
15
+
16
+ This gem supports Ruby 1.9.3 and up.
17
+
18
+ ## License
19
+
20
+ Please see MIT-LICENSE for license.
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'rake/clean'
4
+ require 'rdoc/task'
5
+
6
+ CLOBBER.include 'pkg'
7
+
8
+ task :default => :test
9
+
10
+ Rake::TestTask.new do |t|
11
+ t.libs = %w(lib test)
12
+ t.test_files = FileList["test/**/*_test.rb"]
13
+ end
14
+
15
+ Rake::RDocTask.new do |rd|
16
+ rd.main = "README.md"
17
+ rd.rdoc_files.include("README.md", "lib/**/*.rb")
18
+ rd.rdoc_dir = "rdoc"
19
+ end
data/lib/sailthru.rb CHANGED
@@ -9,11 +9,14 @@ require 'net/http/post/multipart'
9
9
 
10
10
  module Sailthru
11
11
 
12
- Version = VERSION = '2.0.0'
12
+ Version = VERSION = '3.0.0'
13
13
 
14
14
  class SailthruClientException < Exception
15
15
  end
16
16
 
17
+ class SailthruUnavailableException < Exception
18
+ end
19
+
17
20
  module Helpers
18
21
  # params:
19
22
  # params, Hash
@@ -102,13 +105,14 @@ module Sailthru
102
105
  # api_uri, String
103
106
  #
104
107
  # Instantiate a new client; constructor optionally takes overrides for key/secret/uri and proxy server settings.
105
- def initialize(api_key, secret, api_uri=nil, proxy_host=nil, proxy_port=nil)
108
+ def initialize(api_key, secret, api_uri=nil, proxy_host=nil, proxy_port=nil, opts={})
106
109
  @api_key = api_key
107
110
  @secret = secret
108
111
  @api_uri = if api_uri.nil? then 'https://api.sailthru.com' else api_uri end
109
112
  @proxy_host = proxy_host
110
113
  @proxy_port = proxy_port
111
114
  @verify_ssl = true
115
+ @opts = opts
112
116
  end
113
117
 
114
118
  # params:
@@ -126,7 +130,7 @@ module Sailthru
126
130
  # http://docs.sailthru.com/api/send
127
131
  def send(template_name, email, vars={}, options = {}, schedule_time = nil)
128
132
  warn "[DEPRECATION] `send` is deprecated. Please use `send_email` instead."
129
- send_email(template_name, email, vars={}, options = {}, schedule_time = nil)
133
+ send_email(template_name, email, vars, options, schedule_time)
130
134
  end
131
135
 
132
136
  # params:
@@ -138,13 +142,14 @@ module Sailthru
138
142
  # test: send as test email (subject line will be marked, will not count towards stats)
139
143
  # returns:
140
144
  # Hash, response data from server
141
- def send_email(template_name, email, vars={}, options = {}, schedule_time = nil)
145
+ def send_email(template_name, email, vars={}, options = {}, schedule_time = nil, limit = {})
142
146
  post = {}
143
147
  post[:template] = template_name
144
148
  post[:email] = email
145
149
  post[:vars] = vars if vars.length >= 1
146
150
  post[:options] = options if options.length >= 1
147
151
  post[:schedule_time] = schedule_time if !schedule_time.nil?
152
+ post[:limit] = limit if limit.length >= 1
148
153
  return self.api_post(:send, post)
149
154
  end
150
155
 
@@ -321,7 +326,7 @@ module Sailthru
321
326
  data[:templates] = templates unless templates.empty?
322
327
  self.api_post(:email, data)
323
328
  end
324
-
329
+
325
330
  # params:
326
331
  # new_email, String
327
332
  # old_email, String
@@ -336,7 +341,7 @@ module Sailthru
336
341
  data[:change_email] = old_email
337
342
  self.api_post(:email, data)
338
343
  end
339
-
344
+
340
345
  # params:
341
346
  # template_name, String
342
347
  # returns:
@@ -384,6 +389,7 @@ module Sailthru
384
389
  return false unless params[:action] == :verify
385
390
 
386
391
  sig = params.delete(:sig)
392
+ sig = sig.delete_if {|key, value| key == :controller}
387
393
  return false unless sig == get_signature_hash(params, @secret)
388
394
 
389
395
  _send = self.get_send(params[:send_id])
@@ -409,13 +415,14 @@ module Sailthru
409
415
  return false unless params[:action] == 'optout'
410
416
 
411
417
  sig = params.delete(:sig)
418
+ sig = sig.delete_if {|key, value| key == :controller}
412
419
  return false unless sig == get_signature_hash(params, @secret)
413
420
  return true
414
421
  else
415
422
  return false
416
423
  end
417
424
  end
418
-
425
+
419
426
  # params:
420
427
  # params, Hash
421
428
  # request, String
@@ -428,6 +435,7 @@ module Sailthru
428
435
  return false unless params[:action] == 'hardbounce'
429
436
 
430
437
  sig = params.delete(:sig)
438
+ sig = sig.delete_if {|key, value| key == :controller}
431
439
  return false unless sig == get_signature_hash(params, @secret)
432
440
  return true
433
441
  else
@@ -575,16 +583,16 @@ module Sailthru
575
583
  # params
576
584
  # list, String
577
585
  #
578
- # Get information about a list.
586
+ # Get information about a list.
579
587
  def get_list(list)
580
588
  return api_get(:list, {:list => list})
581
589
  end
582
590
 
583
591
  # params
584
592
  #
585
- # Get information about all lists
593
+ # Get information about all lists
586
594
  def get_lists()
587
- return api_get(:list, {})
595
+ return api_get(:list, {})
588
596
  end
589
597
 
590
598
  # params
@@ -594,7 +602,7 @@ module Sailthru
594
602
  def save_list(list, options = {})
595
603
  data = options
596
604
  data[:list] = list
597
- return api_post(:list, data)
605
+ return api_post(:list, data)
598
606
  end
599
607
 
600
608
  # params
@@ -669,42 +677,42 @@ module Sailthru
669
677
  end
670
678
  api_post(:job, data, binary_key)
671
679
  end
672
-
680
+
673
681
  # params
674
682
  # emails, String | Array
675
- # implementation for import_job
676
- def process_import_job(list, emails, report_email = nil, postback_url = nil)
677
- data = {}
683
+ # implementation for import_job
684
+ def process_import_job(list, emails, report_email = nil, postback_url = nil, options = {})
685
+ data = options
678
686
  data['list'] = list
679
687
  data['emails'] = Array(emails).join(',')
680
688
  process_job(:import, data, report_email, postback_url)
681
689
  end
682
-
690
+
683
691
  # implementation for import job using file upload
684
- def process_import_job_from_file(list, file_path, report_email = nil, postback_url = nil)
685
- data = {}
692
+ def process_import_job_from_file(list, file_path, report_email = nil, postback_url = nil, options = {})
693
+ data = options
686
694
  data['list'] = list
687
695
  data['file'] = file_path
688
696
  process_job(:import, data, report_email, postback_url, 'file')
689
697
  end
690
698
 
691
699
  # implementation for update job using file upload
692
- def process_update_job_from_file(file_path, report_email = nil, postback_url = nil)
693
- data = {}
700
+ def process_update_job_from_file(file_path, report_email = nil, postback_url = nil, options = {})
701
+ data = options
694
702
  data['file'] = file_path
695
703
  process_job(:update, data, report_email, postback_url, 'file')
696
704
  end
697
705
 
698
706
  # implementation for snapshot job
699
- def process_snapshot_job(query = {}, report_email = nil, postback_url = nil)
700
- data = {}
707
+ def process_snapshot_job(query = {}, report_email = nil, postback_url = nil, options = {})
708
+ data = options
701
709
  data['query'] = query
702
710
  process_job(:snapshot, data, report_email, postback_url)
703
711
  end
704
712
 
705
713
  # implementation for export list job
706
- def process_export_list_job(list, report_email = nil, postback_url = nil)
707
- data = {}
714
+ def process_export_list_job(list, report_email = nil, postback_url = nil, options = {})
715
+ data = options
708
716
  data['list'] = list
709
717
  process_job(:export_list_data, data, report_email, postback_url)
710
718
  end
@@ -716,94 +724,94 @@ module Sailthru
716
724
 
717
725
  # Get user by Sailthru ID
718
726
  def get_user_by_sid(id, fields = {})
719
- api_get(:user, {'id' => id, 'fields' => fields})
727
+ api_get(:user, {'id' => id, 'fields' => fields})
720
728
  end
721
729
 
722
730
  # Get user by specified key
723
731
  def get_user_by_key(id, key, fields = {})
724
- data = {
725
- 'id' => id,
726
- 'key' => key,
727
- 'fields' => fields
728
- }
729
- api_get(:user, data)
732
+ data = {
733
+ 'id' => id,
734
+ 'key' => key,
735
+ 'fields' => fields
736
+ }
737
+ api_get(:user, data)
730
738
  end
731
739
 
732
740
  # Create new user, or update existing user
733
741
  def save_user(id, options = {})
734
- data = options
735
- data['id'] = id
736
- api_post(:user, data)
742
+ data = options
743
+ data['id'] = id
744
+ api_post(:user, data)
737
745
  end
738
746
 
739
- # params
740
- # Get an existing trigger
747
+ # params
748
+ # Get an existing trigger
741
749
  def get_triggers()
742
- api_get(:trigger, {})
750
+ api_get(:trigger, {})
743
751
  end
744
752
 
745
- # params
746
- # template, String
747
- # trigger_id, String
748
- # Get an existing trigger
753
+ # params
754
+ # template, String
755
+ # trigger_id, String
756
+ # Get an existing trigger
749
757
  def get_trigger_by_template(template, trigger_id = nil)
750
- data = {}
751
- data['template'] = template
752
- if trigger_id != nil then data['trigger_id'] = trigger_id end
753
- api_get(:trigger, data)
758
+ data = {}
759
+ data['template'] = template
760
+ if trigger_id != nil then data['trigger_id'] = trigger_id end
761
+ api_get(:trigger, data)
754
762
  end
755
763
 
756
- # params
757
- # event, String
758
- # Get an existing trigger
764
+ # params
765
+ # event, String
766
+ # Get an existing trigger
759
767
  def get_trigger_by_event(event)
760
- data = {}
761
- data['event'] = event
762
- api_get(:trigger, data)
763
- end
764
-
765
- # params
766
- # template, String
767
- # time, String
768
- # time_unit, String
769
- # event, String
770
- # zephyr, String
771
- # Create or update a trigger
768
+ data = {}
769
+ data['event'] = event
770
+ api_get(:trigger, data)
771
+ end
772
+
773
+ # params
774
+ # template, String
775
+ # time, String
776
+ # time_unit, String
777
+ # event, String
778
+ # zephyr, String
779
+ # Create or update a trigger
772
780
  def post_template_trigger(template, time, time_unit, event, zephyr)
773
- data = {}
774
- data['template'] = template
775
- data['time'] = time
776
- data['time_unit'] = time_unit
777
- data['event'] = event
778
- data['zephyr'] = zephyr
779
- api_post(:trigger, data)
780
- end
781
-
782
- # params
783
- # template, String
784
- # time, String
785
- # time_unit, String
786
- # zephyr, String
787
- # Create or update a trigger
781
+ data = {}
782
+ data['template'] = template
783
+ data['time'] = time
784
+ data['time_unit'] = time_unit
785
+ data['event'] = event
786
+ data['zephyr'] = zephyr
787
+ api_post(:trigger, data)
788
+ end
789
+
790
+ # params
791
+ # template, String
792
+ # time, String
793
+ # time_unit, String
794
+ # zephyr, String
795
+ # Create or update a trigger
788
796
  def post_event_trigger(event, time, time_unit, zephyr)
789
- data = {}
790
- data['time'] = time
791
- data['time_unit'] = time_unit
792
- data['event'] = event
793
- data['zephyr'] = zephyr
794
- api_post(:trigger, data)
795
- end
796
-
797
- # params
798
- # id, String
799
- # event, String
800
- # options, Hash (Can contain vars, Hash and/or key)
801
- # Notify Sailthru of an Event
797
+ data = {}
798
+ data['time'] = time
799
+ data['time_unit'] = time_unit
800
+ data['event'] = event
801
+ data['zephyr'] = zephyr
802
+ api_post(:trigger, data)
803
+ end
804
+
805
+ # params
806
+ # id, String
807
+ # event, String
808
+ # options, Hash (Can contain vars, Hash and/or key)
809
+ # Notify Sailthru of an Event
802
810
  def post_event(id, event, options = {})
803
- data = options
804
- data['id'] = id
805
- data['event'] = event
806
- api_post(:event, data)
811
+ data = options
812
+ data['id'] = id
813
+ data['event'] = event
814
+ api_post(:event, data)
807
815
  end
808
816
 
809
817
  # Perform API GET request
@@ -870,7 +878,7 @@ module Sailthru
870
878
 
871
879
  if binary_data.is_a?(StringIO)
872
880
  data[binary_key] = UploadIO.new(
873
- binary_data, "text/plain"
881
+ binary_data, "text/plain", "local.path"
874
882
  )
875
883
  else
876
884
  data[binary_key] = UploadIO.new(
@@ -924,12 +932,18 @@ module Sailthru
924
932
  if _uri.scheme == 'https'
925
933
  http.use_ssl = true
926
934
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @verify_ssl != true # some openSSL client doesn't work without doing this
935
+ http.ssl_timeout = @opts[:http_ssl_timeout] || 5
927
936
  end
937
+ http.open_timeout = @opts[:http_open_timeout] || 5
938
+ http.read_timeout = @opts[:http_read_timeout] || 10
939
+ http.close_on_empty_response = @opts[:http_close_on_empty_response] || true
928
940
 
929
941
  response = http.start {
930
942
  http.request(req)
931
943
  }
932
944
 
945
+ rescue Timeout::Error, Errno::ETIMEDOUT => e
946
+ raise SailthruUnavailableException.new(["Timed out: #{_uri}", e.inspect, e.backtrace].join("\n"));
933
947
  rescue Exception => e
934
948
  raise SailthruClientException.new(["Unable to open stream: #{_uri}", e.inspect, e.backtrace].join("\n"));
935
949
  end
@@ -942,18 +956,18 @@ module Sailthru
942
956
  end
943
957
 
944
958
  def http_multipart_request(uri, data)
945
- req = Net::HTTP::Post::Multipart.new url.path,
959
+ Net::HTTP::Post::Multipart.new url.path,
946
960
  "file" => UploadIO.new(data['file'], "application/octet-stream")
947
961
  end
948
962
 
949
963
  def prepare_json_payload(data)
950
- payload = {
951
- :api_key => @api_key,
952
- :format => 'json', #<3 XML
953
- :json => data.to_json
954
- }
955
- payload[:sig] = get_signature_hash(payload, @secret)
956
- payload
964
+ payload = {
965
+ :api_key => @api_key,
966
+ :format => 'json', #<3 XML
967
+ :json => data.to_json
968
+ }
969
+ payload[:sig] = get_signature_hash(payload, @secret)
970
+ payload
957
971
  end
958
972
  end
959
973
  end