Class: Megam::MarketPlace
- Inherits:
-
ServerAPI
- Object
- ServerAPI
- Megam::MarketPlace
- Defined in:
- lib/megam/core/marketplace.rb
Class Method Summary collapse
- .create(params) ⇒ Object
- .from_hash(o) ⇒ Object
- .json_create(o) ⇒ Object
- .list(params) ⇒ Object
-
.show(params) ⇒ Object
Load a account by email_p.
Instance Method Summary collapse
- #catorder(arg = nil) ⇒ Object
- #cattype(arg = nil) ⇒ Object
-
#create ⇒ Object
Create the marketplace app via the REST API.
- #created_at(arg = nil) ⇒ Object
- #envs(arg = []) ⇒ Object
- #error? ⇒ Boolean
- #flavor(arg = nil) ⇒ Object
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
- #id(arg = nil) ⇒ Object
- #image(arg = nil) ⇒ Object
-
#initialize(o) ⇒ MarketPlace
constructor
A new instance of MarketPlace.
- #market_place ⇒ Object
- #plans(arg = nil) ⇒ Object
- #settings_name(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
Constructor Details
#initialize(o) ⇒ MarketPlace
Returns a new instance of MarketPlace.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/megam/core/marketplace.rb', line 20 def initialize(o) @id = nil @settings_name = nil @cattype = nil @flavor = nil @image = nil @catorder = nil @url = nil @envs = [] @plans = nil @created_at = nil super(o) end |
Class Method Details
.create(params) ⇒ Object
206 207 208 209 |
# File 'lib/megam/core/marketplace.rb', line 206 def self.create(params) acct = from_hash(params) acct.create end |
.from_hash(o) ⇒ Object
186 187 188 189 190 |
# File 'lib/megam/core/marketplace.rb', line 186 def self.from_hash(o) app = new(o) app.from_hash(o) app end |
.json_create(o) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/megam/core/marketplace.rb', line 170 def self.json_create(o) app = new({}) app.id(o['id']) if o.key?('id') app.settings_name(o['settings_name']) if o.key?('settings_name') app.cattype(o['cattype']) if o.key?('cattype') app.flavor(o['flavor']) if o.key?('flavor') app.image(o['image']) if o.key?('image') app.catorder(o['catorder']) if o.key?('catorder') app.url(o['url']) if o.key?('url') app.envs(o['envs']) if o.key?('envs') app.plans(o['plans']) if o.key?('plans') app.created_at(o['created_at']) if o.key?('created_at') app end |
.list(params) ⇒ Object
222 223 224 225 |
# File 'lib/megam/core/marketplace.rb', line 222 def self.list(params) app = new(params) app.megam_rest.get_marketplaceapps end |
.show(params) ⇒ Object
Load a account by email_p
217 218 219 220 |
# File 'lib/megam/core/marketplace.rb', line 217 def self.show(params) app = new(params) app.megam_rest.get_marketplaceapp(params['id']) end |
Instance Method Details
#catorder(arg = nil) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/megam/core/marketplace.rb', line 78 def catorder(arg = nil) if !arg.nil? @catorder = arg else @catorder end end |
#cattype(arg = nil) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/megam/core/marketplace.rb', line 62 def cattype(arg = nil) if !arg.nil? @cattype = arg else @cattype end end |
#create ⇒ Object
Create the marketplace app via the REST API
212 213 214 |
# File 'lib/megam/core/marketplace.rb', line 212 def create megam_rest.post_marketplaceapp(to_hash) end |
#created_at(arg = nil) ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/megam/core/marketplace.rb', line 111 def created_at(arg = nil) if !arg.nil? @created_at = arg else @created_at end end |
#envs(arg = []) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/megam/core/marketplace.rb', line 102 def envs(arg = []) if arg != [] @envs = arg else @envs end end |
#error? ⇒ Boolean
127 128 129 |
# File 'lib/megam/core/marketplace.rb', line 127 def error? crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error' end |
#flavor(arg = nil) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/megam/core/marketplace.rb', line 70 def flavor(arg = nil) if !arg.nil? @flavor = arg else @flavor end end |
#for_json ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/megam/core/marketplace.rb', line 154 def for_json result = { 'id' => id, 'settings_name' => settings_name, 'cattype' => cattype, 'flavor' => flavor, 'image' => image, 'catorder' => catorder, 'url' => url, 'envs' => envs, 'plans' => plans, 'created_at' => created_at } result end |
#from_hash(o) ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/megam/core/marketplace.rb', line 192 def from_hash(o) @settings_name = o['settings_name'] if o.key?('settings_name') @id = o['id'] if o.key?('id') @cattype = o['cattype'] if o.key?('cattype') @flavor = o['flavor'] if o.key?('flavor') @image = o['image'] if o.key?('image') @catorder = o['catorder'] if o.key?('catorder') @url = o['url'] if o.key?('url') @envs = o['envs'] if o.key?('envs') @plans = o['plans'] if o.key?('plans') @created_at = o['created_at'] if o.key?('created_at') self end |
#id(arg = nil) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/megam/core/marketplace.rb', line 46 def id(arg = nil) if !arg.nil? @id = arg else @id end end |
#image(arg = nil) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/megam/core/marketplace.rb', line 86 def image(arg = nil) if !arg.nil? @image = arg else @image end end |
#market_place ⇒ Object
34 35 36 |
# File 'lib/megam/core/marketplace.rb', line 34 def market_place self end |
#plans(arg = nil) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/megam/core/marketplace.rb', line 54 def plans(arg = nil) if !arg.nil? @plans = arg else @plans end end |
#settings_name(arg = nil) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/megam/core/marketplace.rb', line 38 def settings_name(arg = nil) if !arg.nil? @settings_name = arg else @settings_name end end |
#some_msg(arg = nil) ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/megam/core/marketplace.rb', line 119 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
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/megam/core/marketplace.rb', line 132 def to_hash index_hash = {} index_hash['json_claz'] = self.class.name index_hash['id'] = id index_hash['settings_name'] = settings_name index_hash['cattype'] = cattype index_hash['flavor'] = flavor index_hash['image'] = image index_hash['catorder'] = catorder index_hash['url'] = url index_hash['envs'] = envs 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.
150 151 152 |
# File 'lib/megam/core/marketplace.rb', line 150 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
227 228 229 230 |
# File 'lib/megam/core/marketplace.rb', line 227 def to_s Megam::Stuff.styled_hash(to_hash) # "---> Megam::Account:[error=#{error?}]\n"+ end |
#url(arg = nil) ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/megam/core/marketplace.rb', line 94 def url(arg = nil) if !arg.nil? @url = arg else @url end end |