class Drip::Client

Constants

JSON_API_CONTENT_TYPE
JSON_CONTENT_TYPE

Public Class Methods

new(options = {}) { |config| ... } click to toggle source
# File lib/drip/client.rb, line 65
def initialize(options = {})
  @config = Drip::Client::Configuration.new(**options)
  yield(@config) if block_given?
end

Public Instance Methods

content_type() click to toggle source
# File lib/drip/client.rb, line 75
def content_type
  warn "[DEPRECATED] Drip::Client#content_type is deprecated and will be removed in a future version"
  JSON_API_CONTENT_TYPE
end
generate_resource(key, *args) click to toggle source
# File lib/drip/client.rb, line 70
def generate_resource(key, *args)
  warn "[DEPRECATED] Drip::Client#generate_resource is deprecated and will be removed in a future version"
  private_generate_resource(key, *args)
end

Private Instance Methods

build_response() { || ... } click to toggle source
# File lib/drip/client.rb, line 112
def build_response(&block)
  response = yield
  Drip::Response.new(response.code.to_i, response.body || response.body == "" ? JSON.parse(response.body) : nil)
rescue JSON::ParserError
  Drip::Response.new(response.code.to_i, nil)
end
make_json_api_request(http_verb, path, options = {}) click to toggle source
# File lib/drip/client.rb, line 89
def make_json_api_request(http_verb, path, options = {})
  make_request Drip::Request.new(http_verb, make_uri(path), options, JSON_API_CONTENT_TYPE)
end
make_json_request(http_verb, path, options = {}) click to toggle source
# File lib/drip/client.rb, line 93
def make_json_request(http_verb, path, options = {})
  make_request Drip::Request.new(http_verb, make_uri(path), options, JSON_CONTENT_TYPE)
end
make_request(drip_request) click to toggle source
# File lib/drip/client.rb, line 106
def make_request(drip_request)
  build_response do
    Drip::Client::HTTPClient.new(@config).make_request(drip_request)
  end
end
make_uri(path) click to toggle source
# File lib/drip/client.rb, line 102
def make_uri(path)
  URI(@config.url_prefix) + URI(path)
end
missing_subscriber_identifier(data) click to toggle source
# File lib/drip/client/subscribers.rb, line 163
def missing_subscriber_identifier(data)
  external_ids = data[:external_ids] || {}
  !data.key?(:email) && !data.key?(:id) && !external_ids.key?("bigcommerce_subscriber_id")
end
private_generate_resource(key, *args) click to toggle source
# File lib/drip/client.rb, line 97
def private_generate_resource(key, *args)
  # No reason for this to be part of the public API, so making a duplicate method to make it private.
  { key => args }
end