megam_assembla 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ module Megam
2
+ class Assembla
3
+
4
+ # GET /repos
5
+ def get_spaces(access_token)
6
+ @options = {:path => "/spaces?grant_type=access_token&access_token=#{access_token}",:body => ""}.merge(@options)
7
+ request(
8
+ :expects => 200,
9
+ :method => :get,
10
+ :body => @options[:body]
11
+ )
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Megam
2
+ class Assembla
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,508 @@
1
+ # Copyright:: Copyright (c) 2012, 2013 Megam Systems
2
+ # License:: Apache License, Version 2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Megam
18
+ class Space
19
+ def initialize()
20
+ @id = nil
21
+ @name = nil
22
+ @description = nil
23
+ @project = nil
24
+ @wiki_name = nil
25
+ @public_permissions = nil
26
+ @team_permissions = nil
27
+ @watcher_permissions = nil
28
+ @share_permissions = nil
29
+ @team_tab_role = nil
30
+ @created_at = nil
31
+ @updated_at = nil
32
+ @default_showpage = nil
33
+ @tabs_order = nil
34
+ @parent_id = nil
35
+ @restricted = nil
36
+ @restricted_date = nil
37
+ @commercial_from = nil
38
+ @banner = nil
39
+ @banner_height = nil
40
+ @banner_text = nil
41
+ @banner_link = nil
42
+ @style = nil
43
+ @status = nil
44
+ @approved = nil
45
+ @is_manager = nil
46
+ @is_volunteer = nil
47
+ @is_commercial = nil
48
+ @can_join = nil
49
+ @can_apply = nil
50
+ @last_payer_changed_at = nil
51
+ end
52
+
53
+ def megam_rest
54
+ puts "megam_rest entry"
55
+ Megam::Assembla.new
56
+ end
57
+
58
+ def space
59
+ self
60
+ end
61
+
62
+ def id(arg=nil)
63
+ if arg != nil
64
+ @id = arg
65
+ else
66
+ @id
67
+ end
68
+ end
69
+
70
+ def name(arg=nil)
71
+ if arg != nil
72
+ @name = arg
73
+ else
74
+ @name
75
+ end
76
+ end
77
+
78
+ def description(arg=nil)
79
+ if arg != nil
80
+ @description = arg
81
+ else
82
+ @description
83
+ end
84
+ end
85
+
86
+ def project(arg=nil)
87
+ if arg != nil
88
+ @project = arg
89
+ else
90
+ @project
91
+ end
92
+ end
93
+
94
+ def wiki_name(arg=nil)
95
+ if arg != nil
96
+ @wiki_name = arg
97
+ else
98
+ @wiki_name
99
+ end
100
+ end
101
+
102
+ def public_permissions(arg=nil)
103
+ if arg != nil
104
+ @public_permissions = arg
105
+ else
106
+ @public_permissions
107
+ end
108
+ end
109
+
110
+ def team_permissions(arg=nil)
111
+ if arg != nil
112
+ @team_permissions = arg
113
+ else
114
+ @team_permissions
115
+ end
116
+ end
117
+
118
+ def watcher_permissions(arg=nil)
119
+ if arg != nil
120
+ @watcher_permissions = arg
121
+ else
122
+ @watcher_permissions
123
+ end
124
+ end
125
+
126
+ def share_permissions(arg=nil)
127
+ if arg != nil
128
+ @share_permissions = arg
129
+ else
130
+ @share_permissions
131
+ end
132
+ end
133
+
134
+ def team_tab_role(arg=nil)
135
+ if arg != nil
136
+ @team_tab_role = arg
137
+ else
138
+ @team_tab_role
139
+ end
140
+ end
141
+
142
+ def created_at(arg=nil)
143
+ if arg != nil
144
+ @created_at = arg
145
+ else
146
+ @created_at
147
+ end
148
+ end
149
+
150
+ def updated_at(arg=nil)
151
+ if arg != nil
152
+ @updated_at = arg
153
+ else
154
+ @updated_at
155
+ end
156
+ end
157
+
158
+ def default_showpage(arg=nil)
159
+ if arg != nil
160
+ @default_showpage = arg
161
+ else
162
+ @default_showpage
163
+ end
164
+ end
165
+
166
+ def tabs_order(arg=nil)
167
+ if arg != nil
168
+ @tabs_order = arg
169
+ else
170
+ @tabs_order
171
+ end
172
+ end
173
+
174
+ def parent_id(arg=nil)
175
+ if arg != nil
176
+ @parent_id = arg
177
+ else
178
+ @parent_id
179
+ end
180
+ end
181
+
182
+ def restricted(arg=nil)
183
+ if arg != nil
184
+ @restricted = arg
185
+ else
186
+ @restricted
187
+ end
188
+ end
189
+
190
+ def restricted_date(arg=nil)
191
+ if arg != nil
192
+ @restricted_date = arg
193
+ else
194
+ @restricted_date
195
+ end
196
+ end
197
+
198
+ def commercial_from(arg=nil)
199
+ if arg != nil
200
+ @commercial_from = arg
201
+ else
202
+ @commercial_from
203
+ end
204
+ end
205
+
206
+ def banner(arg=nil)
207
+ if arg != nil
208
+ @banner = arg
209
+ else
210
+ @banner
211
+ end
212
+ end
213
+
214
+ def banner_height(arg=nil)
215
+ if arg != nil
216
+ @banner_height = arg
217
+ else
218
+ @banner_height
219
+ end
220
+ end
221
+
222
+ def banner_link(arg=nil)
223
+ if arg != nil
224
+ @banner_link = arg
225
+ else
226
+ @banner_link
227
+ end
228
+ end
229
+
230
+ def banner_text(arg=nil)
231
+ if arg != nil
232
+ @banner_text = arg
233
+ else
234
+ @banner_text
235
+ end
236
+ end
237
+
238
+ def style(arg=nil)
239
+ if arg != nil
240
+ @style = arg
241
+ else
242
+ @style
243
+ end
244
+ end
245
+
246
+ def status(arg=nil)
247
+ if arg != nil
248
+ @status = arg
249
+ else
250
+ @status
251
+ end
252
+ end
253
+
254
+ def approved(arg=nil)
255
+ if arg != nil
256
+ @approved = arg
257
+ else
258
+ @approved
259
+ end
260
+ end
261
+
262
+ def is_manager(arg=nil)
263
+ if arg != nil
264
+ @is_manager = arg
265
+ else
266
+ @is_manager
267
+ end
268
+ end
269
+
270
+ def is_volunteer(arg=nil)
271
+ if arg != nil
272
+ @is_volunteer = arg
273
+ else
274
+ @is_volunteer
275
+ end
276
+ end
277
+
278
+ def is_commercial(arg=nil)
279
+ if arg != nil
280
+ @is_commercial = arg
281
+ else
282
+ @is_commercial
283
+ end
284
+ end
285
+
286
+ def can_join(arg=nil)
287
+ if arg != nil
288
+ @can_join = arg
289
+ else
290
+ @can_join
291
+ end
292
+ end
293
+
294
+ def can_apply(arg=nil)
295
+ if arg != nil
296
+ @can_apply = arg
297
+ else
298
+ @can_apply
299
+ end
300
+ end
301
+
302
+ def last_payer_changed_at(arg=nil)
303
+ if arg != nil
304
+ @last_payer_changed_at = arg
305
+ else
306
+ @last_payer_changed_at
307
+ end
308
+ end
309
+
310
+ def some_msg(arg=nil)
311
+ if arg != nil
312
+ @some_msg = arg
313
+ else
314
+ @some_msg
315
+ end
316
+ end
317
+
318
+ def error?
319
+ crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
320
+ end
321
+
322
+ # Transform the ruby obj -> to a Hash
323
+ def to_hash
324
+ index_hash = Hash.new
325
+ index_hash["json_claz"] = self.class.name
326
+
327
+ index_hash["id"] = id
328
+ index_hash["name"] = name
329
+ index_hash["description"] = description
330
+ index_hash["project"] = project
331
+ index_hash["wiki_name"] = wiki_name
332
+ index_hash["public_permissions"] = public_permissions
333
+ index_hash["team_permissions"] = team_permissions
334
+ index_hash["watcher_permissions"] = watcher_permissions
335
+ index_hash["share_permissions"] = share_permissions
336
+ index_hash["team_tab_role"] = team_tab_role
337
+ index_hash["created_at"] = created_at
338
+ index_hash["updated_at"] = updated_at
339
+ index_hash["default_showpage"] = default_showpage
340
+ index_hash["tabs_order"] = tabs_order
341
+ index_hash["parent_id"] = parent_id
342
+ index_hash["restricted"] = restricted
343
+ index_hash["restricted_date"] = restricted_date
344
+ index_hash["commercial_from"] = commercial_from
345
+ index_hash["banner"] = banner
346
+ index_hash["banner_height"] = banner_height
347
+ index_hash["banner_text"] = banner_text
348
+ index_hash["banner_link"] = banner_link
349
+ index_hash["style"] = style
350
+ index_hash["status"] = status
351
+ index_hash["approved"] = approved
352
+ index_hash["is_manager"] = is_manager
353
+ index_hash["is_volunteer"] = is_volunteer
354
+ index_hash["is_commercial"] = is_commercial
355
+ index_hash["can_join"] = can_join
356
+ index_hash["can_apply"] = can_apply
357
+ index_hash["last_payer_changed_at"] = last_payer_changed_at
358
+ index_hash
359
+ end
360
+
361
+ # Serialize this object as a hash: called from JsonCompat.
362
+ # Verify if this called from JsonCompat during testing.
363
+ def to_json(*a)
364
+ for_json.to_json(*a)
365
+ end
366
+
367
+ def for_json
368
+ result = {
369
+ "id" => id,
370
+ "name" => name,
371
+ "description" => description,
372
+ "project" => project,
373
+ "wiki_name" => wiki_name,
374
+ "public_permissions" => public_permissions,
375
+ "team_permissions" => team_permissions,
376
+ "watcher_permissions" => watcher_permissions,
377
+ "share_permissions" => share_permissions,
378
+ "team_tab_role" => team_tab_role,
379
+ "created_at" => created_at,
380
+ "updated_at" => updated_at,
381
+ "default_showpage" => default_showpage,
382
+ "tabs_order" => tabs_order,
383
+ "parent_id" => parent_id,
384
+ "restricted" => restricted,
385
+ "restricted_date" => restricted_date,
386
+ "commercial_from" => commercial_from,
387
+ "banner" => banner,
388
+ "banner_height" => banner_height,
389
+ "banner_text" => banner_text,
390
+ "banner_link" => banner_link,
391
+ "style" => style,
392
+ "status" => status,
393
+ "approved" => approved,
394
+ "is_manager" => is_manager,
395
+ "is_volunteer" => is_volunteer,
396
+ "is_commercial" => is_commercial,
397
+ "can_join" => can_join,
398
+ "can_apply" => can_apply,
399
+ "last_payer_changed_at" => last_payer_changed_at
400
+ }
401
+ result
402
+ end
403
+
404
+ def self.json_create(o)
405
+ space = new
406
+ space.id(o["id"]) if o.has_key?("id")
407
+ space.name(o["name"]) if o.has_key?("name")
408
+ space.description(o["description"]) if o.has_key?("description")
409
+ space.project(o["project"]) if o.has_key?("project")
410
+ space.wiki_name(o["wiki_name"]) if o.has_key?("wiki_name")
411
+ space.public_permissions(o["public_permissions"]) if o.has_key?("public_permissions")
412
+ space.team_permissions(o["team_permissions"]) if o.has_key?("team_permissions")
413
+ space.watcher_permissions(o["watcher_permissions"]) if o.has_key?("watcher_permissions")
414
+ space.share_permissions(o["share_permissions"]) if o.has_key?("share_permissions")
415
+ space.team_tab_role(o["team_tab_role"]) if o.has_key?("team_tab_role")
416
+ space.created_at(o["created_at"]) if o.has_key?("created_at")
417
+ space.updated_at(o["updated_at"]) if o.has_key?("updated_at")
418
+ space.default_showpage(o["default_showpage"]) if o.has_key?("default_showpage")
419
+ space.tabs_order(o["tabs_order"]) if o.has_key?("tabs_order")
420
+ space.parent_id(o["parent_id"]) if o.has_key?("parent_id")
421
+ space.restricted(o["restricted"]) if o.has_key?("restricted")
422
+ space.restricted_date(o["restricted_date"]) if o.has_key?("restricted_date")
423
+ space.commercial_from(o["commercial_from"]) if o.has_key?("commercial_from")
424
+ space.banner(o["banner"]) if o.has_key?("banner")
425
+ space.banner_height(o["banner_height"]) if o.has_key?("banner_height")
426
+ space.banner_text(o["banner_text"]) if o.has_key?("banner_text")
427
+ space.banner_link(o["banner_link"]) if o.has_key?("banner_link")
428
+ space.style(o["style"]) if o.has_key?("style")
429
+ space.status(o["status"]) if o.has_key?("status")
430
+ space.approved(o["approved"]) if o.has_key?("approved")
431
+ space.is_manager(o["is_manager"]) if o.has_key?("is_manager")
432
+ space.is_volunteer(o["is_volunteer"]) if o.has_key?("is_volunteer")
433
+ space.is_commercial(o["is_commercial"]) if o.has_key?("is_commercial")
434
+ space.can_join(o["can_join"]) if o.has_key?("can_join")
435
+ space.can_apply(o["can_apply"]) if o.has_key?("can_apply")
436
+ space.last_payer_changed_at(o["last_payer_changed_at"]) if o.has_key?("last_payer_changed_at")
437
+
438
+ #success or error
439
+ space.some_msg[:code] = o["code"] if o.has_key?("code")
440
+ space.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
441
+ space.some_msg[:msg]= o["msg"] if o.has_key?("msg")
442
+ space.some_msg[:links] = o["links"] if o.has_key?("links")
443
+
444
+ space
445
+ end
446
+
447
+ def self.from_hash(o)
448
+ space = self.new
449
+ space.from_hash(o)
450
+ space
451
+ end
452
+
453
+ def from_hash(o)
454
+ @id = o["id"] if o.has_key?("id")
455
+ @name = o["name"] if o.has_key?("name")
456
+ @description = o["description"] if o.has_key?("description")
457
+ @project = o["project"] if o.has_key?("project")
458
+ @wiki_name = o["wiki_name"] if o.has_key?("wiki_name")
459
+ @public_permissions = o["public_permissions"] if o.has_key?("public_permissions")
460
+ @team_permissions = o["team_permissions"] if o.has_key?("team_permissions")
461
+ @watcher_permissions = o["watcher_permissions"] if o.has_key?("watcher_permissions")
462
+ @share_permissions = o["share_permissions"] if o.has_key?("share_permissions")
463
+ @team_tab_role = o["team_tab_role"] if o.has_key?("team_tab_role")
464
+ @created_at = o["created_at"] if o.has_key?("created_at")
465
+ @updated_at = o["updated_at"] if o.has_key?("updated_at")
466
+ @default_showpage = o["default_showpage"] if o.has_key?("default_showpage")
467
+ @tabs_order = o["tabs_order"] if o.has_key?("tabs_order")
468
+ @parent_id = o["parent_id"] if o.has_key?("parent_id")
469
+ @restricted = o["restricted"] if o.has_key?("restricted")
470
+ @restricted_date = o["restricted_date"] if o.has_key?("restricted_date")
471
+ @commercial_from = o["commercial_from"] if o.has_key?("commercial_from")
472
+ @banner = o["banner"] if o.has_key?("banner")
473
+ @banner_height = o["banner_height"] if o.has_key?("banner_height")
474
+ @banner_text = o["banner_text"] if o.has_key?("banner_text")
475
+ @banner_link = o["banner_link"] if o.has_key?("banner_link")
476
+ @style = o["style"] if o.has_key?("style")
477
+ @status = o["status"] if o.has_key?("status")
478
+ @approved = o["approved"] if o.has_key?("approved")
479
+ @is_manager = o["is_manager"] if o.has_key?("is_manager")
480
+ @is_volunteer = o["is_volunteer"] if o.has_key?("is_volunteer")
481
+ @is_commercial = o["is_commercial"] if o.has_key?("is_commercial")
482
+ @can_join = o["can_join"] if o.has_key?("can_join")
483
+ @can_apply = o["can_apply"] if o.has_key?("can_apply")
484
+ @last_payer_changed_at = o["last_payer_changed_at"] if o.has_key?("last_payer_changed_at")
485
+ self
486
+ end
487
+
488
+ def self.create()
489
+ acct = from_hash()
490
+ acct.create
491
+ end
492
+
493
+ def self.list(access_token)
494
+ puts "-----------------------------Entry list"
495
+ space = self.new
496
+ puts "----------------------------create iniliaze"
497
+ puts access_token
498
+ ss = space.megam_rest.get_spaces(access_token)
499
+ puts ss.inspect
500
+ ss
501
+ end
502
+
503
+ def to_s
504
+ Megam::Stuff.styled_hash(to_hash)
505
+ end
506
+
507
+ end
508
+ end