Class: Moltin::Api::Request
- Inherits:
-
Object
- Object
- Moltin::Api::Request
- Defined in:
- lib/moltin/api/request.rb
Class Method Summary collapse
- .build_endpoint(path) ⇒ Object
- .default_headers ⇒ Object
- .delete(path, custom_headers = {}) ⇒ Object
- .get(path, custom_headers = {}) ⇒ Object
- .headers(custom_headers = {}) ⇒ Object
- .post(path, data, custom_headers = {}) ⇒ Object
- .put(path, data, custom_headers = {}) ⇒ Object
Class Method Details
.build_endpoint(path) ⇒ Object
35 36 37 |
# File 'lib/moltin/api/request.rb', line 35 def self.build_endpoint(path) "https://#{Moltin::Config.api_host}/#{Moltin::Config.api_version}/#{path}" end |
.default_headers ⇒ Object
39 40 41 42 43 |
# File 'lib/moltin/api/request.rb', line 39 def self.default_headers { 'Authorization' => "Bearer #{Moltin::Api::Client.access_token}", } end |
.delete(path, custom_headers = {}) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/moltin/api/request.rb', line 28 def self.delete(path, custom_headers = {}) request = Moltin::Api::RestClientWrapper.new(path, custom_headers) request.delete do |response| Moltin::Api::Response.new response end end |
.get(path, custom_headers = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/moltin/api/request.rb', line 7 def self.get(path, custom_headers = {}) request = Moltin::Api::RestClientWrapper.new(path, custom_headers) request.get do |response| Moltin::Api::Response.new response end end |
.headers(custom_headers = {}) ⇒ Object
45 46 47 |
# File 'lib/moltin/api/request.rb', line 45 def self.headers(custom_headers = {}) default_headers.merge(custom_headers) end |
.post(path, data, custom_headers = {}) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/moltin/api/request.rb', line 14 def self.post(path, data, custom_headers = {}) request = Moltin::Api::RestClientWrapper.new(path, custom_headers) request.post data do |response| Moltin::Api::Response.new response end end |
.put(path, data, custom_headers = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/moltin/api/request.rb', line 21 def self.put(path, data, custom_headers = {}) request = Moltin::Api::RestClientWrapper.new(path, custom_headers) request.put data do |response| Moltin::Api::Response.new response end end |