Sha256: 0150e87bd38ac6023d0e9b230170a5d01f5424783868f013c32b030a3de10f39

Contents?: true

Size: 628 Bytes

Versions: 1

Compression:

Stored size: 628 Bytes

Contents

# frozen_string_literal: true

require 'bitly/version'
require 'bitly/config'
require 'bitly/v4'

# Bitly module.
module Bitly
  extend Config

  def self.shorten(long_url, options = {})
    client.shorten(long_url, options)
  end

  class << self
    private

    def client
      validate!
      Bitly::V4::Client.new(access_token: access_token)
    end

    def validate!
      raise StandardError, 'please set api_version.' unless api_version
      raise StandardError, "#{api_version} is not supported." unless api_version == 'v4'
      raise StandardError, 'please set access_token.' unless access_token
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitly-client-0.1.0 lib/bitly.rb