spackle-ruby 0.0.17 → 0.0.19.beta
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/README.md +62 -21
- data/lib/spackle/pricing_table.rb +22 -0
- data/lib/spackle.rb +1 -0
- data/spackle.gemspec +2 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cba8dd3558c9f2fd420c6012270d7a64b75a47abbeb7e78def87a708a7da9f8e
|
4
|
+
data.tar.gz: f0e6d00f8074fd77d142a27c041dbda74423b75146d66ed2037e90a2dc9f8461
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63867ff2ce77badd85923ab5b1cc73445b13e4bd7805256fc6ca4304ae824f725cfcbae90c8cdcc07e25a5a00a552899c0f07291e65d6dbc2f9051a4c8f5ecb3
|
7
|
+
data.tar.gz: 934bb37bc4be6ac675663a499ecb2885d68c7f59ea536c83f538f71625d4ee0894b1f2e3366f319307479f050a6f721323d731327087620a6684c8ec7ebbe992
|
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.beta"
|
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."
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
}
|
20
20
|
|
21
21
|
s.add_dependency "faraday", "~> 2.7"
|
22
|
+
s.add_dependency "faraday-net_http_persistent", '~> 2.0'
|
22
23
|
s.add_dependency "nokogiri", "~> 1.13"
|
23
24
|
s.add_dependency "stripe", "~> 8.3"
|
24
25
|
|
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.beta
|
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
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday-net_http_persistent
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: nokogiri
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,6 +123,7 @@ files:
|
|
109
123
|
- bin/spackle-console
|
110
124
|
- lib/spackle.rb
|
111
125
|
- lib/spackle/customer.rb
|
126
|
+
- lib/spackle/pricing_table.rb
|
112
127
|
- lib/spackle/spackle_configuration.rb
|
113
128
|
- lib/spackle/stores/base.rb
|
114
129
|
- lib/spackle/stores/edge.rb
|
@@ -137,9 +152,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
152
|
version: '0'
|
138
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
154
|
requirements:
|
140
|
-
- - "
|
155
|
+
- - ">"
|
141
156
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
157
|
+
version: 1.3.1
|
143
158
|
requirements: []
|
144
159
|
rubygems_version: 3.4.10
|
145
160
|
signing_key:
|