Sha256: 4bc105e37d1fc16e30fbef8d8f3b56613c2b39913a91e6ea3254d9622327bde9

Contents?: true

Size: 766 Bytes

Versions: 7

Compression:

Stored size: 766 Bytes

Contents

# frozen_string_literal: true

module IronBank
  # Identify and return the proper base URL for a given Zuora domain.
  #
  class Endpoint
    private_class_method :new

    PRODUCTION  = /\Arest\.zuora\.com\z/i.freeze
    SERVICES    = /\A(rest)?(\.)?[a-z]+(\d+)?\.zuora\.com(:\d+)?\z/i.freeze
    APISANDBOX  = /\Arest.apisandbox.zuora\.com\z/i.freeze

    def self.base_url(domain = "")
      new(domain).base_url
    end

    def base_url
      case domain
      when PRODUCTION
        "https://rest.zuora.com/"
      when SERVICES
        "https://#{domain}/".downcase
      when APISANDBOX
        "https://rest.apisandbox.zuora.com/"
      end
    end

    private

    attr_reader :domain

    def initialize(domain)
      @domain = domain
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
iron_bank-5.4.1 lib/iron_bank/endpoint.rb
iron_bank-5.4.0 lib/iron_bank/endpoint.rb
iron_bank-5.3.2 lib/iron_bank/endpoint.rb
iron_bank-5.3.0 lib/iron_bank/endpoint.rb
iron_bank-5.2.6 lib/iron_bank/endpoint.rb
iron_bank-5.2.4 lib/iron_bank/endpoint.rb
iron_bank-5.2.3 lib/iron_bank/endpoint.rb