rs4 0.1.1 → 0.1.2

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: 376ed103e27c3b47fb34551055c590b8212e9945deb78d8def33f2409b33e662
4
- data.tar.gz: ec8890b3dbcf688a036c270ceddd93d231c33369b4ed3cd0049c00f9d0fcfd6a
3
+ metadata.gz: acfc38c392a8ce535063f4f4a998e6c595eaa65df1cdbb2c3293a41329aae942
4
+ data.tar.gz: 760c3bbf2a9faa6a52222014177418dda32edd603fc23b66c57c3f16ced250fe
5
5
  SHA512:
6
- metadata.gz: 5388b4533dd5876f2e85ca12d169cf6bc3ba150549169dc3c0be303e396048c74eb501fc44f41e4b21e68c15e4b9b7b462da9463f1c15ac74a69e3647183260d
7
- data.tar.gz: a6ea6a0c6c1145687869f1bbcce4812f0e4da3ed19781149420aff8f88011bf6068017b6ea5d4af81cb0f6b67fae272097997ecc93eacbeaafe11e9b10b2aa1b
6
+ metadata.gz: aa701fad73581b95f521b673ab97f4165af8e72f484a5f8261075970ee702547bf36753b54da989c4ff59295b19a02ed84dd602f0737b03ae768a091acd27257
7
+ data.tar.gz: ba66c9b74fb9c7a1d9ef25797c353abc4811e8adca8f3ea4b5063e55e1e3b8467f60bffd833397e456c4512424e4a9d784f3e496ae0626b805ce8d48dbef8342
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RS4
2
4
  class << self
3
5
  attr_accessor :configuration
@@ -11,10 +13,5 @@ module RS4
11
13
  class Configuration
12
14
  attr_accessor :private_api_key
13
15
  attr_accessor :api_host
14
-
15
- def initialize
16
- @private_api_key = nil
17
- @api_host = nil
18
- end
19
16
  end
20
17
  end
@@ -1,3 +1,3 @@
1
1
  module RS4
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - donny
@@ -29,7 +29,6 @@ files:
29
29
  - bin/setup
30
30
  - lib/configuration.rb
31
31
  - lib/document.rb
32
- - lib/request.rb
33
32
  - lib/request_error.rb
34
33
  - lib/reusable_template.rb
35
34
  - lib/rs4/version.rb
@@ -1,45 +0,0 @@
1
- require 'uri'
2
- require 'net/http'
3
- require 'openssl'
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
18
-
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
45
- end