spackle-ruby 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6940b7a472063da8897bcf7e297a6497952de4426e628525e832bf6b17ad220
4
- data.tar.gz: '082c7b0646d8dcb33092d1eb2a7d1978f05f0b06f757ce27c943794c90004d6c'
3
+ metadata.gz: 69b7dfaefe38c180f1057f25a9d882a747bc09f30aebb44af6154b3b040a2a37
4
+ data.tar.gz: b0252c13b04939fc3abb8fec6b57f26ebabd2529429898341c75d21096def49d
5
5
  SHA512:
6
- metadata.gz: e128d68bb6d0596794d3b5e2ceeb32332fbf5905969f0e25970e11669efcf70bf19f95088335940bef4550ecdf397901d445c7d28848cbed0927537532073a3a
7
- data.tar.gz: 2a5e1131869a98b15d929f3a8532b0f3aae666185a3772f9b233c631321fcb09872d3a80cc348d00ef8cce48fc9148703b887074c4d2b008e15f8ef523c54954
6
+ metadata.gz: 4b7263e43ffb69eb8546ad4d90d56283064047d1659dfe286206d2f43dbd65d4b352889d3be3e306a43d8fa89db349e56cbac0e25b8c4938fd4154e10f6d58a8
7
+ data.tar.gz: 75bcdb13a9908ef0ee3c556092ec027940fb883457129b9fb912ad1faa13310fafceb9b3c5c9d739cb1a976e7b38997015dd898eaed997a49166ea594b29cf71
data/README.md CHANGED
@@ -115,10 +115,12 @@ In production, Spackle requires a valid Stripe customer. However, that is not de
115
115
  "cus_000000000": {
116
116
  "features": [
117
117
  {
118
+ "type": 0,
118
119
  "key": "flag_feature",
119
120
  "value_flag": true
120
121
  },
121
122
  {
123
+ "type": 1,
122
124
  "key": "limit_feature",
123
125
  "value_limit": 100
124
126
  }
@@ -149,10 +151,12 @@ Spackle.store = Spackle::MemoryStore.new()
149
151
  Spackle.store.set_customer_data("cus_000000000", {
150
152
  "features": [
151
153
  {
154
+ "type": 0,
152
155
  "key": "flag_feature",
153
156
  "value_flag": True,
154
157
  },
155
158
  {
159
+ "type": 1,
156
160
  "key": "limit_feature",
157
161
  "value_limit": 100,
158
162
  },
@@ -14,45 +14,27 @@ module Spackle
14
14
  end
15
15
 
16
16
  def get_customer_data(id)
17
- data = query({
18
- key_condition_expression: 'CustomerId = :customer_id',
19
- filter_expression: 'Version = :version',
20
- expression_attribute_values: {
21
- ':customer_id' => id,
22
- ':version' => Spackle.version
23
- },
24
- limit: 1
25
- })
17
+ result = get_item(id)
26
18
 
27
- if not data.items.any?
19
+ if result.nil? or result.item.nil?
28
20
  raise SpackleError.new "Customer #{id} not found"
29
21
  end
30
22
 
31
- JSON.parse(data.items[0]['State'])
23
+ JSON.parse(result.item['State'])
32
24
  end
33
25
 
34
26
  private
35
27
 
36
- def get_item(key)
37
- key = key.merge({
38
- 'AccountId' => @store_config['identity_id'],
39
- })
40
-
41
- response = @client.get_item({
42
- table_name: @table_name,
43
- key: key
44
- })
45
-
46
- JSON.parse(response.item['State'])
47
- end
48
-
49
- def query(query)
50
- query[:table_name] = @store_config['table_name']
51
- query[:key_condition_expression] = 'AccountId = :account_id AND ' + query[:key_condition_expression]
52
- query[:expression_attribute_values] = query[:expression_attribute_values].merge({
53
- ':account_id' => @store_config['identity_id']
28
+ def get_item(id)
29
+ return @client.get_item({
30
+ table_name: @store_config['table_name'],
31
+ key: {
32
+ AccountId: @store_config['identity_id'],
33
+ CustomerId: "#{id}:#{Spackle.version}"
34
+ }
54
35
  })
55
- @client.query(query)
36
+ rescue StandardError
37
+ return nil
56
38
  end
57
39
 
58
40
  def bootstrap_client
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"
5
+ s.version = "0.0.6"
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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spackle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-06 00:00:00.000000000 Z
11
+ date: 2023-04-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Spackle is the easiest way to integrate your Ruby app with Stripe Billing.
14
14
  See https://www.spackle.so for details.