sailthru-client 1.12 → 1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +2 -0
  2. data/lib/sailthru.rb +7 -17
  3. metadata +5 -5
data/README.md CHANGED
@@ -3,6 +3,8 @@ sailthru-ruby-client
3
3
 
4
4
  A simple client library to remotely access the `Sailthru REST API` as per [http://docs.sailthru.com/api](http://docs.sailthru.com/api)
5
5
 
6
+ By default, it will make request in `JSON` format.
7
+
6
8
  It can make requests to following [API calls](http://docs.sailthru.com/api):
7
9
 
8
10
  * [email](http://docs.sailthru.com/api/email)
data/lib/sailthru.rb CHANGED
@@ -9,7 +9,7 @@ require 'net/http/post/multipart'
9
9
 
10
10
  module Sailthru
11
11
 
12
- Version = VERSION = '1.12'
12
+ Version = VERSION = '1.13'
13
13
 
14
14
  class SailthruClientException < Exception
15
15
  end
@@ -87,18 +87,7 @@ module Sailthru
87
87
  end
88
88
  return f
89
89
  end
90
-
91
- def verify_purchase_items (items)
92
- if items.class == Array and !items.empty?
93
- required_item_fields = ['qty', 'title', 'price', 'id', 'url'].sort
94
- items.each do |v|
95
- keys = v.keys.sort
96
- return false if keys != required_item_fields
97
- end
98
- return true
99
- end
100
- return false
101
- end
90
+
102
91
  end
103
92
 
104
93
  class SailthruClient
@@ -391,12 +380,13 @@ module Sailthru
391
380
  # items, String
392
381
  # incomplete, Integer
393
382
  # message_id, String
383
+ # options, Hash
394
384
  # returns:
395
385
  # hash, response from server
396
386
  #
397
387
  # Record that a user has made a purchase, or has added items to their purchase total.
398
- def purchase(email, items, incomplete = nil, message_id = nil)
399
- data = {}
388
+ def purchase(email, items, incomplete = nil, message_id = nil, options = {})
389
+ data = options
400
390
  data[:email] = email
401
391
  data[:items] = items
402
392
 
@@ -766,13 +756,13 @@ module Sailthru
766
756
  }
767
757
 
768
758
  rescue Exception => e
769
- raise SailthruClientException.new("Unable to open stream: #{_uri.to_s}\n" + e);
759
+ raise SailthruClientException.new("Unable to open stream: #{_uri}\n#{e}");
770
760
  end
771
761
 
772
762
  if response.body
773
763
  return response.body
774
764
  else
775
- raise SailthruClientException.new("No response received from stream: #{_uri.to_s}")
765
+ raise SailthruClientException.new("No response received from stream: #{_uri}")
776
766
  end
777
767
  end
778
768
 
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sailthru-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 12
9
- version: "1.12"
8
+ - 13
9
+ version: "1.13"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Prajwal Tuladhar
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-07-22 00:00:00 Z
17
+ date: 2011-09-08 00:00:00 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: json
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  requirements: []
114
114
 
115
115
  rubyforge_project:
116
- rubygems_version: 1.8.5
116
+ rubygems_version: 1.8.8
117
117
  signing_key:
118
118
  specification_version: 3
119
119
  summary: A simple client library to remotely access the Sailthru REST API.