megam_api 1.5.rc5 → 1.5.rc7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/LICENSE +21 -202
  4. data/README.md +3 -20
  5. data/lib/megam/api.rb +154 -169
  6. data/lib/megam/api/accounts.rb +0 -15
  7. data/lib/megam/api/assemblies.rb +0 -15
  8. data/lib/megam/api/assembly.rb +0 -15
  9. data/lib/megam/api/balances.rb +0 -15
  10. data/lib/megam/api/billedhistories.rb +0 -15
  11. data/lib/megam/api/billingtransactions.rb +0 -15
  12. data/lib/megam/api/components.rb +0 -15
  13. data/lib/megam/api/domains.rb +0 -15
  14. data/lib/megam/api/errors.rb +0 -15
  15. data/lib/megam/api/eventsbilling.rb +0 -15
  16. data/lib/megam/api/eventscontainer.rb +0 -15
  17. data/lib/megam/api/eventsstorage.rb +0 -15
  18. data/lib/megam/api/eventsvm.rb +0 -15
  19. data/lib/megam/api/marketplaces.rb +0 -15
  20. data/lib/megam/api/organizations.rb +0 -15
  21. data/lib/megam/api/promos.rb +0 -15
  22. data/lib/megam/api/requests.rb +0 -15
  23. data/lib/megam/api/sensors.rb +0 -15
  24. data/lib/megam/api/snapshots.rb +0 -15
  25. data/lib/megam/api/sshkeys.rb +0 -15
  26. data/lib/megam/api/version.rb +1 -16
  27. data/lib/megam/core/account.rb +241 -60
  28. data/lib/megam/core/assemblies.rb +0 -16
  29. data/lib/megam/core/assemblies_collection.rb +101 -116
  30. data/lib/megam/core/assembly.rb +201 -218
  31. data/lib/megam/core/assembly_collection.rb +101 -116
  32. data/lib/megam/core/balances.rb +182 -197
  33. data/lib/megam/core/balances_collection.rb +101 -116
  34. data/lib/megam/core/billedhistories.rb +186 -201
  35. data/lib/megam/core/billedhistories_collection.rb +101 -116
  36. data/lib/megam/core/billingtransactions.rb +0 -15
  37. data/lib/megam/core/billingtransactions_collection.rb +0 -15
  38. data/lib/megam/core/components.rb +300 -316
  39. data/lib/megam/core/components_collection.rb +0 -15
  40. data/lib/megam/core/domain_collection.rb +1 -16
  41. data/lib/megam/core/domains.rb +115 -131
  42. data/lib/megam/core/error.rb +55 -70
  43. data/lib/megam/core/eventsbilling.rb +0 -16
  44. data/lib/megam/core/eventsbilling_collection.rb +101 -116
  45. data/lib/megam/core/eventscontainer.rb +0 -16
  46. data/lib/megam/core/eventscontainer_collection.rb +101 -116
  47. data/lib/megam/core/eventsstorage.rb +0 -16
  48. data/lib/megam/core/eventsstorage_collection.rb +0 -15
  49. data/lib/megam/core/eventsvm.rb +0 -16
  50. data/lib/megam/core/eventsvm_collection.rb +101 -116
  51. data/lib/megam/core/json_compat.rb +0 -12
  52. data/lib/megam/core/konipai.rb +0 -15
  53. data/lib/megam/core/log.rb +0 -15
  54. data/lib/megam/core/marketplace.rb +224 -241
  55. data/lib/megam/core/marketplace_collection.rb +0 -15
  56. data/lib/megam/core/organizations.rb +0 -16
  57. data/lib/megam/core/organizations_collection.rb +0 -15
  58. data/lib/megam/core/promos.rb +0 -15
  59. data/lib/megam/core/request.rb +0 -15
  60. data/lib/megam/core/request_collection.rb +0 -15
  61. data/lib/megam/core/rest_adapter.rb +0 -15
  62. data/lib/megam/core/sensors.rb +138 -154
  63. data/lib/megam/core/sensors_collection.rb +0 -15
  64. data/lib/megam/core/snapshots.rb +0 -16
  65. data/lib/megam/core/snapshots_collection.rb +0 -15
  66. data/lib/megam/core/sshkey.rb +169 -184
  67. data/lib/megam/core/sshkey_collection.rb +0 -15
  68. data/lib/megam/core/stuff.rb +17 -32
  69. data/lib/megam/core/text.rb +82 -97
  70. data/lib/megam/mixins/assemblies.rb +10 -25
  71. data/lib/megam/mixins/assembly.rb +33 -49
  72. data/lib/megam/mixins/common_deployable.rb +64 -79
  73. data/lib/megam/mixins/components.rb +160 -175
  74. data/lib/megam/mixins/megam_attributes.rb +22 -37
  75. data/lib/megam/mixins/outputs.rb +14 -29
  76. data/lib/megam/mixins/policies.rb +21 -36
  77. data/lib/megam_api.rb +0 -15
  78. data/test/mixins/test_assemblies.rb +1 -2
  79. data/test/test_accounts.rb +84 -29
  80. data/test/test_billingtranscations.rb +17 -21
  81. data/test/test_eventscontainer.rb +19 -23
  82. data/test/test_eventsstorage.rb +8 -10
  83. data/test/test_eventsvm.rb +19 -23
  84. data/test/test_helper.rb +30 -30
  85. data/test/test_snapshots.rb +16 -22
  86. metadata +2 -2
@@ -1,136 +1,121 @@
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
1
  module Megam
17
- class BalancesCollection
18
- include Enumerable
19
-
20
- attr_reader :iterator
21
- def initialize
22
- @balance = Array.new
23
- @balance_by_name = Hash.new
24
- @insert_after_idx = nil
25
- end
2
+ class BalancesCollection
3
+ include Enumerable
4
+
5
+ attr_reader :iterator
6
+ def initialize
7
+ @balance = Array.new
8
+ @balance_by_name = Hash.new
9
+ @insert_after_idx = nil
10
+ end
26
11
 
27
- def all_balance
28
- @balance
29
- end
12
+ def all_balance
13
+ @balance
14
+ end
30
15
 
31
- def [](index)
32
- @balance[index]
33
- end
16
+ def [](index)
17
+ @balance[index]
18
+ end
34
19
 
35
- def []=(index, arg)
36
- is_megam_balance(arg)
37
- @balance[index] = arg
38
- @balance_by_name[arg.name] = index
39
- end
20
+ def []=(index, arg)
21
+ is_megam_balance(arg)
22
+ @balance[index] = arg
23
+ @balance_by_name[arg.name] = index
24
+ end
40
25
 
41
- def <<(*args)
42
- args.flatten.each do |a|
43
- is_megam_balance(a)
44
- @balance << a
45
- @balance_by_name[a.name] =@balance.length - 1
46
- end
47
- self
48
- end
26
+ def <<(*args)
27
+ args.flatten.each do |a|
28
+ is_megam_balance(a)
29
+ @balance << a
30
+ @balance_by_name[a.name] =@balance.length - 1
31
+ end
32
+ self
33
+ end
49
34
 
50
- # 'push' is an alias method to <<
51
- alias_method :push, :<<
52
-
53
- def insert(balance)
54
- is_megam_balance(balance)
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
- # balance
59
- @balance.insert(@insert_after_idx + 1, balance)
60
- # update name -> location mappings and register new balance
61
- @balance_by_name.each_key do |key|
62
- @balance_by_name[key] += 1 if@balance_by_name[key] > @insert_after_idx
35
+ # 'push' is an alias method to <<
36
+ alias_method :push, :<<
37
+
38
+ def insert(balance)
39
+ is_megam_balance(balance)
40
+ if @insert_after_idx
41
+ # in the middle of executing a run, so any predefs inserted now should
42
+ # be placed after the most recent addition done by the currently executing
43
+ # balance
44
+ @balance.insert(@insert_after_idx + 1, balance)
45
+ # update name -> location mappings and register new balance
46
+ @balance_by_name.each_key do |key|
47
+ @balance_by_name[key] += 1 if@balance_by_name[key] > @insert_after_idx
48
+ end
49
+ @balance_by_name[balance.name] = @insert_after_idx + 1
50
+ @insert_after_idx += 1
51
+ else
52
+ @balance << balance
53
+ @balance_by_name[balance.name] =@balance.length - 1
54
+ end
63
55
  end
64
- @balance_by_name[balance.name] = @insert_after_idx + 1
65
- @insert_after_idx += 1
66
- else
67
- @balance << balance
68
- @balance_by_name[balance.name] =@balance.length - 1
69
- end
70
- end
71
56
 
72
- def each
73
- @balance.each do |balance|
74
- yield balance
75
- end
76
- end
57
+ def each
58
+ @balance.each do |balance|
59
+ yield balance
60
+ end
61
+ end
77
62
 
78
- def each_index
79
- @balance.each_index do |i|
80
- yield i
81
- end
82
- end
63
+ def each_index
64
+ @balance.each_index do |i|
65
+ yield i
66
+ end
67
+ end
83
68
 
84
- def empty?
85
- @balance.empty?
86
- end
69
+ def empty?
70
+ @balance.empty?
71
+ end
87
72
 
88
- def lookup(balance)
89
- lookup_by = nil
90
- if balance.kind_of?(Megam::Balances)
91
- lookup_by = balance.name
92
- elsif balance.kind_of?(String)
93
- lookup_by = balance
94
- else
95
- raise ArgumentError, "Must pass a Megam::Balance or String to lookup"
96
- end
97
- res =@balance_by_name[lookup_by]
98
- unless res
99
- raise ArgumentError, "Cannot find a balance matching #{lookup_by} (did you define it first?)"
100
- end
101
- @balance[res]
102
- end
73
+ def lookup(balance)
74
+ lookup_by = nil
75
+ if balance.kind_of?(Megam::Balances)
76
+ lookup_by = balance.name
77
+ elsif balance.kind_of?(String)
78
+ lookup_by = balance
79
+ else
80
+ raise ArgumentError, "Must pass a Megam::Balance or String to lookup"
81
+ end
82
+ res =@balance_by_name[lookup_by]
83
+ unless res
84
+ raise ArgumentError, "Cannot find a balance matching #{lookup_by} (did you define it first?)"
85
+ end
86
+ @balance[res]
87
+ end
103
88
 
104
- def to_s
105
- @balance.join(", ")
106
- end
89
+ def to_s
90
+ @balance.join(", ")
91
+ end
107
92
 
108
- def for_json
109
- to_a.map { |item| item.to_s }
110
- end
93
+ def for_json
94
+ to_a.map { |item| item.to_s }
95
+ end
111
96
 
112
- def to_json(*a)
113
- Megam::JSONCompat.to_json(for_json, *a)
114
- end
97
+ def to_json(*a)
98
+ Megam::JSONCompat.to_json(for_json, *a)
99
+ end
115
100
 
116
- def self.json_create(o)
117
- collection = self.new()
118
- o["results"].each do |balance_list|
119
- balance_array = balance_list.kind_of?(Array) ? balance_list : [ balance_list ]
120
- balance_array.each do |balance|
121
- collection.insert(balance)
101
+ def self.json_create(o)
102
+ collection = self.new()
103
+ o["results"].each do |balance_list|
104
+ balance_array = balance_list.kind_of?(Array) ? balance_list : [ balance_list ]
105
+ balance_array.each do |balance|
106
+ collection.insert(balance)
107
+ end
108
+ end
109
+ collection
122
110
  end
123
- end
124
- collection
125
- end
126
111
 
127
- private
112
+ private
128
113
 
129
- def is_megam_balance(arg)
130
- unless arg.kind_of?(Megam::Balances)
131
- raise ArgumentError, "Members must be Megam::balance's"
132
- end
133
- true
114
+ def is_megam_balance(arg)
115
+ unless arg.kind_of?(Megam::Balances)
116
+ raise ArgumentError, "Members must be Megam::balance's"
117
+ end
118
+ true
119
+ end
134
120
  end
135
- end
136
121
  end
@@ -1,205 +1,190 @@
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
1
  module Megam
17
- class Billedhistories < Megam::RestAdapter
18
- def initialize(o)
19
- @id = nil
20
- @accounts_id = nil
21
- @assembly_id = nil
22
- @bill_type = nil
23
- @billing_amount = nil
24
- @currency_type = nil
25
- @created_at = nil
26
- @some_msg = {}
27
- super(o)
28
- end
29
-
30
- def billedhistories
31
- self
32
- end
33
-
34
- def id(arg=nil)
35
- if arg != nil
36
- @id = arg
37
- else
38
- @id
39
- end
40
- end
41
-
42
- def accounts_id(arg=nil)
43
- if arg != nil
44
- @accounts_id= arg
45
- else
46
- @accounts_id
47
- end
48
- end
49
-
50
- def assembly_id(arg=nil)
51
- if arg != nil
52
- @assembly_id = arg
53
- else
54
- @assembly_id
55
- end
56
- end
57
-
58
- def bill_type(arg=nil)
59
- if arg != nil
60
- @bill_type = arg
61
- else
62
- @bill_type
63
- end
64
- end
65
-
66
- def billing_amount(arg=nil)
67
- if arg != nil
68
- @billing_amount= arg
69
- else
70
- @billing_amount
71
- end
72
- end
73
-
74
- def currency_type(arg=nil)
75
- if arg != nil
76
- @currency_type = arg
77
- else
78
- @currency_type
79
- end
80
- end
81
-
82
- def created_at(arg=nil)
83
- if arg != nil
84
- @created_at = arg
85
- else
86
- @created_at
87
- end
88
- end
89
-
90
- def some_msg(arg=nil)
91
- if arg != nil
92
- @some_msg = arg
93
- else
94
- @some_msg
95
- end
96
- end
97
-
98
- def error?
99
- crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
100
- end
101
-
102
- # Transform the ruby obj -> to a Hash
103
- def to_hash
104
- index_hash = Hash.new
105
- index_hash["json_claz"] = self.class.name
106
- index_hash["id"] = id
107
- index_hash["accounts_id"] = accounts_id
108
- index_hash["assembly_id"] = assembly_id
109
- index_hash["bill_type"] = bill_type
110
- index_hash["billing_amount"] = billing_amount
111
- index_hash["currency_type"] = currency_type
112
- index_hash["created_at"] = created_at
113
- index_hash
114
- end
115
-
116
- # Serialize this object as a hash: called from JsonCompat.
117
- # Verify if this called from JsonCompat during testing.
118
- def to_json(*a)
119
- for_json.to_json(*a)
120
- end
121
-
122
- def for_json
123
- result = {
124
- "id" => id,
125
- "accounts_id" => accounts_id,
126
- "assembly_id" => assembly_id,
127
- "bill_type" => bill_type,
128
- "billing_amount" => billing_amount,
129
- "currency_type" => currency_type,
130
- "created_at" => created_at
131
- }
132
- result
133
- end
134
-
135
- #
136
- def self.json_create(o)
137
- bal = new({})
138
- bal.id(o["id"]) if o.has_key?("id")
139
- bal.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id")
140
- bal.assembly_id(o["assembly_id"]) if o.has_key?("assembly_id")
141
- bal.bill_type(o["bill_type"]) if o.has_key?("bill_type")
142
- bal.billing_amount(o["billing_amount"]) if o.has_key?("billing_amount")
143
- bal.currency_type(o["currency_type"]) if o.has_key?("currency_type")
144
- bal.created_at(o["created_at"]) if o.has_key?("created_at")
145
- #success or error
146
- bal.some_msg[:code] = o["code"] if o.has_key?("code")
147
- bal.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
148
- bal.some_msg[:msg]= o["msg"] if o.has_key?("msg")
149
- bal.some_msg[:links] = o["links"] if o.has_key?("links")
150
- bal
151
- end
152
-
153
- def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
154
- bal = self.new(tmp_email, tmp_api_key, tmp_host)
155
- bal.from_hash(o)
156
- bal
157
- end
158
-
159
- def from_hash(o)
160
- @id = o[:id] if o.has_key?(:id)
161
- @accounts_id = o[:accounts_id] if o.has_key?(:accounts_id)
162
- @assembly_id = o[:assembly_id] if o.has_key?(:assembly_id)
163
- @bill_type = o[:bill_type] if o.has_key?(:bill_type)
164
- @billing_amount = o[:billing_amount] if o.has_key?(:billing_amount)
165
- @currency_type = o[:currency_type] if o.has_key?(:currency_type)
166
- @created_at = o[:created_at] if o.has_key?(:created_at)
167
- self
168
- end
2
+ class Billedhistories < Megam::RestAdapter
3
+ def initialize(o)
4
+ @id = nil
5
+ @accounts_id = nil
6
+ @assembly_id = nil
7
+ @bill_type = nil
8
+ @billing_amount = nil
9
+ @currency_type = nil
10
+ @created_at = nil
11
+ @some_msg = {}
12
+ super(o)
13
+ end
14
+
15
+ def billedhistories
16
+ self
17
+ end
18
+
19
+ def id(arg=nil)
20
+ if arg != nil
21
+ @id = arg
22
+ else
23
+ @id
24
+ end
25
+ end
26
+
27
+ def accounts_id(arg=nil)
28
+ if arg != nil
29
+ @accounts_id= arg
30
+ else
31
+ @accounts_id
32
+ end
33
+ end
34
+
35
+ def assembly_id(arg=nil)
36
+ if arg != nil
37
+ @assembly_id = arg
38
+ else
39
+ @assembly_id
40
+ end
41
+ end
42
+
43
+ def bill_type(arg=nil)
44
+ if arg != nil
45
+ @bill_type = arg
46
+ else
47
+ @bill_type
48
+ end
49
+ end
50
+
51
+ def billing_amount(arg=nil)
52
+ if arg != nil
53
+ @billing_amount= arg
54
+ else
55
+ @billing_amount
56
+ end
57
+ end
58
+
59
+ def currency_type(arg=nil)
60
+ if arg != nil
61
+ @currency_type = arg
62
+ else
63
+ @currency_type
64
+ end
65
+ end
66
+
67
+ def created_at(arg=nil)
68
+ if arg != nil
69
+ @created_at = arg
70
+ else
71
+ @created_at
72
+ end
73
+ end
74
+
75
+ def some_msg(arg=nil)
76
+ if arg != nil
77
+ @some_msg = arg
78
+ else
79
+ @some_msg
80
+ end
81
+ end
82
+
83
+ def error?
84
+ crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
85
+ end
86
+
87
+ # Transform the ruby obj -> to a Hash
88
+ def to_hash
89
+ index_hash = Hash.new
90
+ index_hash["json_claz"] = self.class.name
91
+ index_hash["id"] = id
92
+ index_hash["accounts_id"] = accounts_id
93
+ index_hash["assembly_id"] = assembly_id
94
+ index_hash["bill_type"] = bill_type
95
+ index_hash["billing_amount"] = billing_amount
96
+ index_hash["currency_type"] = currency_type
97
+ index_hash["created_at"] = created_at
98
+ index_hash
99
+ end
100
+
101
+ # Serialize this object as a hash: called from JsonCompat.
102
+ # Verify if this called from JsonCompat during testing.
103
+ def to_json(*a)
104
+ for_json.to_json(*a)
105
+ end
106
+
107
+ def for_json
108
+ result = {
109
+ "id" => id,
110
+ "accounts_id" => accounts_id,
111
+ "assembly_id" => assembly_id,
112
+ "bill_type" => bill_type,
113
+ "billing_amount" => billing_amount,
114
+ "currency_type" => currency_type,
115
+ "created_at" => created_at
116
+ }
117
+ result
118
+ end
119
+
120
+ #
121
+ def self.json_create(o)
122
+ bal = new({})
123
+ bal.id(o["id"]) if o.has_key?("id")
124
+ bal.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id")
125
+ bal.assembly_id(o["assembly_id"]) if o.has_key?("assembly_id")
126
+ bal.bill_type(o["bill_type"]) if o.has_key?("bill_type")
127
+ bal.billing_amount(o["billing_amount"]) if o.has_key?("billing_amount")
128
+ bal.currency_type(o["currency_type"]) if o.has_key?("currency_type")
129
+ bal.created_at(o["created_at"]) if o.has_key?("created_at")
130
+ #success or error
131
+ bal.some_msg[:code] = o["code"] if o.has_key?("code")
132
+ bal.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
133
+ bal.some_msg[:msg]= o["msg"] if o.has_key?("msg")
134
+ bal.some_msg[:links] = o["links"] if o.has_key?("links")
135
+ bal
136
+ end
137
+
138
+ def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
139
+ bal = self.new(tmp_email, tmp_api_key, tmp_host)
140
+ bal.from_hash(o)
141
+ bal
142
+ end
143
+
144
+ def from_hash(o)
145
+ @id = o[:id] if o.has_key?(:id)
146
+ @accounts_id = o[:accounts_id] if o.has_key?(:accounts_id)
147
+ @assembly_id = o[:assembly_id] if o.has_key?(:assembly_id)
148
+ @bill_type = o[:bill_type] if o.has_key?(:bill_type)
149
+ @billing_amount = o[:billing_amount] if o.has_key?(:billing_amount)
150
+ @currency_type = o[:currency_type] if o.has_key?(:currency_type)
151
+ @created_at = o[:created_at] if o.has_key?(:created_at)
152
+ self
153
+ end
154
+
155
+ def self.create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
156
+ acct = from_hash(o,tmp_email, tmp_api_key, tmp_host)
157
+ acct.create
158
+ end
159
+
160
+ # Create the billing histories via the REST API
161
+ def create
162
+ megam_rest.post_billedhistories(to_hash)
163
+ end
164
+
165
+ # Load all billing histories -
166
+ # returns a BillingHistoriesCollection
167
+ # don't return self. check if the Megam::BillingHistoriesCollection is returned.
168
+ def self.list(params)
169
+ billhistory = self.new(params["email"], params["api_key"], params["host"])
170
+ billhistory.megam_rest.get_billedhistories
171
+ end
172
+
173
+ # Show a particular billing history by name,
174
+ # Megam::BillingHistory
175
+ def self.show(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
176
+ pre = self.new(tmp_email,tmp_api_key, tmp_host)
177
+ pre.megam_rest.get_billedhistory(p_name)
178
+ end
179
+
180
+ def self.delete(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
181
+ pre = self.new(tmp_email,tmp_api_key, tmp_host)
182
+ pre.megam_rest.delete_billedhistory(p_name)
183
+ end
184
+
185
+ def to_s
186
+ Megam::Stuff.styled_hash(to_hash)
187
+ end
169
188
 
170
- def self.create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
171
- acct = from_hash(o,tmp_email, tmp_api_key, tmp_host)
172
- acct.create
173
189
  end
174
-
175
- # Create the billing histories via the REST API
176
- def create
177
- megam_rest.post_billedhistories(to_hash)
178
- end
179
-
180
- # Load all billing histories -
181
- # returns a BillingHistoriesCollection
182
- # don't return self. check if the Megam::BillingHistoriesCollection is returned.
183
- def self.list(params)
184
- billhistory = self.new(params["email"], params["api_key"], params["host"])
185
- billhistory.megam_rest.get_billedhistories
186
- end
187
-
188
- # Show a particular billing history by name,
189
- # Megam::BillingHistory
190
- def self.show(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
191
- pre = self.new(tmp_email,tmp_api_key, tmp_host)
192
- pre.megam_rest.get_billedhistory(p_name)
193
- end
194
-
195
- def self.delete(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
196
- pre = self.new(tmp_email,tmp_api_key, tmp_host)
197
- pre.megam_rest.delete_billedhistory(p_name)
198
- end
199
-
200
- def to_s
201
- Megam::Stuff.styled_hash(to_hash)
202
- end
203
-
204
- end
205
190
  end