megam_api 0.58 → 0.59

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e588bc6c0273dc73140d2f93e492c0567441b400
4
- data.tar.gz: 526674879efb9ae20c3e3632cedd04cfcf0443c1
3
+ metadata.gz: 6962d753033b0018f0d9fa3f7bf84490be095630
4
+ data.tar.gz: 0bc5ed0fcb60fc33613d53e2ab5fa44e2c90c822
5
5
  SHA512:
6
- metadata.gz: b9371e4be212684da2b5e4960a10597c54851e1c9c671f0f51291ea50542d3a1506524b80638e3e1554bda2bcb1a39af447469e323f6ca4685efe1e5502f1d8f
7
- data.tar.gz: d9462be29836ca6e7a21c84f234ffcaf1d007404e11d01c513394b10b2d68171c44bbb7ec321d9c35ff4435e523e4725461fda5fe299948c51946c8cb9067ae5
6
+ metadata.gz: 74add9831ce71475d431e5cc5939aa9d9e8b66bd762b5d9b1a9fe97d407a73683c3c7aa57f6e0e8c7a8a6b30188c84887fcc6cd9fa56744116d45bbf4bcf12d8
7
+ data.tar.gz: e9525f69232eee8935272ffb7c2ef8db7c3af613122a173d1c15f7a0e1942911a84a165c9d6762a745e7cc209edfa38a5612c14f9b354a83bfd0bc37bf2c4d29
@@ -15,7 +15,7 @@ module Megam
15
15
  :body => Megam::JSONCompat.to_json(new_asm)}.merge(@options)
16
16
 
17
17
  request(
18
- :expects => 201,
18
+ :expects => [200, 201],
19
19
  :method => :post,
20
20
  :body => @options[:body]
21
21
  )
@@ -1,18 +1,9 @@
1
1
  module Megam
2
2
  class API
3
3
  def get_discounts
4
+ puts "Entered get discount--weehaa!"
4
5
  @options = {:path => '/discounts',:body => ""}.merge(@options)
5
-
6
- request(
7
- :expects => 200,
8
- :method => :get,
9
- :body => @options[:body]
10
- )
11
- end
12
-
13
- def get_discounts(id)
14
- @options = {:path => "/discounts/#{id}",:body => ""}.merge(@options)
15
-
6
+ puts @options
16
7
  request(
17
8
  :expects => 200,
18
9
  :method => :get,
@@ -20,6 +11,7 @@ module Megam
20
11
  )
21
12
  end
22
13
 
14
+
23
15
  def post_discounts(new_discount)
24
16
  @options = {:path => '/discounts/content',
25
17
  :body => Megam::JSONCompat.to_json(new_discount)}.merge(@options)
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "0.58"
3
+ VERSION = "0.59"
4
4
  end
5
5
  end
@@ -159,16 +159,14 @@ module Megam
159
159
  end
160
160
 
161
161
  def self.create(params)
162
- puts "creating discounts entry...hold tight"
163
- puts params.inspect
164
- discount = from_hash(params)
162
+
163
+ discount = from_hash(params, params[:email], params[:api_key])
165
164
  discount.create
166
165
  end
167
166
 
168
167
  # Create the discounts via the REST API
169
168
  def create
170
- puts "YES. CREATING....JUST A SEC"
171
- puts to_hash
169
+
172
170
  megam_rest.post_discounts(to_hash)
173
171
  end
174
172
 
@@ -185,8 +183,9 @@ module Megam
185
183
  # Load all discounts -
186
184
  # returns a discountsCollection
187
185
  # don't return self. check if the Megam::discountsCollection is returned.
188
- def self.list(tmp_email=nil, tmp_api_key=nil)
189
- cts = self.new(tmp_email, tmp_api_key)
186
+ def self.list(params)
187
+ cts = self.new(params[:email], params[:api_key])
188
+
190
189
  cts.megam_rest.get_discounts
191
190
  end
192
191
 
@@ -35,14 +35,14 @@ module Megam
35
35
  def []=(index, arg)
36
36
  is_megam_discounts(arg)
37
37
  @discounts[index] = arg
38
- @discounts_by_name[arg.repo_name] = index
38
+ @discounts_by_name[arg.code] = index
39
39
  end
40
40
 
41
41
  def <<(*args)
42
42
  args.flatten.each do |a|
43
43
  is_megam_discounts(a)
44
44
  @discounts << a
45
- @discounts_by_name[a.repo_name] =@discounts.length - 1
45
+ @discounts_by_name[a.code] =@discounts.length - 1
46
46
  end
47
47
  self
48
48
  end
@@ -61,11 +61,11 @@ module Megam
61
61
  @discounts_by_name.each_key do |key|
62
62
  @discounts_by_name[key] += 1 if@discounts_by_name[key] > @insert_after_idx
63
63
  end
64
- @discounts_by_name[discounts.repo_name] = @insert_after_idx + 1
64
+ @discounts_by_name[discounts.code] = @insert_after_idx + 1
65
65
  @insert_after_idx += 1
66
66
  else
67
67
  @discounts << discounts
68
- @discounts_by_name[discounts.repo_name] =@discounts.length - 1
68
+ @discounts_by_name[discounts.code] =@discounts.length - 1
69
69
  end
70
70
  end
71
71
 
@@ -88,7 +88,7 @@ module Megam
88
88
  def lookup(discounts)
89
89
  lookup_by = nil
90
90
  if discounts.kind_of?(Megam::Discounts)
91
- lookup_by = discounts.repo_name
91
+ lookup_by = discounts.code
92
92
  elsif discounts.kind_of?(String)
93
93
  lookup_by = discounts
94
94
  else
@@ -105,7 +105,7 @@ module Megam
105
105
  def to_hash
106
106
  index_hash = Hash.new
107
107
  self.each do |discounts|
108
- index_hash[discounts.repo_name] = discounts.to_s
108
+ index_hash[discounts.code] = discounts.to_s
109
109
  end
110
110
  index_hash
111
111
  end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
- #=begin
4
+ =begin
5
5
  def test_post_discount
6
6
  tmp_hash = { :accounts_id => "ACT93476985797",
7
7
  :bill_type => "paypal",
@@ -12,14 +12,16 @@ class TestApps < MiniTest::Unit::TestCase
12
12
  response = megams.post_discounts(tmp_hash)
13
13
  assert_equal(201, response.status)
14
14
  end
15
- #=end
15
+ =end
16
+
16
17
 
17
- =begin
18
18
  def test_get_discounts
19
19
  response = megams.get_discounts
20
+ puts response.inspect
20
21
  assert_equal(200, response.status)
22
+
21
23
  end
22
- =end
24
+
23
25
  =begin
24
26
  def test_get_discounts
25
27
  response = megams.get_discounts("iaas_default")
data/test/test_helper.rb CHANGED
@@ -69,9 +69,9 @@ def sandbox_name
69
69
  end
70
70
 
71
71
  def sandbox_apikey
72
- "S2lTFprreumUrQPfjfKANQ=="
72
+ "DgBRJLv1v5QCfqqneNCh1w=="
73
73
  end
74
74
 
75
75
  def sandbox_email
76
- "super@removedtest.com"
76
+ "morpheyesh@gmail.com"
77
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: megam_api
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.58'
4
+ version: '0.59'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajthilak, Kishorekumar Neelamegam, Thomas Alrin, Yeshwanth Kumar, Subash Sethurajan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -257,34 +257,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  version: '0'
258
258
  requirements: []
259
259
  rubyforge_project:
260
- rubygems_version: 2.4.6
260
+ rubygems_version: 2.4.7
261
261
  signing_key:
262
262
  specification_version: 4
263
263
  summary: Ruby Client for the Megam
264
- test_files:
265
- - test/test_accounts.rb
266
- - test/test_assemblies.rb
267
- - test/test_assembly.rb
268
- - test/test_availableunits.rb
269
- - test/test_balances.rb
270
- - test/test_billinghistories.rb
271
- - test/test_billings.rb
272
- - test/test_cat_requests.rb
273
- - test/test_cloudtoolsettings.rb
274
- - test/test_components.rb
275
- - test/test_credithistories.rb
276
- - test/test_csars.rb
277
- - test/test_discounts.rb
278
- - test/test_domains.rb
279
- - test/test_event.rb
280
- - test/test_helper.rb
281
- - test/test_login.rb
282
- - test/test_logs.rb
283
- - test/test_marketplaceaddons.rb
284
- - test/test_marketplaces.rb
285
- - test/test_organizations.rb
286
- - test/test_predefclouds.rb
287
- - test/test_promos.rb
288
- - test/test_requests.rb
289
- - test/test_sshkeys.rb
290
- - test/test_subscriptions.rb
264
+ test_files: []