megam_api 1.5.rc1 → 1.5.rc2
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/lib/megam/api.rb +18 -3
- data/lib/megam/api/billingtranscations.rb +40 -0
- data/lib/megam/api/eventsbilling.rb +50 -0
- data/lib/megam/api/eventscontainer.rb +50 -0
- data/lib/megam/api/{events.rb → eventsstorage.rb} +4 -5
- data/lib/megam/api/eventsvm.rb +50 -0
- data/lib/megam/api/snapshots.rb +50 -0
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/billingtranscations.rb +244 -0
- data/lib/megam/core/billingtranscations_collection.rb +136 -0
- data/lib/megam/core/{events.rb → eventsbilling.rb} +10 -18
- data/lib/megam/core/eventsbilling_collection.rb +137 -0
- data/lib/megam/core/eventscontainer.rb +190 -0
- data/lib/megam/core/eventscontainer_collection.rb +137 -0
- data/lib/megam/core/eventsstorage.rb +172 -0
- data/lib/megam/core/eventsstorage_collection.rb +137 -0
- data/lib/megam/core/eventsvm.rb +190 -0
- data/lib/megam/core/{events_collection.rb → eventsvm_collection.rb} +38 -38
- data/lib/megam/core/json_compat.rb +36 -6
- data/lib/megam/core/snapshots.rb +184 -0
- data/lib/megam/core/snapshots_collection.rb +137 -0
- data/test/test_billingtranscations.rb +33 -0
- data/test/test_eventsbilling.rb +30 -0
- data/test/test_eventscontainer.rb +30 -0
- data/test/test_eventsstorage.rb +14 -0
- data/test/test_eventsvm.rb +30 -0
- data/test/test_snapshots.rb +32 -0
- metadata +32 -7
- data/test/test_events.rb +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4cf248af16e765d6e80dc8309492cb9dec394ecd
|
|
4
|
+
data.tar.gz: 965f12bf881ad57fdcffd0922a5ab46fff964cb2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66c3fe09164ef45461a9aa86346b6f375a27e7197673f2bae9f1df3df8036cff2ae38d323e6970db7158473a70dc64908687a76072bb850121691054e69fb7df
|
|
7
|
+
data.tar.gz: c436cc03fd372bf936cda71bdc6ff97027b3ec6d5a70f88fb99dad7327fc803d03b0f0328894905597e7e084a0a688ade4306e8550d48d79d9136a87fdedb51b
|
data/lib/megam/api.rb
CHANGED
|
@@ -28,6 +28,7 @@ require 'megam/api/assemblies'
|
|
|
28
28
|
require 'megam/api/assembly'
|
|
29
29
|
require 'megam/api/balances'
|
|
30
30
|
require 'megam/api/billedhistories'
|
|
31
|
+
require 'megam/api/billingtranscations'
|
|
31
32
|
require 'megam/api/components'
|
|
32
33
|
require 'megam/api/domains'
|
|
33
34
|
require 'megam/api/errors'
|
|
@@ -37,7 +38,11 @@ require 'megam/api/promos'
|
|
|
37
38
|
require 'megam/api/requests'
|
|
38
39
|
require 'megam/api/sensors'
|
|
39
40
|
require 'megam/api/sshkeys'
|
|
40
|
-
require 'megam/api/
|
|
41
|
+
require 'megam/api/eventsvm'
|
|
42
|
+
require 'megam/api/eventscontainer'
|
|
43
|
+
require 'megam/api/eventsbilling'
|
|
44
|
+
require 'megam/api/eventsstorage'
|
|
45
|
+
require 'megam/api/snapshots'
|
|
41
46
|
require 'megam/api/version'
|
|
42
47
|
|
|
43
48
|
require 'megam/mixins/assemblies'
|
|
@@ -59,8 +64,14 @@ require 'megam/core/request'
|
|
|
59
64
|
require 'megam/core/request_collection'
|
|
60
65
|
require 'megam/core/sshkey'
|
|
61
66
|
require 'megam/core/sshkey_collection'
|
|
62
|
-
require 'megam/core/
|
|
63
|
-
require 'megam/core/
|
|
67
|
+
require 'megam/core/eventsvm'
|
|
68
|
+
require 'megam/core/eventsvm_collection'
|
|
69
|
+
require 'megam/core/eventscontainer'
|
|
70
|
+
require 'megam/core/eventscontainer_collection'
|
|
71
|
+
require 'megam/core/eventsbilling'
|
|
72
|
+
require 'megam/core/eventsbilling_collection'
|
|
73
|
+
require 'megam/core/eventsstorage'
|
|
74
|
+
require 'megam/core/eventsstorage_collection'
|
|
64
75
|
require 'megam/core/marketplace'
|
|
65
76
|
require 'megam/core/marketplace_collection'
|
|
66
77
|
require 'megam/core/organizations'
|
|
@@ -76,10 +87,14 @@ require 'megam/core/components'
|
|
|
76
87
|
require 'megam/core/components_collection'
|
|
77
88
|
require 'megam/core/sensors'
|
|
78
89
|
require 'megam/core/sensors_collection'
|
|
90
|
+
require 'megam/core/snapshots'
|
|
91
|
+
require 'megam/core/snapshots_collection'
|
|
79
92
|
require 'megam/core/balances_collection'
|
|
80
93
|
require 'megam/core/balances'
|
|
81
94
|
require 'megam/core/billedhistories_collection'
|
|
82
95
|
require 'megam/core/billedhistories'
|
|
96
|
+
require 'megam/core/billingtranscations_collection'
|
|
97
|
+
require 'megam/core/billingtranscations'
|
|
83
98
|
require 'megam/core/promos'
|
|
84
99
|
|
|
85
100
|
module Megam
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2013-2016 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
|
+
module Megam
|
|
17
|
+
class API
|
|
18
|
+
def get_billingtranscations
|
|
19
|
+
@options = {:path => '/billingtranscations',:body => ""}.merge(@options)
|
|
20
|
+
|
|
21
|
+
request(
|
|
22
|
+
:expects => 200,
|
|
23
|
+
:method => :get,
|
|
24
|
+
:body => @options[:body]
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def post_billingtranscations(new_billtranscation)
|
|
29
|
+
@options = {:path => '/billingtranscations/content',
|
|
30
|
+
:body => Megam::JSONCompat.to_json(new_billtranscation)}.merge(@options)
|
|
31
|
+
|
|
32
|
+
request(
|
|
33
|
+
:expects => 201,
|
|
34
|
+
:method => :post,
|
|
35
|
+
:body => @options[:body]
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2013-2016 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
|
+
module Megam
|
|
17
|
+
class API
|
|
18
|
+
# GET /nodes
|
|
19
|
+
def list_eventsbilling(limit)
|
|
20
|
+
@options = {:path => "/eventsbilling/#{limit}",:body => ""}.merge(@options)
|
|
21
|
+
|
|
22
|
+
request(
|
|
23
|
+
:expects => 200,
|
|
24
|
+
:method => :get,
|
|
25
|
+
:body => @options[:body]
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_eventsbilling(limit, new_events)
|
|
31
|
+
@options = {:path => "/eventsbilling/show/#{limit}",
|
|
32
|
+
:body => Megam::JSONCompat.to_json(new_events)}.merge(@options)
|
|
33
|
+
request(
|
|
34
|
+
:expects => 200,
|
|
35
|
+
:method => :post,
|
|
36
|
+
:body => @options[:body]
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def index_eventsbilling
|
|
41
|
+
@options = {:path => "/eventsbilling",:body => ""}.merge(@options)
|
|
42
|
+
|
|
43
|
+
request(
|
|
44
|
+
:expects => 200,
|
|
45
|
+
:method => :get,
|
|
46
|
+
:body => @options[:body]
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2013-2016 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
|
+
module Megam
|
|
17
|
+
class API
|
|
18
|
+
# GET /nodes
|
|
19
|
+
def list_eventscontainer(limit)
|
|
20
|
+
@options = {:path => "/eventscontainer/#{limit}",:body => ""}.merge(@options)
|
|
21
|
+
|
|
22
|
+
request(
|
|
23
|
+
:expects => 200,
|
|
24
|
+
:method => :get,
|
|
25
|
+
:body => @options[:body]
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_eventscontainer(limit, new_events)
|
|
31
|
+
@options = {:path => "/eventscontainer/show/#{limit}",
|
|
32
|
+
:body => Megam::JSONCompat.to_json(new_events)}.merge(@options)
|
|
33
|
+
request(
|
|
34
|
+
:expects => 200,
|
|
35
|
+
:method => :post,
|
|
36
|
+
:body => @options[:body]
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def index_eventscontainer
|
|
41
|
+
@options = {:path => "/eventscontainer",:body => ""}.merge(@options)
|
|
42
|
+
|
|
43
|
+
request(
|
|
44
|
+
:expects => 200,
|
|
45
|
+
:method => :get,
|
|
46
|
+
:body => @options[:body]
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
module Megam
|
|
17
17
|
class API
|
|
18
18
|
# GET /nodes
|
|
19
|
-
def
|
|
20
|
-
@options = {:path => "/
|
|
19
|
+
def list_eventsstorage(limit)
|
|
20
|
+
@options = {:path => "/eventsstorage/#{limit}",:body => ""}.merge(@options)
|
|
21
21
|
|
|
22
22
|
request(
|
|
23
23
|
:expects => 200,
|
|
@@ -26,8 +26,8 @@ module Megam
|
|
|
26
26
|
)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def
|
|
30
|
-
@options = {:path => "/
|
|
29
|
+
def index_eventsstorage
|
|
30
|
+
@options = {:path => "/eventsstorage",:body => ""}.merge(@options)
|
|
31
31
|
|
|
32
32
|
request(
|
|
33
33
|
:expects => 200,
|
|
@@ -35,6 +35,5 @@ module Megam
|
|
|
35
35
|
:body => @options[:body]
|
|
36
36
|
)
|
|
37
37
|
end
|
|
38
|
-
|
|
39
38
|
end
|
|
40
39
|
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2013-2016 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
|
+
module Megam
|
|
17
|
+
class API
|
|
18
|
+
# GET /nodes
|
|
19
|
+
def list_eventsvm(limit)
|
|
20
|
+
@options = {:path => "/eventsvm/#{limit}",:body => ""}.merge(@options)
|
|
21
|
+
|
|
22
|
+
request(
|
|
23
|
+
:expects => 200,
|
|
24
|
+
:method => :get,
|
|
25
|
+
:body => @options[:body]
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_eventsvm(limit, new_events)
|
|
31
|
+
@options = {:path => "/eventsvm/show/#{limit}",
|
|
32
|
+
:body => Megam::JSONCompat.to_json(new_events)}.merge(@options)
|
|
33
|
+
request(
|
|
34
|
+
:expects => 200,
|
|
35
|
+
:method => :post,
|
|
36
|
+
:body => @options[:body]
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def index_eventsvm
|
|
41
|
+
@options = {:path => "/eventsvm",:body => ""}.merge(@options)
|
|
42
|
+
|
|
43
|
+
request(
|
|
44
|
+
:expects => 200,
|
|
45
|
+
:method => :get,
|
|
46
|
+
:body => @options[:body]
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Copyright:: Copyright (c) 2013-2016 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
|
+
module Megam
|
|
17
|
+
class API
|
|
18
|
+
# GET /nodes
|
|
19
|
+
def list_snapshots
|
|
20
|
+
@options = {:path => "/snapshots",:body => ""}.merge(@options)
|
|
21
|
+
|
|
22
|
+
request(
|
|
23
|
+
:expects => 200,
|
|
24
|
+
:method => :get,
|
|
25
|
+
:body => @options[:body]
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def get_snapshots(asm_id)
|
|
30
|
+
@options = {:path => "/snapshots/#{asm_id}",:body => ""}.merge(@options)
|
|
31
|
+
|
|
32
|
+
request(
|
|
33
|
+
:expects => 200,
|
|
34
|
+
:method => :get,
|
|
35
|
+
:body => @options[:body]
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
def post_snapshots(new_sps)
|
|
39
|
+
@options = {:path => '/snapshots/content',
|
|
40
|
+
:body => Megam::JSONCompat.to_json(new_sps)}.merge(@options)
|
|
41
|
+
|
|
42
|
+
request(
|
|
43
|
+
:expects => 201,
|
|
44
|
+
:method => :post,
|
|
45
|
+
:body => @options[:body]
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/megam/api/version.rb
CHANGED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
##
|
|
2
|
+
## Copyright 2013-2016 Megam Systems
|
|
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
|
+
module Megam
|
|
17
|
+
class Billingtranscations < Megam::RestAdapter
|
|
18
|
+
def initialize(o)
|
|
19
|
+
@id = nil
|
|
20
|
+
@accounts_id = nil
|
|
21
|
+
@gateway = nil
|
|
22
|
+
@amountin = nil
|
|
23
|
+
@amountout = nil
|
|
24
|
+
@fees = nil
|
|
25
|
+
@tranid = nil
|
|
26
|
+
@trandate = nil
|
|
27
|
+
@currency_type = nil
|
|
28
|
+
@created_at = nil
|
|
29
|
+
@some_msg = {}
|
|
30
|
+
super(o)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def billingtranscations
|
|
34
|
+
self
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def id(arg=nil)
|
|
38
|
+
if arg != nil
|
|
39
|
+
@id = arg
|
|
40
|
+
else
|
|
41
|
+
@id
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def accounts_id(arg=nil)
|
|
46
|
+
if arg != nil
|
|
47
|
+
@accounts_id= arg
|
|
48
|
+
else
|
|
49
|
+
@accounts_id
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def gateway(arg=nil)
|
|
54
|
+
if arg != nil
|
|
55
|
+
@gateway= arg
|
|
56
|
+
else
|
|
57
|
+
@gateway
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def amountin(arg=nil)
|
|
62
|
+
if arg != nil
|
|
63
|
+
@amountin= arg
|
|
64
|
+
else
|
|
65
|
+
@amountin
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def amountout(arg=nil)
|
|
70
|
+
if arg != nil
|
|
71
|
+
@amountout= arg
|
|
72
|
+
else
|
|
73
|
+
@amountout
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def fees(arg=nil)
|
|
78
|
+
if arg != nil
|
|
79
|
+
@fees = arg
|
|
80
|
+
else
|
|
81
|
+
@fees
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def tranid(arg=nil)
|
|
86
|
+
if arg != nil
|
|
87
|
+
@tranid = arg
|
|
88
|
+
else
|
|
89
|
+
@tranid
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def trandate(arg=nil)
|
|
94
|
+
if arg != nil
|
|
95
|
+
@trandate = arg
|
|
96
|
+
else
|
|
97
|
+
@trandate
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def currency_type(arg=nil)
|
|
102
|
+
if arg != nil
|
|
103
|
+
@currency_type = arg
|
|
104
|
+
else
|
|
105
|
+
@currency_type
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def created_at(arg=nil)
|
|
110
|
+
if arg != nil
|
|
111
|
+
@created_at = arg
|
|
112
|
+
else
|
|
113
|
+
@created_at
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def some_msg(arg=nil)
|
|
118
|
+
if arg != nil
|
|
119
|
+
@some_msg = arg
|
|
120
|
+
else
|
|
121
|
+
@some_msg
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def error?
|
|
126
|
+
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Transform the ruby obj -> to a Hash
|
|
130
|
+
def to_hash
|
|
131
|
+
index_hash = Hash.new
|
|
132
|
+
index_hash["json_claz"] = self.class.name
|
|
133
|
+
index_hash["id"] = id
|
|
134
|
+
index_hash["accounts_id"] = accounts_id
|
|
135
|
+
index_hash["gateway"] = gateway
|
|
136
|
+
index_hash["amountin"] = amountin
|
|
137
|
+
index_hash["amountout"] = amountout
|
|
138
|
+
index_hash["fees"] = fees
|
|
139
|
+
index_hash["tranid"] = tranid
|
|
140
|
+
index_hash["trandate"] = trandate
|
|
141
|
+
index_hash["currency_type"] = currency_type
|
|
142
|
+
index_hash["created_at"] = created_at
|
|
143
|
+
index_hash
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Serialize this object as a hash: called from JsonCompat.
|
|
147
|
+
# Verify if this called from JsonCompat during testing.
|
|
148
|
+
def to_json(*a)
|
|
149
|
+
for_json.to_json(*a)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def for_json
|
|
153
|
+
result = {
|
|
154
|
+
"id" => id,
|
|
155
|
+
"accounts_id" => accounts_id,
|
|
156
|
+
"gateway" => gateway,
|
|
157
|
+
"amountin" => amountin,
|
|
158
|
+
"amountout" => amountout,
|
|
159
|
+
"fees" => fees,
|
|
160
|
+
"tranid" => tranid,
|
|
161
|
+
"trandate" => trandate,
|
|
162
|
+
"currency_type" => currency_type,
|
|
163
|
+
"created_at" => created_at
|
|
164
|
+
}
|
|
165
|
+
result
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
#
|
|
169
|
+
def self.json_create(o)
|
|
170
|
+
bal = new({})
|
|
171
|
+
bal.id(o["id"]) if o.has_key?("id")
|
|
172
|
+
bal.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id")
|
|
173
|
+
bal.gateway(o["gateway"]) if o.has_key?("gateway")
|
|
174
|
+
bal.amountin(o["amountin"]) if o.has_key?("amountin")
|
|
175
|
+
bal.amountout(o["amountout"]) if o.has_key?("amountout")
|
|
176
|
+
bal.fees(o["fees"]) if o.has_key?("fees")
|
|
177
|
+
bal.tranid(o["tranid"]) if o.has_key?("tranid")
|
|
178
|
+
bal.trandate(o["trandate"]) if o.has_key?("trandate")
|
|
179
|
+
bal.currency_type(o["currency_type"]) if o.has_key?("currency_type")
|
|
180
|
+
bal.created_at(o["created_at"]) if o.has_key?("created_at")
|
|
181
|
+
#success or error
|
|
182
|
+
bal.some_msg[:code] = o["code"] if o.has_key?("code")
|
|
183
|
+
bal.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
|
184
|
+
bal.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
|
185
|
+
bal.some_msg[:links] = o["links"] if o.has_key?("links")
|
|
186
|
+
bal
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
|
190
|
+
bal = self.new(tmp_email, tmp_api_key, tmp_host)
|
|
191
|
+
bal.from_hash(o)
|
|
192
|
+
bal
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def from_hash(o)
|
|
196
|
+
@id = o[:id] if o.has_key?(:id)
|
|
197
|
+
@accounts_id = o[:accounts_id] if o.has_key?(:accounts_id)
|
|
198
|
+
@gateway = o[:gateway] if o.has_key?(:gateway)
|
|
199
|
+
@amountin = o[:amountin] if o.has_key?(:amountin)
|
|
200
|
+
@amountout = o[:amountout] if o.has_key?(:amountout)
|
|
201
|
+
@fees = o[:fees] if o.has_key?(:fees)
|
|
202
|
+
@tranid = o[:tranid] if o.has_key?(:tranid)
|
|
203
|
+
@trandate = o[:trandate] if o.has_key?(:trandate)
|
|
204
|
+
@currency_type = o[:currency_type] if o.has_key?(:currency_type)
|
|
205
|
+
@created_at = o[:created_at] if o.has_key?(:created_at)
|
|
206
|
+
self
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def self.create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
|
210
|
+
acct = from_hash(o,tmp_email, tmp_api_key, tmp_host)
|
|
211
|
+
acct.create
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Create the billing transcations via the REST API
|
|
215
|
+
def create
|
|
216
|
+
megam_rest.post_billedhistories(to_hash)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Load all billing transcations -
|
|
220
|
+
# returns a BillingTranscationsCollection
|
|
221
|
+
# don't return self. check if the Megam::BillingTranscationsCollection is returned.
|
|
222
|
+
def self.list(params)
|
|
223
|
+
billtranscations = self.new(params["email"], params["api_key"], params["host"])
|
|
224
|
+
billtranscations.megam_rest.get_billingtranscations
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# Show a particular billing history by name,
|
|
228
|
+
# Megam::BillingHistory
|
|
229
|
+
def self.show(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
|
230
|
+
pre = self.new(tmp_email,tmp_api_key, tmp_host)
|
|
231
|
+
pre.megam_rest.get_billtranscation(p_name)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def self.delete(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
|
235
|
+
pre = self.new(tmp_email,tmp_api_key, tmp_host)
|
|
236
|
+
pre.megam_rest.delete_billtranscation(p_name)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def to_s
|
|
240
|
+
Megam::Stuff.styled_hash(to_hash)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
end
|
|
244
|
+
end
|