candy_check 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +1 -0
  3. data/.rubocop.yml +10 -0
  4. data/.ruby-version +1 -1
  5. data/Gemfile +1 -1
  6. data/Guardfile +5 -3
  7. data/Rakefile +5 -5
  8. data/candy_check.gemspec +10 -10
  9. data/lib/candy_check/app_store/client.rb +7 -7
  10. data/lib/candy_check/app_store/config.rb +7 -9
  11. data/lib/candy_check/app_store/receipt.rb +16 -16
  12. data/lib/candy_check/app_store/receipt_collection.rb +2 -2
  13. data/lib/candy_check/app_store/subscription_verification.rb +5 -5
  14. data/lib/candy_check/app_store/verification.rb +3 -3
  15. data/lib/candy_check/app_store/verification_failure.rb +25 -21
  16. data/lib/candy_check/app_store/verifier.rb +4 -5
  17. data/lib/candy_check/app_store.rb +8 -8
  18. data/lib/candy_check/cli/app.rb +1 -1
  19. data/lib/candy_check/cli/commands/app_store.rb +1 -1
  20. data/lib/candy_check/cli/commands.rb +4 -4
  21. data/lib/candy_check/cli/out.rb +1 -3
  22. data/lib/candy_check/cli.rb +3 -3
  23. data/lib/candy_check/play_store/product_acknowledgements/acknowledgement.rb +2 -1
  24. data/lib/candy_check/play_store/product_purchases/product_purchase.rb +3 -3
  25. data/lib/candy_check/play_store/product_purchases/product_verification.rb +1 -1
  26. data/lib/candy_check/play_store/subscription_purchases/subscription_purchase.rb +2 -1
  27. data/lib/candy_check/play_store/subscription_purchases/subscription_verification.rb +1 -0
  28. data/lib/candy_check/play_store/verification_failure.rb +2 -2
  29. data/lib/candy_check/utils/attribute_reader.rb +3 -2
  30. data/lib/candy_check/utils/config.rb +2 -0
  31. data/lib/candy_check/utils.rb +2 -2
  32. data/lib/candy_check/version.rb +1 -1
  33. data/lib/candy_check.rb +4 -4
  34. data/spec/app_store/client_spec.rb +18 -18
  35. data/spec/app_store/config_spec.rb +9 -9
  36. data/spec/app_store/receipt_collection_spec.rb +38 -40
  37. data/spec/app_store/receipt_spec.rb +47 -47
  38. data/spec/app_store/subscription_verification_spec.rb +35 -32
  39. data/spec/app_store/verifcation_failure_spec.rb +7 -7
  40. data/spec/app_store/verification_spec.rb +23 -11
  41. data/spec/app_store/verifier_spec.rb +40 -48
  42. data/spec/cli/app_spec.rb +11 -13
  43. data/spec/cli/commands/app_store_spec.rb +22 -23
  44. data/spec/cli/commands/play_store_spec.rb +3 -1
  45. data/spec/cli/commands/version_spec.rb +2 -2
  46. data/spec/cli/out_spec.rb +9 -9
  47. data/spec/play_store/acknowledger_spec.rb +4 -0
  48. data/spec/play_store/product_acknowledgements/acknowledgement_spec.rb +4 -0
  49. data/spec/play_store/product_acknowledgements/response_spec.rb +16 -15
  50. data/spec/play_store/product_purchases/product_purchase_spec.rb +6 -27
  51. data/spec/play_store/subscription_purchases/subscription_purchase_spec.rb +22 -46
  52. data/spec/play_store/verification_failure_spec.rb +6 -4
  53. data/spec/play_store/verifier_spec.rb +4 -2
  54. data/spec/spec_helper.rb +5 -7
  55. metadata +76 -76
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0609ac137a3e05f673213d7f5583809227f63986a17c6624bdea3996c6fe60ff'
4
- data.tar.gz: 3e3a451db11ffa96877fd280372c968131f4f2d81697d519963193e5678f31d9
3
+ metadata.gz: 0a0364f397bae2516f6fcb5c051bcffed96864f588a731d82679a41ee1149722
4
+ data.tar.gz: ef8356c0946eddebd063ae602be5a6eed3a6f42499b4adf582aa3f17c7f39b27
5
5
  SHA512:
6
- metadata.gz: ee72d24027ee9c5ae4131e8eca1ba3a52e9e3376227e1b204fdc2a87c0bc53d81cf581b615724b716539f19a59b3535d15d9b3e1e875c1552e87a75ef7f90ddc
7
- data.tar.gz: 7336d9f3808127cac0469b7f2c90867b96567ae35acaf53c9b15528d3bcbf9cc6cb956226291d8fac284aceea1ac676e8d748a104764823d08f14eec83d366b7
6
+ metadata.gz: aead43177558961e62bbfddefbec2f6486715060ad4d304b464e8742a5ff57835a0162d9510e76b0ec8be7478b78eacf6e1ae921dd8a2cac9b942380f1aec073
7
+ data.tar.gz: ef8e0dc05dcd0c22d8ff65c51deabe536d69a4d33e00ac60aa1cb0d6424bc5ecfeb9afe1c3d8f85b01de656635a548a2b82170823811b3fd02648fed2f2e7382
@@ -10,6 +10,7 @@ jobs:
10
10
  - "2.7"
11
11
  - "3.0"
12
12
  - "3.1"
13
+ - "3.2"
13
14
  - "jruby-9.3.10.0"
14
15
  - "jruby-9.4.1.0"
15
16
  steps:
data/.rubocop.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  AllCops:
2
+ TargetRubyVersion: 2.6
2
3
  Exclude:
3
4
  - 'spec/support/*'
4
5
  - 'bin/**/*'
@@ -7,6 +8,8 @@ Style/Documentation:
7
8
  Enabled: false
8
9
  Style/FrozenStringLiteralComment:
9
10
  Enabled: false
11
+ Style/StringLiterals:
12
+ EnforcedStyle: double_quotes
10
13
  Style/NumericPredicate:
11
14
  Enabled: false
12
15
  Lint/UnifiedInteger:
@@ -19,6 +22,7 @@ Style/PercentLiteralDelimiters:
19
22
  Metrics/BlockLength:
20
23
  Exclude:
21
24
  - 'spec/**/*'
25
+ - '*.gemspec'
22
26
  Security/MarshalLoad:
23
27
  Exclude:
24
28
  - 'lib/candy_check/play_store/discovery_repository.rb'
@@ -28,3 +32,9 @@ Style/Encoding:
28
32
  Enabled: false
29
33
  Style/ExpandPathArguments:
30
34
  Enabled: false
35
+ Style/TrailingCommaInArrayLiteral:
36
+ EnforcedStyleForMultiline: comma
37
+ Style/TrailingCommaInArguments:
38
+ EnforcedStyleForMultiline: comma
39
+ Style/TrailingCommaInHashLiteral:
40
+ EnforcedStyleForMultiline: comma
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.3
1
+ 3.2.1
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in candy_check.gemspec
4
4
  gemspec
data/Guardfile CHANGED
@@ -2,8 +2,10 @@
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
4
  ## Uncomment and set this to only include directories you want to watch
5
- directories %w(lib spec) \
6
- .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
5
+ directories(
6
+ %w(lib spec) \
7
+ .select { |d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist") },
8
+ )
7
9
 
8
10
  ## Note: if you are using the `directories` clause above and you are not
9
11
  ## watching the project directory ('.'), then you will want to move
@@ -24,7 +26,7 @@ guard :minitest do
24
26
  # with Minitest::Spec
25
27
  watch(%r{^spec/(.*)_spec\.rb$})
26
28
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
27
- watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
29
+ watch(%r{^spec/spec_helper\.rb$}) { "spec" }
28
30
 
29
31
  # Rails 4
30
32
  # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env rake
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rake/testtask'
5
- require 'rubocop/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+ require "rubocop/rake_task"
6
6
 
7
7
  Rake::TestTask.new(:spec) do |test|
8
- test.test_files = FileList['spec/**/*_spec.rb']
9
- test.libs << 'spec'
8
+ test.test_files = FileList["spec/**/*_spec.rb"]
9
+ test.libs << "spec"
10
10
  test.verbose = true
11
11
  end
12
12
 
data/candy_check.gemspec CHANGED
@@ -20,25 +20,25 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = Gem::Requirement.new(">= 2.6")
22
22
 
23
- spec.add_dependency "google-apis-androidpublisher_v3", "~> 0.25.0"
24
- spec.add_dependency "googleauth", "~> 1.2.0"
23
+ spec.add_dependency "google-apis-androidpublisher_v3", "~> 0.34.0"
24
+ spec.add_dependency "googleauth", "~> 1.3.0"
25
25
  spec.add_dependency "multi_json", "~> 1.15"
26
26
  spec.add_dependency "thor", "< 2.0"
27
27
 
28
+ spec.add_development_dependency "awesome_print"
28
29
  spec.add_development_dependency "bundler", "~> 2.0"
30
+ spec.add_development_dependency "guard"
31
+ spec.add_development_dependency "guard-minitest"
29
32
  spec.add_development_dependency "inch", "~> 0.7"
30
33
  spec.add_development_dependency "minitest", "~> 5.10"
31
34
  spec.add_development_dependency "minitest-around", "~> 0.4"
32
35
  spec.add_development_dependency "minitest-focus"
33
- spec.add_development_dependency "rake", "~> 12.0"
34
- spec.add_development_dependency "rubocop", "~> 0.48"
35
- spec.add_development_dependency "timecop", "~> 0.8"
36
- spec.add_development_dependency "webmock", "~> 3.0"
37
- spec.add_development_dependency "vcr"
38
36
  spec.add_development_dependency "pry"
39
- spec.add_development_dependency "awesome_print"
40
- spec.add_development_dependency "guard"
41
- spec.add_development_dependency "guard-minitest"
37
+ spec.add_development_dependency "rake", "~> 13.0"
38
+ spec.add_development_dependency "rubocop", "~> 1.46"
42
39
  spec.add_development_dependency "simplecov", "~> 0.18.0"
43
40
  spec.add_development_dependency "simplecov-lcov", "~> 0.8.0"
41
+ spec.add_development_dependency "timecop", "~> 0.9"
42
+ spec.add_development_dependency "vcr", "~> 6.1"
43
+ spec.add_development_dependency "webmock", "~> 3.0"
44
44
  end
@@ -1,5 +1,5 @@
1
- require 'multi_json'
2
- require 'net/http'
1
+ require "multi_json"
2
+ require "net/http"
3
3
 
4
4
  module CandyCheck
5
5
  module AppStore
@@ -7,7 +7,7 @@ module CandyCheck
7
7
  # servers (either sandbox or production).
8
8
  class Client
9
9
  # Mimetype for JSON objects
10
- JSON_MIME_TYPE = 'application/json'.freeze
10
+ JSON_MIME_TYPE = "application/json".freeze
11
11
 
12
12
  # Initialize a new client bound to an endpoint
13
13
  # @param endpoint_url [String]
@@ -40,17 +40,17 @@ module CandyCheck
40
40
 
41
41
  def build_request(parameters)
42
42
  Net::HTTP::Post.new(@uri.request_uri).tap do |post|
43
- post['Accept'] = JSON_MIME_TYPE
44
- post['Content-Type'] = JSON_MIME_TYPE
43
+ post["Accept"] = JSON_MIME_TYPE
44
+ post["Content-Type"] = JSON_MIME_TYPE
45
45
  post.body = MultiJson.dump(parameters)
46
46
  end
47
47
  end
48
48
 
49
49
  def build_request_parameters(receipt_data, secret)
50
50
  {
51
- 'receipt-data' => receipt_data
51
+ "receipt-data" => receipt_data,
52
52
  }.tap do |h|
53
- h['password'] = secret if secret
53
+ h["password"] = secret if secret
54
54
  end
55
55
  end
56
56
  end
@@ -5,15 +5,13 @@ module CandyCheck
5
5
  # @return [Symbol] the used environment
6
6
  attr_reader :environment
7
7
 
8
- # Initializes a new configuration from a hash
9
- # @param attributes [Hash]
10
- # @example
11
- # Config.new(
12
- # environment: :production # or :sandbox
13
- # )
14
- def initialize(attributes)
15
- super
16
- end
8
+ # @!method initialize(attributes)
9
+ # Initializes a new configuration from a hash
10
+ # @param attributes [Hash]
11
+ # @example
12
+ # Config.new(
13
+ # environment: :production # or :sandbox
14
+ # )
17
15
 
18
16
  # @return [Boolean] if it is production environment
19
17
  def production?
@@ -18,63 +18,63 @@ module CandyCheck
18
18
  # transaction was canceled.
19
19
  # @return [Boolean]
20
20
  def valid?
21
- !has?('cancellation_date')
21
+ !has?("cancellation_date")
22
22
  end
23
23
 
24
24
  # The receipt's transaction id
25
25
  # @return [String]
26
26
  def transaction_id
27
- read('transaction_id')
27
+ read("transaction_id")
28
28
  end
29
29
 
30
30
  # The receipt's original transaction id which might differ from
31
31
  # the transaction id for restored products
32
32
  # @return [String]
33
33
  def original_transaction_id
34
- read('original_transaction_id')
34
+ read("original_transaction_id")
35
35
  end
36
36
 
37
37
  # The version number for the app
38
38
  # @return [String]
39
39
  def app_version
40
- read('bvrs')
40
+ read("bvrs")
41
41
  end
42
42
 
43
43
  # The app's bundle identifier
44
44
  # @return [String]
45
45
  def bundle_identifier
46
- read('bid')
46
+ read("bid")
47
47
  end
48
48
 
49
49
  # The app's identifier of the product (SKU)
50
50
  # @return [String]
51
51
  def product_id
52
- read('product_id')
52
+ read("product_id")
53
53
  end
54
54
 
55
55
  # The app's item id of the product
56
56
  # @return [String]
57
57
  def item_id
58
- read('item_id')
58
+ read("item_id")
59
59
  end
60
60
 
61
61
  # The quantity of the product
62
- # @return [Fixnum]
62
+ # @return [Integer]
63
63
  def quantity
64
- read_integer('quantity')
64
+ read_integer("quantity")
65
65
  end
66
66
 
67
67
  # The purchase date
68
68
  # @return [DateTime]
69
69
  def purchase_date
70
- read_datetime_from_string('purchase_date')
70
+ read_datetime_from_string("purchase_date")
71
71
  end
72
72
 
73
73
  # The original purchase date which might differ from the
74
74
  # actual purchase date for restored products
75
75
  # @return [DateTime]
76
76
  def original_purchase_date
77
- read_datetime_from_string('original_purchase_date')
77
+ read_datetime_from_string("original_purchase_date")
78
78
  end
79
79
 
80
80
  # The date of when Apple has canceled this transaction.
@@ -82,19 +82,19 @@ module CandyCheck
82
82
  # the same as if no purchase had ever been made."
83
83
  # @return [DateTime]
84
84
  def cancellation_date
85
- read_datetime_from_string('cancellation_date')
85
+ read_datetime_from_string("cancellation_date")
86
86
  end
87
87
 
88
88
  # The date of a subscription's expiration
89
89
  # @return [DateTime]
90
90
  def expires_date
91
- read_datetime_from_string('expires_date')
91
+ read_datetime_from_string("expires_date")
92
92
  end
93
93
 
94
- # rubocop:disable PredicateName
94
+ # rubocop:disable Naming/PredicateName
95
95
  def is_trial_period
96
- # rubocop:enable PredicateName
97
- read_bool('is_trial_period')
96
+ # rubocop:enable Naming/PredicateName
97
+ read_bool("is_trial_period")
98
98
  end
99
99
  end
100
100
  end
@@ -10,9 +10,9 @@ module CandyCheck
10
10
  # from Apple's verification server
11
11
  # @param attributes [Array<Hash>] raw data from Apple's server
12
12
  def initialize(attributes)
13
- @receipts = attributes.map {|r| Receipt.new(r) }.sort{ |a, b|
13
+ @receipts = attributes.map { |r| Receipt.new(r) }.sort do |a, b|
14
14
  a.purchase_date - b.purchase_date
15
- }
15
+ end
16
16
  end
17
17
 
18
18
  # Check if the latest expiration date is passed
@@ -24,9 +24,9 @@ module CandyCheck
24
24
  def call!
25
25
  verify!
26
26
  if valid?
27
- build_collection(@response['latest_receipt_info'])
27
+ build_collection(@response["latest_receipt_info"])
28
28
  else
29
- VerificationFailure.fetch(@response['status'])
29
+ VerificationFailure.fetch(@response["status"])
30
30
  end
31
31
  end
32
32
 
@@ -35,15 +35,15 @@ module CandyCheck
35
35
  def build_collection(latest_receipt_info)
36
36
  unless @product_ids.nil?
37
37
  latest_receipt_info = latest_receipt_info.select do |info|
38
- @product_ids.include?(info['product_id'])
38
+ @product_ids.include?(info["product_id"])
39
39
  end
40
40
  end
41
41
  ReceiptCollection.new(latest_receipt_info)
42
42
  end
43
43
 
44
44
  def valid?
45
- status_is_ok = @response['status'] == STATUS_OK
46
- @response && status_is_ok && @response['latest_receipt_info']
45
+ status_is_ok = @response["status"] == STATUS_OK
46
+ @response && status_is_ok && @response["latest_receipt_info"]
47
47
  end
48
48
  end
49
49
  end
@@ -29,16 +29,16 @@ module CandyCheck
29
29
  def call!
30
30
  verify!
31
31
  if valid?
32
- Receipt.new(@response['receipt'])
32
+ Receipt.new(@response["receipt"])
33
33
  else
34
- VerificationFailure.fetch(@response['status'])
34
+ VerificationFailure.fetch(@response["status"])
35
35
  end
36
36
  end
37
37
 
38
38
  private
39
39
 
40
40
  def valid?
41
- @response && @response['status'] == STATUS_OK && @response['receipt']
41
+ @response && @response["status"] == STATUS_OK && @response["receipt"]
42
42
  end
43
43
 
44
44
  def verify!
@@ -2,7 +2,7 @@ module CandyCheck
2
2
  module AppStore
3
3
  # Represents a failing call against the verification server
4
4
  class VerificationFailure
5
- # @return [Fixnum] the code of the failure
5
+ # @return [Integer] the code of the failure
6
6
  attr_reader :code
7
7
 
8
8
  # @return [String] the message of the failure
@@ -10,7 +10,7 @@ module CandyCheck
10
10
 
11
11
  # Initializes a new instance which bases on a JSON result
12
12
  # from Apple servers
13
- # @param code [Fixnum]
13
+ # @param code [Integer]
14
14
  # @param message [String]
15
15
  def initialize(code, message)
16
16
  @code = code
@@ -20,7 +20,7 @@ module CandyCheck
20
20
  class << self
21
21
  # Gets a known failure or build an unknown failure
22
22
  # without description
23
- # @param code [Fixnum]
23
+ # @param code [Integer]
24
24
  # @return [VerificationFailure]
25
25
  def fetch(code)
26
26
  known.fetch(code) do
@@ -31,7 +31,7 @@ module CandyCheck
31
31
  private
32
32
 
33
33
  def fallback(code)
34
- new(code || -1, 'Unknown error')
34
+ new(code || -1, "Unknown error")
35
35
  end
36
36
 
37
37
  def known
@@ -47,23 +47,27 @@ module CandyCheck
47
47
  end
48
48
  end
49
49
 
50
- add 21_000, 'The App Store could not read the JSON object you provided.'
51
- add 21_002, 'The data in the receipt-data property was malformed' \
52
- ' or missing.'
53
- add 21_003, 'The receipt could not be authenticated.'
54
- add 21_004, 'The shared secret you provided does not match the shared' \
55
- ' secret on file for your account.'
56
- add 21_005, 'The receipt server is not currently available.'
57
- add 21_006, 'This receipt is valid but the subscription has expired.' \
58
- ' When this status code is returned to your server, the' \
59
- ' receipt data is also decoded and returned as part of'\
60
- ' the response.'
61
- add 21_007, 'This receipt is from the test environment, but it was' \
62
- ' sent to the production environment for verification.' \
63
- ' Send it to the test environment instead.'
64
- add 21_008, 'This receipt is from the production environment, but it' \
65
- ' was sent to the test environment for verification.' \
66
- ' Send it to the production environment instead.'
50
+ add 21_000, "The request to the App Store was not made using" \
51
+ " the HTTP POST request method."
52
+ add 21_001, "This status code is no longer sent by the App Store."
53
+ add 21_002, "The data in the receipt-data property was malformed" \
54
+ " or the service experienced a temporary issue. Try again."
55
+ add 21_003, "The receipt could not be authenticated."
56
+ add 21_004, "The shared secret you provided does not match the shared" \
57
+ " secret on file for your account."
58
+ add 21_005, "The receipt server was temporarily unable to provide" \
59
+ " the receipt. Try again."
60
+ add 21_006, "This receipt is valid but the subscription has expired." \
61
+ " When this status code is returned to your server, the" \
62
+ " receipt data is also decoded and returned as part of" \
63
+ " the response. Only returned for iOS 6-style transaction" \
64
+ " receipts for auto-renewable subscriptions."
65
+ add 21_007, "This receipt is from the test environment, but it was" \
66
+ " sent to the production environment for verification."
67
+ add 21_008, "This receipt is from the production environment, but it" \
68
+ " was sent to the test environment for verification."
69
+ add 21_009, "Internal data access error. Try again later."
70
+ add 21_010, "The user account cannot be found or has been deleted."
67
71
  freeze!
68
72
  end
69
73
  end
@@ -4,9 +4,9 @@ module CandyCheck
4
4
  # The call return either an {Receipt} or a {VerificationFailure}
5
5
  class Verifier
6
6
  # HTTPS endpoint for production receipts
7
- PRODUCTION_ENDPOINT = 'https://buy.itunes.apple.com/verifyReceipt'.freeze
7
+ PRODUCTION_ENDPOINT = "https://buy.itunes.apple.com/verifyReceipt".freeze
8
8
  # HTTPS endpoint for sandbox receipts
9
- SANDBOX_ENDPOINT = 'https://sandbox.itunes.apple.com/verifyReceipt'.freeze
9
+ SANDBOX_ENDPOINT = "https://sandbox.itunes.apple.com/verifyReceipt".freeze
10
10
  # Status code from production endpoint when receiving a sandbox
11
11
  # receipt which occurs during the app's review process
12
12
  REDIRECT_TO_SANDBOX_CODE = 21_007
@@ -49,9 +49,8 @@ module CandyCheck
49
49
  def fetch_receipt_information(verifier_class, args)
50
50
  default_endpoint, opposite_endpoint = endpoints
51
51
  result = call_for(verifier_class, args.dup.unshift(default_endpoint))
52
- if should_retry?(result)
53
- return call_for(verifier_class, args.dup.unshift(opposite_endpoint))
54
- end
52
+ return call_for(verifier_class, args.dup.unshift(opposite_endpoint)) if should_retry?(result)
53
+
55
54
  result
56
55
  end
57
56
 
@@ -1,11 +1,11 @@
1
- require 'candy_check/app_store/client'
2
- require 'candy_check/app_store/config'
3
- require 'candy_check/app_store/receipt'
4
- require 'candy_check/app_store/receipt_collection'
5
- require 'candy_check/app_store/verification'
6
- require 'candy_check/app_store/subscription_verification'
7
- require 'candy_check/app_store/verification_failure'
8
- require 'candy_check/app_store/verifier'
1
+ require "candy_check/app_store/client"
2
+ require "candy_check/app_store/config"
3
+ require "candy_check/app_store/receipt"
4
+ require "candy_check/app_store/receipt_collection"
5
+ require "candy_check/app_store/verification"
6
+ require "candy_check/app_store/subscription_verification"
7
+ require "candy_check/app_store/verification_failure"
8
+ require "candy_check/app_store/verifier"
9
9
 
10
10
  module CandyCheck
11
11
  # Module to request and verify a AppStore receipt
@@ -35,7 +35,7 @@ module CandyCheck
35
35
  Commands::PlayStore.run(package, product_id, token, **options)
36
36
  end
37
37
 
38
- desc "version", 'Print the gem\'s version'
38
+ desc "version", "Print the gem's version"
39
39
 
40
40
  def version
41
41
  Commands::Version.run
@@ -25,7 +25,7 @@ module CandyCheck
25
25
 
26
26
  def config
27
27
  CandyCheck::AppStore::Config.new(
28
- environment: options[:environment].to_sym
28
+ environment: options[:environment].to_sym,
29
29
  )
30
30
  end
31
31
  end
@@ -1,7 +1,7 @@
1
- require 'candy_check/cli/commands/base'
2
- require 'candy_check/cli/commands/app_store'
3
- require 'candy_check/cli/commands/play_store'
4
- require 'candy_check/cli/commands/version'
1
+ require "candy_check/cli/commands/base"
2
+ require "candy_check/cli/commands/app_store"
3
+ require "candy_check/cli/commands/play_store"
4
+ require "candy_check/cli/commands/version"
5
5
 
6
6
  module CandyCheck
7
7
  module CLI
@@ -1,5 +1,3 @@
1
- require 'pp'
2
-
3
1
  module CandyCheck
4
2
  module CLI
5
3
  # A wrapper to output text information to any kind of buffer
@@ -18,7 +16,7 @@ module CandyCheck
18
16
 
19
17
  # Prints to +out+
20
18
  # @param text [String]
21
- def print(text = '')
19
+ def print(text = "")
22
20
  out.puts text
23
21
  end
24
22
 
@@ -1,6 +1,6 @@
1
- require 'candy_check/cli/app'
2
- require 'candy_check/cli/commands'
3
- require 'candy_check/cli/out'
1
+ require "candy_check/cli/app"
2
+ require "candy_check/cli/commands"
3
+ require "candy_check/cli/out"
4
4
 
5
5
  module CandyCheck
6
6
  # Namespace holding the implementation of the CLI to
@@ -26,7 +26,8 @@ module CandyCheck
26
26
  acknowledge!
27
27
 
28
28
  CandyCheck::PlayStore::ProductAcknowledgements::Response.new(
29
- result: @response[:result], error_data: @response[:error_data])
29
+ result: @response[:result], error_data: @response[:error_data],
30
+ )
30
31
  end
31
32
 
32
33
  private
@@ -26,7 +26,7 @@ module CandyCheck
26
26
  # The purchase state of the order. Possible values are:
27
27
  # * 0: Purchased
28
28
  # * 1: Cancelled
29
- # @return [Fixnum]
29
+ # @return [Integer]
30
30
  def purchase_state
31
31
  @product_purchase.purchase_state
32
32
  end
@@ -34,7 +34,7 @@ module CandyCheck
34
34
  # The consumption state of the inapp product. Possible values are:
35
35
  # * 0: Yet to be consumed
36
36
  # * 1: Consumed
37
- # @return [Fixnum]
37
+ # @return [Integer]
38
38
  def consumption_state
39
39
  @product_purchase.consumption_state
40
40
  end
@@ -60,7 +60,7 @@ module CandyCheck
60
60
 
61
61
  # The time the product was purchased, in milliseconds since the
62
62
  # epoch (Jan 1, 1970)
63
- # @return [Fixnum]
63
+ # @return [Integer]
64
64
  def purchase_time_millis
65
65
  @product_purchase.purchase_time_millis
66
66
  end
@@ -37,7 +37,7 @@ module CandyCheck
37
37
  private
38
38
 
39
39
  def valid?
40
- @response[:result] && @response[:result].purchase_state && @response[:result].consumption_state
40
+ @response[:result]&.purchase_state && @response[:result]&.consumption_state
41
41
  end
42
42
 
43
43
  def verify!
@@ -5,7 +5,8 @@ module CandyCheck
5
5
  class SubscriptionPurchase
6
6
  include Utils::AttributeReader
7
7
 
8
- # @return [Google::Apis::AndroidpublisherV3::SubscriptionPurchase] the raw subscription purchase from google-api-client
8
+ # @return [Google::Apis::AndroidpublisherV3::SubscriptionPurchase] the raw subscription purchase
9
+ # from google-api-client
9
10
  attr_reader :subscription_purchase
10
11
 
11
12
  # The payment of the subscription is pending (paymentState)
@@ -38,6 +38,7 @@ module CandyCheck
38
38
 
39
39
  def valid?
40
40
  return false unless @response[:result]
41
+
41
42
  ok_kind = @response[:result].kind == "androidpublisher#subscriptionPurchase"
42
43
  @response && @response[:result].expiry_time_millis && ok_kind
43
44
  end
@@ -15,10 +15,10 @@ module CandyCheck
15
15
  end
16
16
 
17
17
  # The code of the failure
18
- # @return [Fixnum]
18
+ # @return [Integer]
19
19
  def code
20
20
  Integer(error.status_code)
21
- rescue
21
+ rescue StandardError
22
22
  -1
23
23
  end
24
24