Sha256: 5e1fe0629355cae212c779f08426e8af2e565878068d2200805727a6e1dfa12a

Contents?: true

Size: 965 Bytes

Versions: 15

Compression:

Stored size: 965 Bytes

Contents

# frozen_string_literal: true

module PriceHubble
  module Client
    # A high level client library for the PriceHubble Authentication API.
    class Authentication < Base
      # Perform a login request while sending the passed credentials.
      #
      # @param args [Hash{Symbol => Mixed}] the authentication credentials
      # @return [PriceHubble::Authentication, nil] the authentication entity,
      #   or +nil+ on error
      def login(**args)
        res = connection.post do |req|
          req.path = '/auth/login/credentials'
          req.body = args.except(:bang)
          use_default_context(req, :login)
        end
        decision(bang: args.fetch(:bang, false)) do |result|
          result.bang { PriceHubble::AuthenticationError.new(nil, res) }
          result.good { PriceHubble::Authentication.new(res.body) }
          successful?(res)
        end
      end

      # Generate bang method variants
      bangers :login
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pricehubble-1.3.0 lib/price_hubble/client/authentication.rb
pricehubble-1.2.5 lib/price_hubble/client/authentication.rb
pricehubble-1.2.4 lib/price_hubble/client/authentication.rb
pricehubble-1.2.3 lib/price_hubble/client/authentication.rb
pricehubble-1.2.2 lib/price_hubble/client/authentication.rb
pricehubble-1.2.1 lib/price_hubble/client/authentication.rb
pricehubble-1.2.0 lib/price_hubble/client/authentication.rb
pricehubble-1.1.0 lib/pricehubble/client/authentication.rb
pricehubble-1.0.0 lib/pricehubble/client/authentication.rb
pricehubble-0.4.2 lib/pricehubble/client/authentication.rb
pricehubble-0.4.1 lib/pricehubble/client/authentication.rb
pricehubble-0.4.0 lib/pricehubble/client/authentication.rb
pricehubble-0.3.0 lib/pricehubble/client/authentication.rb
pricehubble-0.2.0 lib/pricehubble/client/authentication.rb
pricehubble-0.1.0 lib/pricehubble/client/authentication.rb