Sha256: 9c818207d536481233ab413ab91ea33a673bd5a2ea8dc8df1820b1f4a723e342

Contents?: true

Size: 879 Bytes

Versions: 8

Compression:

Stored size: 879 Bytes

Contents

require_relative "base"

module Redd
  module Clients
    # The client that doesn't need a user to function.
    # @note Of course, that means many editing methods throw an error.
    class Userless < Base
      # @!attribute [r] client_id
      attr_reader :client_id

      # @param [Hash] options The options to create the client with.
      # @see Base#initialize
      # @see Redd.it
      def initialize(client_id, secret, **options)
        @client_id = client_id
        @secret = secret
        super(**options)
      end

      # Authorize using the given data.
      # @return [Access] The access given by reddit.
      def authorize!
        response = auth_connection.post(
          "/api/v1/access_token",
          grant_type: "client_credentials"
        )

        @access = Access.new(response.body)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
redd-0.7.8 lib/redd/clients/userless.rb
redd-0.7.7 lib/redd/clients/userless.rb
redd-0.7.6 lib/redd/clients/userless.rb
redd-0.7.5 lib/redd/clients/userless.rb
redd-0.7.4 lib/redd/clients/userless.rb
redd-0.7.3 lib/redd/clients/userless.rb
redd-0.7.2 lib/redd/clients/userless.rb
redd-0.7.1 lib/redd/clients/userless.rb