killbill-client 0.4.5 → 0.4.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33483de38f929a119b1f8fe0397187cd2a1c68a2
4
- data.tar.gz: b1191889e0ce3bdc4e8ac4e725e46460399f66e4
3
+ metadata.gz: 96687e10cab322b867c1387c71d4f30c81ec0328
4
+ data.tar.gz: 5cb7fa0eece1a870191f7bf21ae67e3ce7f8d486
5
5
  SHA512:
6
- metadata.gz: dc46633af7cda5602fce3ff92914112f3724b5c7ef9531903747e4683983b04e1cc2c80da03e01529b22d06482e00a89051e7c245be15571966ba5a179787643
7
- data.tar.gz: 625605bd4e11bf53fdb149965737527d5e0c808a88723405852cc020781c89d140c20a783567741514b94a53b418bf29d43347f240fc1eebfe52620b1dff6f04
6
+ metadata.gz: b0db60114e796354ecc0eb01762e2285bb677706be18735e69a7f82f28d1dcd2206d9116b982719eeefc3810de5d114fd907ef3ca4d1117157c95f42b19c844a
7
+ data.tar.gz: a1c2bc7aa82982dc2b7076675f38e963fb0177f52bdc3e5486530cfdee37ac37d430eb2f56e2227eade58dc23b51186135c4306ea8376729d5ce2acbd09a32b1
@@ -1,10 +1,33 @@
1
1
  module KillBillClient
2
2
  module Model
3
3
  class Bundle < BundleAttributes
4
+
5
+ KILLBILL_API_BUNDLES_PREFIX = "#{KILLBILL_API_PREFIX}/bundles"
6
+
4
7
  has_many :subscriptions, KillBillClient::Model::Subscription
5
8
  has_many :audit_logs, KillBillClient::Model::AuditLog
9
+
10
+ class << self
11
+ def find_by_id(bundle_id, options = {})
12
+ get "#{KILLBILL_API_BUNDLES_PREFIX}/#{bundle_id}",
13
+ {},
14
+ options
15
+ end
16
+
17
+ # Return the active one
18
+ def find_by_external_key(external_key, options = {})
19
+ get "#{KILLBILL_API_BUNDLES_PREFIX}?externalKey=#{external_key}",
20
+ {},
21
+ options
22
+ end
23
+
24
+ # Return active and inactive ones
25
+ def find_all_by_account_id_and_external_key(account_id, external_key, options = {})
26
+ get "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/bundles?externalKey=#{external_key}",
27
+ {},
28
+ options
29
+ end
30
+ end
6
31
  end
7
32
  end
8
33
  end
9
-
10
-
@@ -204,6 +204,15 @@ module KillBillClient
204
204
  self
205
205
  end
206
206
  end
207
+
208
+ def ==(o)
209
+ o.class == self.class && o.to_hash == to_hash
210
+ end
211
+ alias_method :eql?, :==
212
+
213
+ def hash
214
+ to_hash.hash
215
+ end
207
216
  end
208
217
  end
209
218
  end
@@ -6,11 +6,7 @@ module KillBillClient
6
6
 
7
7
  KILLBILL_API_ENTITLEMENT_PREFIX = "#{KILLBILL_API_PREFIX}/subscriptions"
8
8
 
9
- KILLBILL_API_BUNDLE_PREFIX = "#{KILLBILL_API_PREFIX}/bundles"
10
-
11
9
  class << self
12
-
13
-
14
10
  def find_by_id(subscription_id, options = {})
15
11
  get "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}",
16
12
  {},
@@ -18,7 +14,7 @@ module KillBillClient
18
14
  end
19
15
 
20
16
  def find_by_bundle_id(bundle_id, options = {})
21
- get "#{KILLBILL_API_BUNDLE_PREFIX}/#{bundle_id}/subscriptions",
17
+ get "#{Bundle::KILLBILL_API_BUNDLE_PREFIX}/#{bundle_id}/subscriptions",
22
18
  {},
23
19
  options
24
20
  end
@@ -2,7 +2,7 @@ module KillBillClient
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 4
5
- PATCH = 5
5
+ PATCH = 6
6
6
  PRE = nil
7
7
 
8
8
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
@@ -173,6 +173,18 @@ describe KillBillClient::Model do
173
173
  account.bundles.size.should == 1
174
174
  account.bundles[0].subscriptions.size.should == 1
175
175
  account.bundles[0].subscriptions[0].subscription_id.should == sub.subscription_id
176
+ bundle = account.bundles[0]
177
+
178
+ # Verify we can retrieve it by id
179
+ KillBillClient::Model::Bundle.find_by_id(bundle.bundle_id).should == bundle
180
+
181
+ # Verify we can retrieve it by external key
182
+ KillBillClient::Model::Bundle.find_by_external_key(bundle.external_key).should == bundle
183
+
184
+ # Verify we can retrieve it by account id and external key
185
+ bundles = KillBillClient::Model::Bundle.find_all_by_account_id_and_external_key(account.account_id, bundle.external_key)
186
+ bundles.size.should == 1
187
+ bundles[0].should == bundle
176
188
  end
177
189
 
178
190
  it 'should manipulate tag definitions' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Killbill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2013-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json