rspreedly 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ spec = Gem::Specification.new do |s|
20
20
 
21
21
  # Change these as appropriate
22
22
  s.name = "rspreedly"
23
- s.version = "0.1.16"
23
+ s.version = "0.1.17"
24
24
  s.summary = "Ruby library for the Spreedly API"
25
25
  s.author = "Richard Livsey"
26
26
  s.email = "richard@livsey.org"
@@ -182,6 +182,16 @@ module RSpreedly
182
182
  self.attributes = result["subscriber"]
183
183
  true
184
184
  end
185
+
186
+ def subscribe_link(subscription_plan_id, screen_name, return_url=nil)
187
+ params = return_url.nil? ? "" : "?return_url=" + return_url
188
+ "https://spreedly.com/#{RSpreedly::Config.site_name}/subscribers/#{self.customer_id}/subscribe/#{subscription_plan_id}/#{screen_name}#{params}"
189
+ end
190
+
191
+ def subscription_link(return_url=nil)
192
+ params = return_url.nil? ? "" : "?return_url=" + return_url
193
+ "https://spreedly.com/#{RSpreedly::Config.site_name}/subscriber_accounts/#{self.token}#{params}"
194
+ end
185
195
 
186
196
  def to_xml(opts={})
187
197
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rspreedly}
5
- s.version = "0.1.16"
5
+ s.version = "0.1.17"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Richard Livsey"]
@@ -704,5 +704,25 @@ describe RSpreedly::Subscriber do
704
704
  @subscriber.grant_lifetime_subscription("Something")
705
705
  }.should raise_error(RSpreedly::Error::BadRequest)
706
706
  end
707
+
708
+ it "should return subscribe_link for subscriber without return_url" do
709
+ @subscriber.subscribe_link('99', 'spreedster').should == "https://spreedly.com/your-site-name/subscribers/42/subscribe/99/spreedster"
710
+ end
711
+
712
+ it "should return subscribe_link for subscriber with return_url" do
713
+ return_url = "http://mydomain.com/response"
714
+ @subscriber.subscribe_link('99', 'spreedster', return_url).should == "https://spreedly.com/your-site-name/subscribers/42/subscribe/99/spreedster?return_url=http://mydomain.com/response"
715
+ end
716
+
717
+ it "should return subscription_link for subscriber without return_url" do
718
+ @subscriber.stub(:token).and_return("my-token")
719
+ @subscriber.subscription_link.should == "https://spreedly.com/your-site-name/subscriber_accounts/my-token"
720
+ end
721
+
722
+ it "should return subscription_link for subscriber with return_url" do
723
+ @subscriber.stub(:token).and_return("my-token")
724
+ return_url = "http://mydomain.com/response"
725
+ @subscriber.subscription_link(return_url).should == "https://spreedly.com/your-site-name/subscriber_accounts/my-token?return_url=http://mydomain.com/response"
726
+ end
707
727
  end
708
728
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspreedly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
17
- requirement: &2156234480 !ruby/object:Gem::Requirement
17
+ requirement: &2169039060 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.5.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2156234480
25
+ version_requirements: *2169039060
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &2156232940 !ruby/object:Gem::Requirement
28
+ requirement: &2169038400 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2156232940
36
+ version_requirements: *2169038400
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: webmock
39
- requirement: &2156231660 !ruby/object:Gem::Requirement
39
+ requirement: &2169037760 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2156231660
47
+ version_requirements: *2169037760
48
48
  description:
49
49
  email: richard@livsey.org
50
50
  executables: []