candy_check 0.1.2 → 0.2.0
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 +4 -4
- data/.travis.yml +5 -12
- data/Guardfile +42 -0
- data/MIGRATION_GUIDE_0_2_0.md +141 -0
- data/README.md +49 -26
- data/candy_check.gemspec +32 -26
- data/lib/candy_check/cli/app.rb +16 -33
- data/lib/candy_check/cli/commands/play_store.rb +12 -13
- data/lib/candy_check/play_store.rb +17 -10
- data/lib/candy_check/play_store/android_publisher_service.rb +6 -0
- data/lib/candy_check/play_store/product_purchases/product_purchase.rb +90 -0
- data/lib/candy_check/play_store/product_purchases/product_verification.rb +53 -0
- data/lib/candy_check/play_store/subscription_purchases/subscription_purchase.rb +141 -0
- data/lib/candy_check/play_store/subscription_purchases/subscription_verification.rb +55 -0
- data/lib/candy_check/play_store/verification_failure.rb +8 -6
- data/lib/candy_check/play_store/verifier.rb +24 -49
- data/lib/candy_check/version.rb +1 -1
- data/spec/candy_check_spec.rb +2 -2
- data/spec/cli/commands/play_store_spec.rb +10 -43
- data/spec/fixtures/play_store/random_dummy_key.json +12 -0
- data/spec/fixtures/vcr_cassettes/play_store/product_purchases/permission_denied.yml +196 -0
- data/spec/fixtures/vcr_cassettes/play_store/product_purchases/response_with_empty_body.yml +183 -0
- data/spec/fixtures/vcr_cassettes/play_store/product_purchases/valid_but_not_consumed.yml +122 -0
- data/spec/fixtures/vcr_cassettes/play_store/subscription_purchases/permission_denied.yml +196 -0
- data/spec/fixtures/vcr_cassettes/play_store/subscription_purchases/valid_but_expired.yml +127 -0
- data/spec/play_store/product_purchases/product_purchase_spec.rb +110 -0
- data/spec/play_store/product_purchases/product_verification_spec.rb +49 -0
- data/spec/play_store/subscription_purchases/subscription_purchase_spec.rb +181 -0
- data/spec/play_store/subscription_purchases/subscription_verification_spec.rb +65 -0
- data/spec/play_store/verification_failure_spec.rb +18 -18
- data/spec/play_store/verifier_spec.rb +32 -96
- data/spec/spec_helper.rb +24 -11
- metadata +120 -47
- data/lib/candy_check/play_store/client.rb +0 -139
- data/lib/candy_check/play_store/config.rb +0 -51
- data/lib/candy_check/play_store/discovery_repository.rb +0 -33
- data/lib/candy_check/play_store/receipt.rb +0 -81
- data/lib/candy_check/play_store/subscription.rb +0 -139
- data/lib/candy_check/play_store/subscription_verification.rb +0 -30
- data/lib/candy_check/play_store/verification.rb +0 -48
- data/spec/fixtures/api_cache.dump +0 -1
- data/spec/fixtures/play_store/api_cache.dump +0 -1
- data/spec/fixtures/play_store/auth_failure.txt +0 -18
- data/spec/fixtures/play_store/auth_success.txt +0 -20
- data/spec/fixtures/play_store/discovery.txt +0 -2841
- data/spec/fixtures/play_store/dummy.p12 +0 -0
- data/spec/fixtures/play_store/empty.txt +0 -17
- data/spec/fixtures/play_store/products_failure.txt +0 -29
- data/spec/fixtures/play_store/products_success.txt +0 -22
- data/spec/play_store/client_spec.rb +0 -125
- data/spec/play_store/config_spec.rb +0 -96
- data/spec/play_store/discovery_respository_spec.rb +0 -31
- data/spec/play_store/receipt_spec.rb +0 -88
- data/spec/play_store/subscription_spec.rb +0 -138
- data/spec/play_store/subscription_verification_spec.rb +0 -97
- data/spec/play_store/verification_spec.rb +0 -81
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f276e0409f0b3ee54bd5543e939d7635c95059dfc5ae77d9b071d5715d1e291f
|
4
|
+
data.tar.gz: 56858af56be773214faae7e848e4aa9ae5a30b8cba2da782aca8554da7895c94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eb5506e96216125602b47994b99f8038aa20aecf17cf2515ba5ab7578f06415735301f793aa64786bddad59a4c0296bdf5f6f3545151ee0b1f104b7a5eef262
|
7
|
+
data.tar.gz: a6084226820a90997d852976659841930fbeaf5d79507fe392d8551447f0000a3016636f317f79f1af50cb9501f355905a96203751162153ac210ac97bcca519
|
data/.travis.yml
CHANGED
@@ -2,19 +2,12 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
- 2.5
|
6
|
-
- 2.
|
7
|
-
- 2.4.
|
8
|
-
- 2.
|
9
|
-
- 2.2
|
10
|
-
- 2.1
|
11
|
-
- 2.0
|
5
|
+
- 2.6.5
|
6
|
+
- 2.5.7
|
7
|
+
- 2.4.9
|
8
|
+
- jruby-9.2.9.0
|
12
9
|
- ruby-head
|
13
|
-
- jruby-1.7.26
|
14
10
|
- jruby-head
|
15
|
-
env:
|
16
|
-
global:
|
17
|
-
- JRUBY_OPTS="--2.0"
|
18
11
|
matrix:
|
19
12
|
allow_failures:
|
20
13
|
- rvm: ruby-head
|
@@ -22,4 +15,4 @@ matrix:
|
|
22
15
|
fast_finish: true
|
23
16
|
before_install:
|
24
17
|
- gem update --system
|
25
|
-
- gem install bundler -v
|
18
|
+
- gem install bundler -v 2.0.2
|
data/Guardfile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
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")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
guard :minitest do
|
19
|
+
# with Minitest::Unit
|
20
|
+
# watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
21
|
+
# watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
22
|
+
# watch(%r{^test/test_helper\.rb$}) { 'test' }
|
23
|
+
|
24
|
+
# with Minitest::Spec
|
25
|
+
watch(%r{^spec/(.*)_spec\.rb$})
|
26
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
27
|
+
watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
|
28
|
+
|
29
|
+
# Rails 4
|
30
|
+
# watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
31
|
+
# watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
|
32
|
+
# watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
|
33
|
+
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
34
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
|
35
|
+
# watch(%r{^test/.+_test\.rb$})
|
36
|
+
# watch(%r{^test/test_helper\.rb$}) { 'test' }
|
37
|
+
|
38
|
+
# Rails < 4
|
39
|
+
# watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
|
40
|
+
# watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
|
41
|
+
# watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
|
42
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# Migration Guide from v0.1.x to v0.2.0
|
2
|
+
|
3
|
+
Due to changes in the PlayStore API, Candy Check needed to introduce some breaking changes in version `0.2.0`.
|
4
|
+
|
5
|
+
To adapt your old implementation to these changes, follow the steps below:
|
6
|
+
|
7
|
+
## Authorization
|
8
|
+
|
9
|
+
First we have to change, how our verifier authenticates against the Google API.
|
10
|
+
|
11
|
+
Change code like this
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
# < v0.2.0
|
15
|
+
config = CandyCheck::PlayStore::Config.new(
|
16
|
+
application_name: 'YourApplication',
|
17
|
+
application_version: '1.0',
|
18
|
+
issuer: 'abcdefg@developer.gserviceaccount.com',
|
19
|
+
key_file: 'local/google.p12',
|
20
|
+
key_secret: 'notasecret',
|
21
|
+
cache_file: 'tmp/candy_check_play_store_cache'
|
22
|
+
)
|
23
|
+
verifier = CandyCheck::PlayStore::Verifier.new(config)
|
24
|
+
verifier.boot!
|
25
|
+
```
|
26
|
+
|
27
|
+
to
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# v0.2.0
|
31
|
+
authorization = CandyCheck::PlayStore.authorization("/path/to/key.json")
|
32
|
+
verifier = CandyCheck::PlayStore::Verifier.new(authorization: authorization)
|
33
|
+
```
|
34
|
+
|
35
|
+
If you're not sure how to get a `.json` key file, follow this part of the [`README`](/README.md#getting-the-json-key-file).
|
36
|
+
|
37
|
+
If you need other means of authentication follow this part of the [`README`](/README.md#building-an-authorization-object).
|
38
|
+
|
39
|
+
## Verifying Purchases
|
40
|
+
|
41
|
+
To be more descriptive and consistent with the PlayStore API, the verifier got a new signature and return values have been adapted accordingly.
|
42
|
+
|
43
|
+
### Verifying Product Purchases
|
44
|
+
|
45
|
+
Change all occurences of
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# < v0.2.0
|
49
|
+
verifier.verify("my-package-name", "my product id", "my token")
|
50
|
+
# => Receipt or VerificationFailure
|
51
|
+
```
|
52
|
+
|
53
|
+
to
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
# v0.2.0
|
57
|
+
verifier.verify_product_purchase(
|
58
|
+
package_name: "my-package-name",
|
59
|
+
product_id: "my product id",
|
60
|
+
token: "my token"
|
61
|
+
)
|
62
|
+
# => ProductPurchase or VerificationFailure
|
63
|
+
```
|
64
|
+
|
65
|
+
*NOTE:* Take a closer look at the possible return values: `CandyCheck::PlayStore::Receipt` was moved to `CandyCheck::PlayStore::ProductPurchases::ProductPurchase`. In case you're matching at the class name of the result, please adapt your code accordingly.
|
66
|
+
|
67
|
+
#### Accessing Raw ProductPurchase Attributes
|
68
|
+
|
69
|
+
CandyCheck `< 0.2.0` provided the raw `ProductPurchase` attributes given by the PlayStore API like this:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
# < v0.2.0
|
73
|
+
result = verifier.verify("my-package-name", "my product id", "my token")
|
74
|
+
result.attributes
|
75
|
+
# => Hash
|
76
|
+
```
|
77
|
+
|
78
|
+
To get the same behaviour in CandyCheck `0.2.0`, change the code above to:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
# v0.2.0
|
82
|
+
result = verifier.verify_product_purchase(
|
83
|
+
package_name: "my-package-name",
|
84
|
+
product_id: "my product id",
|
85
|
+
token: "my token"
|
86
|
+
)
|
87
|
+
result.product_purchase.to_h
|
88
|
+
# => Hash
|
89
|
+
```
|
90
|
+
|
91
|
+
The hash key access must be changed from strings in `camelCase` to symbols in `snake_case`:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
# < 0.2.0
|
95
|
+
result.attributes["purchaseState"]
|
96
|
+
|
97
|
+
# 0.2.0
|
98
|
+
result.product_purchase.to_h[:purchase_state]
|
99
|
+
```
|
100
|
+
|
101
|
+
## Verifying Subscription Purchases
|
102
|
+
|
103
|
+
Change all occurences of
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
# < v0.2.0
|
107
|
+
verifier.verify_subscription("my-package-name", "my-subscription-id", "my-token")
|
108
|
+
# => Subscription or VerificationFailure
|
109
|
+
```
|
110
|
+
|
111
|
+
to
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
# v0.2.0
|
115
|
+
verifier.verify_subscription_purchase(
|
116
|
+
package_name: "my-package-name",
|
117
|
+
subscription_id: "my-subscription-id",
|
118
|
+
token: "my-token"
|
119
|
+
)
|
120
|
+
# => SubscriptionPurchase or VerificationFailure
|
121
|
+
```
|
122
|
+
|
123
|
+
*NOTE:* Again take a closer look at the possible return values: `CandyCheck::PlayStore::Subscription` was moved to `CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase`. In case you're matching at the class name of the result, please adapt your code accordingly.
|
124
|
+
|
125
|
+
## Using the CLI
|
126
|
+
|
127
|
+
The way the CandyCheck CLI gets used, needed to be changed too.
|
128
|
+
|
129
|
+
The old PlayStore command:
|
130
|
+
|
131
|
+
```bash
|
132
|
+
# < v0.2.0
|
133
|
+
$ candy_check play_store PACKAGE PRODUCT_ID TOKEN --issuer=ISSUER --key-file=KEY_FILE
|
134
|
+
```
|
135
|
+
|
136
|
+
was changed to
|
137
|
+
|
138
|
+
```bash
|
139
|
+
# v0.2.0
|
140
|
+
$ candy_check play_store PACKAGE PRODUCT_ID TOKEN --json-key-file=/path/to/key.json
|
141
|
+
```
|
data/README.md
CHANGED
@@ -43,12 +43,7 @@ called "[service account](https://developers.google.com/accounts/docs/OAuth2Serv
|
|
43
43
|
new account by yourself, export the generated certificate file and grant the correct permissions to the account for
|
44
44
|
your app using the [Google Developer Console](https://console.developers.google.com).
|
45
45
|
|
46
|
-
|
47
|
-
which suggest to use a locally cached service discovery. If you don't omit the `cache_file` configuration this is done
|
48
|
-
automatically.
|
49
|
-
|
50
|
-
If you have set up the Android app correctly you should get a [`purchaseToken`](http://developer.android.com/google/play/billing/billing_reference.html#getBuyIntent) per purchased item. You should use this string in combination with `packageName` and `productId`
|
51
|
-
to verify the purchase.
|
46
|
+
If you have set up the Android app correctly you should get a [`purchaseToken`](http://developer.android.com/google/play/billing/billing_reference.html#getBuyIntent) per purchased item. You should use this string in combination with `packageName` and `productId` to verify the purchase.
|
52
47
|
|
53
48
|
## Usage
|
54
49
|
|
@@ -85,40 +80,68 @@ Please see the class documentation for [`CandyCheck::AppStore::ReceiptCollection
|
|
85
80
|
|
86
81
|
### PlayStore
|
87
82
|
|
88
|
-
|
89
|
-
|
90
|
-
|
83
|
+
> :warning: Version `0.2.0` of `CandyCheck` introduced some breaking changes to the PlayStore functionality to adapt to changes in the Google API. If you're upgrading from a `CandyCheck` version `< 0.2.0` see the [migration guide](/MIGRATION_GUIDE_0_2_0.md) for more.
|
84
|
+
|
85
|
+
#### Authorization
|
86
|
+
|
87
|
+
##### Getting the JSON Key File
|
88
|
+
|
89
|
+
First we have to get a `.json` key file, that gives access to the Google API.
|
90
|
+
|
91
|
+
This `.json` key file can be generated under the following URL (make sure to adapt the `project=my-project-name` parameter accordingly):
|
91
92
|
|
92
|
-
|
93
|
+
[https://console.developers.google.com/apis/credentials/serviceaccountkey?project=my-project-name](https://console.developers.google.com/apis/credentials/serviceaccountkey?project=my-project-name)
|
94
|
+
|
95
|
+
##### Building an Authorization Object
|
96
|
+
|
97
|
+
With the `.json` key file downloaded, we can build an authorization object:
|
93
98
|
|
94
99
|
```ruby
|
95
|
-
|
96
|
-
application_name: 'YourApplication',
|
97
|
-
application_version: '1.0',
|
98
|
-
issuer: 'abcdefg@developer.gserviceaccount.com',
|
99
|
-
key_file: 'local/google.p12',
|
100
|
-
key_secret: 'notasecret',
|
101
|
-
cache_file: 'tmp/candy_check_play_store_cache'
|
102
|
-
)
|
103
|
-
verifier = CandyCheck::PlayStore::Verifier.new(config)
|
104
|
-
verifier.boot!
|
100
|
+
authorization = CandyCheck::PlayStore.authorization("/path/to/key.json")
|
105
101
|
```
|
106
102
|
|
107
|
-
|
103
|
+
> **Note:** `CandyCheck` provides the `CandyCheck::PlayStore.authorization` method as convenience to build an authorization object. In case you need more control over your authorization object, refer to the [`google-auth-library-ruby`](https://github.com/googleapis/google-auth-library-ruby) docs, which describes building authorization objects in detail.
|
104
|
+
|
105
|
+
##### Building a verifier
|
106
|
+
|
107
|
+
With the `authorization` object in place, we can build a verifier:
|
108
108
|
|
109
109
|
```ruby
|
110
|
-
verifier.
|
110
|
+
verifier = CandyCheck::PlayStore::Verifier.new(authorization: authorization)
|
111
111
|
```
|
112
112
|
|
113
|
-
|
113
|
+
> **Note:** If you need to verify against multiple Google Service Accounts, just instantiate a new verifier with another authorization object that got build with a different `.json` key file.
|
114
|
+
|
115
|
+
#### Verifying product purchases
|
116
|
+
|
117
|
+
This `verifier` can be used to verify product purchases in the PlayStore, all you need to do is to pass the `package_name`, `product_id` and `token` of the product purchase you want to verify:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
result = verifier.verify_product_purchase(
|
121
|
+
package_name: "my-package-name",
|
122
|
+
product_id: "my product id",
|
123
|
+
token: "my token"
|
124
|
+
)
|
125
|
+
# => ProductPurchase or VerificationFailure
|
126
|
+
```
|
127
|
+
|
128
|
+
On success this will return an instance of `CandyCheck::Playstore::ProductPurchases::ProductPurchase`, which is a wrapper for the raw [google-api-ruby-client](https://github.com/googleapis/google-api-ruby-client) data, but additionally provides some handy convenience methods.
|
129
|
+
Please see the class documentations [`CandyCheck::PlayStore::ProductPurchases::ProductPurchase`](http://www.rubydoc.info/github/jnbt/candy_check/master/CandyCheck/PlayStore/ProductPurchases/ProductPurchase) and [`CandyCheck::PlayStore::VerificationFailure`](http://www.rubydoc.info/github/jnbt/candy_check/master/CandyCheck/PlayStore/VerificationFailure) for further details about the responses.
|
130
|
+
|
131
|
+
#### Verifying subscriptions
|
114
132
|
|
115
133
|
In order to **verify a subscription** from the Play Store, do the following:
|
116
134
|
|
117
135
|
```ruby
|
118
|
-
verifier.
|
136
|
+
result = verifier.verify_subscription_purchase(
|
137
|
+
package_name: "my-package-name",
|
138
|
+
subscription_id: "my-subscription-id",
|
139
|
+
token: "my-token"
|
140
|
+
)
|
141
|
+
# => SubscriptionPurchase or VerificationFailure
|
119
142
|
```
|
120
143
|
|
121
|
-
Please see documenation for [`CandyCheck::PlayStore::
|
144
|
+
Please see documenation for [`CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase`](http://www.rubydoc.info/github/jnbt/candy_check/master/CandyCheck/PlayStore/SubscriptionPurchases/SubscriptionPurchase) for further details.
|
122
145
|
|
123
146
|
## CLI
|
124
147
|
|
@@ -144,7 +167,7 @@ For the PlayStore you need to specify at least the issuer, the key file, your pa
|
|
144
167
|
purchase token:
|
145
168
|
|
146
169
|
```bash
|
147
|
-
$ candy_check play_store
|
170
|
+
$ candy_check play_store PACKAGE_NAME PRODUCT_ID TOKEN --json-key-file=/path/to/key.json
|
148
171
|
```
|
149
172
|
|
150
173
|
See all options:
|
data/candy_check.gemspec
CHANGED
@@ -1,36 +1,42 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "candy_check/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
12
|
-
spec.summary
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
8
|
+
spec.name = "candy_check"
|
9
|
+
spec.version = CandyCheck::VERSION
|
10
|
+
spec.authors = ["Jonas Thiel", "Christoph Weegen"]
|
11
|
+
spec.email = ["jonas@thiel.io"]
|
12
|
+
spec.summary = "Check and verify in-app receipts"
|
13
|
+
spec.homepage = "https://github.com/jnbt/candy_check"
|
14
|
+
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files
|
17
|
-
spec.executables
|
18
|
-
spec.test_files
|
19
|
-
spec.require_paths = [
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
21
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4")
|
22
22
|
|
23
|
-
spec.add_dependency
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
23
|
+
spec.add_dependency "google-api-client", "~> 0.34.0"
|
24
|
+
spec.add_dependency "multi_json", "~> 1.10"
|
25
|
+
spec.add_dependency "thor", "~> 0.19"
|
26
26
|
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
28
|
+
spec.add_development_dependency "coveralls", "~> 0.8"
|
29
|
+
spec.add_development_dependency "inch", "~> 0.7"
|
30
|
+
spec.add_development_dependency "minitest", "~> 5.10"
|
31
|
+
spec.add_development_dependency "minitest-around", "~> 0.4"
|
32
|
+
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
|
+
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"
|
36
42
|
end
|
data/lib/candy_check/cli/app.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "thor"
|
2
2
|
|
3
3
|
module CandyCheck
|
4
4
|
module CLI
|
@@ -6,54 +6,37 @@ module CandyCheck
|
|
6
6
|
# @example
|
7
7
|
# $> candy_check help
|
8
8
|
class App < Thor
|
9
|
-
package_name
|
9
|
+
package_name "CandyCheck"
|
10
10
|
|
11
|
-
desc
|
11
|
+
desc "app_store RECEIPT_DATA", "Verify a base64 encoded AppStore receipt"
|
12
12
|
method_option :environment,
|
13
|
-
default:
|
13
|
+
default: "production",
|
14
14
|
type: :string,
|
15
15
|
enum: %w(production sandbox),
|
16
|
-
aliases:
|
17
|
-
desc:
|
16
|
+
aliases: "-e",
|
17
|
+
desc: "The environment to use for verfication"
|
18
18
|
method_option :secret,
|
19
|
-
aliases:
|
19
|
+
aliases: "-s",
|
20
20
|
type: :string,
|
21
|
-
desc:
|
21
|
+
desc: "The shared secret for auto-renewable subscriptions"
|
22
|
+
|
22
23
|
def app_store(receipt)
|
23
24
|
Commands::AppStore.run(receipt, options)
|
24
25
|
end
|
25
26
|
|
26
|
-
desc
|
27
|
-
method_option :
|
28
|
-
required: true,
|
29
|
-
type: :string,
|
30
|
-
aliases: '-i',
|
31
|
-
desc: 'The issuer\'s email address for the API call'
|
32
|
-
method_option :key_file,
|
27
|
+
desc "play_store PACKAGE PRODUCT_ID TOKEN", "Verify PlayStore purchase"
|
28
|
+
method_option :json_key_file,
|
33
29
|
required: true,
|
34
30
|
type: :string,
|
35
|
-
aliases:
|
36
|
-
desc:
|
37
|
-
|
38
|
-
default: 'notasecret',
|
39
|
-
type: :string,
|
40
|
-
aliases: '-s',
|
41
|
-
desc: 'The secret to decrypt the key_file'
|
42
|
-
method_option :application_name,
|
43
|
-
default: 'CandyCheck',
|
44
|
-
type: :string,
|
45
|
-
aliases: '-a',
|
46
|
-
desc: 'Your application\'s name'
|
47
|
-
method_option :application_version,
|
48
|
-
default: CandyCheck::VERSION,
|
49
|
-
type: :string,
|
50
|
-
aliases: '-v',
|
51
|
-
desc: 'Your application\'s version'
|
31
|
+
aliases: "-k",
|
32
|
+
desc: "The json key file to use for API authentication"
|
33
|
+
|
52
34
|
def play_store(package, product_id, token)
|
53
35
|
Commands::PlayStore.run(package, product_id, token, options)
|
54
36
|
end
|
55
37
|
|
56
|
-
desc
|
38
|
+
desc "version", 'Print the gem\'s version'
|
39
|
+
|
57
40
|
def version
|
58
41
|
Commands::Version.run
|
59
42
|
end
|