cookbook_client 0.0.3 → 0.0.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: 9ad67f6ebac3867db8c99b4b24b25f7b1db4208c764a9efb9dbffec4b7bd1796
4
- data.tar.gz: 278fdbc6f2bf4f512781f08a7bc5c8cdc67362dbe6176e317c5566b769f78004
3
+ metadata.gz: ef5bd90caf116b8cd7115fbee7349e6c941ae769792d320d5f0f99e973f45555
4
+ data.tar.gz: f128f72cf6cda584cb2e758ceea0e3c0e7fb745f0542b8ce82af09d129aaa954
5
5
  SHA512:
6
- metadata.gz: 2d9efdb28a68984f02204e077fa7c51ac80296fc7cac06cc9f577796e7b57452a1fe9ce5bf327ddc228288b5c5d9be67decbf10d98412ffd14d14b2ab5916985
7
- data.tar.gz: 746c2d2ebc5897e266f7b821bc98dc54acc0afe8ff86ba148490a66309b2ef4d6a323da71879d8ec7fba60e8cdbb7c9f75c5a56f039bbd1432860b2996e569cd
6
+ metadata.gz: 9e3c1db2dcc2624b82c8269fa96f33ceba76db3b7b4b8d6c794e14f6d7d471994e18a3843045939bc466b8f53360a44e7a5b34f4102eb2c4b79624622ddf26f4
7
+ data.tar.gz: e3f06dcca4aa594dd897ff8f7c02d8aaec13d76762834adf514b01d0879c7984b141e01aebb6b1a7955ed2c272eb242708adfa413894d0df55dd2547b1cc5d3e
@@ -42,3 +42,4 @@ end
42
42
 
43
43
  require 'cookbook_client/recipe'
44
44
  require 'cookbook_client/cuisine'
45
+ require 'cookbook_client/recipe_type'
@@ -0,0 +1,35 @@
1
+ class CookbookClient::RecipeType
2
+ attr_accessor :id, :name
3
+
4
+ def initialize(info:)
5
+ @id = info['id']
6
+ @name = info['name']
7
+ end
8
+
9
+ def self.all
10
+ response = CookbookClient.http.get('/api/v1/recipe_types')
11
+
12
+ if response.status != 200
13
+ raise StandardError, "Error #{response.status} - #{response.body}"
14
+ end
15
+
16
+ format_recipe_type recipe_types: JSON.parse(response.body)
17
+ end
18
+
19
+ def self.find_by_name(name)
20
+ response = CookbookClient.http.get('/api/v1/recipe_types/name', name: name)
21
+
22
+ if response.status != 200
23
+ raise StandardError, "Error #{response.status} - #{response.body}"
24
+ end
25
+
26
+ format_recipe_type(recipe_types: JSON.parse(response.body)).first
27
+ end
28
+
29
+ def self.format_recipe_type(recipe_types:)
30
+ recipe_types = [recipe_types] unless recipe_types.is_a? Array
31
+ recipe_types.map do |rp|
32
+ new info: rp
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookbook_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jefferson Barbosa
@@ -34,6 +34,7 @@ files:
34
34
  - lib/cookbook_client.rb
35
35
  - lib/cookbook_client/cuisine.rb
36
36
  - lib/cookbook_client/recipe.rb
37
+ - lib/cookbook_client/recipe_type.rb
37
38
  homepage:
38
39
  licenses:
39
40
  - MIT