challonge_user_rails 0.1.0 → 0.1.1
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 +4 -4
- data/.tool-versions +1 -0
- data/Gemfile.lock +2 -2
- data/lib/challonge_user_rails/client.rb +27 -7
- data/lib/challonge_user_rails/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fcc83e717e53784cb2e5b1face51cca680f8b61b74682816dbcd603f76d686f
|
4
|
+
data.tar.gz: d50fc847ab547662b8cfcf14b92d20b410947bf7afc0a50eb3f6f897afa9d87f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64ce0a1baaa411c42566975d8f0e5fa5a683d5e39be69dc956b752b7e9825f9f560c998c2abbce3536ae74b39a56309fc8f6af64e312a43089d4f21cab10b4b1
|
7
|
+
data.tar.gz: a474c14308038dbb2913f33dab32774c0f020982b584772c1172eb915566e774367dce9183f7e6025ccc8079e640040def4e00b022bbb09d7cb7ec3392ac9892
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.2
|
data/Gemfile.lock
CHANGED
@@ -4,6 +4,7 @@ require "faraday_middleware"
|
|
4
4
|
module ChallongeUserRails
|
5
5
|
class Client
|
6
6
|
BASE_URL = "https://api.challonge.com/v2/"
|
7
|
+
|
7
8
|
attr_reader :api_key, :adapter
|
8
9
|
|
9
10
|
def initialize(api_key:, adapter: Faraday.default_adapter )
|
@@ -21,6 +22,7 @@ module ChallongeUserRails
|
|
21
22
|
conn.headers['Accept'] = 'application/json'
|
22
23
|
conn.headers['Authorization-Type'] = 'v1'
|
23
24
|
conn.headers['Authorization'] = @api_key
|
25
|
+
conn.use Faraday::Response::RaiseError
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -28,32 +30,50 @@ module ChallongeUserRails
|
|
28
30
|
|
29
31
|
#get all tournaments from user account
|
30
32
|
def tournaments
|
31
|
-
|
33
|
+
response = connection.get("tournaments.json")
|
34
|
+
{ code: response.status, status: '200 Success', data: response.body }
|
35
|
+
rescue Faraday::ClientError => err
|
36
|
+
{ code: err.response[:status], status: err.response[:headers][:status], data: JSON.parse(err.response[:body])["errors"]["detail"] }
|
32
37
|
end
|
33
38
|
|
34
39
|
#get specific tournament via slug/url
|
35
40
|
def tournament(slug)
|
36
|
-
connection.get("tournaments/#{slug}.json")
|
41
|
+
response = connection.get("tournaments/#{slug}.json")
|
42
|
+
{ code: response.status, status: '200 Success', data: response.body }
|
43
|
+
rescue Faraday::ClientError => err
|
44
|
+
{ code: err.response[:status], status: err.response[:headers][:status], data: JSON.parse(err.response[:body])["errors"]["detail"] }
|
37
45
|
end
|
38
46
|
|
39
47
|
#get all matches of specific tournament
|
40
48
|
def matches(slug)
|
41
|
-
connection.get("tournaments/#{slug}/matches.json")
|
49
|
+
response = connection.get("tournaments/#{slug}/matches.json")
|
50
|
+
{ code: response.status, status: '200 Success', data: response.body }
|
51
|
+
rescue Faraday::ClientError => err
|
52
|
+
{ code: err.response[:status], status: err.response[:headers][:status], data: JSON.parse(err.response[:body])["errors"]["detail"] }
|
42
53
|
end
|
43
54
|
|
44
55
|
#get specific match
|
45
56
|
def match(slug, id)
|
46
|
-
connection.get("tournaments/#{slug}/matches/#{id}.json")
|
57
|
+
response = connection.get("tournaments/#{slug}/matches/#{id}.json")
|
58
|
+
{ code: response.status, status: '200 Success', data: response.body }
|
59
|
+
rescue Faraday::ClientError => err
|
60
|
+
{ code: err.response[:status], status: err.response[:headers][:status], data: JSON.parse(err.response[:body])["errors"]["detail"] }
|
47
61
|
end
|
48
62
|
|
49
63
|
#create tournament
|
50
64
|
def create_tournament(data)
|
51
|
-
connection.post("tournaments.json", data)
|
65
|
+
response = connection.post("tournaments.json", data)
|
66
|
+
{ code: response.status, status: '200 Success', data: response.body }
|
67
|
+
rescue Faraday::ClientError => err
|
68
|
+
{ code: err.response[:status], status: err.response[:headers][:status], data: JSON.parse(err.response[:body])["errors"]["detail"] }
|
52
69
|
end
|
53
70
|
|
54
71
|
#delete tournament
|
55
72
|
def delete_tournament(slug)
|
56
|
-
connection.delete("tournaments/#{slug}.json")
|
73
|
+
response = connection.delete("tournaments/#{slug}.json")
|
74
|
+
{ code: response.status, status: '200 Success', data: response.body }
|
75
|
+
rescue Faraday::ClientError => err
|
76
|
+
{ code: err.response[:status], status: err.response[:headers][:status], data: JSON.parse(err.response[:body])["errors"]["detail"] }
|
57
77
|
end
|
58
78
|
|
59
79
|
#change once deployed
|
@@ -61,4 +81,4 @@ module ChallongeUserRails
|
|
61
81
|
"#<ChallongUserAPI::Client>"
|
62
82
|
end
|
63
83
|
end
|
64
|
-
end
|
84
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: challonge_user_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Michael Dollosa
|
@@ -47,6 +47,7 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
49
|
- ".rspec"
|
50
|
+
- ".tool-versions"
|
50
51
|
- ".travis.yml"
|
51
52
|
- CODE_OF_CONDUCT.md
|
52
53
|
- Gemfile
|
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
81
|
- !ruby/object:Gem::Version
|
81
82
|
version: '0'
|
82
83
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
84
|
+
rubygems_version: 3.2.27
|
84
85
|
signing_key:
|
85
86
|
specification_version: 4
|
86
87
|
summary: This is a simple API wrapper for Challong API users.
|