Sha256: 7d3a5fadf8d735a9486ff41d3e6c1c13a5c3331df962c8dd702414001abfcbd3
Contents?: true
Size: 1.75 KB
Versions: 8
Compression:
Stored size: 1.75 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 class << self def faraday_connection(url) Faraday.new(url: url) do |c| c.request :json c.request :retry, max: 2, interval: 0.05, interval_randomness: 0.5, backoff_factor: 2 add_middleware(c) c.adapter Faraday.default_adapter end end private def add_middleware(c) c.use Yext::Api::Utils::Middleware::ResponseParser c.use Yext::Api::Utils::Middleware::DefaultParameters c.use Yext::Api::Utils::Middleware::ApiRateLimits c.use Yext::Api::Utils::Middleware::UriCleanup end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems