Skip to content

Commit

Permalink
Add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviablaza committed Feb 12, 2024
1 parent 5d6b2d7 commit 515bb64
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/thunderstore/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/thunderstore/error.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module Thunderstore
# Error class to catch if operations in this library are thrown.
class Error < Exception
property message : String?

Expand Down
1 change: 1 addition & 0 deletions src/thunderstore_client.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "json"
require "http/client"

# Specifies information related to this shard, like the `ThunderstoreClient::VERSION`
class ThunderstoreClient
VERSION = "1.0.2"
end
Expand Down

0 comments on commit 515bb64

Please sign in to comment.