rs4 0.1.3 → 0.1.4

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: c68d7c9729dc665292fad36e4941883c8463cc1023646ae749cb90aae8d1c086
4
- data.tar.gz: 1ca39c4a0bb4332e0fb0f3b31cd613bf5fea3145a4547f3ae2c6a2bf3a70a3f2
3
+ metadata.gz: dbf0795919c6835f30a843f728b8bfc7cbd3efdd1027d199bbe39c6450963380
4
+ data.tar.gz: 18578752a41d6727cf72b560aae3270194dedf3b033395410c0f41b32de3aa73
5
5
  SHA512:
6
- metadata.gz: 8c7f1236840b7da3593c717416b5313dab2a6a1c1e5982e4accd7d161b246981d64efc2ddced70cd4cd1a834bc32e3a036252c1cf575c70739e2c696a3d449de
7
- data.tar.gz: 743fc9ff74312577fd610019519487a0312a81de74de7e4f951020d9befd048357e230d851ce1facc24a1e5f38ec6f71c010c9e087987e5b0f96f555e8bec603
6
+ metadata.gz: bfa79ca3aabe08ae7432c7224ad806d169bad8305b89f3ce8300fdfa7bce9871da58749becfa3cfc74c72f0248d7a8b00d68a9da8e5123cf93eeb1677511be23
7
+ data.tar.gz: 2731bf2ba14e69d77541441e1e064cbc90b8c1589047f6d30ac736e38a405e2e7a3aec89360e31d4e622e0cf6fec00207655720c5b1460472ca0c434e785dbb2
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  *.gem
13
+ *.swp
data/lib/rs4.rb CHANGED
@@ -2,44 +2,11 @@ require 'uri'
2
2
  require 'net/http'
3
3
  require 'openssl'
4
4
 
5
- module RS4
6
- # Prepares the HTTP request with the headers
7
- # required by the RS4 endpoints
8
- class Request
9
- # Reattempt the request before giving up
10
- MAX_RETRIES = 5
11
-
12
- class << self
13
- def execute(path, method = :get, body = {})
14
- url = URI(RS4.configuration.api_host + '/public/v1/' + path)
15
-
16
- http = Net::HTTP.new(url.host, url.port)
17
- http.use_ssl = true
5
+ require 'rs4/request.rb'
6
+ require 'rs4/document.rb'
7
+ require 'rs4/configuration.rb'
8
+ require 'rs4/request_error.rb'
9
+ require 'rs4/reusable_template.rb'
18
10
 
19
- request = case method
20
- when :get
21
- Net::HTTP::Get.new(url)
22
- when :post
23
- Net::HTTP::Post.new(url)
24
- when :put
25
- Net::HTTP::Put.new(url)
26
- when :delete
27
- Net::HTTP::Delete.new(url)
28
- end
29
-
30
- request.body = body.to_json unless method == :get
31
- request['Content-Type'] = 'application/json' unless method == :get
32
- request['Authorization'] = "Basic #{Base64.strict_encode64(RS4.configuration.private_api_key)}"
33
-
34
- # https://stackoverflow.com/questions/5370697/what-s-the-best-way-to-handle-exceptions-from-nethttp#answer-11802674
35
- begin
36
- retries ||= 0
37
- http.request(request)
38
- rescue StandardError => e
39
- Rails.logger.error(e)
40
- retry if (retries += 1) < MAX_RETRIES
41
- end
42
- end
43
- end
44
- end
11
+ module RS4
45
12
  end
File without changes
@@ -0,0 +1,41 @@
1
+ module RS4
2
+ # Prepares the HTTP request with the headers
3
+ # required by the RS4 endpoints
4
+ class Request
5
+ # Reattempt the request before giving up
6
+ MAX_RETRIES = 5
7
+
8
+ class << self
9
+ def execute(path, method = :get, body = {})
10
+ url = URI(RS4.configuration.api_host + '/public/v1/' + path)
11
+
12
+ http = Net::HTTP.new(url.host, url.port)
13
+ http.use_ssl = true
14
+
15
+ request = case method
16
+ when :get
17
+ Net::HTTP::Get.new(url)
18
+ when :post
19
+ Net::HTTP::Post.new(url)
20
+ when :put
21
+ Net::HTTP::Put.new(url)
22
+ when :delete
23
+ Net::HTTP::Delete.new(url)
24
+ end
25
+
26
+ request.body = body.to_json unless method == :get
27
+ request['Content-Type'] = 'application/json' unless method == :get
28
+ request['Authorization'] = "Basic #{Base64.strict_encode64(RS4.configuration.private_api_key)}"
29
+
30
+ # https://stackoverflow.com/questions/5370697/what-s-the-best-way-to-handle-exceptions-from-nethttp#answer-11802674
31
+ begin
32
+ retries ||= 0
33
+ http.request(request)
34
+ rescue StandardError => e
35
+ Rails.logger.error(e)
36
+ retry if (retries += 1) < MAX_RETRIES
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module RS4
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rs4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - donny
@@ -27,11 +27,12 @@ files:
27
27
  - Rakefile
28
28
  - bin/console
29
29
  - bin/setup
30
- - lib/configuration.rb
31
- - lib/document.rb
32
- - lib/request_error.rb
33
- - lib/reusable_template.rb
34
30
  - lib/rs4.rb
31
+ - lib/rs4/configuration.rb
32
+ - lib/rs4/document.rb
33
+ - lib/rs4/request.rb
34
+ - lib/rs4/request_error.rb
35
+ - lib/rs4/reusable_template.rb
35
36
  - lib/rs4/version.rb
36
37
  - license.txt
37
38
  - rs4.gemspec