dog_api_bindings 0.0.0 → 0.1.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dog-api.rb +22 -7
  3. metadata +22 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b9e202c21bb0f274f885171628a78f0a105e999baa49b9f752d3d0cebd8184a
4
- data.tar.gz: b03c0513f70151e44a6bf81605cb456d36b93cc0f619588d080edf0a58fec484
3
+ metadata.gz: 9fef5139fe652f9f67f0ab361f72722d91fc52c120fb416b49b66c2875e5beff
4
+ data.tar.gz: 0cd4b4f70f9d9c0d4999c05b1268a48447e2341ed27f5cfe63e7d565eb2886bf
5
5
  SHA512:
6
- metadata.gz: b679b696d7899dc913ec4b046865f8bdd2678cf2b98156920271df68d48cf904c1337e7306e6e4a8325268fe8e8daef18f711662600077a5635c4fc2467018b1
7
- data.tar.gz: 150053398bac9f1a2db992cc7eaf60627718816e03ea72323f523bab2f22bd95c62ceb4f7a28ac6d4d11809c7b2e7f78f2b58fa016ee0b4c13c2035b69aa6b27
6
+ metadata.gz: b9489400c7effa57ac2de01e49c246c571e55b066f31ba0702f86f0d9900c5f493236f979e673ddec58ad68e497c2e5599adeff36f774e25b399d470c1c5cb50
7
+ data.tar.gz: 7738d7aef2415891340399382583ef54319d1844948d658704abe078a5fb31541c37c1b37d2a5bb500523a74daf47a92f93737afa888b587d0ca0631603a3e63
data/lib/dog-api.rb CHANGED
@@ -2,33 +2,41 @@
2
2
 
3
3
  require 'http'
4
4
 
5
+ # BASE API URI
5
6
  API_ENDPOINT = 'https://dog.ceo/api'
6
7
 
7
- def return_breeds_list
8
+ # Returns a hash of all available breeds.
9
+ def breeds_list
8
10
  response = HTTP.get("#{API_ENDPOINT}/breeds/list/all")
9
11
  hashed_response = response.parse['message'] if response.code == 200
10
12
  hashed_response or "Could not connect to the API, Status Code: #{response.code}"
11
13
  end
12
14
 
13
- def return_sub_breeds_list(breed)
15
+ # Returns a hash of all available sub-breeds of the given breed.
16
+ def sub_breeds_list(breed)
14
17
  response = HTTP.get("#{API_ENDPOINT}/breed/#{breed}/list")
15
18
  hashed_response = response.parse['message'] if response.code == 200
16
19
  hashed_response || "Could not connect to the API, Status Code: #{response.code}. Perhaps this breed does not have any sub-breeds?"
17
20
  end
18
21
 
19
- def return_breed_images(breed)
22
+ # Returns an array of all available images of the given breed.
23
+ def all_breed_images(breed)
20
24
  response = HTTP.get("#{API_ENDPOINT}/breed/#{breed}/images")
21
25
  hashed_response = response.parse['message'] if response.code == 200
22
26
  hashed_response || "Could not connect to the API, Status Code: #{response.code}"
23
27
  end
24
28
 
25
- def return_sub_breed_images(breed, sub_breed)
29
+ # Returns an array of all available images of the given breed and sub-breed.
30
+ def all_sub_breed_images(breed, sub_breed)
26
31
  response = HTTP.get("#{API_ENDPOINT}/breed/#{breed}/#{sub_breed}/images")
27
32
  hashed_response = response.parse['message'] if response.code == 200
28
33
  hashed_response || "Could not connect to the API, Status Code: #{response.code} Perhaps this breed does not have any sub-breeds?"
29
34
  end
30
35
 
31
- def return_random_images(amount)
36
+ # Returns an array of random breed images equivalent to the passed amount.
37
+ #
38
+ # Due to API limitations, it can only return an amount between 1 and 50.
39
+ def random_images(amount)
32
40
  if amount >= 1 && amount <= 50
33
41
  response = HTTP.get("#{API_ENDPOINT}/breeds/image/random/#{amount}")
34
42
  hashed_response = response.parse['message'] if response.code == 200
@@ -38,7 +46,10 @@ def return_random_images(amount)
38
46
  end
39
47
  end
40
48
 
41
- def return_random_breed_images(breed, amount)
49
+ # Returns an array of breed images equivalent to the passed amount.
50
+ #
51
+ # Due to API limitations, it can only return an amount between 1 and 50.
52
+ def random_breed_images(breed, amount)
42
53
  if amount >= 1 && amount <= 50
43
54
  response = HTTP.get("#{API_ENDPOINT}/breed/#{breed}/images/random/#{amount}")
44
55
  hashed_response = response.parse['message'] if response.code == 200
@@ -48,7 +59,11 @@ def return_random_breed_images(breed, amount)
48
59
  end
49
60
  end
50
61
 
51
- def return_random_sub_breed_images(breed, sub_breed, amount)
62
+ # Returns an array of sub-breed images equivalent to the passed amount.
63
+ #
64
+ # Due to API limitations, it can only return an amount between 1 and 50.
65
+ def random_sub_breed_images(breed, sub_breed, amount)
66
+
52
67
  if amount >= 1 && amount <= 50
53
68
  response = HTTP.get("#{API_ENDPOINT}/breed/#{breed}/#{sub_breed}/images/random/#{amount}")
54
69
  hashed_response = response.parse['message'] if response.code == 200
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dog_api_bindings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quinton Oglesby
@@ -9,8 +9,25 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2022-01-25 00:00:00.000000000 Z
12
- dependencies: []
13
- description: My first ruby gem.
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.0.4
27
+ description: |2
28
+ This is an api wrapper for dog.ceo written in Ruby.
29
+
30
+ ```Test```
14
31
  email: qoglesby97@gmail.com
15
32
  executables: []
16
33
  extensions: []
@@ -29,7 +46,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
29
46
  requirements:
30
47
  - - ">="
31
48
  - !ruby/object:Gem::Version
32
- version: '0'
49
+ version: 3.1.0
33
50
  required_rubygems_version: !ruby/object:Gem::Requirement
34
51
  requirements:
35
52
  - - ">="
@@ -39,5 +56,5 @@ requirements: []
39
56
  rubygems_version: 3.3.5
40
57
  signing_key:
41
58
  specification_version: 4
42
- summary: Ruby bindings for the dog.ceo API.
59
+ summary: Ruby API wrapper for the dog.ceo API.
43
60
  test_files: []