lib/dev_ruby/client.rb in dev_ruby-0.1.2 vs lib/dev_ruby/client.rb in dev_ruby-0.2.0

- old
+ new

@@ -1,31 +1,72 @@ # frozen_string_literal: true module DevRuby class Client BASE_URL = 'https://dev.to/api' - API_KEY = 'api-key' + AUTHORIZATION_KEY = 'api-key' attr_reader :api_key, :adapter def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) @api_key = api_key @adapter = adapter - - # Test stubs for requests - @stubs = stubs + @stubs = stubs # Test stubs for requests end def articles DevRuby::Resources::ArticlesResource.new(self) end + def comments + DevRuby::Resources::CommentsResource.new(self) + end + + def follows + DevRuby::Resources::FollowsResource.new(self) + end + + def followers + DevRuby::Resources::FollowersResource.new(self) + end + + def listings + DevRuby::Resources::ListingsResource.new(self) + end + + def organizations + DevRuby::Resources::OrganizationsResource.new(self) + end + + def podcast_episodes + DevRuby::Resources::PodcastEpisodesResource.new(self) + end + + def readinglist + DevRuby::Resources::ReadinglistsResource.new(self) + end + + def tags + DevRuby::Resources::TagsResource.new(self) + end + + def users + DevRuby::Resources::UsersResource.new(self) + end + + def profile_images + DevRuby::Resources::ProfileImagesResource.new(self) + end + + # rubocop:disable Layout/LineLength def connection @connection ||= Faraday.new(BASE_URL) do |conn| - conn.headers[API_KEY] = api_key + conn.headers[AUTHORIZATION_KEY] = api_key conn.request :json conn.response :json, content_type: 'application/json' + conn.response :logger, DevRuby.logger, body: true, bodies: { request: true, response: true } if DevRuby.log_api_bodies conn.adapter adapter, @stubs end end + # rubocop:enable Layout/LineLength end end