Class: Megam::MarketPlace
- Defined in:
- lib/megam/core/marketplace.rb
Instance Attribute Summary
Attributes inherited from ServerAPI
Class Method Summary collapse
- .create(params) ⇒ Object
- .from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
- .json_create(o) ⇒ Object
- .list(params) ⇒ Object
-
.show(params) ⇒ Object
Load a account by email_p.
Instance Method Summary collapse
- #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
- #image(arg = nil) ⇒ Object
-
#initialize(email = nil, api_key = nil, host = nil) ⇒ MarketPlace
constructor
A new instance of MarketPlace.
- #market_place ⇒ Object
- #name(arg = nil) ⇒ Object
- #order(arg = nil) ⇒ Object
- #plans(arg = nil) ⇒ Object
- #some_msg(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
- #url(arg = nil) ⇒ Object
Methods inherited from ServerAPI
Constructor Details
#initialize(email = nil, api_key = nil, host = nil) ⇒ MarketPlace
Returns a new instance of MarketPlace.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/megam/core/marketplace.rb', line 20 def initialize(email=nil, api_key=nil, host=nil) @id = nil @name = nil @cattype = nil @order = nil @image = nil @url = nil @plans= nil @created_at = nil super(email, api_key, host) end |
Class Method Details
.create(params) ⇒ Object
180 181 182 183 |
# File 'lib/megam/core/marketplace.rb', line 180 def self.create(params) acct = from_hash(params, params["email"], params["api_key"], params["host"]) acct.create end |
.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
162 163 164 165 166 |
# File 'lib/megam/core/marketplace.rb', line 162 def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) app = self.new(tmp_email, tmp_api_key, tmp_host) app.from_hash(o) app end |
.json_create(o) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/megam/core/marketplace.rb', line 148 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.cattype(o["cattype"]) if o.has_key?("cattype") app.order(o["order"]) if o.has_key?("order") app.image(o["image"]) if o.has_key?("image") app.url(o["url"]) if o.has_key?("url") app.plans(o["plans"]) if o.has_key?("plans") app.created_at(o["created_at"]) if o.has_key?("created_at") app end |
.list(params) ⇒ Object
196 197 198 199 |
# File 'lib/megam/core/marketplace.rb', line 196 def self.list(params) app = self.new(params["email"], params["api_key"], params["host"]) app.megam_rest.get_marketplaceapps end |
.show(params) ⇒ Object
Load a account by email_p
191 192 193 194 |
# File 'lib/megam/core/marketplace.rb', line 191 def self.show(params) app = self.new(params["email"], params["api_key"], params["host"]) app.megam_rest.get_marketplaceapp(params["id"]) end |
Instance Method Details
#cattype(arg = nil) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/megam/core/marketplace.rb', line 61 def cattype(arg=nil) if arg != nil @cattype = arg else @cattype end end |
#create ⇒ Object
Create the marketplace app via the REST API
186 187 188 |
# File 'lib/megam/core/marketplace.rb', line 186 def create megam_rest.post_marketplaceapp(to_hash) end |
#created_at(arg = nil) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/megam/core/marketplace.rb', line 93 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
109 110 111 |
# File 'lib/megam/core/marketplace.rb', line 109 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/megam/core/marketplace.rb', line 134 def for_json result = { "id" => id, "name" => name, "cattype" => cattype, "order" => order, "image" => image, "url" => url, "plans" => plans, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/megam/core/marketplace.rb', line 168 def from_hash(o) @name = o["name"] if o.has_key?("name") @id = o["id"] if o.has_key?("id") @cattype = o["cattype"] if o.has_key?("cattype") @order = o["order"] if o.has_key?("order") @image = o["image"] if o.has_key?("image") @url = o["url"] if o.has_key?("url") @plans = o["plans"] if o.has_key?("plans") @created_at = o["created_at"] if o.has_key?("created_at") self end |
#id(arg = nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/megam/core/marketplace.rb', line 45 def id(arg=nil) if arg != nil @id = arg else @id end end |
#image(arg = nil) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/megam/core/marketplace.rb', line 77 def image(arg=nil) if arg != nil @image = arg else @image end end |
#market_place ⇒ Object
32 33 34 |
# File 'lib/megam/core/marketplace.rb', line 32 def market_place self end |
#name(arg = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/megam/core/marketplace.rb', line 37 def name(arg=nil) if arg != nil @name = arg else @name end end |
#order(arg = nil) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/megam/core/marketplace.rb', line 69 def order(arg=nil) if arg != nil @order = arg else @order end end |
#plans(arg = nil) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/megam/core/marketplace.rb', line 53 def plans(arg=nil) if arg != nil @plans = arg else @plans end end |
#some_msg(arg = nil) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/megam/core/marketplace.rb', line 101 def some_msg(arg=nil) if arg != nil @some_msg = arg else @some_msg end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/megam/core/marketplace.rb', line 114 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["name"] = name index_hash["cattype"] = cattype index_hash["order"] = order index_hash["image"] = image index_hash["url"] = url index_hash["plans"] = plans 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.
130 131 132 |
# File 'lib/megam/core/marketplace.rb', line 130 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
201 202 203 204 |
# File 'lib/megam/core/marketplace.rb', line 201 def to_s Megam::Stuff.styled_hash(to_hash) #"---> Megam::Account:[error=#{error?}]\n"+ end |
#url(arg = nil) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/megam/core/marketplace.rb', line 85 def url(arg=nil) if arg != nil @url = arg else @url end end |