Sha256: 9fc456fa81b3c548b27a581841ced95b197ef7eb464bfdbbc02a442c36259101

Contents?: true

Size: 671 Bytes

Versions: 2

Compression:

Stored size: 671 Bytes

Contents

# frozen_String_literal: true

module Dendreo
  module Requests
    class Url
      attr_reader :complete_url

      def initialize(url, endpoint, url_data, api_key)
        @endpoint = endpoint.to_s
        @url_data = url_data
        @url = url
        @api_key = api_key
        @complete_url = build_complete_url
      end

      private

      def build_data_url
        @url_data.map do |k, v|
          "#{k}=#{v}"
        end.join('&')
      end

      def build_url
        return '' if @url_data&.empty?

        build_data_url
      end

      def build_complete_url
        "#{@url}/#{@endpoint}.php?key=#{@api_key}&#{build_url}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Dendreo-1.1.2 lib/dendreo/requests/url.rb
Dendreo-1.1.1 lib/dendreo/requests/url.rb