class SolidusDrip::Base

Attributes

client[RW]

Public Class Methods

new(*_args) click to toggle source
# File lib/solidus_drip/base.rb, line 9
def initialize(*_args)
  @client = ::Drip::Client.new do |c|
    c.api_key = ENV['DRIP_API_KEY']
    c.account_id = ENV['DRIP_ACCOUNT_ID']
  end
end

Private Instance Methods

handle_error_response(response) click to toggle source

When a response is not successful this method should be called to handle it appropriately. Currently it logs the bad request and does not stop the execution flow. A failed response from Drip shouldn't affect the user experience with the site.

# File lib/solidus_drip/base.rb, line 24
def handle_error_response(response)
  # Some errors come back under the `message` key while others are nested
  # under `error`
  error_message = response.body.dig('message') || response.body.dig('error', 'message')
  Rails.logger.error("SOLIDUS DRIP | #{error_message}")
end