decathlon-sports 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31d87e6957a05ec46402c840bb20eab365d3831716f4c82564ad016da8a29631
4
- data.tar.gz: bbaca6b03011fa40b1e92daa34186fab67d7f79cacf0813f1e69d220df587358
3
+ metadata.gz: 83c5b9fb9c30ab0bcbccff92d750ce7458069d027a0e3894a203aa78447bc9d6
4
+ data.tar.gz: 5170bde54322c0f88ba255a75a6bb8f7d52525660578e18d51d5f46bc1bb2118
5
5
  SHA512:
6
- metadata.gz: 46ce0453c61e9e17fb7e55faefa31167ae6df3962357b11a87cb91f30a4a3107a6e13b265799b0a4402d1a69d89ad4867ef3d54ab80f09da0ecb1c9444929843
7
- data.tar.gz: 91f0aa81e0bb5055ade13a72091b143768a79bfeec0762073f2b9bc972b363efff5397f5442d2eb45913b68db6534451d1f5a2143b792eb47e6412bc0ae535c7
6
+ metadata.gz: 8157a40cd03453f294644949d5ac6c1c2340d2b0e2e39dfde9c55bd2120303bab3bbca7dbab46afbe1f1128c481b1eafe91e2805046f675d1a70eb38d5ad30ad
7
+ data.tar.gz: ba7600138b3b105d6b2861a62878d4fcbc72498df5c3e6ff1f6ba25fc7c45b7f9b09c4e6640148638d37638247517d2540328d9178c2ab0ca0527046b146e154
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- decathlon-sports (0.1.3)
4
+ decathlon-sports (0.1.4)
5
5
  faraday (~> 0.15.3)
6
6
  json (~> 2.1.0)
7
7
 
@@ -38,4 +38,4 @@ DEPENDENCIES
38
38
  rspec (~> 3.0)
39
39
 
40
40
  BUNDLED WITH
41
- 1.16.6
41
+ 1.17.2
data/README.md CHANGED
@@ -30,6 +30,11 @@ sports = Decathlon::Sports.all
30
30
  sport = Decathlon::Sports.find(175)
31
31
  ```
32
32
 
33
+ ### Decathlon::Sports.search
34
+ ```ruby
35
+ sport = Decathlon::Sports.search('Snowboarding')
36
+ ```
37
+
33
38
  ### Decathlon::Sports::Recommendations.get
34
39
  ```ruby
35
40
  recommendations = Decathlon::Sports::Recommendations.get(175)
@@ -1,23 +1,44 @@
1
1
  require 'faraday'
2
2
  require 'json'
3
3
 
4
- API_URL = 'https://sports-decathlon.herokuapp.com'.freeze
4
+ API_URL = 'https://sports.api.decathlon.com'.freeze
5
5
 
6
6
  module Decathlon
7
7
  module Sports
8
8
  def self.all
9
- response = Faraday.get("#{API_URL}/sports")
10
- JSON.parse(response.body)
9
+ call "#{API_URL}/sports"
11
10
  end
12
11
 
13
12
  def self.find(id)
14
- response = Faraday.get("#{API_URL}/sports/#{id}")
15
- JSON.parse(response.body)
13
+ call "#{API_URL}/sports/#{id}"
16
14
  end
17
15
 
18
16
  def self.search(name)
19
17
  response = Faraday.get("#{API_URL}/sports?q=#{name}")
20
18
  JSON.parse(response.body)
21
19
  end
20
+
21
+ def self.call(url)
22
+ response = Faraday.get(url)
23
+ JSON.parse(response.body)
24
+ end
25
+
26
+ def self.filter(**args)
27
+ response = Faraday.get do |req|
28
+ req.url "#{API_URL}/sports"
29
+ req.params['tag'] = args[:tag] if args[:tag]
30
+ req.params['decathlon_id'] = args[:decathlon_id] if args[:decathlon_id]
31
+ req.params['parents_only'] = args[:parents_only] if args[:parents_only]
32
+ end
33
+ JSON.parse(response.body)
34
+ end
35
+
36
+ def groups
37
+ call "#{API_URL}/groups"
38
+ end
39
+
40
+ def group(id)
41
+ call "#{API_URL}/groups/#{id}"
42
+ end
22
43
  end
23
44
  end
@@ -1,5 +1,5 @@
1
1
  module Decathlon
2
2
  module Sports
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decathlon-sports
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Decathlon Canada
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-01-04 00:00:00.000000000 Z
12
+ date: 2019-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -127,8 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
- rubyforge_project:
131
- rubygems_version: 2.7.6
130
+ rubygems_version: 3.0.1
132
131
  signing_key:
133
132
  specification_version: 4
134
133
  summary: Gem to wrap the Decathlon Sports API