ios-receipt 0.1.3 → 0.1.4

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: 0060863e32d0a16251f838322b8e325f74f1263e
4
- data.tar.gz: 15c5f436fe757b2b9c9a591c580dab75e3f9bfe6
3
+ metadata.gz: 911593675fa6cdd21f74bb4f9424edf2531c75ee
4
+ data.tar.gz: 6b8a60b1a78100a7a6cfbc93c9f31b16b1d68834
5
5
  SHA512:
6
- metadata.gz: 9986caf180832d0acfbe4db786bc6cfdb5838d3b2e91a0f98bcce5f450ed2ee5247b79205b80a4b3a7a09ec6c66d0339164506590d2e2bf0c849a1c02dda5895
7
- data.tar.gz: a25782aacd73de2c3c2aef93bdc7f0b49bfa86989a7b045ad82194a4f0084a046bcec95847d6c9a299500be5d59b20a055688291184f83e3ab881d5db835f224
6
+ metadata.gz: fcb3276a2776218b15578563c738d835f5f980b15c7f9e42d3fd0eeeed9b9983b803da78a818075cc27debed59d223fd3f8c8eec5b2b3b0f8698c73bec829667
7
+ data.tar.gz: 9e49987e1d2f5b7fe8a8d22fd24f20e4cce671418bafb55639cd877ef35f5184fdb70da8f1f72ac4db100932f77278b40cd751d455c063ac73ed4fb3b7bb58e2
@@ -1,12 +1,12 @@
1
1
  class Ios::Receipt::Result
2
2
  attr_reader :result, :environment, :bundle_id, :application_version, :original_application_version,
3
- :in_app, :latest
3
+ :in_app, :latest, :receipt_style
4
4
 
5
5
  def initialize(result, environment=nil)
6
6
  @result = result
7
7
  @status = result['status']
8
8
  check_status!
9
-
9
+
10
10
  @environment = (result['environment'] || environment).try(:downcase).try(:to_sym)
11
11
  raise Ios::Receipt::Exceptions::InvalidConfiguration if @environment.nil?
12
12
 
@@ -15,7 +15,8 @@ class Ios::Receipt::Result
15
15
  @application_version = receipt['application_version']
16
16
  @original_application_version = receipt['original_application_version']
17
17
 
18
- if receipt['original_transaction_id'] # ios6 style receipt
18
+ @receipt_style = receipt['original_transaction_id'] ? :ios6 : :ios7
19
+ if @receipt_style == :ios6
19
20
  latest = result['latest_receipt_info'] || result['latest_expired_receipt_info']
20
21
  @latest = if latest
21
22
  [ Ios::Receipt::Receipt.new(latest) ]
@@ -37,15 +38,15 @@ class Ios::Receipt::Result
37
38
  def once_off_receipts
38
39
  @once_offs ||= @latest.select { |r| r.once_off? }
39
40
  end
40
-
41
+
41
42
  def expired?
42
43
  @status == 21006
43
44
  end
44
-
45
+
45
46
  def sandbox?
46
47
  @environment == :sandbox
47
48
  end
48
-
49
+
49
50
  def production?
50
51
  @environment == :production
51
52
  end
@@ -65,9 +66,9 @@ class Ios::Receipt::Result
65
66
  def transaction_ids
66
67
  (@in_app.collect { |r| r.transaction_id } + @latest.collect { |r| r.transaction_id }).flatten.compact.uniq
67
68
  end
68
-
69
+
69
70
  protected
70
-
71
+
71
72
  def check_status!
72
73
  case @status
73
74
  when 21000 then raise Ios::Receipt::Exceptions::Json
@@ -79,4 +80,4 @@ class Ios::Receipt::Result
79
80
  when 21008 then raise Ios::Receipt::Exceptions::ProductionReceipt
80
81
  end
81
82
  end
82
- end
83
+ end
@@ -1,5 +1,5 @@
1
1
  module Ios
2
2
  module Receipt
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ios-receipt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - DailyBurn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2016-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client