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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 795487f9f9e2ad543bfaa81e453dc83b1c0208361ef06d9d08fb047f4bf3fd79
4
- data.tar.gz: e323d78c7aa5bea8a576867c26987d77ab9658243c6bf5df5e4b21c5662581c7
3
+ metadata.gz: 25a757e90585b4f83972e91eb65b2979514b7ae1b586824b6aa66e8cf51ca901
4
+ data.tar.gz: 2fd3d0e0c33779f8f9d3f2855e7f932ec7b84e7bcfcab36d80a888d04ae3a41c
5
5
  SHA512:
6
- metadata.gz: 97972075c937dbf110455613781162bd8a5dc0cfea4f486f8b7dd3c4258c1fd40816df630f33bfe2d4bb8f61e8d7d0fac20f4d28e7510d9bb9d06cda6e1bf0a4
7
- data.tar.gz: 4e9eed41750cfca6638fc4e081cb8a4a56547ba07fafbc065268799cd0a71f889bd57342ee0c9b6ca6f28f45a26f97f6d46a893f7d7f4bb4a379a01a692e6377
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- challonge_user_rails (0.1.0)
4
+ challonge_user_rails (0.1.4)
5
5
  faraday (~> 1.7)
6
6
  faraday_middleware (~> 1.1)
7
7
 
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  rspec (~> 3.0)
57
57
 
58
58
  BUNDLED WITH
59
- 2.1.4
59
+ 2.2.27
data/bin/console CHANGED
@@ -10,7 +10,5 @@ require "challonge_user_rails"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- client = ChallongeUserRails::Client.new(api_key: "Bu1jqfn2whgYiS2uOeD4iiTf25P2amiyuxLhHMKZ")
14
-
15
13
  require "irb"
16
14
  IRB.start(__FILE__)
@@ -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 Challong API users.}
10
- spec.description = %q{Used for Avion Project using api wrappers.}
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
- res = connection.get("tournaments.json").body
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").body
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").body
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").body
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).body
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").body
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
@@ -1,5 +1,4 @@
1
1
  module ChallongeUserRails
2
2
  class Error
3
-
4
3
  end
5
- end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module ChallongeUserRails
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.4"
3
3
  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.0
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-09-30 00:00:00.000000000 Z
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: Used for Avion Project using api wrappers.
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.1.6
84
+ rubygems_version: 3.2.27
84
85
  signing_key:
85
86
  specification_version: 4
86
- summary: This is a simple API wrapper for Challong API users.
87
+ summary: This is a simple API wrapper for Challonge API users.
87
88
  test_files: []