fastspring-saasy 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -3
- data/VERSION +1 -1
- data/fastspring-saasy.gemspec +4 -2
- data/lib/fastspring-saasy.rb +1 -0
- data/lib/fastspring-saasy/account.rb +26 -0
- data/lib/fastspring-saasy/subscription.rb +9 -3
- data/spec/account_spec.rb +15 -0
- data/spec/subscription_spec.rb +12 -3
- metadata +15 -13
data/README.rdoc
CHANGED
@@ -9,13 +9,20 @@ Ruby library to access the FastSpring Saasy API.
|
|
9
9
|
== Usage
|
10
10
|
|
11
11
|
require 'fastspring-saasy'
|
12
|
-
|
12
|
+
|
13
|
+
FastSpring::Account.setup do |config|
|
14
|
+
config[:username] = 'user'
|
15
|
+
config[:password] = 'password'
|
16
|
+
config[:company] = 'company'
|
17
|
+
end
|
18
|
+
|
19
|
+
#get subscription
|
20
|
+
FastSpring::Subscription.find('reference')
|
13
21
|
|
14
22
|
== Todo
|
15
23
|
|
16
|
-
* Support update
|
17
24
|
* Support the order API
|
18
|
-
|
25
|
+
|
19
26
|
== Copyright
|
20
27
|
|
21
28
|
Copyright (c) 2011 Richard Patching. See LICENSE.txt for
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/fastspring-saasy.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "fastspring-saasy"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.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
|
+
s.date = "2011-11-11"
|
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 = [
|
@@ -27,9 +27,11 @@ Gem::Specification.new do |s|
|
|
27
27
|
"VERSION",
|
28
28
|
"fastspring-saasy.gemspec",
|
29
29
|
"lib/fastspring-saasy.rb",
|
30
|
+
"lib/fastspring-saasy/account.rb",
|
30
31
|
"lib/fastspring-saasy/customer.rb",
|
31
32
|
"lib/fastspring-saasy/error.rb",
|
32
33
|
"lib/fastspring-saasy/subscription.rb",
|
34
|
+
"spec/account_spec.rb",
|
33
35
|
"spec/customer_spec.rb",
|
34
36
|
"spec/fixtures/basic_subscription.xml",
|
35
37
|
"spec/spec_helper.rb",
|
data/lib/fastspring-saasy.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
module FastSpring
|
2
|
+
module Account
|
3
|
+
|
4
|
+
def self.config
|
5
|
+
@config ||= {:username => 'user', :password => 'pass', :company => 'your-company'}
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.[]=(key, val)
|
9
|
+
config[key] = val
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.fetch(key)
|
13
|
+
config[key]
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.setup
|
17
|
+
yield self
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def [](key)
|
22
|
+
config[key]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -10,13 +10,19 @@ module FastSpring
|
|
10
10
|
attr_reader :customer
|
11
11
|
|
12
12
|
# Get the subscription from Saasy
|
13
|
-
def initialize(
|
14
|
-
@auth = {:username => username,
|
15
|
-
|
13
|
+
def initialize(reference)
|
14
|
+
@auth = {:username => FastSpring::Account.fetch(:username),
|
15
|
+
:password => FastSpring::Account.fetch(:password)}
|
16
|
+
@company = FastSpring::Account.fetch(:company)
|
16
17
|
@reference = reference
|
17
18
|
@response = self.class.get(base_subscription_path, :basic_auth => @auth)
|
18
19
|
end
|
19
20
|
|
21
|
+
# Find a subscription by reference
|
22
|
+
def self.find(reference)
|
23
|
+
self.new(reference)
|
24
|
+
end
|
25
|
+
|
20
26
|
# Returns the base path for a subscription
|
21
27
|
def base_subscription_path
|
22
28
|
"/company/#{@company}/subscription/#{@reference}"
|
@@ -0,0 +1,15 @@
|
|
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::Account do
|
5
|
+
before do
|
6
|
+
FastSpring::Account.setup do |config|
|
7
|
+
config[:username] = 'johndoe'
|
8
|
+
config[:password] = 'secret'
|
9
|
+
config[:company] = 'acme'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
it 'stores the configuration for the account setup' do
|
13
|
+
FastSpring::Account.config.should == {:username=>"johndoe", :password=>"secret", :company=>"acme"}
|
14
|
+
end
|
15
|
+
end
|
data/spec/subscription_spec.rb
CHANGED
@@ -2,8 +2,17 @@ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/fastspring-sa
|
|
2
2
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper.rb'))
|
3
3
|
|
4
4
|
describe FastSpring::Subscription do
|
5
|
+
|
6
|
+
before do
|
7
|
+
FastSpring::Account.setup do |config|
|
8
|
+
config[:username] = 'admin'
|
9
|
+
config[:password] = 'test'
|
10
|
+
config[:company] = 'acme'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
5
14
|
context 'url for subscriptions' do
|
6
|
-
subject { FastSpring::Subscription.
|
15
|
+
subject { FastSpring::Subscription.find('test_ref') }
|
7
16
|
before do
|
8
17
|
stub_request(:get, "https://admin:test@api.fastspring.com/company/acme/subscription/test_ref").
|
9
18
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -15,7 +24,7 @@ describe FastSpring::Subscription do
|
|
15
24
|
end
|
16
25
|
|
17
26
|
context 'subscription details' do
|
18
|
-
subject { FastSpring::Subscription.
|
27
|
+
subject { FastSpring::Subscription.find('test_ref') }
|
19
28
|
let(:customer) { mock(:customer) }
|
20
29
|
before do
|
21
30
|
stub_request(:get, "https://admin:test@api.fastspring.com/company/acme/subscription/test_ref").
|
@@ -79,7 +88,7 @@ describe FastSpring::Subscription do
|
|
79
88
|
end
|
80
89
|
|
81
90
|
context 'renew' do
|
82
|
-
subject { FastSpring::Subscription.
|
91
|
+
subject { FastSpring::Subscription.find('test_ref') }
|
83
92
|
before do
|
84
93
|
stub_request(:get, "https://admin:test@api.fastspring.com/company/acme/subscription/test_ref").
|
85
94
|
to_return(stub_http_response_with('basic_subscription.xml'))
|
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.3.
|
4
|
+
version: 0.3.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
|
+
date: 2011-11-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70301329265660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70301329265660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70301329263260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70301329263260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70301329261120 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70301329261120
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70301329258540 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70301329258540
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: httparty
|
60
|
-
requirement: &
|
60
|
+
requirement: &70301329256600 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 0.8.1
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70301329256600
|
69
69
|
description: Ruby lib for using the FastSpring (Saas) subscription management API
|
70
70
|
email: richard@justaddpixels.com
|
71
71
|
executables: []
|
@@ -84,9 +84,11 @@ files:
|
|
84
84
|
- VERSION
|
85
85
|
- fastspring-saasy.gemspec
|
86
86
|
- lib/fastspring-saasy.rb
|
87
|
+
- lib/fastspring-saasy/account.rb
|
87
88
|
- lib/fastspring-saasy/customer.rb
|
88
89
|
- lib/fastspring-saasy/error.rb
|
89
90
|
- lib/fastspring-saasy/subscription.rb
|
91
|
+
- spec/account_spec.rb
|
90
92
|
- spec/customer_spec.rb
|
91
93
|
- spec/fixtures/basic_subscription.xml
|
92
94
|
- spec/spec_helper.rb
|
@@ -106,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
108
|
version: '0'
|
107
109
|
segments:
|
108
110
|
- 0
|
109
|
-
hash:
|
111
|
+
hash: 4459669591776827499
|
110
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
113
|
none: false
|
112
114
|
requirements:
|