spackle-ruby 0.0.5 → 0.0.7

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: c6940b7a472063da8897bcf7e297a6497952de4426e628525e832bf6b17ad220
4
- data.tar.gz: '082c7b0646d8dcb33092d1eb2a7d1978f05f0b06f757ce27c943794c90004d6c'
3
+ metadata.gz: 88a684f832fdbd25801c0548a9c11e3a9e2fedac9e24e967630c216b9baf8fb8
4
+ data.tar.gz: 01a3950d81410f73dad15fbf329b0beb49ff09aba9a12a9a2bf56e32d10f700f
5
5
  SHA512:
6
- metadata.gz: e128d68bb6d0596794d3b5e2ceeb32332fbf5905969f0e25970e11669efcf70bf19f95088335940bef4550ecdf397901d445c7d28848cbed0927537532073a3a
7
- data.tar.gz: 2a5e1131869a98b15d929f3a8532b0f3aae666185a3772f9b233c631321fcb09872d3a80cc348d00ef8cce48fc9148703b887074c4d2b008e15f8ef523c54954
6
+ metadata.gz: 23ad5d82c45799cbdfe4946f667185f320023eaed31722cfa9f5216f0a4b151a0208441c34b6d1a99c0c7bc09a88a228d6bd1e926ae39794d2f76d2a672e6376
7
+ data.tar.gz: 39d199e6944eee7b5d2e30e53a7aee0cc2876b998786f6ba83310d66c26ca8dc2534084e44457f9d72e97ab7d40e2b98cce0da093e2f1e54d8aab4f49985c2c5
data/Gemfile CHANGED
@@ -4,9 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
+ gemspec
7
8
  gem "aws-sdk", "~> 3"
8
9
  gem "rake", "~> 13.0"
9
10
  gem "nokogiri", "~> 1.13"
10
11
  gem "minitest", "~> 5.18"
11
-
12
12
  gem "stripe", "~> 8.3"
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.7"
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.7
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-02 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.