spackle-ruby 0.0.14 → 0.0.16

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: cafee13ca0d2f07ea47389d6a8dc8c48fb85ba5c32fd4e7b4dbcdec8b1ade3e5
4
- data.tar.gz: 1bd2685e9bc6a5103cae2ab1aee788a01f99e410e4d98d5bf817b0c644f38866
3
+ metadata.gz: 2836d3a94748b633923e713c61666b48202ec2a69e88a47e1f49f43697ac446a
4
+ data.tar.gz: 567c08ffaf04b62443c7e7c35de97179781834c6ad2992a7df5ac634a3c71c77
5
5
  SHA512:
6
- metadata.gz: 0af2295c908d9a31a31f20c87149af87c0149fae0908f836152ffd312330803dadd481c677c081f36af859516d6e0b99245dfe21d6f550b5029de1a38cbfccab
7
- data.tar.gz: 1d0dd8dba75ed289375c0b7d2da98ab49c8d1561c7bee794c7fbae6c5cc7e1dcd6c9342b30e9bdc93bd7f72bf8274bb6c452e601714519079a951ae40adfe99e
6
+ metadata.gz: 7fa9cb1dcd0df67dde5d2466f0ddecd37c727038c018408c4473836dc1aa5ea3de9dca87e054256b412d393578027f861967a50104f7a12ac02bd4694747196d
7
+ data.tar.gz: a98c28187be567457ff71b9c61728aa2764cb805f950fddca6899c37b39dca4e19ee1b0db39e202c164f5ffed1a711f4a804ba471a01224bb024dadf52a26a89
data/Gemfile CHANGED
@@ -9,3 +9,4 @@ gem "nokogiri", "~> 1.13"
9
9
  gem "minitest", "~> 5.18"
10
10
  gem "webmock", "~> 3.18"
11
11
  gem "stripe", "~> 8.3"
12
+ gem "faraday", "~> 2.7"
@@ -1,46 +1,45 @@
1
- require 'net/http'
1
+ require 'faraday'
2
2
  require 'json'
3
3
  require 'logger'
4
4
 
5
5
  module Spackle
6
6
  class EdgeStore < BaseStore
7
7
  def initialize()
8
- edge_uri = URI(Spackle.edge_base)
9
- @edge_http = Net::HTTP.new(edge_uri.host, edge_uri.port)
10
- @edge_http.use_ssl = true
11
-
12
- api_uri = URI(Spackle.api_base)
13
- @api_http = Net::HTTP.new(api_uri.host, api_uri.port)
14
- @api_http.use_ssl = true
8
+ @edge = Faraday.new(
9
+ url: Spackle.edge_base,
10
+ headers: {
11
+ 'Authorization' => "Bearer #{Spackle.api_key}",
12
+ 'X-Spackle-Schema-Version' => Spackle.version.to_s,
13
+ }
14
+ )
15
+ @api = Faraday.new(
16
+ url: Spackle.api_base,
17
+ headers: {
18
+ 'Authorization' => "Bearer #{Spackle.api_key}",
19
+ 'X-Spackle-Schema-Version' => Spackle.version.to_s,
20
+ }
21
+ )
15
22
  end
16
23
 
17
24
  def get_customer_data(id)
18
- request = Net::HTTP::Get.new(Spackle.edge_base + '/customers/' + id + '/state')
19
- request['Authorization'] = 'Bearer ' + Spackle.api_key
20
- request['X-Spackle-Schema-Version'] = Spackle.version.to_s
25
+ response = @edge.get("/customers/#{id}/state")
21
26
 
22
- response = @edge_http.request(request)
23
- if response.code != '200'
27
+ if response.status != 200
24
28
  return fetch_state_from_api(id)
25
29
  end
26
30
 
27
- JSON.parse(response.body)
31
+ return JSON.parse(response.body)
28
32
  end
29
33
 
30
34
  def fetch_state_from_api(id)
31
35
  Util.log_warn("Customer #{id} not found. Fetching from API...")
32
- request = Net::HTTP::Get.new(Spackle.api_base + '/customers/' + id + '/state')
33
- request['Authorization'] = 'Bearer ' + Spackle.api_key
34
- request['X-Spackle-Schema-Version'] = Spackle.version.to_s
36
+ response = @api.get(Spackle.api_base + "/customers/#{id}/state")
35
37
 
36
- response = @api_http.request(request)
37
- if response.code != '200'
38
- puts response.code
39
- puts response.body
38
+ if response.status != 200
40
39
  raise SpackleError.new "Customer #{id} not found"
41
40
  end
42
41
 
43
- JSON.parse(response.body)
42
+ return JSON.parse(response.body)
44
43
  end
45
44
  end
46
45
  end
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.14"
5
+ s.version = "0.0.16"
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."
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  "source_code_uri" => "https://github.com/spackleso/spackle-ruby",
19
19
  }
20
20
 
21
+ s.add_dependency "faraday", "~> 2.7"
21
22
  s.add_dependency "nokogiri", "~> 1.13"
22
23
  s.add_dependency "stripe", "~> 8.3"
23
24
 
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spackle-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.16
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-23 00:00:00.000000000 Z
11
+ date: 2023-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: nokogiri
15
29
  requirement: !ruby/object:Gem::Requirement