fastspring-saasy 0.4.0 → 0.5.1

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.
data/.document CHANGED
@@ -1,5 +1,5 @@
1
1
  lib/**/*.rb
2
2
  bin/*
3
- -
3
+ -
4
4
  features/**/*.feature
5
5
  LICENSE.txt
data/Gemfile CHANGED
@@ -1,14 +1,16 @@
1
1
  source :rubygems
2
2
 
3
3
  gem 'httparty'
4
- gem 'rake'
5
4
 
6
5
  group :development do
6
+ gem 'rake'
7
7
  gem 'bundler'
8
8
  gem 'jeweler'
9
+ gem 'ruby-debug19', :require => 'ruby-debug'
9
10
  end
10
11
 
11
12
  group :test do
12
13
  gem 'rspec'
13
14
  gem 'webmock'
15
+ gem 'ruby-debug19', :require => 'ruby-debug'
14
16
  end
data/Gemfile.lock CHANGED
@@ -2,6 +2,8 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  addressable (2.2.6)
5
+ archive-tar-minitar (0.5.2)
6
+ columnize (0.3.5)
5
7
  crack (0.3.1)
6
8
  diff-lcs (1.1.3)
7
9
  git (1.2.5)
@@ -12,18 +14,30 @@ GEM
12
14
  bundler (~> 1.0)
13
15
  git (>= 1.2.5)
14
16
  rake
15
- multi_json (1.0.3)
17
+ linecache19 (0.5.12)
18
+ ruby_core_source (>= 0.1.4)
19
+ multi_json (1.0.4)
16
20
  multi_xml (0.4.1)
17
- rake (0.9.2)
21
+ rake (0.9.2.2)
18
22
  rspec (2.7.0)
19
23
  rspec-core (~> 2.7.0)
20
24
  rspec-expectations (~> 2.7.0)
21
25
  rspec-mocks (~> 2.7.0)
22
- rspec-core (2.7.0)
26
+ rspec-core (2.7.1)
23
27
  rspec-expectations (2.7.0)
24
28
  diff-lcs (~> 1.1.2)
25
29
  rspec-mocks (2.7.0)
26
- webmock (1.7.7)
30
+ ruby-debug-base19 (0.11.25)
31
+ columnize (>= 0.3.1)
32
+ linecache19 (>= 0.5.11)
33
+ ruby_core_source (>= 0.1.4)
34
+ ruby-debug19 (0.11.6)
35
+ columnize (>= 0.3.1)
36
+ linecache19 (>= 0.5.11)
37
+ ruby-debug-base19 (>= 0.11.19)
38
+ ruby_core_source (0.1.5)
39
+ archive-tar-minitar (>= 0.5.2)
40
+ webmock (1.7.8)
27
41
  addressable (~> 2.2, > 2.2.5)
28
42
  crack (>= 0.1.7)
29
43
 
@@ -36,4 +50,5 @@ DEPENDENCIES
36
50
  jeweler
37
51
  rake
38
52
  rspec
53
+ ruby-debug19
39
54
  webmock
data/README.rdoc CHANGED
@@ -19,9 +19,8 @@ Ruby library to access the FastSpring Saasy API.
19
19
  #get subscription
20
20
  FastSpring::Subscription.find('reference')
21
21
 
22
- == Todo
23
-
24
- * Support the order API
22
+ #get order
23
+ FastSpring::Order.find('reference')
25
24
 
26
25
  == Copyright
27
26
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fastspring-saasy"
8
- s.version = "0.4.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Richard Patching"]
12
- s.date = "2011-11-12"
12
+ s.date = "2012-01-10"
13
13
  s.description = "Ruby lib for using the FastSpring (Saas) subscription management API"
14
14
  s.email = "richard@justaddpixels.com"
15
15
  s.extra_rdoc_files = [
@@ -29,17 +29,23 @@ Gem::Specification.new do |s|
29
29
  "lib/fastspring-saasy.rb",
30
30
  "lib/fastspring-saasy/account.rb",
31
31
  "lib/fastspring-saasy/address.rb",
32
- "lib/fastspring-saasy/base.rb",
33
32
  "lib/fastspring-saasy/customer.rb",
34
33
  "lib/fastspring-saasy/error.rb",
35
34
  "lib/fastspring-saasy/item.rb",
35
+ "lib/fastspring-saasy/localized_store_pricing.rb",
36
36
  "lib/fastspring-saasy/order.rb",
37
37
  "lib/fastspring-saasy/payment.rb",
38
+ "lib/fastspring-saasy/private_api_base.rb",
39
+ "lib/fastspring-saasy/public_api_base.rb",
38
40
  "lib/fastspring-saasy/subscription.rb",
41
+ "lib/httparty/txt_parser.rb",
39
42
  "spec/account_spec.rb",
40
43
  "spec/customer_spec.rb",
44
+ "spec/fixtures/basic_localized_store_pricing.txt",
45
+ "spec/fixtures/basic_localized_store_pricing_with_3_products.txt",
41
46
  "spec/fixtures/basic_order.xml",
42
47
  "spec/fixtures/basic_subscription.xml",
48
+ "spec/localized_store_pricing_spec.rb",
43
49
  "spec/order_spec.rb",
44
50
  "spec/spec_helper.rb",
45
51
  "spec/subscription_spec.rb"
@@ -47,7 +53,7 @@ Gem::Specification.new do |s|
47
53
  s.homepage = "http://github.com/patchfx/fastspring"
48
54
  s.licenses = ["MIT"]
49
55
  s.require_paths = ["lib"]
50
- s.rubygems_version = "1.8.10"
56
+ s.rubygems_version = "1.8.11"
51
57
  s.summary = "Ruby lib for using the FastSpring (Saasy) API"
52
58
 
53
59
  if s.respond_to? :specification_version then
@@ -55,15 +61,17 @@ Gem::Specification.new do |s|
55
61
 
56
62
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
63
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
58
- s.add_runtime_dependency(%q<rake>, [">= 0"])
64
+ s.add_development_dependency(%q<rake>, [">= 0"])
59
65
  s.add_development_dependency(%q<bundler>, [">= 0"])
60
66
  s.add_development_dependency(%q<jeweler>, [">= 0"])
67
+ s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
61
68
  s.add_development_dependency(%q<httparty>, ["~> 0.8.1"])
62
69
  else
63
70
  s.add_dependency(%q<httparty>, [">= 0"])
64
71
  s.add_dependency(%q<rake>, [">= 0"])
65
72
  s.add_dependency(%q<bundler>, [">= 0"])
66
73
  s.add_dependency(%q<jeweler>, [">= 0"])
74
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
67
75
  s.add_dependency(%q<httparty>, ["~> 0.8.1"])
68
76
  end
69
77
  else
@@ -71,6 +79,7 @@ Gem::Specification.new do |s|
71
79
  s.add_dependency(%q<rake>, [">= 0"])
72
80
  s.add_dependency(%q<bundler>, [">= 0"])
73
81
  s.add_dependency(%q<jeweler>, [">= 0"])
82
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
74
83
  s.add_dependency(%q<httparty>, ["~> 0.8.1"])
75
84
  end
76
85
  end
@@ -1,6 +1,8 @@
1
1
  require 'httparty'
2
2
 
3
- require_relative 'fastspring-saasy/base'
3
+ require_relative 'httparty/txt_parser'
4
+
5
+ require_relative 'fastspring-saasy/private_api_base'
4
6
  require_relative 'fastspring-saasy/account'
5
7
  require_relative 'fastspring-saasy/subscription'
6
8
  require_relative 'fastspring-saasy/customer'
@@ -8,4 +10,8 @@ require_relative 'fastspring-saasy/order'
8
10
  require_relative 'fastspring-saasy/item'
9
11
  require_relative 'fastspring-saasy/payment'
10
12
  require_relative 'fastspring-saasy/address'
13
+
14
+ require_relative 'fastspring-saasy/public_api_base'
15
+ require_relative 'fastspring-saasy/localized_store_pricing'
16
+
11
17
  require_relative 'fastspring-saasy/error'
@@ -3,11 +3,11 @@ module FastSpring
3
3
  attr_accessor :first_name, :last_name, :company, :email, :phone_number
4
4
 
5
5
  def initialize(details)
6
- @first_name = details.fetch('firstName')
7
- @last_name = details.fetch('lastName')
8
- @company = details.fetch('company')
6
+ @first_name = details.fetch('firstName', '')
7
+ @last_name = details.fetch('lastName', '')
8
+ @company = details.fetch('company', '')
9
9
  @email = details.fetch('email')
10
- @phone_number = details.fetch('phoneNumber')
10
+ @phone_number = details.fetch('phoneNumber', '')
11
11
  end
12
12
 
13
13
  end
@@ -0,0 +1,89 @@
1
+ module FastSpring
2
+ class LocalizedStorePricing < PublicApiBase
3
+ # Get the localized store pricing from Saasy
4
+ def find
5
+ # For some reason the implicit determination of the Txt parser does not work.
6
+ # So we'll just blatently pass it in right now.
7
+ @response = self.class.get(base_localized_store_pricing_path, :query => query, :parser => Parser::Txt)
8
+ self
9
+ end
10
+
11
+ def base_localized_store_pricing_path
12
+ "/#{@company}/api/price"
13
+ end
14
+
15
+ def query
16
+ query_hash = Hash.new
17
+ @product_paths.each_index{ |index| query_hash["product_#{(index + 1)}_path".to_sym] = @product_paths[index] }
18
+ query_hash.merge({
19
+ :user_remote_addr => @remote_ip,
20
+ :user_accept_language => @http_accept_language,
21
+ :user_x_forwarded_for => @http_x_forwarded_for
22
+ })
23
+ end
24
+
25
+ def user_country
26
+ parsed_response['user_country']
27
+ end
28
+
29
+ def user_language
30
+ parsed_response['user_language']
31
+ end
32
+
33
+ def user_currency
34
+ parsed_response['user_currency']
35
+ end
36
+
37
+ def product_quantity(product_path)
38
+ parsed_response[product_path]["quantity"]
39
+ end
40
+
41
+ def product_unit_value(product_path)
42
+ parsed_response[product_path]["unit_value"]
43
+ end
44
+
45
+ def product_unit_currency(product_path)
46
+ parsed_response[product_path]["unit_currency"]
47
+ end
48
+
49
+ def product_unit_display(product_path)
50
+ parsed_response[product_path]["unit_display"]
51
+ end
52
+
53
+ def product_unit_html(product_path)
54
+ parsed_response[product_path]["unit_html"]
55
+ end
56
+
57
+
58
+ protected
59
+
60
+ def parsed_response
61
+ @parsed_response ||= parse_response
62
+ end
63
+
64
+ def parse_response
65
+ response = Hash.new
66
+
67
+ index = 1
68
+ more_products = true
69
+ while more_products
70
+ product_path = @response.parsed_response["product_#{index}_path"]
71
+ if product_path
72
+ @response.parsed_response.each do |key, value|
73
+ if key.match("product_#{index}") && key != "product_#{index}_path" then
74
+ response[product_path] ||= Hash.new
75
+ response[product_path][key.match(/\d+_(.*)/)[1]] = value
76
+ end
77
+ end
78
+ index += 1
79
+ else
80
+ more_products = false
81
+ end
82
+ end
83
+
84
+ response.merge(
85
+ @response.parsed_response.reject{ |key, value| key.match(/^product_/) }
86
+ )
87
+ end
88
+ end
89
+ end
@@ -1,5 +1,5 @@
1
1
  module FastSpring
2
- class Order < Base
2
+ class Order < PrivateApiBase
3
3
  attr_reader :purchaser, :items
4
4
  # Get the order from Saasy
5
5
  def find
@@ -1,5 +1,5 @@
1
1
  module FastSpring
2
- class Base
2
+ class PrivateApiBase
3
3
  include HTTParty
4
4
  base_uri 'https://api.fastspring.com'
5
5
  format :xml
@@ -8,7 +8,7 @@ module FastSpring
8
8
  attr_reader :customer
9
9
 
10
10
  def initialize(reference)
11
- @auth = {:username => FastSpring::Account.fetch(:username),
11
+ @auth = {:username => FastSpring::Account.fetch(:username),
12
12
  :password => FastSpring::Account.fetch(:password)}
13
13
  @company = FastSpring::Account.fetch(:company)
14
14
  @reference = reference
@@ -17,6 +17,10 @@ module FastSpring
17
17
  def self.find(reference)
18
18
  self.new(reference).find
19
19
  end
20
+
21
+ def reference
22
+ @reference
23
+ end
20
24
 
21
25
  # Returns the current status
22
26
  def status
@@ -53,6 +57,5 @@ module FastSpring
53
57
  def value_for(attribute)
54
58
  parsed_response.fetch(attribute)
55
59
  end
56
-
57
60
  end
58
61
  end
@@ -0,0 +1,18 @@
1
+ module FastSpring
2
+ class PublicApiBase
3
+ include HTTParty
4
+ base_uri 'http://sites.fastspring.com'
5
+
6
+ def initialize(product_paths, http_request)
7
+ @company = FastSpring::Account.fetch(:company)
8
+ @product_paths = product_paths
9
+ @remote_ip = http_request.respond_to?(:remote_ip) ? http_request.remote_ip : "127.0.0.1"
10
+ @http_accept_language = http_request.respond_to?(:env) ? http_request.env["HTTP_ACCEPT_LANGUAGE"] : "en"
11
+ @http_x_forwarded_for = http_request.respond_to?(:env) ? http_request.env["HTTP_X_FORWARDED_FOR"] : ""
12
+ end
13
+
14
+ def self.find(product_path, http_request)
15
+ self.new(product_path, http_request).find
16
+ end
17
+ end
18
+ end
@@ -1,7 +1,7 @@
1
1
  require 'date'
2
2
 
3
3
  module FastSpring
4
- class Subscription < Base
4
+ class Subscription < PrivateApiBase
5
5
 
6
6
  # Get the subscription from Saasy
7
7
  def find
@@ -0,0 +1,20 @@
1
+ class ParseTxt
2
+ include HTTParty
3
+
4
+ # Replace the :plain parser with this text parser
5
+ class Parser::Txt < HTTParty::Parser
6
+ SupportedFormats["text/plain"] = :txt
7
+
8
+ # perform text parsing on body
9
+ def txt
10
+ parsed_response = Hash.new
11
+ body.each_line do |line|
12
+ name_value = line.split("=")
13
+ parsed_response[name_value[0].strip] = name_value[1].strip if name_value.count == 2
14
+ end
15
+ parsed_response
16
+ end
17
+ end
18
+
19
+ parser Parser::Txt
20
+ end
@@ -3,35 +3,66 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper.rb'))
3
3
 
4
4
  describe FastSpring::Customer do
5
5
  context 'new' do
6
- let(:customer_details) {
7
- {
8
- "firstName" => "John",
9
- "lastName" => "Doe",
10
- "company" => "Doe Inc",
11
- "email" => "john@example.com",
12
- "phoneNumber" => "0123456789"
6
+ context "with all parameters" do
7
+ let(:customer_details) {
8
+ {
9
+ "firstName" => "John",
10
+ "lastName" => "Doe",
11
+ "company" => "Doe Inc",
12
+ "email" => "john@example.com",
13
+ "phoneNumber" => "0123456789"
14
+ }
13
15
  }
14
- }
15
- subject { FastSpring::Customer.new(customer_details) }
16
+ subject { FastSpring::Customer.new(customer_details) }
16
17
 
17
- it 'has a first name' do
18
- subject.first_name.should == 'John'
19
- end
18
+ it 'has a first name' do
19
+ subject.first_name.should == 'John'
20
+ end
20
21
 
21
- it 'has a last name' do
22
- subject.last_name.should == 'Doe'
23
- end
22
+ it 'has a last name' do
23
+ subject.last_name.should == 'Doe'
24
+ end
24
25
 
25
- it 'has a company' do
26
- subject.company.should == 'Doe Inc'
27
- end
26
+ it 'has a company' do
27
+ subject.company.should == 'Doe Inc'
28
+ end
28
29
 
29
- it 'has a email address' do
30
- subject.email.should == 'john@example.com'
30
+ it 'has a email address' do
31
+ subject.email.should == 'john@example.com'
32
+ end
33
+
34
+ it 'has a phone number' do
35
+ subject.phone_number.should == '0123456789'
36
+ end
31
37
  end
38
+
39
+ context "with only an email" do
40
+ let(:customer_details) {
41
+ {
42
+ "email" => "john@example.com",
43
+ }
44
+ }
45
+ subject { FastSpring::Customer.new(customer_details) }
46
+
47
+ it 'has an empty first name' do
48
+ subject.first_name.should == ''
49
+ end
50
+
51
+ it 'has an empty last name' do
52
+ subject.last_name.should == ''
53
+ end
54
+
55
+ it 'has an empty company name' do
56
+ subject.company.should == ''
57
+ end
58
+
59
+ it 'has a email address' do
60
+ subject.email.should == 'john@example.com'
61
+ end
32
62
 
33
- it 'has a phone number' do
34
- subject.phone_number.should == '0123456789'
63
+ it 'has an empty phone number' do
64
+ subject.phone_number.should == ''
65
+ end
35
66
  end
36
67
  end
37
68
  end
@@ -0,0 +1,9 @@
1
+ user_country=US
2
+ user_language=en
3
+ user_currency=USD
4
+ product_1_path=/standard
5
+ product_1_quantity=1
6
+ product_1_unit_value=35.00
7
+ product_1_unit_currency=USD
8
+ product_1_unit_display=$35.00
9
+ product_1_unit_html=$35.00
@@ -0,0 +1,21 @@
1
+ user_country=US
2
+ user_language=en
3
+ user_currency=USD
4
+ product_1_path=/basic
5
+ product_1_quantity=1
6
+ product_1_unit_value=19.00
7
+ product_1_unit_currency=USD
8
+ product_1_unit_display=$19.00
9
+ product_1_unit_html=$19.00
10
+ product_2_path=/standard
11
+ product_2_quantity=1
12
+ product_2_unit_value=35.00
13
+ product_2_unit_currency=USD
14
+ product_2_unit_display=$35.00
15
+ product_2_unit_html=$35.00
16
+ product_3_path=/plus
17
+ product_3_quantity=1
18
+ product_3_unit_value=59.00
19
+ product_3_unit_currency=USD
20
+ product_3_unit_display=$59.00
21
+ product_3_unit_html=$59.00
@@ -0,0 +1,152 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/fastspring-saasy.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper.rb'))
3
+
4
+ describe FastSpring::LocalizedStorePricing do
5
+ def valid_http_request
6
+ request = double('request')
7
+ request.stub(:remote_ip).and_return("192.168.1.1")
8
+ request.stub(:env).and_return({ "HTTP_ACCEPT_LANGUAGE" => "nl", "HTTP_X_FORWARDED_FOR" => "192.168.1.2" })
9
+ request
10
+ end
11
+
12
+ def invalid_http_request
13
+ double('request')
14
+ end
15
+
16
+ def partial_http_request
17
+ request = double('request')
18
+ request.stub(:remote_ip).and_return("192.168.1.1")
19
+ request.stub(:env).and_return({ "HTTP_ACCEPT_LANGUAGE" => "nl" })
20
+ request
21
+ end
22
+
23
+ before do
24
+ FastSpring::Account.setup do |config|
25
+ config[:username] = 'admin'
26
+ config[:password] = 'test'
27
+ config[:company] = 'acme'
28
+ end
29
+ end
30
+
31
+ context 'url for localized store pricing' do
32
+ context "with valid http request" do
33
+ subject { FastSpring::LocalizedStorePricing.find(['/standard'], valid_http_request) }
34
+ before do
35
+ stub_request(:get, "http://sites.fastspring.com/acme/api/price?product_1_path=/standard&user_accept_language=nl&user_remote_addr=192.168.1.1&user_x_forwarded_for=192.168.1.2").
36
+ to_return(:status => 200, :body => "", :headers => {})
37
+ end
38
+
39
+ it 'returns the path for the company' do
40
+ subject.base_localized_store_pricing_path.should == "/acme/api/price"
41
+ end
42
+ end
43
+
44
+ context "with invalid http request" do
45
+ subject { FastSpring::LocalizedStorePricing.find(['/standard'], invalid_http_request) }
46
+ before do
47
+ stub_request(:get, "http://sites.fastspring.com/acme/api/price?product_1_path=/standard&user_accept_language=en&user_remote_addr=127.0.0.1&user_x_forwarded_for=").
48
+ to_return(:status => 200, :body => "", :headers => {})
49
+ end
50
+
51
+ it 'returns the path for the company' do
52
+ subject.base_localized_store_pricing_path.should == "/acme/api/price"
53
+ end
54
+ end
55
+
56
+ context "with partial http request" do
57
+ subject { FastSpring::LocalizedStorePricing.find(['/standard'], partial_http_request) }
58
+ before do
59
+ stub_request(:get, "http://sites.fastspring.com/acme/api/price?product_1_path=/standard&user_accept_language=nl&user_remote_addr=192.168.1.1&user_x_forwarded_for=").
60
+ to_return(:status => 200, :body => "", :headers => {})
61
+ end
62
+
63
+ it 'returns the path for the company' do
64
+ subject.base_localized_store_pricing_path.should == "/acme/api/price"
65
+ end
66
+ end
67
+ end
68
+
69
+ context "parsed response for 1 product" do
70
+ subject { FastSpring::LocalizedStorePricing.find(['/standard'], valid_http_request) }
71
+ before do
72
+ stub_request(:get, "https://api.fastspring.com/bizplay/api/price?product_1_path=/standard&user_accept_language=nl&user_remote_addr=192.168.1.1&user_x_forwarded_for=192.168.1.2").
73
+ to_return(stub_http_response_with('basic_localized_store_pricing.txt'))
74
+ end
75
+
76
+ it 'returns "US" as the user country' do
77
+ subject.user_country.should == "US"
78
+ end
79
+
80
+ it 'returns "en" as the user language' do
81
+ subject.user_language.should == "en"
82
+ end
83
+
84
+ it 'returns "USD" as the user currency' do
85
+ subject.user_currency.should == "USD"
86
+ end
87
+
88
+ it 'returns "1" as the quantity of product 1' do
89
+ subject.product_quantity("/standard").should == "1"
90
+ end
91
+
92
+ it 'returns "35.00" as unit value of product 1' do
93
+ subject.product_unit_value("/standard").should == "35.00"
94
+ end
95
+
96
+ it 'returns "USD" as the unit currency of product 1' do
97
+ subject.product_unit_currency("/standard").should == "USD"
98
+ end
99
+
100
+ it 'returns "$35.00" as the unit display of product 1' do
101
+ subject.product_unit_display("/standard").should == "$35.00"
102
+ end
103
+
104
+ it 'returns "$35.00" as the unit html of product 1' do
105
+ subject.product_unit_html("/standard").should == "$35.00"
106
+ end
107
+ end
108
+
109
+ context "localized pricing details specifically for 3 product" do
110
+ subject { FastSpring::LocalizedStorePricing.find(['/basic','/standard','/plus'], valid_http_request) }
111
+ before do
112
+ stub_request(:get, "http://sites.fastspring.com/acme/api/price?product_1_path=/basic&product_2_path=/standard&product_3_path=/plus&user_accept_language=nl&user_remote_addr=192.168.1.1&user_x_forwarded_for=192.168.1.2").
113
+ to_return(stub_http_response_with('basic_localized_store_pricing_with_3_products.txt'))
114
+ end
115
+
116
+ it 'it sends "/basic" as the product_1_path' do
117
+ subject.query[:product_1_path].should == "/basic"
118
+ end
119
+
120
+ it 'it sends "/standard" as the product_2_path' do
121
+ subject.query[:product_2_path].should == "/standard"
122
+ end
123
+
124
+ it 'it sends "/plus" as the product_3_path' do
125
+ subject.query[:product_3_path].should == "/plus"
126
+ end
127
+
128
+ it 'returns "US" as the user country' do
129
+ subject.user_country.should == "US"
130
+ end
131
+
132
+ it 'returns "en" as the user language' do
133
+ subject.user_language.should == "en"
134
+ end
135
+
136
+ it 'returns "USD" as the user currency' do
137
+ subject.user_currency.should == "USD"
138
+ end
139
+
140
+ it 'returns "$19.00" as the unit display of product 1' do
141
+ subject.product_unit_display("/basic").should == "$19.00"
142
+ end
143
+
144
+ it 'returns "$35.00" as the unit display of product 2' do
145
+ subject.product_unit_display("/standard").should == "$35.00"
146
+ end
147
+
148
+ it 'returns "$59.00" as the unit display of product 3' do
149
+ subject.product_unit_display("/plus").should == "$59.00"
150
+ end
151
+ end
152
+ end
data/spec/spec_helper.rb CHANGED
@@ -14,7 +14,11 @@ def stub_http_response_with(filename)
14
14
  response = Net::HTTPOK.new("1.1", 200, "Content for you")
15
15
  response.stub!(:body).and_return(data)
16
16
 
17
- http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => format)
17
+ if format == :txt
18
+ http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => format, :parser => HTTParty::Parser::Txt)
19
+ else
20
+ http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => format)
21
+ end
18
22
  http_request.stub_chain(:http, :request).and_return(response)
19
23
 
20
24
  HTTParty::Request.should_receive(:new).and_return(http_request)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastspring-saasy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-12 00:00:00.000000000Z
12
+ date: 2012-01-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70174611931540 !ruby/object:Gem::Requirement
16
+ requirement: &70151054446520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70174611931540
24
+ version_requirements: *70151054446520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70174612187520 !ruby/object:Gem::Requirement
27
+ requirement: &70151054446040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
- type: :runtime
33
+ type: :development
34
34
  prerelease: false
35
- version_requirements: *70174612187520
35
+ version_requirements: *70151054446040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70174612371500 !ruby/object:Gem::Requirement
38
+ requirement: &70151054445560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,21 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70174612371500
46
+ version_requirements: *70151054445560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70174615205380 !ruby/object:Gem::Requirement
49
+ requirement: &70151054445080 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70151054445080
58
+ - !ruby/object:Gem::Dependency
59
+ name: ruby-debug19
60
+ requirement: &70151054444600 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *70174615205380
68
+ version_requirements: *70151054444600
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: httparty
60
- requirement: &70174615396940 !ruby/object:Gem::Requirement
71
+ requirement: &70151054444120 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ~>
@@ -65,7 +76,7 @@ dependencies:
65
76
  version: 0.8.1
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *70174615396940
79
+ version_requirements: *70151054444120
69
80
  description: Ruby lib for using the FastSpring (Saas) subscription management API
70
81
  email: richard@justaddpixels.com
71
82
  executables: []
@@ -86,17 +97,23 @@ files:
86
97
  - lib/fastspring-saasy.rb
87
98
  - lib/fastspring-saasy/account.rb
88
99
  - lib/fastspring-saasy/address.rb
89
- - lib/fastspring-saasy/base.rb
90
100
  - lib/fastspring-saasy/customer.rb
91
101
  - lib/fastspring-saasy/error.rb
92
102
  - lib/fastspring-saasy/item.rb
103
+ - lib/fastspring-saasy/localized_store_pricing.rb
93
104
  - lib/fastspring-saasy/order.rb
94
105
  - lib/fastspring-saasy/payment.rb
106
+ - lib/fastspring-saasy/private_api_base.rb
107
+ - lib/fastspring-saasy/public_api_base.rb
95
108
  - lib/fastspring-saasy/subscription.rb
109
+ - lib/httparty/txt_parser.rb
96
110
  - spec/account_spec.rb
97
111
  - spec/customer_spec.rb
112
+ - spec/fixtures/basic_localized_store_pricing.txt
113
+ - spec/fixtures/basic_localized_store_pricing_with_3_products.txt
98
114
  - spec/fixtures/basic_order.xml
99
115
  - spec/fixtures/basic_subscription.xml
116
+ - spec/localized_store_pricing_spec.rb
100
117
  - spec/order_spec.rb
101
118
  - spec/spec_helper.rb
102
119
  - spec/subscription_spec.rb
@@ -115,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
132
  version: '0'
116
133
  segments:
117
134
  - 0
118
- hash: -4339639904534215693
135
+ hash: -3957425532684118813
119
136
  required_rubygems_version: !ruby/object:Gem::Requirement
120
137
  none: false
121
138
  requirements:
@@ -124,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
141
  version: '0'
125
142
  requirements: []
126
143
  rubyforge_project:
127
- rubygems_version: 1.8.10
144
+ rubygems_version: 1.8.11
128
145
  signing_key:
129
146
  specification_version: 3
130
147
  summary: Ruby lib for using the FastSpring (Saasy) API