breathe 0.3.1 → 0.3.2

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: ff2837bf3695cdf7014639abd4e60f70dca9f6832167e1c0846a08416c446212
4
- data.tar.gz: 468036efeb1ef793a94c1568f92c0abda53a4a82e1b9ca16318a728396820c3f
3
+ metadata.gz: 96b92d21eb2bfb0d148c30e774fb209332d9d417921c26f1a51448ebea86a949
4
+ data.tar.gz: 863903e2d56dc255f219ed8b6da8164dc3e685c0c25e87db341319f49f21aab7
5
5
  SHA512:
6
- metadata.gz: 339a9998eea5fdbce58e178ac1ec545a966da3593b8a44ff89ad77091f446a22b42fd85c72918cfa5233307c57c31639c1e7b6a66fce4d2b8c301bfd14221a2b
7
- data.tar.gz: 93f1d9a8582071ae1f78471bbcd62c0f0d6a5c59bcf3fad2e9fa84adde101286cb7f33159397645b80f08ab470b0b693d740dedc80fbf35d717efb4201f6a89d
6
+ metadata.gz: 0447d915f7761db9d2c55728349d4d00655bc1b16f37be622de6c2b22288186836c0330198eca6b1267445a412c73fa8c9dcbb8bf95a48e5ff2135bd3d375d5c
7
+ data.tar.gz: 1d79b24732559cb2373eff989a23073295ffc8f7a2a940a2b5ccaa93c4ddcf8d2d9d8865a21e1223f07a6839e91262b0734d12576ee9d2872f6c69ebf4e3696d
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog]
6
6
 
7
+ [0.3.2]
8
+
9
+ - Support listing of training courses
10
+
7
11
  [0.3.1]
8
12
 
9
13
  - Fix bug with auto pagination
@@ -30,6 +34,7 @@ The format is based on [Keep a Changelog]
30
34
 
31
35
  - Allow listing of absences
32
36
 
37
+ [0.3.2]: https://github.com/dxw/breathe_ruby/releases/tag/0.3.2
33
38
  [0.3.1]: https://github.com/dxw/breathe_ruby/releases/tag/0.3.1
34
39
  [0.3.0]: https://github.com/dxw/breathe_ruby/releases/tag/0.3.0
35
40
  [0.2.0]: https://github.com/dxw/breathe_ruby/releases/tag/0.2.0
data/README.md CHANGED
@@ -66,6 +66,13 @@ client.employees.get(id)
66
66
  #=> [...]
67
67
  ```
68
68
 
69
+ ### List employee training courses
70
+
71
+ ```ruby
72
+ client.employee_training_courses.list
73
+ #=> [...]
74
+ ```
75
+
69
76
  ### Filtering
70
77
 
71
78
  You can also pass in arguments like so:
@@ -3,14 +3,17 @@ require "sawyer"
3
3
  require "breathe/version"
4
4
  require "breathe/client"
5
5
  require "breathe/response"
6
+ require "breathe/resource"
6
7
 
7
8
  require "breathe/absences"
8
9
  require "breathe/sicknesses"
9
10
  require "breathe/employees"
11
+ require "breathe/employee_training_courses"
10
12
 
11
13
  module Breathe
12
14
  class Error < StandardError; end
13
15
  class AuthenticationError < StandardError; end
14
16
  class UnknownError < StandardError; end
17
+ class NotSupportedError < StandardError; end
15
18
  # Your code goes here...
16
19
  end
@@ -1,17 +1,8 @@
1
1
  module Breathe
2
- class Absences
3
- attr_reader :client
4
-
5
- def initialize(client)
6
- @client = client
7
- end
8
-
9
- def list(args = {})
10
- client.response(
11
- method: :get,
12
- path: "absences",
13
- args: args
14
- )
15
- end
2
+ class Absences < Resource
3
+ RESOURCE_NAME = "absences"
4
+ SUPPORTED_ENDPOINTS = [
5
+ :list,
6
+ ]
16
7
  end
17
8
  end
@@ -21,6 +21,10 @@ module Breathe
21
21
  @employees ||= Employees.new(self)
22
22
  end
23
23
 
24
+ def employee_training_courses
25
+ @employee_training_courses ||= EmployeeTrainingCourses.new(self)
26
+ end
27
+
24
28
  def response(method:, path:, args: {})
25
29
  response = request(method: method, path: path, options: {query: args})
26
30
  parsed_response = Response.new(response: response, type: path.split("/").first)
@@ -0,0 +1,8 @@
1
+ module Breathe
2
+ class EmployeeTrainingCourses < Resource
3
+ RESOURCE_NAME = "employee_training_courses"
4
+ SUPPORTED_ENDPOINTS = [
5
+ :list,
6
+ ]
7
+ end
8
+ end
@@ -1,24 +1,9 @@
1
1
  module Breathe
2
- class Employees
3
- attr_reader :client
4
-
5
- def initialize(client)
6
- @client = client
7
- end
8
-
9
- def list(args = {})
10
- client.response(
11
- method: :get,
12
- path: "employees",
13
- args: args
14
- )
15
- end
16
-
17
- def get(id)
18
- client.response(
19
- method: :get,
20
- path: "employees/#{id.to_i}"
21
- )
22
- end
2
+ class Employees < Resource
3
+ RESOURCE_NAME = "employees"
4
+ SUPPORTED_ENDPOINTS = [
5
+ :list,
6
+ :get,
7
+ ]
23
8
  end
24
9
  end
@@ -0,0 +1,34 @@
1
+ module Breathe
2
+ class Resource
3
+ attr_reader :client
4
+
5
+ def initialize(client)
6
+ @client = client
7
+ end
8
+
9
+ def list(args = {})
10
+ raise NotSupportedError unless self.class::SUPPORTED_ENDPOINTS.include?(:list)
11
+
12
+ client.response(
13
+ method: :get,
14
+ path: resource_name,
15
+ args: args
16
+ )
17
+ end
18
+
19
+ def get(id)
20
+ raise NotSupportedError unless self.class::SUPPORTED_ENDPOINTS.include?(:get)
21
+
22
+ client.response(
23
+ method: :get,
24
+ path: "#{resource_name}/#{id.to_i}"
25
+ )
26
+ end
27
+
28
+ private
29
+
30
+ def resource_name
31
+ @resource_name ||= self.class::RESOURCE_NAME
32
+ end
33
+ end
34
+ end
@@ -1,17 +1,8 @@
1
1
  module Breathe
2
- class Sicknesses
3
- attr_reader :client
4
-
5
- def initialize(client)
6
- @client = client
7
- end
8
-
9
- def list(args = {})
10
- client.response(
11
- method: :get,
12
- path: "sicknesses",
13
- args: args
14
- )
15
- end
2
+ class Sicknesses < Resource
3
+ RESOURCE_NAME = "sicknesses"
4
+ SUPPORTED_ENDPOINTS = [
5
+ :list,
6
+ ]
16
7
  end
17
8
  end
@@ -1,3 +1,3 @@
1
1
  module Breathe
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breathe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Harrison
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-24 00:00:00.000000000 Z
11
+ date: 2020-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -147,7 +147,9 @@ files:
147
147
  - lib/breathe.rb
148
148
  - lib/breathe/absences.rb
149
149
  - lib/breathe/client.rb
150
+ - lib/breathe/employee_training_courses.rb
150
151
  - lib/breathe/employees.rb
152
+ - lib/breathe/resource.rb
151
153
  - lib/breathe/response.rb
152
154
  - lib/breathe/sicknesses.rb
153
155
  - lib/breathe/version.rb