dog_api_bindings 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/dog-api.rb +59 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7b9e202c21bb0f274f885171628a78f0a105e999baa49b9f752d3d0cebd8184a
4
+ data.tar.gz: b03c0513f70151e44a6bf81605cb456d36b93cc0f619588d080edf0a58fec484
5
+ SHA512:
6
+ metadata.gz: b679b696d7899dc913ec4b046865f8bdd2678cf2b98156920271df68d48cf904c1337e7306e6e4a8325268fe8e8daef18f711662600077a5635c4fc2467018b1
7
+ data.tar.gz: 150053398bac9f1a2db992cc7eaf60627718816e03ea72323f523bab2f22bd95c62ceb4f7a28ac6d4d11809c7b2e7f78f2b58fa016ee0b4c13c2035b69aa6b27
data/lib/dog-api.rb ADDED
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'http'
4
+
5
+ API_ENDPOINT = 'https://dog.ceo/api'
6
+
7
+ def return_breeds_list
8
+ response = HTTP.get("#{API_ENDPOINT}/breeds/list/all")
9
+ hashed_response = response.parse['message'] if response.code == 200
10
+ hashed_response or "Could not connect to the API, Status Code: #{response.code}"
11
+ end
12
+
13
+ def return_sub_breeds_list(breed)
14
+ response = HTTP.get("#{API_ENDPOINT}/breed/#{breed}/list")
15
+ hashed_response = response.parse['message'] if response.code == 200
16
+ hashed_response || "Could not connect to the API, Status Code: #{response.code}. Perhaps this breed does not have any sub-breeds?"
17
+ end
18
+
19
+ def return_breed_images(breed)
20
+ response = HTTP.get("#{API_ENDPOINT}/breed/#{breed}/images")
21
+ hashed_response = response.parse['message'] if response.code == 200
22
+ hashed_response || "Could not connect to the API, Status Code: #{response.code}"
23
+ end
24
+
25
+ def return_sub_breed_images(breed, sub_breed)
26
+ response = HTTP.get("#{API_ENDPOINT}/breed/#{breed}/#{sub_breed}/images")
27
+ hashed_response = response.parse['message'] if response.code == 200
28
+ hashed_response || "Could not connect to the API, Status Code: #{response.code} Perhaps this breed does not have any sub-breeds?"
29
+ end
30
+
31
+ def return_random_images(amount)
32
+ if amount >= 1 && amount <= 50
33
+ response = HTTP.get("#{API_ENDPOINT}/breeds/image/random/#{amount}")
34
+ hashed_response = response.parse['message'] if response.code == 200
35
+ hashed_response || "Could not connect to the API, Status Code: #{response.code}"
36
+ else
37
+ 'Can only return between 1 and 50 images.'
38
+ end
39
+ end
40
+
41
+ def return_random_breed_images(breed, amount)
42
+ if amount >= 1 && amount <= 50
43
+ response = HTTP.get("#{API_ENDPOINT}/breed/#{breed}/images/random/#{amount}")
44
+ hashed_response = response.parse['message'] if response.code == 200
45
+ hashed_response || "Could not connect to the API, Status Code: #{response.code}"
46
+ else
47
+ 'Can only return between 1 and 50 images.'
48
+ end
49
+ end
50
+
51
+ def return_random_sub_breed_images(breed, sub_breed, amount)
52
+ if amount >= 1 && amount <= 50
53
+ response = HTTP.get("#{API_ENDPOINT}/breed/#{breed}/#{sub_breed}/images/random/#{amount}")
54
+ hashed_response = response.parse['message'] if response.code == 200
55
+ hashed_response || "Could not connect to the API, Status Code: #{response.code} Perhaps this breed does not have any sub-breeds?"
56
+ else
57
+ 'Can only return between 1 and 50 images.'
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dog_api_bindings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Quinton Oglesby
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-01-25 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: My first ruby gem.
14
+ email: qoglesby97@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/dog-api.rb
20
+ homepage: https://rubygems.org/gems/dog_api_bindings
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.3.5
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Ruby bindings for the dog.ceo API.
43
+ test_files: []