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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 795487f9f9e2ad543bfaa81e453dc83b1c0208361ef06d9d08fb047f4bf3fd79
4
- data.tar.gz: e323d78c7aa5bea8a576867c26987d77ab9658243c6bf5df5e4b21c5662581c7
3
+ metadata.gz: 1fcc83e717e53784cb2e5b1face51cca680f8b61b74682816dbcd603f76d686f
4
+ data.tar.gz: d50fc847ab547662b8cfcf14b92d20b410947bf7afc0a50eb3f6f897afa9d87f
5
5
  SHA512:
6
- metadata.gz: 97972075c937dbf110455613781162bd8a5dc0cfea4f486f8b7dd3c4258c1fd40816df630f33bfe2d4bb8f61e8d7d0fac20f4d28e7510d9bb9d06cda6e1bf0a4
7
- data.tar.gz: 4e9eed41750cfca6638fc4e081cb8a4a56547ba07fafbc065268799cd0a71f889bd57342ee0c9b6ca6f28f45a26f97f6d46a893f7d7f4bb4a379a01a692e6377
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
@@ -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.1)
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
@@ -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
- res = connection.get("tournaments.json").body
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").body
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").body
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").body
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).body
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").body
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
@@ -1,3 +1,3 @@
1
1
  module ChallongeUserRails
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  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.0
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.1.6
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.