Sha256: 2a4013610fb8fb234e934c6a6b8453854c8ae6191b33fe7ff282f61ec709363a
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Yext module Api module Concerns # This module defines methods that set the connection for a Spyke class. # # The default connection is to the sandbox or the API based on the value of the configuration # sandbox setting. # # A class function live_api is provided to allow LiveApi module classes to use the live endpoint. module FaradayConnection extend ActiveSupport::Concern included do url = if Yext::Api.configuration.sandbox "https://sandbox.yext.com/v2" else "https://api.yext.com/v2" end self.connection = Yext::Api::Concerns::FaradayConnection.faraday_connection(url) end class_methods do def live_api self.connection = Yext::Api::Concerns::FaradayConnection.faraday_connection("https://live.yext.com/v2") end end def self.faraday_connection(url) Faraday.new(url: url) do |c| c.request :json c.use Yext::Api::Utils::ResponseParser c.use Yext::Api::Utils::DefaultParameters c.use Yext::Api::Utils::ApiRateLimits c.adapter Faraday.default_adapter end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yext-api-0.1.1 | lib/yext/api/concerns/faraday_connection.rb |