Class: Subscription
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- Subscription
- Defined in:
- lib/sharkapps/subscription.rb
Constant Summary collapse
- VALID =
"active"
- EXPIRED =
"expired"
- TRIAL =
"trial"
- UNAUTHORIZED =
"unauthorized"
Class Method Summary collapse
- .check_account_authorized(account_id, acc_hash) ⇒ Object
- .check_admin_authorized(account_id, user_id) ⇒ Object
- .get_all_subscriptions(account) ⇒ Object
- .initialize_from_yaml ⇒ Object
Class Method Details
.check_account_authorized(account_id, acc_hash) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sharkapps/subscription.rb', line 10 def self.(account_id, acc_hash) path = "#{self.site}accounts/app_authorized/#{account_id}/#{SharkApps.app_id}/#{acc_hash}.xml" url = URI.parse(path) req = Net::HTTP::Get.new(url.path) req.basic_auth self.user, self.password res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) } return res.body #doc = REXML::Document.new(res.body) end |
.check_admin_authorized(account_id, user_id) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sharkapps/subscription.rb', line 24 def self.(account_id, user_id) path = "#{self.site}accounts/app_authorized/#{account_id}/#{user_id}.xml" url = URI.parse(path) req = Net::HTTP::Get.new(url.path) req.basic_auth self.user, self.password res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) } return res.body end |
.get_all_subscriptions(account) ⇒ Object
36 37 38 39 |
# File 'lib/sharkapps/subscription.rb', line 36 def self.get_all_subscriptions(account) sub = Subscription.find(account.fbid) return sub.subscriptions unless sub.nil? end |