cookbook_client 0.0.2 → 0.0.3

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: be76326629c54e79e3dbc2fe0d253c04094c273a7fb8d114e077f02839bb008e
4
- data.tar.gz: c695ab16526502ecaa9e719da604c6c3808116247a00292e81b5065f32a857dc
3
+ metadata.gz: 9ad67f6ebac3867db8c99b4b24b25f7b1db4208c764a9efb9dbffec4b7bd1796
4
+ data.tar.gz: 278fdbc6f2bf4f512781f08a7bc5c8cdc67362dbe6176e317c5566b769f78004
5
5
  SHA512:
6
- metadata.gz: 6e3acae49ecd29f63a798d9c037b53cb4db9ec0eb83d8e862fbe57f818eeeab55fe9ff1cd8c0044844b28f4ce3ca036c6b090d8d6f6848f8361c4063bc9b13c4
7
- data.tar.gz: c792356c204f397902e7060442d1b5329bfca1e50a83e7032066126d272e9089559817f22bb3a6ca0e891d151f28197df197303c232f5b6ef201421d070ad507
6
+ metadata.gz: 2d9efdb28a68984f02204e077fa7c51ac80296fc7cac06cc9f577796e7b57452a1fe9ce5bf327ddc228288b5c5d9be67decbf10d98412ffd14d14b2ab5916985
7
+ data.tar.gz: 746c2d2ebc5897e266f7b821bc98dc54acc0afe8ff86ba148490a66309b2ef4d6a323da71879d8ec7fba60e8cdbb7c9f75c5a56f039bbd1432860b2996e569cd
@@ -0,0 +1,35 @@
1
+ class CookbookClient::Cuisine
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/cuisines')
11
+
12
+ if response.status != 200
13
+ raise StandardError, "Error #{response.status} - #{response.body}"
14
+ end
15
+
16
+ format_cuisines cuisines: JSON.parse(response.body)
17
+ end
18
+
19
+ def self.find_by_name(name)
20
+ response = CookbookClient.http.get('/api/v1/cuisines/name', name: name)
21
+
22
+ if response.status != 200
23
+ raise StandardError, "Error #{response.status} - #{response.body}"
24
+ end
25
+
26
+ format_cuisines(cuisines: JSON.parse(response.body)).first
27
+ end
28
+
29
+ def self.format_cuisines(cuisines:)
30
+ cuisines = [cuisines] unless cuisines.is_a? Array
31
+ cuisines.map do |c|
32
+ new info: c
33
+ end
34
+ end
35
+ end
@@ -41,3 +41,4 @@ class CookbookClient
41
41
  end
42
42
 
43
43
  require 'cookbook_client/recipe'
44
+ require 'cookbook_client/cuisine'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookbook_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jefferson Barbosa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-09 00:00:00.000000000 Z
11
+ date: 2019-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -32,6 +32,7 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - lib/cookbook_client.rb
35
+ - lib/cookbook_client/cuisine.rb
35
36
  - lib/cookbook_client/recipe.rb
36
37
  homepage:
37
38
  licenses: