class Megam::Subscriptions
Public Class Methods
create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 142 def self.create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) acct = from_hash(o,tmp_email, tmp_api_key, tmp_host) acct.create end
from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 126 def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) sbs = self.new(tmp_email, tmp_api_key, tmp_host) sbs.from_hash(o) sbs end
json_create(o)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 110 def self.json_create(o) sbs = new({}) sbs.id(o["id"]) if o.has_key?("id") sbs.account_id(o["account_id"]) if o.has_key?("account_id") sbs.model(o["model"]) if o.has_key?("model") sbs.license(o["license"]) if o.has_key?("license") sbs.trial_ends(o["trial_ends"]) if o.has_key?("trial_ends") sbs.created_at(o["created_at"]) if o.has_key?("created_at") #success or error sbs.some_msg[:code] = o["code"] if o.has_key?("code") sbs.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") sbs.some_msg[:msg]= o["msg"] if o.has_key?("msg") sbs.some_msg[:links] = o["links"] if o.has_key?("links") sbs end
new(o)
click to toggle source
Calls superclass method
Megam::RestAdapter::new
# File lib/megam/core/subscriptions.rb, line 3 def initialize(o) @id = nil @account_id = nil @model = nil @license = nil @trial_ends = nil @created_at = nil @some_msg = {} super(o) end
show(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
click to toggle source
Load all subscriptions - returns a SubscriptionsCollection
don’t return self. check if the Megam::SubscriptionsCollection
is returned.
# File lib/megam/core/subscriptions.rb, line 156 def self.show(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) pre = self.new(tmp_email,tmp_api_key, tmp_host) pre.megam_rest.get_subscription end
Public Instance Methods
account_id(arg=nil)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 26 def account_id(arg=nil) if arg != nil @account_id= arg else @account_id end end
create()
click to toggle source
Create the subscriptions via the REST API
# File lib/megam/core/subscriptions.rb, line 148 def create megam_rest.post_subscriptions(to_hash) end
created_at(arg=nil)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 58 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end
error?()
click to toggle source
# File lib/megam/core/subscriptions.rb, line 74 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end
for_json()
click to toggle source
# File lib/megam/core/subscriptions.rb, line 97 def for_json result = { "id" => id, "account_id" => account_id, "model" => model, "license" => license, "trial_ends" => trial_ends, "created_at" => created_at } result end
from_hash(o)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 132 def from_hash(o) @id = o[:id] if o.has_key?(:id) @account_id = o[:account_id] if o.has_key?(:account_id) @model = o[:model] if o.has_key?(:model) @license = o[:license] if o.has_key?(:license) @trial_ends = o[:trial_ends] if o.has_key?(:trial_ends) @created_at = o[:created_at] if o.has_key?(:created_at) self end
id(arg=nil)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 18 def id(arg=nil) if arg != nil @id = arg else @id end end
license(arg=nil)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 42 def license(arg=nil) if arg != nil @license= arg else @license end end
model(arg=nil)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 34 def model(arg=nil) if arg != nil @model = arg else @model end end
some_msg(arg=nil)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 66 def some_msg(arg=nil) if arg != nil @some_msg = arg else @some_msg end end
subscriptions()
click to toggle source
# File lib/megam/core/subscriptions.rb, line 14 def subscriptions self end
to_hash()
click to toggle source
Transform the ruby obj -> to a Hash
# File lib/megam/core/subscriptions.rb, line 79 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["account_id"] = account_id index_hash["model"] = model index_hash["license"] = license index_hash["trial_ends"] = trial_ends index_hash["created_at"] = created_at index_hash end
to_json(*a)
click to toggle source
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
# File lib/megam/core/subscriptions.rb, line 93 def to_json(*a) for_json.to_json(*a) end
to_s()
click to toggle source
# File lib/megam/core/subscriptions.rb, line 162 def to_s Megam::Stuff.styled_hash(to_hash) end
trial_ends(arg=nil)
click to toggle source
# File lib/megam/core/subscriptions.rb, line 50 def trial_ends(arg=nil) if arg != nil @trial_ends = arg else @trial_ends end end