Class: Subscription

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/sharkapps/subscription.rb

Constant Summary collapse

VALID =
"active"
EXPIRED =
"expired"
TRIAL =
"trial"
UNAUTHORIZED =
"unauthorized"

Class Method Summary collapse

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.(, acc_hash)
  path = "#{self.site}accounts/app_authorized/#{}/#{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.check_admin_authorized(, user_id)
  path = "#{self.site}accounts/app_authorized/#{}/#{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()
  sub = Subscription.find(.fbid)
  return sub.subscriptions unless sub.nil?
end

.initialize_from_yamlObject



41
42
43
44
45
# File 'lib/sharkapps/subscription.rb', line 41

def self.initialize_from_yaml
  self.site = SharkApps.server_url
  self.user = SharkApps.username
  self.password = SharkApps.password
end