Class: BrazeRuby::HTTP
- Inherits:
-
Object
- Object
- BrazeRuby::HTTP
- Defined in:
- lib/braze_ruby/http.rb
Instance Method Summary collapse
- #connection ⇒ Object
- #get(path, query) ⇒ Object
-
#initialize(braze_url) ⇒ HTTP
constructor
A new instance of HTTP.
- #post(path, payload) ⇒ Object
Constructor Details
#initialize(braze_url) ⇒ HTTP
Returns a new instance of HTTP.
6 7 8 |
# File 'lib/braze_ruby/http.rb', line 6 def initialize(braze_url) @braze_url = braze_url end |
Instance Method Details
#connection ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/braze_ruby/http.rb', line 20 def connection @connection ||= Faraday.new(url: @braze_url) do |connection| connection.request :json connection.response :logger if ENV['BRAZE_RUBY_DEBUG'] connection.adapter Faraday.default_adapter end end |
#get(path, query) ⇒ Object
16 17 18 |
# File 'lib/braze_ruby/http.rb', line 16 def get(path, query) connection.get path, query end |
#post(path, payload) ⇒ Object
10 11 12 13 14 |
# File 'lib/braze_ruby/http.rb', line 10 def post(path, payload) connection.post path do |request| request.body = payload end end |