megam_api 0.73 → 0.75

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67d28ae2a87930c4b944ae4b778696e72ce0ac7c
4
- data.tar.gz: fa247596489d7a31251b48b8335c1fafffd95498
3
+ metadata.gz: 71c2300fe07469f9620a2a8aa85416daca5ec6a7
4
+ data.tar.gz: 625d47cb3a4f19f7c4c4597e4a9bc5c304f4fdd2
5
5
  SHA512:
6
- metadata.gz: 4922f672dcafdb0993c93ef84e96a392dcea443eec3403d5dd4cbc72198ff78c808db5352234c238fb8ce7085d4d2bb773dc362783fb4f0697c9e4f568fe694e
7
- data.tar.gz: 3895bfc122d83b32c1ee3ec9dbaa2948786527a8c0ff6f767313bbf9a9a2125848be2d46a7a83daabe78a5eec7562d48f85e51fc4fedf104bbbd7349de378fc7
6
+ metadata.gz: 607188d7cae267b3418ee76b2ade88323a87ab161862bb8677f21eb18142d138f7ef688ffd31c6413868e47f2c996ba548f3a50e857d69973de953471d275b90
7
+ data.tar.gz: 7eb58498ba9585db3401e347d9ef9bf84b230ad0100485a3406d8ccfb5a0c24d8b11f70ab4086677bd258b909c9c0a2e2540dd13350e8c42e9ad8901db4eded2
data/lib/megam/api.rb CHANGED
@@ -33,6 +33,7 @@ require 'megam/api/credithistories'
33
33
  require 'megam/api/discounts'
34
34
  require 'megam/api/subscriptions'
35
35
  require 'megam/api/promos'
36
+ require 'megam/api/invoices'
36
37
 
37
38
  require 'megam/core/server_api'
38
39
  require 'megam/core/config'
@@ -82,6 +83,8 @@ require 'megam/core/discounts'
82
83
  require 'megam/core/subscriptions_collection'
83
84
  require 'megam/core/subscriptions'
84
85
  require 'megam/core/promos'
86
+ require 'megam/core/invoices_collection'
87
+ require 'megam/core/invoices'
85
88
 
86
89
  module Megam
87
90
  class API
@@ -1,26 +1,25 @@
1
+
1
2
  module Megam
2
3
  class API
3
4
  def get_one_assembly(asm_id)
4
-
5
- @options = {:path => "/assembly/#{asm_id}",:body => ""}.merge(@options)
5
+ @options = { path: "/assembly/#{asm_id}", body: '' }.merge(@options)
6
6
 
7
7
  request(
8
- :expects => 200,
9
- :method => :get,
10
- :body => @options[:body]
8
+ expects: 200,
9
+ method: :get,
10
+ body: @options[:body]
11
11
  )
12
12
  end
13
-
14
- def update_assembly(new_asm)
15
- @options = {:path => '/assembly/update',
16
- :body => Megam::JSONCompat.to_json(new_asm)}.merge(@options)
13
+
14
+ def update_assembly(new_asm)
15
+ @options = { path: '/assembly/update',
16
+ body: Megam::JSONCompat.to_json(new_asm) }.merge(@options)
17
17
 
18
18
  request(
19
- :expects => [200, 201],
20
- :method => :post,
21
- :body => @options[:body]
19
+ expects: [200, 201],
20
+ method: :post,
21
+ body: @options[:body]
22
22
  )
23
- end
24
-
23
+ end
25
24
  end
26
25
  end
@@ -1,25 +1,24 @@
1
1
  module Megam
2
2
  class API
3
3
  def get_components(comp_id)
4
- @options = {:path => "/components/#{comp_id}",:body => ""}.merge(@options)
4
+ @options = { path: "/components/#{comp_id}", body: '' }.merge(@options)
5
5
 
6
6
  request(
7
- :expects => 200,
8
- :method => :get,
9
- :body => @options[:body]
7
+ expects: 200,
8
+ method: :get,
9
+ body: @options[:body]
10
10
  )
11
11
  end
12
12
 
13
- def update_component(new_asm)
14
- @options = {:path => '/components/update',
15
- :body => Megam::JSONCompat.to_json(new_asm)}.merge(@options)
13
+ def update_component(new_asm)
14
+ @options = { path: '/components/update',
15
+ body: Megam::JSONCompat.to_json(new_asm) }.merge(@options)
16
16
 
17
17
  request(
18
- :expects => [200, 201],
19
- :method => :post,
20
- :body => @options[:body]
18
+ expects: [200, 201],
19
+ method: :post,
20
+ body: @options[:body]
21
21
  )
22
- end
23
-
22
+ end
24
23
  end
25
24
  end
@@ -0,0 +1,35 @@
1
+ module Megam
2
+ class API
3
+ def get_invoices
4
+ @options = {:path => '/invoices',:body => ""}.merge(@options)
5
+
6
+ request(
7
+ :expects => 200,
8
+ :method => :get,
9
+ :body => @options[:body]
10
+ )
11
+ end
12
+
13
+ def get_invoice(id)
14
+ @options = {:path => "/invoices/#{id}",:body => ""}.merge(@options)
15
+
16
+ request(
17
+ :expects => 200,
18
+ :method => :get,
19
+ :body => @options[:body]
20
+ )
21
+ end
22
+
23
+ def post_invoices(new_invoices)
24
+ @options = {:path => '/invoices/content',
25
+ :body => Megam::JSONCompat.to_json(new_invoices)}.merge(@options)
26
+
27
+ request(
28
+ :expects => 201,
29
+ :method => :post,
30
+ :body => @options[:body]
31
+ )
32
+ end
33
+
34
+ end
35
+ end
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "0.73"
3
+ VERSION = "0.75"
4
4
  end
5
5
  end
@@ -16,19 +16,18 @@
16
16
 
17
17
  module Megam
18
18
  class Assembly < Megam::ServerAPI
19
- def initialize(email=nil, api_key=nil, host=nil)
19
+ def initialize(email = nil, api_key = nil, host = nil)
20
20
  @id = nil
21
21
  @asms_id = nil
22
22
  @name = nil
23
- @tosca_type = nil
24
23
  @components = []
25
- @requirements = []
26
- @policies=[]
24
+ @tosca_type = nil
25
+ @policies = []
27
26
  @inputs = []
28
- @operations = []
29
27
  @outputs = []
30
28
  @status = nil
31
29
  @created_at = nil
30
+
32
31
  super(email, api_key, host)
33
32
  end
34
33
 
@@ -36,11 +35,11 @@ module Megam
36
35
  self
37
36
  end
38
37
 
39
- def id(arg=nil)
40
- if arg != nil
38
+ def id(arg = nil)
39
+ if !arg.nil?
41
40
  @id = arg
42
41
  else
43
- @id
42
+ @id
44
43
  end
45
44
  end
46
45
 
@@ -52,106 +51,88 @@ module Megam
52
51
  end
53
52
  end
54
53
 
55
- def name(arg=nil)
56
- if arg != nil
54
+ def name(arg = nil)
55
+ if !arg.nil?
57
56
  @name = arg
58
57
  else
59
- @name
58
+ @name
60
59
  end
61
60
  end
62
61
 
63
- def tosca_type(arg=nil)
64
- if arg != nil
62
+ def tosca_type(arg = nil)
63
+ if !arg.nil?
65
64
  @tosca_type = arg
66
65
  else
67
- @tosca_type
66
+ @tosca_type
68
67
  end
69
68
  end
70
69
 
71
- def components(arg=[])
70
+ def components(arg = [])
72
71
  if arg != []
73
72
  @components = arg
74
73
  else
75
- @components
76
- end
77
- end
78
-
79
- def requirements(arg=[])
80
- if arg != []
81
- @requirements = arg
82
- else
83
- @requirements
74
+ @components
84
75
  end
85
76
  end
86
77
 
87
- def policies(arg=[])
78
+ def policies(arg = [])
88
79
  if arg != []
89
80
  @policies = arg
90
81
  else
91
- @policies
82
+ @policies
92
83
  end
93
84
  end
94
85
 
95
- def inputs(arg=[])
86
+ def inputs(arg = [])
96
87
  if arg != []
97
88
  @inputs = arg
98
89
  else
99
- @inputs
90
+ @inputs
100
91
  end
101
92
  end
102
93
 
103
- def operations(arg=nil)
104
- if arg != nil
105
- @operations = arg
106
- else
107
- @operations
108
- end
109
- end
110
-
111
- def outputs(arg=[])
94
+ def outputs(arg = [])
112
95
  if arg != []
113
96
  @outputs = arg
114
97
  else
115
- @outputs
98
+ @outputs
116
99
  end
117
100
  end
118
101
 
119
- def status(arg=nil)
120
- if arg != nil
102
+ def status(arg = nil)
103
+ if !arg.nil?
121
104
  @status = arg
122
105
  else
123
- @status
106
+ @status
124
107
  end
125
108
  end
126
109
 
127
- def created_at(arg=nil)
128
- if arg != nil
110
+ def created_at(arg = nil)
111
+ if !arg.nil?
129
112
  @created_at = arg
130
113
  else
131
- @created_at
114
+ @created_at
115
+ end
132
116
  end
133
- end
134
117
 
135
118
  def error?
136
- crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
119
+ crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
137
120
  end
138
121
 
139
122
  # Transform the ruby obj -> to a Hash
140
123
  def to_hash
141
- index_hash = Hash.new
142
- index_hash["json_claz"] = self.class.name
143
- index_hash["id"] = id
144
- index_hash["asms_id"] = asms_id
145
- index_hash["name"] = name
146
- index_hash["tosca_type"] = tosca_type
147
- index_hash["components"] = components
148
- index_hash["requirements"] = requirements
149
- index_hash["policies"] = policies
150
- index_hash["inputs"] = inputs
151
- index_hash["operations"] = operations
152
- index_hash["outputs"] = outputs
153
- index_hash["status"] = status
154
- index_hash["created_at"] = created_at
124
+ index_hash = {}
125
+ index_hash['json_claz'] = self.class.name
126
+ index_hash['id'] = id
127
+ index_hash["asms_id"] = asms_id
128
+ index_hash['name'] = name
129
+ index_hash['components'] = components
130
+ index_hash['tosca_type'] = tosca_type
131
+ index_hash['policies'] = policies
132
+ index_hash['inputs'] = inputs
133
+ index_hash['outputs'] = outputs
134
+ index_hash['status'] = status
135
+ index_hash['created_at'] = created_at
155
136
  index_hash
156
137
  end
157
138
 
@@ -163,17 +144,15 @@ module Megam
163
144
 
164
145
  def for_json
165
146
  result = {
166
- "id" => id,
167
- "name" => name,
168
- "tosca_type" => tosca_type,
169
- "components" => components,
170
- "requirements" => requirements,
171
- "policies" => policies,
172
- "inputs" => inputs,
173
- "operations" => operations,
174
- "outputs" => outputs,
175
- "status" => status,
176
- "created_at" => created_at
147
+ 'id' => id,
148
+ 'name' => name,
149
+ 'components' => components,
150
+ 'tosca_type' => tosca_type,
151
+ 'policies' => policies,
152
+ 'inputs' => inputs,
153
+ 'outputs' => outputs,
154
+ 'status' => status,
155
+ 'created_at' => created_at
177
156
  }
178
157
 
179
158
  result
@@ -181,53 +160,48 @@ module Megam
181
160
 
182
161
  def self.json_create(o)
183
162
  asm = new
184
- asm.id(o["id"]) if o.has_key?("id")
163
+ asm.id(o['id']) if o.key?('id')
185
164
  asm.asms_id(o["asms_id"]) if o.has_key?("asms_id")
186
- asm.name(o["name"]) if o.has_key?("name")
187
- asm.tosca_type(o["tosca_type"]) if o.has_key?("tosca_type")
188
- asm.components(o["components"]) if o.has_key?("components")
189
- asm.requirements(o["requirements"]) if o.has_key?("requirements")
190
- asm.policies(o["policies"]) if o.has_key?("policies") #this will be an array? can hash store array?
191
- asm.inputs(o["inputs"]) if o.has_key?("inputs")
192
- asm.operations(o["operations"]) if o.has_key?("operations")
193
- asm.outputs(o["outputs"]) if o.has_key?("outputs")
194
- asm.status(o["status"]) if o.has_key?("status")
195
- asm.created_at(o["created_at"]) if o.has_key?("created_at")
165
+ asm.name(o['name']) if o.key?('name')
166
+ asm.components(o['components']) if o.key?('components')
167
+ asm.tosca_type(o['tosca_type']) if o.key?('tosca_type')
168
+ asm.policies(o['policies']) if o.key?('policies') # this will be an array? can hash store array?
169
+ asm.inputs(o['inputs']) if o.key?('inputs')
170
+ asm.outputs(o['outputs']) if o.key?('outputs')
171
+ asm.status(o['status']) if o.key?('status')
172
+ asm.created_at(o['created_at']) if o.key?('created_at')
196
173
  asm
197
174
  end
198
175
 
199
- def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
200
- asm = self.new(tmp_email, tmp_api_key, tmp_host)
176
+ def self.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil)
177
+ asm = new(tmp_email, tmp_api_key, tmp_host)
201
178
  asm.from_hash(o)
202
179
  asm
203
180
  end
204
181
 
205
182
  def from_hash(o)
206
- @id = o["id"] if o.has_key?("id")
207
- @asms_id = o["asmd_id"] if o.has_key?("asms_id")
208
- @name = o["name"] if o.has_key?("name")
209
- @tosca_type = o["tosca_type"] if o.has_key?("tosca_type")
210
- @components = o["components"] if o.has_key?("components")
211
- @requirements = o["requirements"] if o.has_key?("requirements")
212
- @policies = o["policies"] if o.has_key?("policies")
213
- @inputs = o["inputs"] if o.has_key?("inputs")
214
- @operations = o["operations"] if o.has_key?("operations")
215
- @outputs = o["outputs"] if o.has_key?("outputs")
216
- @status = o["status"] if o.has_key?("status")
217
- @created_at = o["created_at"] if o.has_key?("created_at")
183
+ @id = o['id'] if o.key?('id')
184
+ @asms_id = o["asms_id"] if o.has_key?("asms_id")
185
+ @name = o['name'] if o.key?('name')
186
+ @components = o['components'] if o.key?('components')
187
+ @tosca_type = o['tosca_type'] if o.key?('tosca_type')
188
+ @policies = o['policies'] if o.key?('policies')
189
+ @inputs = o['inputs'] if o.key?('inputs')
190
+ @outputs = o['outputs'] if o.key?('outputs')
191
+ @status = o['status'] if o.key?('status')
192
+ @created_at = o['created_at'] if o.key?('created_at')
218
193
  self
219
194
  end
220
195
 
221
-
222
196
  def self.show(params)
223
- asm = self.new(params["email"], params["api_key"], params["host"])
224
- asm.megam_rest.get_one_assembly(params["id"])
197
+ asm = new(params['email'], params['api_key'], params['host'])
198
+ asm.megam_rest.get_one_assembly(params['id'])
225
199
  end
226
200
 
227
- def self.update(params)
228
- asm = from_hash(params, params["email"] || params[:email], params["api_key"] || params[:api_key], params["host"] || params[:host])
201
+ def self.update(params)
202
+ asm = from_hash(params, params['email'] || params[:email], params['api_key'] || params[:api_key], params['host'] || params[:host])
229
203
  asm.update
230
- end
204
+ end
231
205
 
232
206
  # Create the node via the REST API
233
207
  def update
@@ -237,6 +211,5 @@ module Megam
237
211
  def to_s
238
212
  Megam::Stuff.styled_hash(to_hash)
239
213
  end
240
-
241
214
  end
242
215
  end
@@ -16,12 +16,12 @@
16
16
 
17
17
  module Megam
18
18
  class Components < Megam::ServerAPI
19
- def initialize(email=nil, api_key=nil, host=nil)
19
+ def initialize(email = nil, api_key = nil, host = nil)
20
20
  @id = nil
21
- @name =nil
21
+ @name = nil
22
22
  @tosca_type = nil
23
23
  @inputs = []
24
- @outputs = []
24
+ @outputs = []
25
25
  @artifacts = {}
26
26
  @artifact_type = nil
27
27
  @content = nil
@@ -29,6 +29,11 @@ module Megam
29
29
  @related_components = []
30
30
  @operations = []
31
31
  @status = nil
32
+ @repo = {}
33
+ @rtype = nil
34
+ @source = nil
35
+ @oneclick = nil
36
+ @url = nil
32
37
  @created_at = nil
33
38
 
34
39
  super(email, api_key, host)
@@ -38,128 +43,169 @@ module Megam
38
43
  self
39
44
  end
40
45
 
41
- def id(arg=nil)
42
- if arg != nil
46
+ def id(arg = nil)
47
+ if !arg.nil?
43
48
  @id = arg
44
49
  else
45
- @id
50
+ @id
46
51
  end
47
52
  end
48
53
 
49
- def name(arg=nil)
50
- if arg != nil
54
+ def name(arg = nil)
55
+ if !arg.nil?
51
56
  @name = arg
52
57
  else
53
- @name
58
+ @name
54
59
  end
55
60
  end
56
61
 
57
- def tosca_type(arg=nil)
58
- if arg != nil
62
+ def tosca_type(arg = nil)
63
+ if !arg.nil?
59
64
  @tosca_type = arg
60
65
  else
61
- @tosca_type
66
+ @tosca_type
62
67
  end
63
68
  end
64
-
65
- def inputs(arg=[])
69
+
70
+ def inputs(arg = [])
66
71
  if arg != []
67
72
  @inputs = arg
68
73
  else
69
- @inputs
74
+ @inputs
70
75
  end
71
76
  end
72
-
73
- def outputs(arg=[])
77
+
78
+ def outputs(arg = [])
74
79
  if arg != []
75
80
  @outputs = arg
76
81
  else
77
- @outputs
82
+ @outputs
78
83
  end
79
84
  end
80
85
 
81
- def artifacts(arg=nil)
82
- if arg != nil
86
+ def artifacts(arg = nil)
87
+ if !arg.nil?
83
88
  @artifacts = arg
84
89
  else
85
- @artifacts
90
+ @artifacts
86
91
  end
87
92
  end
88
93
 
89
- def artifact_type(arg=nil)
90
- if arg != nil
94
+ def artifact_type(arg = nil)
95
+ if !arg.nil?
91
96
  @artifact_type = arg
92
97
  else
93
- @artifact_type
98
+ @artifact_type
94
99
  end
95
100
  end
96
101
 
97
- def content(arg=nil)
98
- if arg != nil
102
+ def content(arg = nil)
103
+ if !arg.nil?
99
104
  @content = arg
100
105
  else
101
- @content
106
+ @content
102
107
  end
103
108
  end
104
109
 
105
- def artifact_requirements(arg=[])
110
+ def artifact_requirements(arg = [])
106
111
  if arg != []
107
112
  @artifact_requirements = arg
108
113
  else
109
- @artifact_requirements
114
+ @artifact_requirements
110
115
  end
111
116
  end
112
117
 
113
- def related_components(arg=[])
118
+ def related_components(arg = [])
114
119
  if arg != []
115
120
  @related_components = arg
116
121
  else
117
- @related_components
122
+ @related_components
118
123
  end
119
124
  end
120
125
 
121
- def operations(arg=[])
126
+ def operations(arg = [])
122
127
  if arg != []
123
128
  @operations = arg
124
129
  else
125
- @operations
130
+ @operations
126
131
  end
127
132
  end
128
-
129
- def status(arg=nil)
130
- if arg != nil
133
+
134
+ def status(arg = nil)
135
+ if !arg.nil?
131
136
  @status = arg
132
137
  else
133
- @status
138
+ @status
139
+ end
140
+ end
141
+
142
+ def repo(arg = nil)
143
+ if !arg.nil?
144
+ @repo = arg
145
+ else
146
+ @repo
147
+ end
148
+ end
149
+
150
+ def rtype(arg = nil)
151
+ if !arg.nil?
152
+ @rtype = arg
153
+ else
154
+ @rtype
155
+ end
156
+ end
157
+
158
+ def source(arg = nil)
159
+ if !arg.nil?
160
+ @source = arg
161
+ else
162
+ @source
163
+ end
164
+ end
165
+
166
+ def oneclick(arg = nil)
167
+ if !arg.nil?
168
+ @oneclick = arg
169
+ else
170
+ @oneclick
134
171
  end
135
172
  end
136
173
 
137
- def created_at(arg=nil)
138
- if arg != nil
174
+ def url(arg = nil)
175
+ if !arg.nil?
176
+ @url = arg
177
+ else
178
+ @url
179
+ end
180
+ end
181
+
182
+ def created_at(arg = nil)
183
+ if !arg.nil?
139
184
  @created_at = arg
140
185
  else
141
- @created_at
186
+ @created_at
142
187
  end
143
188
  end
144
189
 
145
190
  def error?
146
- crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
191
+ crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
147
192
  end
148
193
 
149
194
  # Transform the ruby obj -> to a Hash
150
195
  def to_hash
151
- index_hash = Hash.new
152
- index_hash["json_claz"] = self.class.name
153
- index_hash["id"] = id
154
- index_hash["name"] = name
155
- index_hash["tosca_type"] = tosca_type
156
- index_hash["inputs"] = inputs
157
- index_hash["outputs"] = outputs
158
- index_hash["artifacts"] = artifacts
159
- index_hash["related_components"] = related_components
160
- index_hash["operations"] = operations
161
- index_hash["status"] = status
162
- index_hash["created_at"] = created_at
196
+ index_hash = {}
197
+ index_hash['json_claz'] = self.class.name
198
+ index_hash['id'] = id
199
+ index_hash['name'] = name
200
+ index_hash['tosca_type'] = tosca_type
201
+ index_hash['inputs'] = inputs
202
+ index_hash['outputs'] = outputs
203
+ index_hash['artifacts'] = artifacts
204
+ index_hash['related_components'] = related_components
205
+ index_hash['operations'] = operations
206
+ index_hash['status'] = status
207
+ index_hash['repo'] = repo
208
+ index_hash['created_at'] = created_at
163
209
  index_hash
164
210
  end
165
211
 
@@ -171,73 +217,81 @@ module Megam
171
217
 
172
218
  def for_json
173
219
  result = {
174
- "id" => id,
175
- "name" => name,
176
- "tosca_type" => tosca_type,
177
- "inputs" => inputs,
178
- "outputs" => outputs,
179
- "artifacts" => artifacts,
180
- "related_components" => related_components,
181
- "operations" => operations,
182
- "status" => status,
183
- "created_at" => created_at
220
+ 'id' => id,
221
+ 'name' => name,
222
+ 'tosca_type' => tosca_type,
223
+ 'inputs' => inputs,
224
+ 'outputs' => outputs,
225
+ 'artifacts' => artifacts,
226
+ 'related_components' => related_components,
227
+ 'operations' => operations,
228
+ 'status' => status,
229
+ 'repo' => repo,
230
+ 'created_at' => created_at
184
231
  }
185
232
  result
186
233
  end
187
234
 
188
235
  def self.json_create(o)
189
236
  asm = new
190
- asm.id(o["id"]) if o.has_key?("id")
191
- asm.name(o["name"]) if o.has_key?("name")
192
- asm.tosca_type(o["tosca_type"]) if o.has_key?("tosca_type")
193
- asm.inputs(o["inputs"]) if o.has_key?("inputs")
194
- asm.outputs(o["outputs"]) if o.has_key?("outputs")
195
-
196
- ar = o["artifacts"]
197
- asm.artifacts[:artifact_type] = ar["artifact_type"] if ar && ar.has_key?("artifact_type")
198
- asm.artifacts[:content] = ar["content"] if ar && ar.has_key?("content")
199
- asm.artifacts[:artifact_requirements] = ar["artifact_requirements"] if ar && ar.has_key?("artifact_requirements")
200
-
201
- asm.related_components(o["related_components"]) if o.has_key?("related_components")
202
- asm.operations(o["operations"]) if o.has_key?("operations")
203
- asm.status(o["status"]) if o.has_key?("status")
204
- asm.created_at(o["created_at"]) if o.has_key?("created_at")
237
+ asm.id(o['id']) if o.key?('id')
238
+ asm.name(o['name']) if o.key?('name')
239
+ asm.tosca_type(o['tosca_type']) if o.key?('tosca_type')
240
+ asm.inputs(o['inputs']) if o.key?('inputs')
241
+ asm.outputs(o['outputs']) if o.key?('outputs')
242
+
243
+ ar = o['artifacts']
244
+ asm.artifacts[:artifact_type] = ar['artifact_type'] if ar && ar.key?('artifact_type')
245
+ asm.artifacts[:content] = ar['content'] if ar && ar.key?('content')
246
+ asm.artifacts[:artifact_requirements] = ar['artifact_requirements'] if ar && ar.key?('artifact_requirements')
247
+
248
+ asm.related_components(o['related_components']) if o.key?('related_components')
249
+ asm.operations(o['operations']) if o.key?('operations')
250
+ asm.status(o['status']) if o.key?('status')
251
+
252
+ ro = o['repo']
253
+ asm.repo[:rtype] = ro['rtype'] if ro && ro.key?('rtype')
254
+ asm.repo[:source] = ro['source'] if ro && ro.key?('source')
255
+ asm.repo[:oneclick] = ro['oneclick'] if ro && ro.key?('oneclick')
256
+ asm.repo[:url] = ro['url'] if ro && ro.key?('url')
257
+ asm.created_at(o['created_at']) if o.key?('created_at')
205
258
  asm
206
259
  end
207
260
 
208
- def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
209
- asm = self.new(tmp_email, tmp_api_key, tmp_host)
261
+ def self.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil)
262
+ asm = new(tmp_email, tmp_api_key, tmp_host)
210
263
  asm.from_hash(o)
211
264
  asm
212
265
  end
213
266
 
214
267
  def from_hash(o)
215
- @id = o["id"] if o.has_key?("id")
216
- @name = o["name"] if o.has_key?("name")
217
- @tosca_type = o["tosca_type"] if o.has_key?("tosca_type")
218
- @inputs = o["inputs"] if o.has_key?("inputs")
219
- @outputs = o["outputs"] if o.has_key?("outputs")
220
- @artifacts = o["artifacts"] if o.has_key?("artifacts")
221
- @related_components = o["related_components"] if o.has_key?("related_components")
222
- @operations = o["operations"] if o.has_key?("operations")
223
- @status = o["status"] if o.has_key?("status")
224
- @created_at = o["created_at"] if o.has_key?("created_at")
268
+ @id = o['id'] if o.key?('id')
269
+ @name = o['name'] if o.key?('name')
270
+ @tosca_type = o['tosca_type'] if o.key?('tosca_type')
271
+ @inputs = o['inputs'] if o.key?('inputs')
272
+ @outputs = o['outputs'] if o.key?('outputs')
273
+ @artifacts = o['artifacts'] if o.key?('artifacts')
274
+ @related_components = o['related_components'] if o.key?('related_components')
275
+ @operations = o['operations'] if o.key?('operations')
276
+ @status = o['status'] if o.key?('status')
277
+ @repo = o['repo'] if o.key?('repo')
278
+ @created_at = o['created_at'] if o.key?('created_at')
225
279
  self
226
280
  end
227
281
 
228
282
  def self.create(params)
229
- asm = from_hash(params, params["email"], params["api_key"], params["host"])
283
+ asm = from_hash(params, params['email'], params['api_key'], params['host'])
230
284
  asm.create
231
285
  end
232
286
 
233
287
  # Load a account by email_p
234
288
  def self.show(params)
235
- asm = self.new(params["email"], params["api_key"], params["host"])
236
- asm.megam_rest.get_components(params["id"])
289
+ asm = new(params['email'], params['api_key'], params['host'])
290
+ asm.megam_rest.get_components(params['id'])
237
291
  end
238
292
 
239
293
  def self.update(params)
240
- asm = from_hash(params, params["email"] || params[:email], params["api_key"] || params[:api_key], params["host"] || params[:host])
294
+ asm = from_hash(params, params['email'] || params[:email], params['api_key'] || params[:api_key], params['host'] || params[:host])
241
295
  asm.update
242
296
  end
243
297
 
@@ -249,6 +303,5 @@ module Megam
249
303
  def to_s
250
304
  Megam::Stuff.styled_hash(to_hash)
251
305
  end
252
-
253
306
  end
254
- end
307
+ end