polytoriarb 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 296157b168c77954001a5a0e290482ea166e42ec5a1827588bd5aa091de3df47
4
+ data.tar.gz: b800732536b0440c642be3bcde3b531f7e32e9f0af136959eef47d4fb4648428
5
+ SHA512:
6
+ metadata.gz: f37b915d755dd0f42aa152633cefe6cc749cbbbf0597d027c14dea52b4bb7e6b1e3c6ad822bd2e96d8833d03675baee67fe54bf8c5814859c6616f475a0033ed
7
+ data.tar.gz: 848ca56176a1ca25b97c25d800421e9998a947248e763b2fb2ca977fbe71f94f336eca4fd224138f3b3d81cdf6d255738584059b232fa5065c79abb28d4b4a2c
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Roxanne Wolf
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # polytoriarb
2
+
3
+ Polytoriarb is a Ruby package (a.k.a. Gem) for interacting with Polytoria's REST API. The goal of this gem is to make using Polytoria's REST API easy to use for your Ruby projects.
4
+
5
+ You need Ruby 3.0 or newer in order to use this package (Ruby 3.2 or newer is recommended)
6
+
7
+ DISCLAIMER: This Ruby gem is not an official Polytoria product and made by a 3rd party. This gem is not officially endorsed by Polytoria.
8
+
9
+ ## Setup
10
+
11
+ You can install polytoriarb through the following methods:
12
+
13
+ #### Method 1: Install from rubygems.org (Bundler)
14
+
15
+ Add the following to your Gemfile file and run the "[bundle install](https://rubygems.org/gems/polytoriarb)" command:
16
+
17
+ ```ruby
18
+ gem 'polytoriarb'
19
+ ```
20
+
21
+ #### Method 2: Install via Git
22
+
23
+ Add the following to your Gemfile file and run the "bundle install" command:
24
+
25
+ ```ruby
26
+ gem 'polytoriarb', git: 'https://gitlab.com/roxannewolf/polytoriarb'
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ Here is a basic example of using the /v1/places/#{id} endpoint
32
+
33
+ ```ruby
34
+ require 'polytoriarb'
35
+ polytoriaclient = PolytoriaRB.client
36
+
37
+ place_id = 1822
38
+ begin
39
+ place_data = polytoriaclient.place(place_id)
40
+ puts "Place Name: #{place_data['name']}"
41
+ puts "Visits: #{place_data['visits']}"
42
+ rescue PolytoriaRB::APIError => e
43
+ puts "Error: #{e.code} - #{e.message}"
44
+ end
45
+ ```
46
+
47
+ Here is an example of using the /v1/places/#{id}/achievements endpoint that has query with a limit of 3
48
+
49
+ ```ruby
50
+ require 'polytoriarb'
51
+ polytoriaclient = PolytoriaRB.client
52
+
53
+ place_id = 1822
54
+ begin
55
+ achievements_response = polytoriaclient.place_achievements(place_id, limit: 3)
56
+ achievements_array = achievements_response['achievements']
57
+ puts "Found #{achievements_array.length} achievements in this place:"
58
+ achievements_array.each do |achievement|
59
+ puts " - #{achievement['asset']['name']} (ID: #{achievement['asset']['id']})"
60
+ end
61
+ rescue PolytoriaRB::APIError => e
62
+ puts "Error fetching achievements: #{e.code} - #{e.message}"
63
+ end
64
+ ```
65
+
66
+ ## Support and Help
67
+
68
+ If you need help with this ruby package (a.k.a. Gem), feel free to open an issue on our [Gitlab repo](https://gitlab.com/roxannewolf/polytoriarb) or [Codeberg repo](https://codeberg.org/roxannewolf/polytoriarb)
@@ -0,0 +1,115 @@
1
+ # lib/polytoriarb/client.rb
2
+ module PolytoriaRB
3
+ class Client
4
+ include HTTParty
5
+ base_uri "https://api.polytoria.com"
6
+
7
+ def format_response(data)
8
+ case data
9
+ when Hash
10
+ data.transform_values { |v| format_response(v) }
11
+ when Array
12
+ data.map { |v| format_response(v) }
13
+ when NilClass
14
+ 'N/A'
15
+ else
16
+ data
17
+ end
18
+ end
19
+
20
+ def self.get(path, options = {})
21
+ response = super(path, options)
22
+ unless response.success?
23
+ raise PolytoriaRB::APIError.new(response)
24
+ end
25
+ Client.new.send(:format_response, response.parsed_response)
26
+ end
27
+
28
+
29
+
30
+ # ---------- PLACES ----------
31
+ def place(id)
32
+ self.class.get("/v1/places/#{id}")
33
+ end
34
+
35
+ # Query: search (string), page (integer), limit (integer)
36
+ def place_achievements(id, options = {})
37
+ self.class.get("/v1/places/#{id}/achievements", query: options)
38
+ end
39
+
40
+ # Query: page (integer), limit (integer)
41
+ def place_gamepasses(id, options = {})
42
+ self.class.get("/v1/places/#{id}/gamepasses", query: options)
43
+ end
44
+
45
+ # ---------- GUILDS ----------
46
+ def guild(id)
47
+ self.class.get("/v1/guilds/#{id}")
48
+ end
49
+
50
+ # Query: page (integer), limit (query)
51
+ def guilds(options = {})
52
+ self.class.get("/v1/guilds", query: options)
53
+ end
54
+
55
+ # Query: page (integer), limit (integer)
56
+ def guild_members(id, options = {})
57
+ self.class.get("/v1/guilds/#{id}/members", query: options)
58
+ end
59
+
60
+ # Query: page (integer), limit (integer)
61
+ def guild_store(id, options = {})
62
+ self.class.get("/v1/guilds/#{id}/store", query: options)
63
+ end
64
+
65
+ # ---------- STORE ----------
66
+ def store_item(id)
67
+ self.class.get("/v1/store/#{id}")
68
+ end
69
+
70
+ # Query: search (string), sort (string. accepts: name, price, createdAt, updatedAt), order (string. accepts: asc, desc), page (integer), limit (integer)
71
+ def store(options = {})
72
+ self.class.get("/v1/store", query: options)
73
+ end
74
+
75
+ # ---------- USERS ----------
76
+ # Query: search (string, accepts: id, username, registeredAt, lastSeenAt), sort (string), order (string, accepts asc, desc), page (integer), limit (integer)
77
+ def users(options = {})
78
+ self.class.get("/v1/users", query: options)
79
+ end
80
+
81
+ def user(username)
82
+ self.class.get("/v1/users/find?username=#{username}")
83
+ end
84
+
85
+ # Query: page (integer), limit (integer)
86
+ def user_friends(id, options = {})
87
+ self.class.get("/v1/users/#{id}/friends", query: options)
88
+ end
89
+
90
+ # Query: type (string, accepts: achievement, audio, decal, face, gamePass, hat, mesh, pants, shirt, tool), limited (boolean), page (integer), limit (integer)
91
+ def user_inventory(id, options = {})
92
+ self.class.get("/v1/users/#{id}/inventory", query: options)
93
+ end
94
+
95
+ # Query: page (integer), limit (integer)
96
+ def user_store(id, options = {})
97
+ self.class.get("/v1/users/#{id}/store", query: options)
98
+ end
99
+
100
+ # Query: page (integer), limit (integer)
101
+ def user_badges(id, options = {})
102
+ self.class.get("/v1/users/#{id}/badges", query: options)
103
+ end
104
+ end
105
+ class APIError < StandardError
106
+ attr_reader :code, :message, :response
107
+
108
+ def initialize(response)
109
+ @code = response.code
110
+ @message = response.message
111
+ @response = response
112
+ super("[Polytoriarb] AN ERROR HAS OCCURED: Polytoria REST API request failed with status code #{code}: #{message}")
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,6 @@
1
+ # lib/polytoriarb/version.rb
2
+
3
+ module PolytoriaRB
4
+ # The current version of polytoriarb
5
+ VERSION = "1.0.0"
6
+ end
@@ -0,0 +1,12 @@
1
+ # lib/polytoriarb.rb
2
+ require "httparty"
3
+ require "polytoriarb/version"
4
+ require "polytoriarb/client"
5
+
6
+ module PolytoriaRB
7
+ class << self
8
+ def client
9
+ @client ||= Client.new
10
+ end
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: polytoriarb
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Roxanne Studios
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: httparty
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.20'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.20'
26
+ description: A simple gem made to help with interacting with Polytoria's REST API
27
+ for the Ruby programming language in a simplier way. Not officially endorsed by
28
+ Polytoria
29
+ email:
30
+ - ''
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE
36
+ - README.md
37
+ - lib/polytoriarb.rb
38
+ - lib/polytoriarb/client.rb
39
+ - lib/polytoriarb/version.rb
40
+ homepage: https://gitlab.com/roxannewolf/polytoriarb
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '3.0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.6.9
59
+ specification_version: 4
60
+ summary: A Ruby gem for using the Polytoria REST API.
61
+ test_files: []