Class: DiffTest::ApiClient
- Inherits:
-
Object
- Object
- DiffTest::ApiClient
- Includes:
- HTTParty
- Defined in:
- lib/diff_test/api_client.rb
Class Method Summary collapse
- .delete(path, options = {}, &block) ⇒ Object
- .get(path, options = {}, &block) ⇒ Object
- .gzip_body(options) ⇒ Object
- .jsonify_body(options) ⇒ Object
- .patch(path, options = {}, &block) ⇒ Object
- .post(path, options = {}, &block) ⇒ Object
- .process_options(options) ⇒ Object
- .put(path, options = {}, &block) ⇒ Object
- .set_api_key_in_headers(options) ⇒ Object
Class Method Details
.delete(path, options = {}, &block) ⇒ Object
27 28 29 30 |
# File 'lib/diff_test/api_client.rb', line 27 def self.delete(path, = {}, &block) () super end |
.get(path, options = {}, &block) ⇒ Object
7 8 9 10 |
# File 'lib/diff_test/api_client.rb', line 7 def self.get(path, = {}, &block) () super end |
.gzip_body(options) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/diff_test/api_client.rb', line 45 def self.gzip_body() return unless [:body] buffer = StringIO.new gz = Zlib::GzipWriter.new(buffer) gz.write([:body]) gz.close [:body] = buffer.string [:headers] ||= {} [:headers]['Content-Encoding'] = 'gzip' end |
.jsonify_body(options) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/diff_test/api_client.rb', line 38 def self.jsonify_body() return unless [:body] && [:body].is_a?(Hash) [:body] = [:body].to_json [:headers] ||= {} [:headers]['Content-Type'] = 'application/json' end |
.patch(path, options = {}, &block) ⇒ Object
22 23 24 25 |
# File 'lib/diff_test/api_client.rb', line 22 def self.patch(path, = {}, &block) () super end |
.post(path, options = {}, &block) ⇒ Object
12 13 14 15 |
# File 'lib/diff_test/api_client.rb', line 12 def self.post(path, = {}, &block) () super end |
.process_options(options) ⇒ Object
32 33 34 35 36 |
# File 'lib/diff_test/api_client.rb', line 32 def self.() jsonify_body() gzip_body() set_api_key_in_headers() end |
.put(path, options = {}, &block) ⇒ Object
17 18 19 20 |
# File 'lib/diff_test/api_client.rb', line 17 def self.put(path, = {}, &block) () super end |
.set_api_key_in_headers(options) ⇒ Object
57 58 59 60 61 |
# File 'lib/diff_test/api_client.rb', line 57 def self.set_api_key_in_headers() base_uri DiffTest.configuration.base_api_url [:headers] ||= {} [:headers]['X-Diff-Test-Api-Key'] = DiffTest.configuration.api_key end |