megam_api 0.100 → 1.5.beta2
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/README.md +5 -69
- data/lib/megam/api.rb +15 -37
- data/lib/megam/api/errors.rb +19 -19
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/account.rb +1 -1
- data/lib/megam/core/assemblies.rb +1 -1
- data/lib/megam/core/assemblies_collection.rb +7 -15
- data/lib/megam/core/assembly.rb +1 -1
- data/lib/megam/core/assembly_collection.rb +7 -15
- data/lib/megam/core/balances.rb +1 -1
- data/lib/megam/core/balances_collection.rb +8 -16
- data/lib/megam/core/billedhistories.rb +1 -1
- data/lib/megam/core/billedhistories_collection.rb +7 -15
- data/lib/megam/core/components.rb +1 -1
- data/lib/megam/core/components_collection.rb +103 -110
- data/lib/megam/core/domain_collection.rb +102 -109
- data/lib/megam/core/domains.rb +1 -1
- data/lib/megam/core/error.rb +1 -15
- data/lib/megam/core/json_compat.rb +170 -208
- data/lib/megam/core/marketplace.rb +1 -1
- data/lib/megam/core/marketplace_collection.rb +7 -16
- data/lib/megam/core/organizations.rb +1 -1
- data/lib/megam/core/organizations_collection.rb +8 -40
- data/lib/megam/core/promos.rb +1 -1
- data/lib/megam/core/request.rb +1 -1
- data/lib/megam/core/request_collection.rb +7 -16
- data/lib/megam/core/rest_adapter.rb +54 -0
- data/lib/megam/core/sensors.rb +1 -1
- data/lib/megam/core/sensors_collection.rb +7 -14
- data/lib/megam/core/sshkey.rb +1 -1
- data/lib/megam/core/sshkey_collection.rb +103 -110
- data/lib/megam/core/stuff.rb +2 -34
- data/lib/megam/core/text.rb +1 -0
- data/lib/megam/core/text_formatter.rb +2 -1
- data/megam_api.gemspec +2 -2
- metadata +10 -56
- data/lib/megam/api/availableunits.rb +0 -50
- data/lib/megam/api/billings.rb +0 -50
- data/lib/megam/api/credithistories.rb +0 -50
- data/lib/megam/api/csars.rb +0 -75
- data/lib/megam/api/discounts.rb +0 -50
- data/lib/megam/api/invoices.rb +0 -50
- data/lib/megam/api/login.rb +0 -29
- data/lib/megam/api/subscriptions.rb +0 -50
- data/lib/megam/core/auth.rb +0 -91
- data/lib/megam/core/availableunits.rb +0 -182
- data/lib/megam/core/availableunits_collection.rb +0 -144
- data/lib/megam/core/billings.rb +0 -242
- data/lib/megam/core/billings_collection.rb +0 -144
- data/lib/megam/core/config.rb +0 -41
- data/lib/megam/core/credithistories.rb +0 -191
- data/lib/megam/core/credithistories_collection.rb +0 -144
- data/lib/megam/core/csar.rb +0 -179
- data/lib/megam/core/csar_collection.rb +0 -148
- data/lib/megam/core/discounts.rb +0 -204
- data/lib/megam/core/discounts_collection.rb +0 -164
- data/lib/megam/core/invoices.rb +0 -231
- data/lib/megam/core/invoices_collection.rb +0 -144
- data/lib/megam/core/server_api.rb +0 -52
- data/lib/megam/core/subscriptions.rb +0 -191
- data/lib/megam/core/subscriptions_collection.rb +0 -144
- data/test/test_availableunits.rb +0 -28
- data/test/test_billings.rb +0 -33
- data/test/test_cat_requests.rb +0 -20
- data/test/test_credithistories.rb +0 -29
- data/test/test_csars.rb +0 -22
- data/test/test_discounts.rb +0 -31
- data/test/test_invoices.rb +0 -31
- data/test/test_login.rb +0 -10
- data/test/test_marketplaceaddons.rb +0 -46
- data/test/test_predefclouds.rb +0 -80
- data/test/test_subscriptions.rb +0 -29
@@ -1,148 +0,0 @@
|
|
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 csarlicable 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 CSARCollection
|
18
|
-
include Enumerable
|
19
|
-
|
20
|
-
|
21
|
-
attr_reader :iterator
|
22
|
-
def initialize
|
23
|
-
@csars = Array.new
|
24
|
-
@csars_by_name = Hash.new
|
25
|
-
@insert_after_idx = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def all_csars
|
29
|
-
@csars
|
30
|
-
end
|
31
|
-
|
32
|
-
def [](index)
|
33
|
-
@csars[index]
|
34
|
-
end
|
35
|
-
|
36
|
-
def []=(index, arg)
|
37
|
-
is_megam_csar(arg)
|
38
|
-
@csars[index] = arg
|
39
|
-
@csars_by_name[arg.name] = index
|
40
|
-
end
|
41
|
-
|
42
|
-
def <<(*args)
|
43
|
-
args.flatten.each do |a|
|
44
|
-
is_megam_csar(a)
|
45
|
-
@csars << a
|
46
|
-
@csars_by_name[a.name] = @csars.length - 1
|
47
|
-
end
|
48
|
-
self
|
49
|
-
end
|
50
|
-
|
51
|
-
# 'push' is an alias method to <<
|
52
|
-
alias_method :push, :<<
|
53
|
-
|
54
|
-
def insert(csar)
|
55
|
-
is_megam_csar(csar)
|
56
|
-
if @insert_after_idx
|
57
|
-
# in the middle of executing a run, so any nodes inserted now should
|
58
|
-
# be placed after the most recent addition done by the currently executing
|
59
|
-
# node
|
60
|
-
@csars.insert(@insert_after_idx + 1, csar)
|
61
|
-
# update name -> location mcsarings and register new node
|
62
|
-
@csars_by_name.each_key do |key|
|
63
|
-
@csars_by_name[key] += 1 if @csars_by_name[key] > @insert_after_idx
|
64
|
-
end
|
65
|
-
@csars_by_name[csar.link] = @insert_after_idx + 1
|
66
|
-
@insert_after_idx += 1
|
67
|
-
else
|
68
|
-
@csars << csar
|
69
|
-
@csars_by_name[csar.link] = @csars.length - 1
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def each
|
74
|
-
@csars.each do |csar|
|
75
|
-
yield csar
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def each_index
|
80
|
-
@csars.each_index do |i|
|
81
|
-
yield i
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def empty?
|
86
|
-
@csars.empty?
|
87
|
-
end
|
88
|
-
|
89
|
-
def lookup(csar)
|
90
|
-
lookup_by = nil
|
91
|
-
if csar.kind_of?(Megam::CSAR)
|
92
|
-
lookup_by = csar.link
|
93
|
-
elsif csar.kind_of?(String)
|
94
|
-
lookup_by = csar
|
95
|
-
else
|
96
|
-
raise ArgumentError, "Must pass a Megam::CSAR or String to lookup"
|
97
|
-
end
|
98
|
-
res = @csars_by_name[lookup_by]
|
99
|
-
unless res
|
100
|
-
raise ArgumentError, "Cannot find a csar matching #{lookup_by} (did you define it first?)"
|
101
|
-
end
|
102
|
-
@csars[res]
|
103
|
-
end
|
104
|
-
|
105
|
-
# Transform the ruby obj -> to a Hash
|
106
|
-
def to_hash
|
107
|
-
index_hash = Hash.new
|
108
|
-
self.each do |csar|
|
109
|
-
index_hash[csar.link] = csar.to_s
|
110
|
-
end
|
111
|
-
index_hash
|
112
|
-
end
|
113
|
-
|
114
|
-
# Serialize this object as a hash: called from JsonCompat.
|
115
|
-
# Verify if this called from JsonCompat during testing.
|
116
|
-
def to_json(*a)
|
117
|
-
for_json.to_json(*a)
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
def self.json_create(o)
|
122
|
-
collection = self.new()
|
123
|
-
o["results"].each do |csars_list|
|
124
|
-
csars_array = csars_list.kind_of?(Array) ? csars_list : [ csars_list ]
|
125
|
-
csars_array.each do |csar|
|
126
|
-
collection.insert(csar)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
collection
|
130
|
-
end
|
131
|
-
|
132
|
-
private
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
def is_megam_csar(arg)
|
137
|
-
unless arg.kind_of?(Megam::CSAR)
|
138
|
-
raise ArgumentError, "Members must be Megam::CSAR's"
|
139
|
-
end
|
140
|
-
true
|
141
|
-
end
|
142
|
-
|
143
|
-
def to_s
|
144
|
-
Megam::Stuff.styled_hash(to_hash)
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
end
|
data/lib/megam/core/discounts.rb
DELETED
@@ -1,204 +0,0 @@
|
|
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 Discounts < Megam::ServerAPI
|
18
|
-
|
19
|
-
def initialize(email=nil, api_key=nil, host=nil)
|
20
|
-
@id = nil
|
21
|
-
@accounts_id = nil
|
22
|
-
@bill_type = nil
|
23
|
-
@code = nil
|
24
|
-
@status = nil
|
25
|
-
@created_at = nil
|
26
|
-
@some_msg = {}
|
27
|
-
super(email, api_key, host)
|
28
|
-
end
|
29
|
-
|
30
|
-
def cloud_tool_setting
|
31
|
-
self
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
def id(arg=nil)
|
36
|
-
if arg != nil
|
37
|
-
@id = arg
|
38
|
-
else
|
39
|
-
@id
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def accounts_id(arg=nil)
|
44
|
-
if arg != nil
|
45
|
-
@accounts_id= arg
|
46
|
-
else
|
47
|
-
@accounts_id
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def bill_type(arg=nil)
|
52
|
-
if arg != nil
|
53
|
-
@bill_type = arg
|
54
|
-
else
|
55
|
-
@bill_type
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def code(arg=nil)
|
60
|
-
if arg != nil
|
61
|
-
@code = arg
|
62
|
-
else
|
63
|
-
@code
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def status(arg=nil)
|
68
|
-
if arg != nil
|
69
|
-
@status = arg
|
70
|
-
else
|
71
|
-
@status
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def created_at(arg=nil)
|
76
|
-
if arg != nil
|
77
|
-
@created_at = arg
|
78
|
-
else
|
79
|
-
@created_at
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def some_msg(arg=nil)
|
84
|
-
if arg != nil
|
85
|
-
@some_msg = arg
|
86
|
-
else
|
87
|
-
@some_msg
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def error?
|
92
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
93
|
-
end
|
94
|
-
|
95
|
-
# Transform the ruby obj -> to a Hash
|
96
|
-
def to_hash
|
97
|
-
index_hash = Hash.new
|
98
|
-
index_hash["json_claz"] = self.class.name
|
99
|
-
index_hash["id"] = id
|
100
|
-
index_hash["accounts_id"] = accounts_id
|
101
|
-
index_hash["bill_type"] = bill_type
|
102
|
-
index_hash["code"] = code
|
103
|
-
index_hash["status"] = status
|
104
|
-
index_hash["created_at"] = created_at
|
105
|
-
index_hash["some_msg"] = some_msg
|
106
|
-
index_hash
|
107
|
-
end
|
108
|
-
|
109
|
-
# Serialize this object as a hash: called from JsonCompat.
|
110
|
-
# Verify if this called from JsonCompat during testing.
|
111
|
-
def to_json(*a)
|
112
|
-
for_json.to_json(*a)
|
113
|
-
end
|
114
|
-
|
115
|
-
def for_json
|
116
|
-
result = {
|
117
|
-
"id" => id,
|
118
|
-
"accounts_id" => accounts_id,
|
119
|
-
"bill_type" => bill_type,
|
120
|
-
"code" => code,
|
121
|
-
"status" => status,
|
122
|
-
"created_at" => created_at
|
123
|
-
}
|
124
|
-
result
|
125
|
-
end
|
126
|
-
|
127
|
-
#
|
128
|
-
def self.json_create(o)
|
129
|
-
cts = new
|
130
|
-
cts.id(o["id"]) if o.has_key?("id")
|
131
|
-
cts.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id")
|
132
|
-
cts.bill_type(o["bill_type"]) if o.has_key?("bill_type")
|
133
|
-
cts.code(o["code"]) if o.has_key?("code")
|
134
|
-
cts.status(o["status"]) if o.has_key?("status")
|
135
|
-
|
136
|
-
cts.created_at(o["created_at"]) if o.has_key?("created_at")
|
137
|
-
#success or error
|
138
|
-
cts.some_msg[:code] = o["code"] if o.has_key?("code")
|
139
|
-
cts.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
140
|
-
cts.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
141
|
-
cts.some_msg[:links] = o["links"] if o.has_key?("links")
|
142
|
-
cts
|
143
|
-
end
|
144
|
-
|
145
|
-
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
146
|
-
cts = self.new(tmp_email,tmp_api_key,tmp_host)
|
147
|
-
cts.from_hash(o)
|
148
|
-
cts
|
149
|
-
end
|
150
|
-
|
151
|
-
def from_hash(o)
|
152
|
-
@id = o[:id] if o.has_key?(:id)
|
153
|
-
@accounts_id = o[:accounts_id] if o.has_key?(:accounts_id)
|
154
|
-
@bill_type = o[:bill_type] if o.has_key?(:bill_type)
|
155
|
-
@code = o[:code] if o.has_key?(:code)
|
156
|
-
@status = o[:status] if o.has_key?(:status)
|
157
|
-
@created_at = o[:created_at] if o.has_key?(:created_at)
|
158
|
-
self
|
159
|
-
end
|
160
|
-
|
161
|
-
def self.create(params)
|
162
|
-
|
163
|
-
discount = from_hash(params, params[:email], params[:api_key], params[:host])
|
164
|
-
discount.create
|
165
|
-
end
|
166
|
-
|
167
|
-
# Create the discounts via the REST API
|
168
|
-
def create
|
169
|
-
|
170
|
-
megam_rest.post_discounts(to_hash)
|
171
|
-
end
|
172
|
-
|
173
|
-
def self.update(o)
|
174
|
-
discount = from_hash(o)
|
175
|
-
discount.update
|
176
|
-
end
|
177
|
-
|
178
|
-
# Create the node via the REST API
|
179
|
-
def update
|
180
|
-
megam_rest.update_discounts(to_hash)
|
181
|
-
end
|
182
|
-
|
183
|
-
# Load all discounts -
|
184
|
-
# returns a discountsCollection
|
185
|
-
# don't return self. check if the Megam::discountsCollection is returned.
|
186
|
-
def self.list(params)
|
187
|
-
cts = self.new(params[:email], params[:api_key], params[:host])
|
188
|
-
|
189
|
-
cts.megam_rest.get_discounts
|
190
|
-
end
|
191
|
-
|
192
|
-
# Show a particular discounts by name,
|
193
|
-
# Megam::discounts
|
194
|
-
def self.show(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
195
|
-
pre = self.new(tmp_email, tmp_api_key, tmp_host)
|
196
|
-
pre.megam_rest.get_discounts(p_name)
|
197
|
-
end
|
198
|
-
|
199
|
-
def to_s
|
200
|
-
Megam::Stuff.styled_hash(to_hash)
|
201
|
-
end
|
202
|
-
|
203
|
-
end
|
204
|
-
end
|
@@ -1,164 +0,0 @@
|
|
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 DiscountsCollection
|
18
|
-
include Enumerable
|
19
|
-
|
20
|
-
attr_reader :iterator
|
21
|
-
def initialize
|
22
|
-
@discounts = Array.new
|
23
|
-
@discounts_by_name = Hash.new
|
24
|
-
@insert_after_idx = nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def all_discounts
|
28
|
-
@discounts
|
29
|
-
end
|
30
|
-
|
31
|
-
def [](index)
|
32
|
-
@discounts[index]
|
33
|
-
end
|
34
|
-
|
35
|
-
def []=(index, arg)
|
36
|
-
is_megam_discounts(arg)
|
37
|
-
@discounts[index] = arg
|
38
|
-
@discounts_by_name[arg.code] = index
|
39
|
-
end
|
40
|
-
|
41
|
-
def <<(*args)
|
42
|
-
args.flatten.each do |a|
|
43
|
-
is_megam_discounts(a)
|
44
|
-
@discounts << a
|
45
|
-
@discounts_by_name[a.code] =@discounts.length - 1
|
46
|
-
end
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
|
-
# 'push' is an alias method to <<
|
51
|
-
alias_method :push, :<<
|
52
|
-
|
53
|
-
def insert(discounts)
|
54
|
-
is_megam_discounts(discounts)
|
55
|
-
if @insert_after_idx
|
56
|
-
# in the middle of executing a run, so any discounts inserted now should
|
57
|
-
# be placed after the most recent addition done by the currently executing
|
58
|
-
# discounts
|
59
|
-
@discounts.insert(@insert_after_idx + 1, discounts)
|
60
|
-
# update name -> location mappings and register new discounts
|
61
|
-
@discounts_by_name.each_key do |key|
|
62
|
-
@discounts_by_name[key] += 1 if@discounts_by_name[key] > @insert_after_idx
|
63
|
-
end
|
64
|
-
@discounts_by_name[discounts.code] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@discounts << discounts
|
68
|
-
@discounts_by_name[discounts.code] =@discounts.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def each
|
73
|
-
@discounts.each do |discounts|
|
74
|
-
yield discounts
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def each_index
|
79
|
-
@discounts.each_index do |i|
|
80
|
-
yield i
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def empty?
|
85
|
-
@discounts.empty?
|
86
|
-
end
|
87
|
-
|
88
|
-
def lookup(discounts)
|
89
|
-
lookup_by = nil
|
90
|
-
if discounts.kind_of?(Megam::Discounts)
|
91
|
-
lookup_by = discounts.code
|
92
|
-
elsif discounts.kind_of?(String)
|
93
|
-
lookup_by = discounts
|
94
|
-
else
|
95
|
-
raise ArgumentError, "Must pass a Megam::discounts or String to lookup"
|
96
|
-
end
|
97
|
-
res =@discounts_by_name[lookup_by]
|
98
|
-
unless res
|
99
|
-
raise ArgumentError, "Cannot find a discounts matching #{lookup_by} (did you define it first?)"
|
100
|
-
end
|
101
|
-
@discounts[res]
|
102
|
-
end
|
103
|
-
|
104
|
-
#THIS RETURNS NIL WHEN A PARTICULAR PROMO TYPE IS NOT PRESENT -
|
105
|
-
#DID NOT DISTURB THE ACTUAL LOOKUP
|
106
|
-
def lookup_p(discounts)
|
107
|
-
lookup_by = nil
|
108
|
-
if discounts.kind_of?(Megam::Discounts)
|
109
|
-
lookup_by = discounts.code
|
110
|
-
elsif discounts.kind_of?(String)
|
111
|
-
lookup_by = discounts
|
112
|
-
else
|
113
|
-
raise ArgumentError, "Must pass a Megam::discounts or String to lookup"
|
114
|
-
end
|
115
|
-
res =@discounts_by_name[lookup_by]
|
116
|
-
unless res
|
117
|
-
return nil
|
118
|
-
end
|
119
|
-
@discounts[res]
|
120
|
-
end
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
# Transform the ruby obj -> to a Hash
|
125
|
-
def to_hash
|
126
|
-
index_hash = Hash.new
|
127
|
-
self.each do |discounts|
|
128
|
-
index_hash[discounts.code] = discounts.to_s
|
129
|
-
end
|
130
|
-
index_hash
|
131
|
-
end
|
132
|
-
|
133
|
-
# Serialize this object as a hash: called from JsonCompat.
|
134
|
-
# Verify if this called from JsonCompat during testing.
|
135
|
-
def to_json(*a)
|
136
|
-
for_json.to_json(*a)
|
137
|
-
end
|
138
|
-
|
139
|
-
def self.json_create(o)
|
140
|
-
collection = self.new()
|
141
|
-
o["results"].each do |discounts_list|
|
142
|
-
discounts_array = discounts_list.kind_of?(Array) ? discounts_list : [ discounts_list ]
|
143
|
-
discounts_array.each do |discounts|
|
144
|
-
collection.insert(discounts)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
collection
|
148
|
-
end
|
149
|
-
|
150
|
-
private
|
151
|
-
|
152
|
-
def is_megam_discounts(arg)
|
153
|
-
unless arg.kind_of?(Megam::Discounts)
|
154
|
-
raise ArgumentError, "Members must be Megam::discounts"
|
155
|
-
end
|
156
|
-
true
|
157
|
-
end
|
158
|
-
|
159
|
-
def to_s
|
160
|
-
Megam::Stuff.styled_hash(to_hash)
|
161
|
-
end
|
162
|
-
|
163
|
-
end
|
164
|
-
end
|