Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add update subscription api

  • Loading branch information...
commit e7e3ed80b7aa692f823961b2dd779fe87e3c7b61 1 parent 5bea1ad
zhendi.wang authored
1  Gemfile
View
@@ -9,6 +9,7 @@ gemspec
gem "jquery-rails", "1.0.12"
gem 'sqlite3'
gem "nokogiri"
+gem "httparty"
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
10 Gemfile.lock
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- saasy_simple (0.1.1)
+ saasy_simple (0.1.5)
rails (~> 3.0.6)
GEM
@@ -38,6 +38,9 @@ GEM
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
+ httparty (0.8.3)
+ multi_json (~> 1.0)
+ multi_xml
i18n (0.5.0)
jquery-rails (1.0.12)
railties (~> 3.0)
@@ -48,7 +51,9 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.18)
+ mime-types (1.19)
+ multi_json (1.3.6)
+ multi_xml (0.5.1)
nokogiri (1.5.0)
polyglot (0.3.3)
rack (1.2.5)
@@ -84,6 +89,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ httparty
jquery-rails (= 1.0.12)
nokogiri
saasy_simple!
17 lib/SaasySimple.rb
View
@@ -1,6 +1,7 @@
require "SaasySimple/engine"
require 'net/https'
require 'uri'
+require 'httparty'
module SaasySimple
def self.config(&block)
@@ -34,6 +35,22 @@ def self.subscription(user)
end
s
end
+
+ def update_subscription(subscription_update)
+ url = subscription_url(subscription_update.reference)
+ @auth = { :username => SaasySimple.config.username, :password => SaasySimple.config.password }
+ options = { :headers => { 'Content-Type' => 'application/xml' }, :body => subscription_update.to_xml, :basic_auth => @auth }
+ response = HTTParty.put(url, options)
+
+ if response.code == 200
+ sub = parse_subscription(response.parsed_response.fetch('subscription'))
+ else
+ exception = FsprgException.new(response.code, nil)
+ raise exception, "An error occurred calling the FastSpring subscription service", caller
+ end
+
+ sub
+ end
def self.cancel(user)
s = {}
2  lib/SaasySimple/version.rb
View
@@ -1,3 +1,3 @@
module SaasySimple
- VERSION = "0.1.5"
+ VERSION = "0.1.6"
end
Please sign in to comment.
Something went wrong with that request. Please try again.