spackle-ruby 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/spackle/stores/dynamodb.rb +17 -30
- data/lib/spackle.rb +4 -0
- data/spackle.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69b7dfaefe38c180f1057f25a9d882a747bc09f30aebb44af6154b3b040a2a37
|
4
|
+
data.tar.gz: b0252c13b04939fc3abb8fec6b57f26ebabd2529429898341c75d21096def49d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,49 +14,36 @@ module Spackle
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_customer_data(id)
|
17
|
-
|
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
|
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(
|
23
|
+
JSON.parse(result.item['State'])
|
32
24
|
end
|
33
25
|
|
34
26
|
private
|
35
27
|
|
36
|
-
def get_item(
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
36
|
+
rescue StandardError
|
37
|
+
return nil
|
56
38
|
end
|
57
39
|
|
58
40
|
def bootstrap_client
|
59
41
|
Util.log_debug('Bootstrapping DynamoDB client...')
|
42
|
+
|
43
|
+
if Spackle.api_key.nil?
|
44
|
+
raise SpackleError.new 'API key not set'
|
45
|
+
end
|
46
|
+
|
60
47
|
uri = URI(Spackle.api_base + '/sessions')
|
61
48
|
https = Net::HTTP.new(uri.host, uri.port)
|
62
49
|
https.use_ssl = true
|
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.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.
|
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-
|
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.
|