diff --git a/LICENSE b/LICENSE index d6a2dd5..b8c6806 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 Hostari Philippines, Inc. +Copyright (c) 2022-2024 Hostari Philippines, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index c34019e..d2ea2ca 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ The Thunderstore API Crystal wrapper. Fetch game modification info from your Crystal code. -Copyright 2022 Hostari Philippines, Inc. See LICENSE for copying information. +Copyright 2022-2024 Hostari Philippines, Inc. See LICENSE for copying information. 📝 Implements: [REST API Reference (V1)](https://valheim.thunderstore.io/api/docs/) 😘 Maintainer(s): @xaviablaza diff --git a/shard.yml b/shard.yml index 9f3e30e..29cc326 100644 --- a/shard.yml +++ b/shard.yml @@ -1,10 +1,10 @@ name: thunderstore_client -version: 1.0.2 +version: 1.0.3 authors: - Xavi Ablaza -crystal: 1.2.2 +crystal: ~> 1.6.2 development_dependencies: webmock: diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index 1c08c7f..d214d15 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -1,4 +1,5 @@ require "spec" require "webmock" Spec.before_each &->WebMock.reset +require "json" require "../src/thunderstore/**" diff --git a/src/thunderstore/client.cr b/src/thunderstore/client.cr index 99c8352..d6998a1 100644 --- a/src/thunderstore/client.cr +++ b/src/thunderstore/client.cr @@ -5,18 +5,23 @@ module Thunderstore def initialize(@community : String = "") end + # Sets the `@community` instance variable. + # You can find a list of communities by going to https://thunderstore.io + # and looking at the the subdomains that each mod community is listed under. def set_community(community : String) @community = community end - # Returns the base url for which this client will make API requests to + # Returns the base url for which this client will make API requests to. def base_url : URI return URI.parse("https://thunderstore.io") if community.empty? URI.parse("https://#{community}.thunderstore.io") end - def get(path : String) + # Initializes an `HTTP::Client` for the configured `base_url`, and executes a GET request on the specified `path`. + # The response will have its body as a String, accessed via `HTTP::Client::Response#body`. + def get(path : String) : HTTP::Client::Response HTTP::Client.new(base_url).get(path) end end diff --git a/src/thunderstore/error.cr b/src/thunderstore/error.cr index 82672ca..c111855 100644 --- a/src/thunderstore/error.cr +++ b/src/thunderstore/error.cr @@ -1,4 +1,5 @@ module Thunderstore + # Error class to catch if operations in this library are thrown. class Error < Exception property message : String? diff --git a/src/thunderstore_client.cr b/src/thunderstore_client.cr index 96eb91a..b439951 100644 --- a/src/thunderstore_client.cr +++ b/src/thunderstore_client.cr @@ -1,8 +1,9 @@ require "json" require "http/client" +# Specifies information related to this shard, like the `ThunderstoreClient::VERSION` class ThunderstoreClient - VERSION = "1.0.2" + VERSION = "1.0.3" end require "./thunderstore/**"