Sha256: 983e359b94b25a933f2b753f3a5f81ef4c50975209331a2f8a3b2ebfbc57b9d6

Contents?: true

Size: 1.67 KB

Versions: 10

Compression:

Stored size: 1.67 KB

Contents

require 'json'
require 'percy/config'
require 'percy/client/environment'
require 'percy/client/connection'
require 'percy/client/version'
require 'percy/client/builds'
require 'percy/client/snapshots'
require 'percy/client/resources'

module Percy
  class Client
    include Percy::Client::Connection
    include Percy::Client::Builds
    include Percy::Client::Snapshots
    include Percy::Client::Resources

    class Error < RuntimeError; end
    class TimeoutError < Error; end
    class ConnectionFailed < Error; end
    class HttpError < Error
      attr_reader :status
      attr_reader :method
      attr_reader :url
      attr_reader :body

      def initialize(status, method, url, body, *args)
        @status = status
        @method = method
        @url = url
        @body = body
        super(*args)
      end
    end

    # 4xx
    class ClientError < HttpError; end

    # 400
    class BadRequestError < ClientError; end

    # 401
    class UnauthorizedError < ClientError; end

    # 402
    class PaymentRequiredError < ClientError; end

    # 403
    class ForbiddenError < ClientError; end

    # 404
    class NotFoundError < ClientError; end

    # 409
    class ConflictError < ClientError; end

    # 5xx
    class ServerError < HttpError; end

    # 500
    class InternalServerError < ServerError; end

    # 502
    class BadGatewayError < ServerError; end

    # 503
    class ServiceUnavailableError < ServerError; end

    attr_reader :config, :client_info, :environment_info

    def initialize(options = {})
      @config = options[:config] || Percy::Config.new
      @client_info = options[:client_info]
      @environment_info = options[:environment_info]
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
percy-client-2.0.1 lib/percy/client.rb
percy-client-2.0.0 lib/percy/client.rb
percy-client-1.15.0 lib/percy/client.rb
percy-client-1.14.1 lib/percy/client.rb
percy-client-1.14.0 lib/percy/client.rb
percy-client-1.13.10 lib/percy/client.rb
percy-client-1.13.9 lib/percy/client.rb
percy-client-1.13.8 lib/percy/client.rb
percy-client-1.13.7 lib/percy/client.rb
percy-client-1.13.6 lib/percy/client.rb