challonge_user_rails 0.1.0 → 0.1.4
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/bin/console +0 -2
- data/challonge_user_rails.gemspec +2 -2
- data/lib/challonge_user_rails/client.rb +27 -11
- data/lib/challonge_user_rails/error.rb +1 -2
- data/lib/challonge_user_rails/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25a757e90585b4f83972e91eb65b2979514b7ae1b586824b6aa66e8cf51ca901
|
4
|
+
data.tar.gz: 2fd3d0e0c33779f8f9d3f2855e7f932ec7b84e7bcfcab36d80a888d04ae3a41c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab0a97882457c9fa400b29889b058b4059c233d2d3da424e9716b0598c3d6dfd63a2a7613768189e338fb399b700dfdb8e846329aed9404fb0f805ff815459a0
|
7
|
+
data.tar.gz: b736c2ccc8b5ea6a63772796fc56f1e5f69084a235798d7dd3d1f4091e1174be2ee8119b1213ba3e21f5c15f606c37dce4b577e6fdcac36f6ef28ff59fc7e929
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.2
|
data/Gemfile.lock
CHANGED
data/bin/console
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["Christian Michael Dollosa"]
|
7
7
|
spec.email = ["dollosa.christian@gmail.com"]
|
8
8
|
|
9
|
-
spec.summary = %q{This is a simple API wrapper for
|
10
|
-
spec.description = %q{
|
9
|
+
spec.summary = %q{This is a simple API wrapper for Challonge API users.}
|
10
|
+
spec.description = %q{This is a simple API wrapper for Challonge API.}
|
11
11
|
spec.homepage = "https://github.com/michael-dollosa/challonge-user-rails"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
@@ -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,37 +30,51 @@ 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: '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: '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: '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: '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: '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: '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
|
-
#change once deployed
|
60
|
-
def inspect
|
61
|
-
"#<ChallongUserAPI::Client>"
|
62
|
-
end
|
63
79
|
end
|
64
|
-
end
|
80
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Michael Dollosa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.1'
|
41
|
-
description:
|
41
|
+
description: This is a simple API wrapper for Challonge API.
|
42
42
|
email:
|
43
43
|
- dollosa.christian@gmail.com
|
44
44
|
executables: []
|
@@ -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,8 +81,8 @@ 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
|
-
summary: This is a simple API wrapper for
|
87
|
+
summary: This is a simple API wrapper for Challonge API users.
|
87
88
|
test_files: []
|