megam_api 1.5.rc2 → 1.5.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/megam/api.rb +3 -3
- data/lib/megam/api/{billingtranscations.rb → billingtransactions.rb} +5 -5
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/billingtransactions.rb +229 -0
- data/lib/megam/core/billingtransactions_collection.rb +137 -0
- data/lib/megam/core/json_compat.rb +59 -59
- data/test/test_billingtranscations.rb +4 -10
- metadata +5 -5
- data/lib/megam/core/billingtranscations.rb +0 -244
- data/lib/megam/core/billingtranscations_collection.rb +0 -136
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84355616466a199bfaa204d9541505476917eec9
|
4
|
+
data.tar.gz: c76351b0c22edb2082520b5a3cbb5530d8e7a56d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a748368c58ee56525c34d68e09800227a60f1ca765c8ad387aa4a0557010a94957f276e8be87a2b80ed4a455a5fd3525b1176d9f1354ee56860445bc0432b87
|
7
|
+
data.tar.gz: 933493abb83af5fc57177923a5a3bb86b05fc89a1468ec393c93d52d7bf46867b1bc303c8d5162ef4b8d1a0e0aada861977b517960a92ef4fcfd7786eee16af0
|
data/lib/megam/api.rb
CHANGED
@@ -28,7 +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/
|
31
|
+
require 'megam/api/billingtransactions'
|
32
32
|
require 'megam/api/components'
|
33
33
|
require 'megam/api/domains'
|
34
34
|
require 'megam/api/errors'
|
@@ -93,8 +93,8 @@ require 'megam/core/balances_collection'
|
|
93
93
|
require 'megam/core/balances'
|
94
94
|
require 'megam/core/billedhistories_collection'
|
95
95
|
require 'megam/core/billedhistories'
|
96
|
-
require 'megam/core/
|
97
|
-
require 'megam/core/
|
96
|
+
require 'megam/core/billingtransactions_collection'
|
97
|
+
require 'megam/core/billingtransactions'
|
98
98
|
require 'megam/core/promos'
|
99
99
|
|
100
100
|
module Megam
|
@@ -15,8 +15,8 @@
|
|
15
15
|
#
|
16
16
|
module Megam
|
17
17
|
class API
|
18
|
-
def
|
19
|
-
@options = {:path => '/
|
18
|
+
def get_billingtransactions
|
19
|
+
@options = {:path => '/billingtransactions',:body => ""}.merge(@options)
|
20
20
|
|
21
21
|
request(
|
22
22
|
:expects => 200,
|
@@ -25,9 +25,9 @@ module Megam
|
|
25
25
|
)
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
@options = {:path => '/
|
30
|
-
:body => Megam::JSONCompat.to_json(
|
28
|
+
def post_billingtransactions(new_billtransaction)
|
29
|
+
@options = {:path => '/billingtransactions/content',
|
30
|
+
:body => Megam::JSONCompat.to_json(new_billtransaction)}.merge(@options)
|
31
31
|
|
32
32
|
request(
|
33
33
|
:expects => 201,
|
data/lib/megam/api/version.rb
CHANGED
@@ -0,0 +1,229 @@
|
|
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 Billingtransactions < 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
|
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)
|
190
|
+
bal = self.new(o)
|
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(params)
|
210
|
+
acct = from_hash(params)
|
211
|
+
acct.create
|
212
|
+
end
|
213
|
+
|
214
|
+
def create
|
215
|
+
megam_rest.post_billedhistories(to_hash)
|
216
|
+
end
|
217
|
+
|
218
|
+
def self.list(params)
|
219
|
+
bill = self.new(params)
|
220
|
+
bill.megam_rest.get_billingtransactions
|
221
|
+
end
|
222
|
+
|
223
|
+
|
224
|
+
def to_s
|
225
|
+
Megam::Stuff.styled_hash(to_hash)
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
229
|
+
end
|
@@ -0,0 +1,137 @@
|
|
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 BillingtransactionsCollection
|
18
|
+
include Enumerable
|
19
|
+
|
20
|
+
attr_reader :iterator
|
21
|
+
def initialize
|
22
|
+
@billingtransactions = Array.new
|
23
|
+
@billingtransactions_by_name = Hash.new
|
24
|
+
@insert_after_idx = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def all_billingtransactions
|
28
|
+
@billingtransactions
|
29
|
+
end
|
30
|
+
|
31
|
+
def [](index)
|
32
|
+
@billingtransactions[index]
|
33
|
+
end
|
34
|
+
|
35
|
+
def []=(index, arg)
|
36
|
+
is_megam_billingtransactions(arg)
|
37
|
+
@@billingtransactions[index] = arg
|
38
|
+
@billingtransactions_by_name[arg.accounts_id] = index
|
39
|
+
end
|
40
|
+
|
41
|
+
def <<(*args)
|
42
|
+
args.flatten.each do |a|
|
43
|
+
is_megam_billingtransactions(a)
|
44
|
+
@billingtransactions << a
|
45
|
+
@billingtransactions_by_name[a.accounts_id] =@billingtransactions.length - 1
|
46
|
+
end
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
# 'push' is an alias method to <<
|
51
|
+
alias_method :push, :<<
|
52
|
+
|
53
|
+
def insert(billingtransactions)
|
54
|
+
is_megam_billingtransactions(billingtransactions)
|
55
|
+
if @insert_after_idx
|
56
|
+
# in the middle of executing a run, so any predefs inserted now should
|
57
|
+
# be placed after the most recent addition done by the currently executing
|
58
|
+
#
|
59
|
+
@billingtransactions.insert(@insert_after_idx + 1,billingtransactions)
|
60
|
+
# update name -> location mappings and register new
|
61
|
+
@billingtransactions_by_name.each_key do |key|
|
62
|
+
@billingtransactions_by_name[key] += 1 if@billingtransactions_by_name[key] > @insert_after_idx
|
63
|
+
end
|
64
|
+
@billingtransactions_by_name[billingtransactions.accounts_id] = @insert_after_idx + 1
|
65
|
+
@insert_after_idx += 1
|
66
|
+
else
|
67
|
+
@billingtransactions << billingtransactions
|
68
|
+
@billingtransactions_by_name[billingtransactions.accounts_id] =@billingtransactions.length - 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def each
|
73
|
+
@billingtransactions.each do |billingtransactions|
|
74
|
+
yield billingtransactions
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def each_index
|
79
|
+
@billingtransactions.each_index do |i|
|
80
|
+
yield i
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def empty?
|
85
|
+
@billingtransactions.empty?
|
86
|
+
end
|
87
|
+
|
88
|
+
def lookup(billingtransactions)
|
89
|
+
lookup_by = nil
|
90
|
+
if billingtransactions.kind_of?(Megam::Billingtransactions)
|
91
|
+
lookup_by = billingtransactions.accounts_id
|
92
|
+
elsif billingtransactions.kind_of?(String)
|
93
|
+
lookup_by = billingtransactions
|
94
|
+
else
|
95
|
+
raise ArgumentError, "Must pass a Megam::Billingtransactions or String to lookup"
|
96
|
+
end
|
97
|
+
res =@billingtransactions_by_name[lookup_by]
|
98
|
+
unless res
|
99
|
+
raise ArgumentError, "Cannot find a matching #{lookup_by} (did you define it first?)"
|
100
|
+
end
|
101
|
+
@billingtransactions[res]
|
102
|
+
end
|
103
|
+
|
104
|
+
def to_s
|
105
|
+
@billingtransactions.join(", ")
|
106
|
+
end
|
107
|
+
|
108
|
+
def for_json
|
109
|
+
to_a.map { |item| item.to_s }
|
110
|
+
end
|
111
|
+
|
112
|
+
def to_json(*a)
|
113
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.json_create(o)
|
117
|
+
collection = self.new()
|
118
|
+
o["results"].each do |billingtransactions_list|
|
119
|
+
billingtransactions_array = billingtransactions_list.kind_of?(Array) ? billingtransactions_list : [ billingtransactions_list ]
|
120
|
+
billingtransactions_array.each do |billingtransactions|
|
121
|
+
collection.insert(billingtransactions)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
collection
|
125
|
+
end
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
def is_megam_billingtransactions(arg)
|
130
|
+
unless arg.kind_of?(Megam::Billingtransactions)
|
131
|
+
raise ArgumentError, "Members must be Megam::Billingtransactions's"
|
132
|
+
end
|
133
|
+
true
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
@@ -24,43 +24,43 @@ module Megam
|
|
24
24
|
|
25
25
|
JSON_CLAZ = 'json_claz'.freeze
|
26
26
|
|
27
|
-
MEGAM_ACCOUNT
|
28
|
-
MEGAM_ASSEMBLIES
|
29
|
-
MEGAM_ASSEMBLIESCOLLECTION
|
30
|
-
MEGAM_ASSEMBLY
|
31
|
-
MEGAM_ASSEMBLYCOLLECTION
|
32
|
-
MEGAM_BALANCES
|
33
|
-
MEGAM_BALANCESCOLLECTION
|
34
|
-
MEGAM_BILLEDHISTORIES
|
35
|
-
MEGAM_BILLEDHISTORIESCOLLECTION
|
36
|
-
|
37
|
-
|
38
|
-
MEGAM_COMPONENTS
|
39
|
-
MEGAM_COMPONENTSCOLLECTION
|
40
|
-
MEGAM_DOMAIN
|
41
|
-
MEGAM_DOMAINCOLLECTION
|
42
|
-
MEGAM_ERROR
|
43
|
-
MEGAM_MARKETPLACE
|
44
|
-
MEGAM_MARKETPLACECOLLECTION
|
45
|
-
MEGAM_ORGANIZATION
|
46
|
-
MEGAM_ORGANIZATIONSCOLLECTION
|
47
|
-
MEGAM_REQUEST
|
48
|
-
MEGAM_REQUESTCOLLECTION
|
49
|
-
MEGAM_SENSORS
|
50
|
-
MEGAM_SENSORSCOLLECTION
|
51
|
-
MEGAM_SNAPSHOTS
|
52
|
-
MEGAM_SNAPSHOTSCOLLECTION
|
53
|
-
MEGAM_SSHKEY
|
54
|
-
MEGAM_SSHKEYCOLLECTION
|
55
|
-
MEGAM_EVENTSVM
|
56
|
-
MEGAM_EVENTSVMCOLLECTION
|
57
|
-
MEGAM_EVENTSCONTAINER
|
58
|
-
MEGAM_EVENTSCONTAINERCOLLECTION
|
59
|
-
MEGAM_EVENTSBILLING
|
60
|
-
MEGAM_EVENTSBILLINGCOLLECTION
|
61
|
-
MEGAM_EVENTSSTORAGE
|
62
|
-
MEGAM_EVENTSSTORAGECOLLECTION
|
63
|
-
MEGAM_PROMOS
|
27
|
+
MEGAM_ACCOUNT = 'Megam::Account'.freeze
|
28
|
+
MEGAM_ASSEMBLIES = 'Megam::Assemblies'.freeze
|
29
|
+
MEGAM_ASSEMBLIESCOLLECTION = 'Megam::AssembliesCollection'.freeze
|
30
|
+
MEGAM_ASSEMBLY = 'Megam::Assembly'.freeze
|
31
|
+
MEGAM_ASSEMBLYCOLLECTION = 'Megam::AssemblyCollection'.freeze
|
32
|
+
MEGAM_BALANCES = 'Megam::Balances'.freeze
|
33
|
+
MEGAM_BALANCESCOLLECTION = 'Megam::BalancesCollection'.freeze
|
34
|
+
MEGAM_BILLEDHISTORIES = 'Megam::Billedhistories'.freeze
|
35
|
+
MEGAM_BILLEDHISTORIESCOLLECTION = 'Megam::BilledhistoriesCollection'.freeze
|
36
|
+
MEGAM_BILLINGTRANSACTIONS = 'Megam::Billingtransactions'.freeze
|
37
|
+
MEGAM_BILLINGTRANSACTIONSCOLLECTION = 'Megam::BillingtransactionsCollection'.freeze
|
38
|
+
MEGAM_COMPONENTS = 'Megam::Components'.freeze
|
39
|
+
MEGAM_COMPONENTSCOLLECTION = 'Megam::ComponentsCollection'.freeze
|
40
|
+
MEGAM_DOMAIN = 'Megam::Domains'.freeze
|
41
|
+
MEGAM_DOMAINCOLLECTION = 'Megam::DomainsCollection'.freeze
|
42
|
+
MEGAM_ERROR = 'Megam::Error'.freeze
|
43
|
+
MEGAM_MARKETPLACE = 'Megam::MarketPlace'.freeze
|
44
|
+
MEGAM_MARKETPLACECOLLECTION = 'Megam::MarketPlaceCollection'.freeze
|
45
|
+
MEGAM_ORGANIZATION = 'Megam::Organizations'.freeze
|
46
|
+
MEGAM_ORGANIZATIONSCOLLECTION = 'Megam::OrganizationsCollection'.freeze
|
47
|
+
MEGAM_REQUEST = 'Megam::Request'.freeze
|
48
|
+
MEGAM_REQUESTCOLLECTION = 'Megam::RequestCollection'.freeze
|
49
|
+
MEGAM_SENSORS = 'Megam::Sensors'.freeze
|
50
|
+
MEGAM_SENSORSCOLLECTION = 'Megam::SensorsCollection'.freeze
|
51
|
+
MEGAM_SNAPSHOTS = 'Megam::Snapshots'.freeze
|
52
|
+
MEGAM_SNAPSHOTSCOLLECTION = 'Megam::SnapshotsCollection'.freeze
|
53
|
+
MEGAM_SSHKEY = 'Megam::SshKey'.freeze
|
54
|
+
MEGAM_SSHKEYCOLLECTION = 'Megam::SshKeyCollection'.freeze
|
55
|
+
MEGAM_EVENTSVM = 'Megam::EventsVm'.freeze
|
56
|
+
MEGAM_EVENTSVMCOLLECTION = 'Megam::EventsVmCollection'.freeze
|
57
|
+
MEGAM_EVENTSCONTAINER = 'Megam::EventsContainer'.freeze
|
58
|
+
MEGAM_EVENTSCONTAINERCOLLECTION = 'Megam::EventsContainerCollection'.freeze
|
59
|
+
MEGAM_EVENTSBILLING = 'Megam::EventsBilling'.freeze
|
60
|
+
MEGAM_EVENTSBILLINGCOLLECTION = 'Megam::EventsBillingCollection'.freeze
|
61
|
+
MEGAM_EVENTSSTORAGE = 'Megam::EventsStorage'.freeze
|
62
|
+
MEGAM_EVENTSSTORAGECOLLECTION = 'Megam::EventsStorageCollection'.freeze
|
63
|
+
MEGAM_PROMOS = 'Megam::Promos'.freeze
|
64
64
|
|
65
65
|
class <<self
|
66
66
|
# API to use to avoid create_addtions
|
@@ -167,22 +167,22 @@ module Megam
|
|
167
167
|
Megam::SshKey
|
168
168
|
when MEGAM_SSHKEYCOLLECTION
|
169
169
|
Megam::SshKeyCollection
|
170
|
-
|
171
|
-
|
170
|
+
when MEGAM_EVENTSVM
|
171
|
+
Megam::EventsVm
|
172
172
|
when MEGAM_EVENTSVMCOLLECTION
|
173
|
-
|
174
|
-
|
175
|
-
|
173
|
+
Megam::EventsVmCollection
|
174
|
+
when MEGAM_EVENTSCONTAINER
|
175
|
+
Megam::EventsContainer
|
176
176
|
when MEGAM_EVENTSCONTAINERCOLLECTION
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
177
|
+
Megam::EventsContainerCollection
|
178
|
+
when MEGAM_EVENTSBILLING
|
179
|
+
Megam::EventsBilling
|
180
|
+
when MEGAM_EVENTSBILLINGCOLLECTION
|
181
|
+
Megam::EventsBillingCollection
|
182
|
+
when MEGAM_EVENTSSTORAGE
|
183
|
+
Megam::EventsStorage
|
184
|
+
when MEGAM_EVENTSSTORAGECOLLECTION
|
185
|
+
Megam::EventsStorageCollection
|
186
186
|
when MEGAM_MARKETPLACE
|
187
187
|
Megam::MarketPlace
|
188
188
|
when MEGAM_MARKETPLACECOLLECTION
|
@@ -199,10 +199,10 @@ module Megam
|
|
199
199
|
Megam::Sensors
|
200
200
|
when MEGAM_SENSORSCOLLECTION
|
201
201
|
Megam::SensorsCollection
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
202
|
+
when MEGAM_SNAPSHOTS
|
203
|
+
Megam::Snapshots
|
204
|
+
when MEGAM_SNAPSHOTSCOLLECTION
|
205
|
+
Megam::SnapshotsCollection
|
206
206
|
when MEGAM_BALANCES
|
207
207
|
Megam::Balances
|
208
208
|
when MEGAM_BALANCESCOLLECTION
|
@@ -211,10 +211,10 @@ module Megam
|
|
211
211
|
Megam::Billedhistories
|
212
212
|
when MEGAM_BILLEDHISTORIESCOLLECTION
|
213
213
|
Megam::BilledhistoriesCollection
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
214
|
+
when MEGAM_BILLINGTRANSACTIONS
|
215
|
+
Megam::Billingtransactions
|
216
|
+
when MEGAM_BILLINGTRANSACTIONSCOLLECTION
|
217
|
+
Megam::BillingtransactionsCollection
|
218
218
|
when MEGAM_PROMOS
|
219
219
|
Megam::Promos
|
220
220
|
else
|
@@ -2,7 +2,7 @@ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
|
|
2
2
|
|
3
3
|
class TestApps < MiniTest::Unit::TestCase
|
4
4
|
#=begin
|
5
|
-
def
|
5
|
+
def test_post_billingtransactions
|
6
6
|
tmp_hash = { :accounts_id => "5555555",
|
7
7
|
:gateway => "paypal",
|
8
8
|
:amountin => "5",
|
@@ -13,21 +13,15 @@ class TestApps < MiniTest::Unit::TestCase
|
|
13
13
|
:currency_type => "USD"
|
14
14
|
}
|
15
15
|
|
16
|
-
response = megams.
|
16
|
+
response = megams.post_billingtransactions(tmp_hash)
|
17
17
|
assert_equal(201, response.status)
|
18
18
|
end
|
19
19
|
#=end
|
20
20
|
|
21
21
|
#=begin
|
22
|
-
def
|
23
|
-
response = megams.
|
22
|
+
def test_get_billingtransactions
|
23
|
+
response = megams.get_billingtransactions
|
24
24
|
assert_equal(200, response.status)
|
25
25
|
end
|
26
26
|
#=end
|
27
|
-
=begin
|
28
|
-
def test_get_billingtranscations
|
29
|
-
response = megams.get_billingtranscations("iaas_default")
|
30
|
-
assert_equal(200, response.status)
|
31
|
-
end
|
32
|
-
=end
|
33
27
|
end
|
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.5.
|
4
|
+
version: 1.5.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajthilak, Kishorekumar Neelamegam, Thomas Alrin, Yeshwanth Kumar, Subash Sethurajan,
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-06-
|
12
|
+
date: 2016-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: excon
|
@@ -138,7 +138,7 @@ files:
|
|
138
138
|
- lib/megam/api/assembly.rb
|
139
139
|
- lib/megam/api/balances.rb
|
140
140
|
- lib/megam/api/billedhistories.rb
|
141
|
-
- lib/megam/api/
|
141
|
+
- lib/megam/api/billingtransactions.rb
|
142
142
|
- lib/megam/api/components.rb
|
143
143
|
- lib/megam/api/domains.rb
|
144
144
|
- lib/megam/api/errors.rb
|
@@ -163,8 +163,8 @@ files:
|
|
163
163
|
- lib/megam/core/balances_collection.rb
|
164
164
|
- lib/megam/core/billedhistories.rb
|
165
165
|
- lib/megam/core/billedhistories_collection.rb
|
166
|
-
- lib/megam/core/
|
167
|
-
- lib/megam/core/
|
166
|
+
- lib/megam/core/billingtransactions.rb
|
167
|
+
- lib/megam/core/billingtransactions_collection.rb
|
168
168
|
- lib/megam/core/components.rb
|
169
169
|
- lib/megam/core/components_collection.rb
|
170
170
|
- lib/megam/core/domain_collection.rb
|
@@ -1,244 +0,0 @@
|
|
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
|
@@ -1,136 +0,0 @@
|
|
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 BillingtranscationsCollection
|
18
|
-
include Enumerable
|
19
|
-
|
20
|
-
attr_reader :iterator
|
21
|
-
def initialize
|
22
|
-
@billingtranscations = Array.new
|
23
|
-
@billingtranscations_by_name = Hash.new
|
24
|
-
@insert_after_idx = nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def all_billingtranscations
|
28
|
-
@billingtranscations
|
29
|
-
end
|
30
|
-
|
31
|
-
def [](index)
|
32
|
-
@billingtranscations[index]
|
33
|
-
end
|
34
|
-
|
35
|
-
def []=(index, arg)
|
36
|
-
is_megam_billingtranscations(arg)
|
37
|
-
@billingtranscations[index] = arg
|
38
|
-
@billingtranscations_by_name[arg.accounts_id] = index
|
39
|
-
end
|
40
|
-
|
41
|
-
def <<(*args)
|
42
|
-
args.flatten.each do |a|
|
43
|
-
is_megam_billingtranscations(a)
|
44
|
-
@billingtranscations << a
|
45
|
-
@billingtranscations_by_name[a.accounts_id] =@billingtranscations.length - 1
|
46
|
-
end
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
|
-
# 'push' is an alias method to <<
|
51
|
-
alias_method :push, :<<
|
52
|
-
|
53
|
-
def insert(billingtranscations)
|
54
|
-
is_megam_billingtranscations(billingtranscations)
|
55
|
-
if @insert_after_idx
|
56
|
-
# in the middle of executing a run, so any predefs inserted now should
|
57
|
-
# be placed after the most recent addition done by the currently executing
|
58
|
-
# billingtranscations
|
59
|
-
@billingtranscations.insert(@insert_after_idx + 1, billingtranscations)
|
60
|
-
# update name -> location mappings and register new billingtranscations
|
61
|
-
@billingtranscations_by_name.each_key do |key|
|
62
|
-
@billingtranscations_by_name[key] += 1 if@billingtranscations_by_name[key] > @insert_after_idx
|
63
|
-
end
|
64
|
-
@billingtranscations_by_name[billingtranscations.accounts_id] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@billingtranscations << billingtranscations
|
68
|
-
@billingtranscations_by_name[billingtranscations.accounts_id] =@billingtranscations.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def each
|
73
|
-
@billingtranscations.each do |billingtranscations|
|
74
|
-
yield billingtranscations
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def each_index
|
79
|
-
@billingtranscations.each_index do |i|
|
80
|
-
yield i
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def empty?
|
85
|
-
@billingtranscations.empty?
|
86
|
-
end
|
87
|
-
|
88
|
-
def lookup(billingtranscations)
|
89
|
-
lookup_by = nil
|
90
|
-
if billingtranscations.kind_of?(Megam::billingtranscations)
|
91
|
-
lookup_by = billingtranscations.accounts_id
|
92
|
-
elsif billingtranscations.kind_of?(String)
|
93
|
-
lookup_by = billingtranscations
|
94
|
-
else
|
95
|
-
raise ArgumentError, "Must pass a Megam::billingtranscations or String to lookup"
|
96
|
-
end
|
97
|
-
res =@billingtranscations_by_name[lookup_by]
|
98
|
-
unless res
|
99
|
-
raise ArgumentError, "Cannot find a billingtranscations matching #{lookup_by} (did you define it first?)"
|
100
|
-
end
|
101
|
-
@billingtranscations[res]
|
102
|
-
end
|
103
|
-
|
104
|
-
def to_s
|
105
|
-
@billingtranscations.join(", ")
|
106
|
-
end
|
107
|
-
|
108
|
-
def for_json
|
109
|
-
to_a.map { |item| item.to_s }
|
110
|
-
end
|
111
|
-
|
112
|
-
def to_json(*a)
|
113
|
-
Megam::JSONCompat.to_json(for_json, *a)
|
114
|
-
end
|
115
|
-
|
116
|
-
def self.json_create(o)
|
117
|
-
collection = self.new()
|
118
|
-
o["results"].each do |billingtranscations_list|
|
119
|
-
billingtranscations_array = billingtranscations_list.kind_of?(Array) ? billingtranscations_list : [ billingtranscations_list ]
|
120
|
-
billingtranscations_array.each do |billingtranscations|
|
121
|
-
collection.insert(billingtranscations)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
collection
|
125
|
-
end
|
126
|
-
|
127
|
-
private
|
128
|
-
|
129
|
-
def is_megam_billingtranscations(arg)
|
130
|
-
unless arg.kind_of?(Megam::Billingtranscations)
|
131
|
-
raise ArgumentError, "Members must be Megam::billingtranscations's"
|
132
|
-
end
|
133
|
-
true
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|