Class: Megam::MarketPlace
- Defined in:
- lib/megam/core/marketplace.rb
Instance Attribute Summary
Attributes inherited from ServerAPI
Class Method Summary collapse
- .create(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
- .from_hash(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
- .json_create(o) ⇒ Object
- .list(params) ⇒ Object
-
.show(params) ⇒ Object
Load a account by email_p.
Instance Method Summary collapse
- #catalog(arg = nil) ⇒ Object
- #cattype(arg = nil) ⇒ Object
-
#create ⇒ Object
Create the marketplace app via the REST API.
- #created_at(arg = nil) ⇒ Object
- #error? ⇒ Boolean
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
- #id(arg = nil) ⇒ Object
-
#initialize(email = nil, api_key = nil) ⇒ MarketPlace
constructor
A new instance of MarketPlace.
- #market_place ⇒ Object
- #name(arg = nil) ⇒ Object
- #plans(arg = nil) ⇒ Object
- #predef(arg = nil) ⇒ Object
- #some_msg(arg = nil) ⇒ Object
- #status(arg = nil) ⇒ Object
-
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash.
-
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat.
- #to_s ⇒ Object
Methods inherited from ServerAPI
Constructor Details
#initialize(email = nil, api_key = nil) ⇒ MarketPlace
Returns a new instance of MarketPlace.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/megam/core/marketplace.rb', line 20 def initialize(email=nil, api_key=nil) @id = nil @name = nil @catalog = {} @plans=nil @cattype =nil @predef =nil @some_msg = {} @status = nil @created_at = nil super(email, api_key) end |
Class Method Details
.create(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
222 223 224 225 |
# File 'lib/megam/core/marketplace.rb', line 222 def self.create(o,tmp_email=nil, tmp_api_key=nil) acct = from_hash(o, tmp_email, tmp_api_key) acct.create end |
.from_hash(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
202 203 204 205 206 |
# File 'lib/megam/core/marketplace.rb', line 202 def self.from_hash(o,tmp_email=nil, tmp_api_key=nil) app = self.new(tmp_email, tmp_api_key) app.from_hash(o) app end |
.json_create(o) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/megam/core/marketplace.rb', line 156 def self.json_create(o) app = new app.id(o["id"]) if o.has_key?("id") app.name(o["name"]) if o.has_key?("name") app.logo(o["logo"]) if o.has_key?("logo") app.catagory(o["catagory"]) if o.has_key?("catagory") app.attach(o["attach"]) if o.has_key?("attach") app.predefnode(o["predefnode"]) if o.has_key?("predefnode") app.approved(o["approved"]) if o.has_key?("approved") app.created_at(o["created_at"]) if o.has_key?("created_at") app.plans(o["plans"]) if o.has_key?("plans") #requests oq = o["features"] app.features[:feature1] = oq["feature1"] if oq && oq.has_key?("feature1") app.features[:feature2] = oq["feature2"] if oq && oq.has_key?("feature2") app.features[:feature3] = oq["feature3"] if oq && oq.has_key?("feature3") app.features[:feature4] = oq["feature4"] if oq && oq.has_key?("feature4") oa = o["appdetails"] app.appdetails[:logo] = oa["logo"] if oa && oa.has_key?("logo") app.appdetails[:category] = oa["category"] if oa && oa.has_key?("category") app.appdetails[:description] = oa["description"] if oa && oa.has_key?("description") #op = o["plan"] #app.plan[:price] = op["price"] if op && op.has_key?("price") #app.plan[:description] = op["description"] if op && op.has_key?("description") #app.plan[:plantype]= op["plantype"] if op && op.has_key?("plantype") ol = o["applinks"] app.applinks[:free_support] = ol["free_support"] if ol && ol.has_key?("free_support") app.applinks[:paid_support] = ol["paid_support"] if ol && ol.has_key?("paid_support") app.applinks[:home_link] = ol["home_link"] if ol && ol.has_key?("home_link") app.applinks[:info_link] = ol["info_link"] if ol && ol.has_key?("info_link") app.applinks[:content_link] = ol["content_link"] if ol && ol.has_key?("content_link") app.applinks[:wiki_link] = ol["wiki_link"] if ol && ol.has_key?("wiki_link") app.applinks[:source_link] = ol["source_link"] if ol && ol.has_key?("source_link") #success or error app.some_msg[:code] = o["code"] if o.has_key?("code") app.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") app.some_msg[:msg]= o["msg"] if o.has_key?("msg") app.some_msg[:links] = o["links"] if o.has_key?("links") app end |
.list(params) ⇒ Object
238 239 240 241 |
# File 'lib/megam/core/marketplace.rb', line 238 def self.list(params) app = self.new(params["email"], params["api_key"]) app.megam_rest.get_marketplaceapps end |
.show(params) ⇒ Object
Load a account by email_p
233 234 235 236 |
# File 'lib/megam/core/marketplace.rb', line 233 def self.show(params) app = self.new(params["email"], params["api_key"]) app.megam_rest.get_marketplaceapp(params["id"]) end |
Instance Method Details
#catalog(arg = nil) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/megam/core/marketplace.rb', line 46 def catalog(arg=nil) if arg != nil @catalog = arg else @catalog end end |
#cattype(arg = nil) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/megam/core/marketplace.rb', line 80 def cattype(arg=nil) if arg != nil @cattype = arg else @cattype end end |
#create ⇒ Object
Create the marketplace app via the REST API
228 229 230 |
# File 'lib/megam/core/marketplace.rb', line 228 def create megam_rest.post_marketplaceapp(to_hash) end |
#created_at(arg = nil) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/megam/core/marketplace.rb', line 96 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
112 113 114 |
# File 'lib/megam/core/marketplace.rb', line 112 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/megam/core/marketplace.rb', line 140 def for_json result = { "id" => id, "name" => name, "appdetails" => appdetails, "features" => features, "plans" => plans, "applinks" => applinks, "attach" => attach, "predefnode" => predefnode, "approved" => approved, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/megam/core/marketplace.rb', line 208 def from_hash(o) @name = o["name"] if o.has_key?("name") @id = o["id"] if o.has_key?("id") @appdetails = o["appdetails"] if o.has_key?("appdetails") @features = o["features"] if o.has_key?("features") @plans = o["plans"] if o.has_key?("plans") @applinks = o["applinks"] if o.has_key?("applinks") @attach = o["attach"] if o.has_key?("attach") @predefnode = o["predefnode"] if o.has_key?("predefnode") @approved = o["approved"] if o.has_key?("approved") @created_at = o["created_at"] if o.has_key?("created_at") self end |
#id(arg = nil) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/megam/core/marketplace.rb', line 54 def id(arg=nil) if arg != nil @id = arg else @id end end |
#market_place ⇒ Object
33 34 35 |
# File 'lib/megam/core/marketplace.rb', line 33 def market_place self end |
#name(arg = nil) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/megam/core/marketplace.rb', line 38 def name(arg=nil) if arg != nil @name = arg else @name end end |
#plans(arg = nil) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/megam/core/marketplace.rb', line 63 def plans(arg=nil) if arg != nil @plans = arg else @plans end end |
#predef(arg = nil) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/megam/core/marketplace.rb', line 72 def predef(arg=nil) if arg != nil @predef = arg else @predef end end |
#some_msg(arg = nil) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/megam/core/marketplace.rb', line 104 def some_msg(arg=nil) if arg != nil @some_msg = arg else @some_msg end end |
#status(arg = nil) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/megam/core/marketplace.rb', line 88 def status(arg=nil) if arg != nil @status = arg else @status end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/megam/core/marketplace.rb', line 117 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["name"] = name index_hash["appdetails"] = appdetails index_hash["features"] = features index_hash["plans"] = plans index_hash["applinks"] = applinks index_hash["attach"] = attach index_hash["predefnode"] = predefnode index_hash["approved"] = approved index_hash["some_msg"] = some_msg index_hash["created_at"] = created_at index_hash end |
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
136 137 138 |
# File 'lib/megam/core/marketplace.rb', line 136 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
243 244 245 246 |
# File 'lib/megam/core/marketplace.rb', line 243 def to_s Megam::Stuff.styled_hash(to_hash) #"---> Megam::Account:[error=#{error?}]\n"+ end |