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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a5b9861dc2d74dffa6bc745b4bcc0bc7469b0ecd8e96fb593a2d5d3f590e090
4
- data.tar.gz: 221a36058f512b719cfa413df10a4352baa94534ceeec737eea70d1fbbbebd54
3
+ metadata.gz: 3a068195f85f43b672e48420f8020bfc91f02122894cad7f4fc1f04f511c5b91
4
+ data.tar.gz: 1bb74da02b2774c447c6dacb77d379bb9c4335fde6c67253d49ee6a959e879a3
5
5
  SHA512:
6
- metadata.gz: ca4c8170d6e4b076f62202ab5e17a47d75aadc8467380c41312d5d2ce59a97a9ab67bbb66edf7aa310c9d92e9744d31b77645473b2fc5f5182f534655d05ca36
7
- data.tar.gz: 5460ac9cbcabdd41531d1165b33bde4979944a6afbda2ae44aa21df133e2da02ac3719f0ec636514acf037797263601526585a2f9a6e533fa4a94d23f84e26d6
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
- ### Fetch a customer
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
- ### Verify feature access
95
+ #### Verify feature access
55
96
 
56
97
  ```ruby
57
98
  customer.enabled("feature_key")
58
99
  ```
59
100
 
60
- ### Fetch a feature limit
101
+ #### Fetch a feature limit
61
102
 
62
103
  ```ruby
63
104
  customer.limit("feature_key")
64
105
  ```
65
106
 
66
- ### Examine a customer's subscriptions
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
- ## Waiters
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
- ## Logging
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
@@ -2,6 +2,7 @@ require 'logger'
2
2
  require 'forwardable'
3
3
 
4
4
  require 'spackle/customer'
5
+ require 'spackle/pricing_table'
5
6
  require 'spackle/spackle_configuration'
6
7
  require 'spackle/util'
7
8
  require 'spackle/waiters'
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.18"
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.18
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-07-24 00:00:00.000000000 Z
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