megam_api 1.6.4 → 1.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -4
- data/lib/megam/api.rb +6 -5
- data/lib/megam/api/accounts.rb +16 -5
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/account.rb +22 -12
- data/lib/megam/core/rest_adapter.rb +3 -3
- metadata +27 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e2116834f32ccc85a0f032e1aa194ddcec1ddf1
|
4
|
+
data.tar.gz: bf6d94110b3cd5381975b00474fa8b527c482dd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83a21792cf1e6f210706181ec91657d7273b406bc6621ba448e45a98180fd02690f798315e18906660cb03142dc9cb7525b0b487d4d155c7b3b66fd04f91245e
|
7
|
+
data.tar.gz: 99257e6adb30fd253b70fc56f44e0a2eec86f89dd87bf2653522d57d854d7f972afbc00328e233619340c68551619eb036fcbe51ccaf5480df812e55251e2c43
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -3,9 +3,7 @@ Ruby API for Vertice
|
|
3
3
|
|
4
4
|
[](http://badge.fury.io/rb/megam_api)
|
5
5
|
|
6
|
-
This is a Ruby SDK API for Vertice
|
7
|
-
|
8
|
-
[](https://travis-ci.org/megamsys/megam_api)
|
6
|
+
This is a Ruby SDK API for Vertice.
|
9
7
|
|
10
8
|
|
11
9
|
Usage
|
@@ -22,7 +20,7 @@ For more implementation details [see nilavu](http://github.com/megamsys/nilavu.g
|
|
22
20
|
|
23
21
|
# License
|
24
22
|
|
25
|
-
|
23
|
+
Apache V2
|
26
24
|
|
27
25
|
# Author
|
28
26
|
|
data/lib/megam/api.rb
CHANGED
@@ -134,10 +134,10 @@ module Megam
|
|
134
134
|
@options = OPTIONS.merge(options)
|
135
135
|
@api_key = @options.delete(:api_key) || ENV['MEGAM_API_KEY']
|
136
136
|
@email = @options.delete(:email)
|
137
|
-
@
|
137
|
+
@password_hash = @options.delete(:password_hash)
|
138
138
|
@org_id = @options.delete(:org_id)
|
139
139
|
unless !@options.delete(:reset_flag)
|
140
|
-
fail Megam::API::Errors::AuthKeysMissing if (@email.nil? && @api_key.nil?) || (@email.nil? && @
|
140
|
+
fail Megam::API::Errors::AuthKeysMissing if (@email.nil? && @api_key.nil?) || (@email.nil? && @password_hash.nil?)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -223,7 +223,8 @@ module Megam
|
|
223
223
|
@options[:headers] = HEADERS.merge(X_Megam_HMAC => encoded_api_header[:hmac],
|
224
224
|
X_Megam_DATE => encoded_api_header[:date], X_Megam_ORG => "#{@org_id}").merge(@options[:headers])
|
225
225
|
if (@api_key == "" || @api_key.nil?)
|
226
|
-
|
226
|
+
Megam::Log.debug("> PWH #{@password_hash}")
|
227
|
+
@options[:headers] = @options[:headers].merge(X_Megam_PUTTUSAVI => "true") unless (@password_hash == "" || @password_hash.nil?)
|
227
228
|
end
|
228
229
|
|
229
230
|
Megam::Log.debug('HTTP Request Data:')
|
@@ -258,8 +259,8 @@ module Megam
|
|
258
259
|
|
259
260
|
digest = OpenSSL::Digest.new('sha1')
|
260
261
|
movingFactor = data.rstrip!
|
261
|
-
if !(@
|
262
|
-
hash = OpenSSL::HMAC.hexdigest(digest, Base64.strict_decode64(@
|
262
|
+
if !(@password_hash.nil?) && @api_key.nil?
|
263
|
+
hash = OpenSSL::HMAC.hexdigest(digest, Base64.strict_decode64(@password_hash), movingFactor)
|
263
264
|
elsif !(@api_key.nil?)
|
264
265
|
hash = OpenSSL::HMAC.hexdigest(digest, @api_key, movingFactor)
|
265
266
|
else
|
data/lib/megam/api/accounts.rb
CHANGED
@@ -3,7 +3,6 @@ module Megam
|
|
3
3
|
# GET /accounts
|
4
4
|
#Yet to be tested
|
5
5
|
def get_accounts(email)
|
6
|
-
|
7
6
|
@options = {:path => "/accounts/#{email}",
|
8
7
|
:body => ''}.merge(@options)
|
9
8
|
|
@@ -14,6 +13,18 @@ module Megam
|
|
14
13
|
)
|
15
14
|
end
|
16
15
|
|
16
|
+
# The body content needs to be a json.
|
17
|
+
def login(new_account)
|
18
|
+
@options = {:path => '/accounts/login',
|
19
|
+
:body => Megam::JSONCompat.to_json(new_account)}.merge(@options)
|
20
|
+
|
21
|
+
request(
|
22
|
+
:expects => 302,
|
23
|
+
:method => :post,
|
24
|
+
:body => @options[:body]
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
17
28
|
# The body content needs to be a json.
|
18
29
|
def post_accounts(new_account)
|
19
30
|
@options = {:path => '/accounts/content',
|
@@ -37,8 +48,8 @@ module Megam
|
|
37
48
|
)
|
38
49
|
end
|
39
50
|
|
40
|
-
def
|
41
|
-
@options = {:path => "/accounts/
|
51
|
+
def forgot(account)
|
52
|
+
@options = {:path => "/accounts/forgot/#{account["email"]}",
|
42
53
|
:body => ''}.merge(@options)
|
43
54
|
|
44
55
|
request(
|
@@ -48,8 +59,8 @@ module Megam
|
|
48
59
|
)
|
49
60
|
end
|
50
61
|
|
51
|
-
def
|
52
|
-
@options = {:path => "/accounts/
|
62
|
+
def password_reset(account)
|
63
|
+
@options = {:path => "/accounts/password_reset",
|
53
64
|
:body => Megam::JSONCompat.to_json(account)}.merge(@options)
|
54
65
|
|
55
66
|
request(
|
data/lib/megam/api/version.rb
CHANGED
data/lib/megam/core/account.rb
CHANGED
@@ -28,8 +28,9 @@ module Megam
|
|
28
28
|
@suspend = {}
|
29
29
|
@dates = {}
|
30
30
|
@some_msg = {}
|
31
|
+
|
31
32
|
super({ email: o[:email], api_key: o[:api_key],
|
32
|
-
|
33
|
+
host: o[:host], password_hash: o[:password_hash], org_id: o[:org_id] })
|
33
34
|
end
|
34
35
|
|
35
36
|
def account
|
@@ -103,7 +104,7 @@ module Megam
|
|
103
104
|
|
104
105
|
|
105
106
|
def self.from_hash(o)
|
106
|
-
acct = new(email: o[:email], api_key: o[:api_key], host: o[:host],
|
107
|
+
acct = new(email: o[:email], api_key: o[:api_key], host: o[:host], password_hash: o[:password_hash], org_id: o[:org_id])
|
107
108
|
acct.from_hash(o)
|
108
109
|
acct
|
109
110
|
end
|
@@ -119,7 +120,7 @@ module Megam
|
|
119
120
|
@phone[:phone] = o[:phone] if o.key?(:phone)
|
120
121
|
@phone[:phone_verified] = o[:phone_verified] if o.key?(:phone_verified)
|
121
122
|
|
122
|
-
@password[:
|
123
|
+
@password[:password_hash] = o[:password_hash] if o.key?(:password_hash)
|
123
124
|
@password[:password_reset_key] = o[:password_reset_key] if o.key?(:password_reset_key)
|
124
125
|
@password[:password_reset_sent_at] = o[:password_reset_sent_at] if o.key?(:password_reset_sent_at)
|
125
126
|
|
@@ -145,6 +146,15 @@ module Megam
|
|
145
146
|
self
|
146
147
|
end
|
147
148
|
|
149
|
+
def self.login(o)
|
150
|
+
acct = from_hash(o)
|
151
|
+
acct.login
|
152
|
+
end
|
153
|
+
|
154
|
+
def login
|
155
|
+
megam_rest.login(to_hash)
|
156
|
+
end
|
157
|
+
|
148
158
|
def self.create(o)
|
149
159
|
acct = from_hash(o)
|
150
160
|
acct.create
|
@@ -155,7 +165,7 @@ module Megam
|
|
155
165
|
end
|
156
166
|
|
157
167
|
def self.show(o)
|
158
|
-
acct =
|
168
|
+
acct = from_hash(o)
|
159
169
|
acct.megam_rest.get_accounts(o[:email])
|
160
170
|
end
|
161
171
|
|
@@ -164,26 +174,26 @@ module Megam
|
|
164
174
|
acct.update
|
165
175
|
end
|
166
176
|
|
167
|
-
def self.
|
177
|
+
def self.forgot(o)
|
168
178
|
acct = from_hash(o)
|
169
|
-
acct.
|
179
|
+
acct.forgot
|
170
180
|
end
|
171
181
|
|
172
|
-
def self.
|
182
|
+
def self.password_reset(o)
|
173
183
|
acct = from_hash(o)
|
174
|
-
acct.
|
184
|
+
acct.password_reset
|
175
185
|
end
|
176
186
|
|
177
187
|
def update
|
178
188
|
megam_rest.update_accounts(to_hash)
|
179
189
|
end
|
180
190
|
|
181
|
-
def
|
182
|
-
megam_rest.
|
191
|
+
def forgot
|
192
|
+
megam_rest.forgot(to_hash)
|
183
193
|
end
|
184
194
|
|
185
|
-
def
|
186
|
-
megam_rest.
|
195
|
+
def password_reset
|
196
|
+
megam_rest.password_reset(to_hash)
|
187
197
|
end
|
188
198
|
|
189
199
|
def to_s
|
@@ -5,7 +5,7 @@ module Megam
|
|
5
5
|
attr_reader :host
|
6
6
|
# the name :password is used as attr_accessor in accounts,
|
7
7
|
# hence we use gpassword
|
8
|
-
attr_reader :
|
8
|
+
attr_reader :password_hash
|
9
9
|
attr_reader :org_id
|
10
10
|
attr_reader :headers
|
11
11
|
|
@@ -15,7 +15,7 @@ module Megam
|
|
15
15
|
@email = o[:email]
|
16
16
|
@api_key = o[:api_key] || nil
|
17
17
|
@host = o[:host]
|
18
|
-
@
|
18
|
+
@password_hash = o[:password_hash] || nil
|
19
19
|
@org_id = o[:org_id]
|
20
20
|
@headers = o[:headers]
|
21
21
|
end
|
@@ -29,7 +29,7 @@ module Megam
|
|
29
29
|
:email => email,
|
30
30
|
:api_key => api_key,
|
31
31
|
:org_id => org_id,
|
32
|
-
:
|
32
|
+
:password_hash => password_hash,
|
33
33
|
:host => host
|
34
34
|
}
|
35
35
|
if headers
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: megam_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajthilak, Kishorekumar Neelamegam, Ranjitha R, Rajesh Rajagopalan, Thomas Alrin,
|
@@ -265,4 +265,29 @@ rubygems_version: 2.5.1
|
|
265
265
|
signing_key:
|
266
266
|
specification_version: 4
|
267
267
|
summary: Ruby Client for the Megam
|
268
|
-
test_files:
|
268
|
+
test_files:
|
269
|
+
- test/mixins/test_assemblies.rb
|
270
|
+
- test/mixins/test_assembly.rb
|
271
|
+
- test/mixins/test_component.rb
|
272
|
+
- test/test_accounts.rb
|
273
|
+
- test/test_addons.rb
|
274
|
+
- test/test_assemblies.rb
|
275
|
+
- test/test_assembly.rb
|
276
|
+
- test/test_balances.rb
|
277
|
+
- test/test_billedhistories.rb
|
278
|
+
- test/test_billingtranscations.rb
|
279
|
+
- test/test_components.rb
|
280
|
+
- test/test_domains.rb
|
281
|
+
- test/test_eventsbilling.rb
|
282
|
+
- test/test_eventscontainer.rb
|
283
|
+
- test/test_eventsstorage.rb
|
284
|
+
- test/test_eventsvm.rb
|
285
|
+
- test/test_helper.rb
|
286
|
+
- test/test_marketplaces.rb
|
287
|
+
- test/test_organizations.rb
|
288
|
+
- test/test_promos.rb
|
289
|
+
- test/test_requests.rb
|
290
|
+
- test/test_sensors.rb
|
291
|
+
- test/test_snapshots.rb
|
292
|
+
- test/test_sshkeys.rb
|
293
|
+
- test/test_subscriptions.rb
|