monza 1.3.1 → 1.3.2

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: b144535e2ce5230aa5c42f59e55b6a85fdbc75f6
4
- data.tar.gz: 9293b3be0030e1eae0d68a7c65e5f830eeb06744
3
+ metadata.gz: 2333e5c5c78dc623cd42815e38543cbd1828329f
4
+ data.tar.gz: d826c632a53edefd2308f5f25ff56212d98a86ba
5
5
  SHA512:
6
- metadata.gz: a63c211b1404f911c7e786b450ed32456d50694bf3adf68e0604f5e34f6b3635478dc497f2aa1b5b6e0cf4a83f158baab785afa143be97561fc591244fd751b3
7
- data.tar.gz: 9138a72a7d3a4ebfad98c013bb02062327fa15c80f10c3c7a23d537dc4b7bd28624c84077c05f7aaa71c5dca3f24068fe9410f3075b63be788dd12da5ff1003a
6
+ metadata.gz: d5c679b821e72871737c806c631e43b70c319e5d9c94c816bafb8bd13887a528a63e855a48d0c2632ce3ea8264fe7025fdb5430d6ea7a22a3fdbdeffe0a6e324
7
+ data.tar.gz: ee0401f99b07f3b9081042caddc544161e59e45365d2fa5216f0e44e3daeb56845057bce6f44974f922c2c6e8580d428ee093650c7b63908305ad753550155b0
data/README.md CHANGED
@@ -46,6 +46,9 @@ response.is_subscription_active? # => true or false
46
46
  # this is helpful in case the most recent transaction was cancelled but the user still has a previous transaction or subscription that is active
47
47
  response.is_any_subscription_active? # => true or false
48
48
 
49
+ # Returns the active subscription TransactionReceipt or nil
50
+ response.latest_active_transaction_receipt # => TransactionReceipt instance
51
+
49
52
  # Check most recent expiry date
50
53
  # ActiveSupport::TimeWithZone
51
54
  response.latest_expiry_date # => Fri, 17 Jun 2016 01:57:28 UTC +00:00
@@ -43,7 +43,7 @@ module Monza
43
43
  false
44
44
  end
45
45
  end
46
-
46
+
47
47
  def is_any_subscription_active?
48
48
  expires_dates_ms = @latest_receipt_info.map(&:expires_date_ms)
49
49
  latest_expires_date_ms = expires_dates_ms.max
@@ -55,6 +55,16 @@ module Monza
55
55
  end
56
56
  end
57
57
 
58
+ def latest_active_transaction_receipt
59
+ latest_active_sub = @latest_receipt_info.sort_by(&:expires_date_ms).last
60
+
61
+ if latest_active_sub && latest_active_sub.expires_date_ms >= Time.zone.now
62
+ return latest_active_sub
63
+ else
64
+ return nil
65
+ end
66
+ end
67
+
58
68
  def latest_expiry_date
59
69
  @latest_receipt_info.last.expires_date_ms if @latest_receipt_info.last
60
70
  end
data/lib/monza/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Monza
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monza
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Garza