spackle-ruby 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +62 -21
- data/lib/spackle/pricing_table.rb +22 -0
- data/lib/spackle.rb +1 -0
- data/spackle.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a068195f85f43b672e48420f8020bfc91f02122894cad7f4fc1f04f511c5b91
|
4
|
+
data.tar.gz: 1bb74da02b2774c447c6dacb77d379bb9c4335fde6c67253d49ee6a959e879a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77aa643922bdcb3f22c07bb9e8521a7ca0d81802f789185a98ef460950a409bd9278654ab92dc8f4d0603b576887032bc6eb321daa4b5821847a5ba6a86f1c51
|
7
|
+
data.tar.gz: 3d31d216ee9473293ca70ae4bd4497d0a9170fb2f6d555e1402dc31366b364d588df6cc3c6a7b7ae3ce4fd5f8545efbcc502cbfe43354871988c8223f57455d9
|
data/README.md
CHANGED
@@ -43,7 +43,48 @@ Spackle.bootstrap()
|
|
43
43
|
|
44
44
|
## Usage
|
45
45
|
|
46
|
-
###
|
46
|
+
### Pricing tables
|
47
|
+
|
48
|
+
#### Fetch a pricing table
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
pricing_table = Spackle::PricingTable.retrieve("abcde123")
|
52
|
+
```
|
53
|
+
|
54
|
+
#### Pricing table object
|
55
|
+
```ts
|
56
|
+
{
|
57
|
+
id: string
|
58
|
+
name: string
|
59
|
+
intervals: string[]
|
60
|
+
products: {
|
61
|
+
id: string
|
62
|
+
features: {
|
63
|
+
id: string
|
64
|
+
name: string
|
65
|
+
key: string
|
66
|
+
type: number
|
67
|
+
value_flag: boolean
|
68
|
+
value_limit: number | null
|
69
|
+
}[]
|
70
|
+
name: string
|
71
|
+
prices: {
|
72
|
+
month?: {
|
73
|
+
unit_amount: number
|
74
|
+
currency: string
|
75
|
+
}
|
76
|
+
year?: {
|
77
|
+
unit_amount: number
|
78
|
+
currency: string
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}[]
|
82
|
+
}
|
83
|
+
```
|
84
|
+
|
85
|
+
### Entitlements
|
86
|
+
|
87
|
+
#### Fetch a customer
|
47
88
|
|
48
89
|
Spackle uses stripe ids as references to customer features.
|
49
90
|
|
@@ -51,19 +92,19 @@ Spackle uses stripe ids as references to customer features.
|
|
51
92
|
customer = Spackle::Customer.retrieve("cus_00000000")
|
52
93
|
```
|
53
94
|
|
54
|
-
|
95
|
+
#### Verify feature access
|
55
96
|
|
56
97
|
```ruby
|
57
98
|
customer.enabled("feature_key")
|
58
99
|
```
|
59
100
|
|
60
|
-
|
101
|
+
#### Fetch a feature limit
|
61
102
|
|
62
103
|
```ruby
|
63
104
|
customer.limit("feature_key")
|
64
105
|
```
|
65
106
|
|
66
|
-
|
107
|
+
#### Examine a customer's subscriptions
|
67
108
|
|
68
109
|
A customer's current subscriptions are available on the `subscriptions` property. These are valid `Stripe::Subscription` objects as defined in the [Stripe Ruby library](https://stripe.com/docs/api/subscriptions/object?lang=ruby).
|
69
110
|
|
@@ -71,7 +112,7 @@ A customer's current subscriptions are available on the `subscriptions` property
|
|
71
112
|
customer.subscriptions
|
72
113
|
```
|
73
114
|
|
74
|
-
|
115
|
+
#### Waiters
|
75
116
|
|
76
117
|
There is a brief delay between when an action takes place in Stripe and when it is reflected in Spackle. To account for this, Spackle provides a `Waiters` module that can be used to wait for a Stripe object to be updated and replicated.
|
77
118
|
|
@@ -90,22 +131,7 @@ There is a brief delay between when an action takes place in Stripe and when it
|
|
90
131
|
|
91
132
|
These will block until Spackle is updated with the latest information from Stripe or until a timeout occurs.
|
92
133
|
|
93
|
-
|
94
|
-
The Spackle Ruby library emits logs as it performs various internal tasks. You can control the verbosity of Spackle's logging a few different ways:
|
95
|
-
|
96
|
-
1. Set the environment variable SPACKLE_LOG to the value `debug`, `info`, `warn` or `error`
|
97
|
-
|
98
|
-
```sh
|
99
|
-
$ export SPACKLE_LOG=debug
|
100
|
-
```
|
101
|
-
|
102
|
-
2. Set Spackle.log_level:
|
103
|
-
|
104
|
-
```ruby
|
105
|
-
Spackle.log_level = 'debug'
|
106
|
-
```
|
107
|
-
|
108
|
-
## Usage in development environments
|
134
|
+
#### Usage in development environments
|
109
135
|
In production, Spackle requires a valid Stripe customer. However, that is not development environments where state needs to be controlled. As an alternative, you can use a file store to test your application with seed data.
|
110
136
|
|
111
137
|
```json
|
@@ -172,3 +198,18 @@ Spackle.store.set_customer_data("cus_000000000", {
|
|
172
198
|
```
|
173
199
|
|
174
200
|
**Note:** The in-memory store is not thread-safe and state will reset on each application restart.
|
201
|
+
|
202
|
+
## Logging
|
203
|
+
The Spackle Ruby library emits logs as it performs various internal tasks. You can control the verbosity of Spackle's logging a few different ways:
|
204
|
+
|
205
|
+
1. Set the environment variable SPACKLE_LOG to the value `debug`, `info`, `warn` or `error`
|
206
|
+
|
207
|
+
```sh
|
208
|
+
$ export SPACKLE_LOG=debug
|
209
|
+
```
|
210
|
+
|
211
|
+
2. Set Spackle.log_level:
|
212
|
+
|
213
|
+
```ruby
|
214
|
+
Spackle.log_level = 'debug'
|
215
|
+
```
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Spackle
|
2
|
+
class PricingTable
|
3
|
+
def self.retrieve(id)
|
4
|
+
@api = Faraday.new(
|
5
|
+
url: Spackle.api_base,
|
6
|
+
headers: {
|
7
|
+
'Authorization' => "Bearer #{Spackle.api_key}",
|
8
|
+
}
|
9
|
+
) do |faraday|
|
10
|
+
faraday.adapter :net_http_persistent
|
11
|
+
end
|
12
|
+
|
13
|
+
response = @api.get(Spackle.api_base + "/pricing_tables/#{id}")
|
14
|
+
|
15
|
+
if response.status != 200
|
16
|
+
raise SpackleError.new "Pricing table #{id} not found"
|
17
|
+
end
|
18
|
+
|
19
|
+
return JSON.parse(response.body)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/spackle.rb
CHANGED
data/spackle.gemspec
CHANGED
@@ -2,7 +2,7 @@ $LOAD_PATH.unshift(::File.join(::File.dirname(__FILE__), "lib"))
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "spackle-ruby"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.19"
|
6
6
|
s.summary = "Spackle Ruby gem"
|
7
7
|
s.description = "Spackle is the easiest way to integrate your Ruby app with Stripe Billing. " \
|
8
8
|
"See https://www.spackle.so for details."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spackle-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spackle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- bin/spackle-console
|
124
124
|
- lib/spackle.rb
|
125
125
|
- lib/spackle/customer.rb
|
126
|
+
- lib/spackle/pricing_table.rb
|
126
127
|
- lib/spackle/spackle_configuration.rb
|
127
128
|
- lib/spackle/stores/base.rb
|
128
129
|
- lib/spackle/stores/edge.rb
|