checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4f5b250dcfe6e85b5a093e85115faa1275a0e42c8ea8befa20a876ceecabc564
4
+ data.tar.gz: 57baa4e9a4d52578a9f53f39fb56f3fb24365aabc7899f3cb4d8720bb8f23354
5
+ SHA512:
6
+ metadata.gz: bfceddd95470e2f296543aff02ace0d33a4f4ec812004043609f09293a29d583f921ca307314f7f22357dfc1b43e64474d6308db1ce7171d622ac2ba4a6841a9
7
+ data.tar.gz: c8c5156a632a5bf28076dfef3df318ca36f4d4f46272057edf08609a12fe490db58e967942bf0d04363b693864a681a36747544dec0c5553883cf66fd5afff6b
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,15 @@
1
+ image: "ruby:2.6"
2
+
3
+ before_script:
4
+ - ruby -v
5
+ - which ruby
6
+ - gem install bundler --no-document
7
+ - bundle install --jobs $(nproc) "${FLAGS[@]}"
8
+
9
+ rspec:
10
+ script:
11
+ - bundle exec rspec
12
+
13
+ rubocop:
14
+ script:
15
+ - bundle exec rubocop
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,29 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6.3
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ Metrics/LineLength:
8
+ Max: 190
9
+
10
+ Style/HashSyntax:
11
+ EnforcedStyle: ruby19
12
+
13
+ Metrics/MethodLength:
14
+ Exclude:
15
+ - 'spec/**/*'
16
+ - 'spec/support/fake_pexels.rb'
17
+ - 'pexels_api_client.gemspec'
18
+
19
+ Metrics/BlockLength:
20
+ Exclude:
21
+ - 'spec/**/*'
22
+ - 'spec/support/fake_pexels.rb'
23
+ - 'pexels_api_client.gemspec'
24
+
25
+ Metrics/ClassLength:
26
+ Exclude:
27
+ - 'spec/**/*'
28
+ - 'spec/support/fake_pexels.rb'
29
+ - 'pexels_api_client.gemspec'
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 2.0.2
data/CHANGELOG ADDED
File without changes
data/CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at noragmora@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in pexels_api_client.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,110 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pexels_api_client (0.1.3)
5
+ flexirest (~> 1.8.6)
6
+ json (~> 2.2.0)
7
+ rest-client (~> 2.1.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (6.0.1)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 0.7, < 2)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ zeitwerk (~> 2.2)
18
+ addressable (2.7.0)
19
+ public_suffix (>= 2.0.2, < 5.0)
20
+ ast (2.4.0)
21
+ bump (0.8.0)
22
+ concurrent-ruby (1.1.5)
23
+ crack (0.4.3)
24
+ safe_yaml (~> 1.0.0)
25
+ diff-lcs (1.3)
26
+ domain_name (0.5.20190701)
27
+ unf (>= 0.0.5, < 1.0.0)
28
+ faraday (0.17.1)
29
+ multipart-post (>= 1.2, < 3)
30
+ flexirest (1.8.6)
31
+ activesupport
32
+ crack
33
+ faraday
34
+ mime-types
35
+ multi_json
36
+ hashdiff (1.0.0)
37
+ http-accept (1.7.0)
38
+ http-cookie (1.0.3)
39
+ domain_name (~> 0.5)
40
+ i18n (1.7.0)
41
+ concurrent-ruby (~> 1.0)
42
+ jaro_winkler (1.5.4)
43
+ json (2.2.0)
44
+ mime-types (3.3)
45
+ mime-types-data (~> 3.2015)
46
+ mime-types-data (3.2019.1009)
47
+ minitest (5.13.0)
48
+ multi_json (1.14.1)
49
+ multipart-post (2.1.1)
50
+ netrc (0.11.0)
51
+ parallel (1.19.1)
52
+ parser (2.6.5.0)
53
+ ast (~> 2.4.0)
54
+ public_suffix (4.0.1)
55
+ rainbow (3.0.0)
56
+ rest-client (2.1.0)
57
+ http-accept (>= 1.7.0, < 2.0)
58
+ http-cookie (>= 1.0.2, < 2.0)
59
+ mime-types (>= 1.16, < 4.0)
60
+ netrc (~> 0.8)
61
+ rspec (3.9.0)
62
+ rspec-core (~> 3.9.0)
63
+ rspec-expectations (~> 3.9.0)
64
+ rspec-mocks (~> 3.9.0)
65
+ rspec-core (3.9.0)
66
+ rspec-support (~> 3.9.0)
67
+ rspec-expectations (3.9.0)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.9.0)
70
+ rspec-mocks (3.9.0)
71
+ diff-lcs (>= 1.2.0, < 2.0)
72
+ rspec-support (~> 3.9.0)
73
+ rspec-support (3.9.0)
74
+ rubocop (0.77.0)
75
+ jaro_winkler (~> 1.5.1)
76
+ parallel (~> 1.10)
77
+ parser (>= 2.6)
78
+ rainbow (>= 2.2.2, < 4.0)
79
+ ruby-progressbar (~> 1.7)
80
+ unicode-display_width (>= 1.4.0, < 1.7)
81
+ ruby-progressbar (1.10.1)
82
+ safe_yaml (1.0.5)
83
+ thread_safe (0.3.6)
84
+ tzinfo (1.2.5)
85
+ thread_safe (~> 0.1)
86
+ unf (0.1.4)
87
+ unf_ext
88
+ unf_ext (0.0.7.6)
89
+ unicode-display_width (1.6.0)
90
+ vcr (5.0.0)
91
+ webmock (3.7.6)
92
+ addressable (>= 2.3.6)
93
+ crack (>= 0.3.2)
94
+ hashdiff (>= 0.4.0, < 2.0.0)
95
+ zeitwerk (2.2.2)
96
+
97
+ PLATFORMS
98
+ ruby
99
+
100
+ DEPENDENCIES
101
+ bump (~> 0.8.0)
102
+ bundler (~> 2.0)
103
+ pexels_api_client!
104
+ rspec (~> 3.9.0)
105
+ rubocop (~> 0.77.0)
106
+ vcr (~> 5.0.0)
107
+ webmock (~> 3.7.6)
108
+
109
+ BUNDLED WITH
110
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Nora Gabriela Alvarado
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,165 @@
1
+ # PexelsApiClient
2
+
3
+ PexelsApiClient its a Ruby wrapper for the [Pexels](https://www.pexels.com) API. Please read Pexel's [documentation](https://www.pexels.com/api/documentation/) on how to start using their API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pexels_api_client'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pexels_api_client
20
+
21
+ ## Usage
22
+
23
+ To start using the Pexel's API you'll first need to setup an [account](https://www.pexels.com/join/) on their site, once you have an account you will need to request an [Api Key](https://www.pexels.com/api/new/)
24
+
25
+ Now you can configure the gem with:
26
+
27
+ ```ruby
28
+ PexelsApiClient.config do |config|
29
+ config.api_key = '<API_KEY>'
30
+ end
31
+ ```
32
+
33
+ #### Photo Methods
34
+
35
+ * **Find**: If you have the id of a photo, you can retrieve the data of it.
36
+
37
+ ```ruby
38
+ photo = PexelsApiClient::Photo.find(id)
39
+ photo.width # => 1400
40
+ photo.photographer # => John Doe
41
+ # ...
42
+ ```
43
+
44
+ * **Curated**: Get a Curated list of trending photos.
45
+
46
+ | **options** | |
47
+ | ------ | ------ |
48
+ | per_page | Defines the number of results per page. (optional, default: 15, max: 80) |
49
+ | page | Defines the number of the page. (optional, default: 1) |
50
+
51
+ ```ruby
52
+ curated_photos = PexelsApiClient::Photo.curated # => Fallback to default options
53
+ -- or --
54
+ curated_photos = PexelsApiClient::Photo.curated(per_page: 5, page: 2) # => With custom options
55
+
56
+ curated_photos.photos # => [photo1, photo2,etc]
57
+ curated_photos.photos.first.photographer # => John Doe
58
+ # ...
59
+ ```
60
+
61
+ * **Random**: Returns a random photo from the curated photos
62
+
63
+ ```ruby
64
+ random_photo = PexelsApiClient::Photo.random
65
+
66
+ random_photo.photos # => [photo1]
67
+ random_photo.photos.first.photographer # => John Doe
68
+ # ...
69
+ ```
70
+
71
+ * **Search**: Search for photos related to a query
72
+
73
+ | **options** | |
74
+ | ------ | ------ |
75
+ | query | Get photos related to this query. (required) |
76
+ | per_page | Defines the number of results per page. (optional, default: 15, max: 80) |
77
+ | page | Defines the number of the page. (optional, default: 1) |
78
+
79
+ ```ruby
80
+ search_photos = PexelsApiClient::Photo.search(per_page: 5, page: 2, query: 'people')
81
+
82
+ curated_photos.photos # => [photo1, photo2,etc]
83
+ curated_photos.photos.first.photographer # => John Doe
84
+ # ...
85
+ ```
86
+
87
+ #### Video Methods
88
+
89
+ * **Find**: If you have the id of a video, you can retrieve the data of it.
90
+
91
+ ```ruby
92
+ video = PexelsApiClient::Video.find(id)
93
+ video.width # => 1400
94
+ video.user.name # => John Doe
95
+ # ...
96
+ ```
97
+
98
+ * **Popular**: Get a list of popular videos.
99
+
100
+ | **options** | |
101
+ | ------ | ------ |
102
+ | per_page | Defines the number of results per page. (optional, default: 15, max: 80) |
103
+ | page | Defines the number of the page. (optional, default: 1) |
104
+ | min_width | The minimum width in pixels of the returned videos. (optional, default: "") |
105
+ | max_width | The maximum width in pixels of the returned videos. (optional, default: "") |
106
+ | min_duration | The minimum duration in seconds of the returned videos. (optional, default: "")|
107
+ | max_duration | The maximum duration in seconds of the returned videos. (optional, default: "") |
108
+
109
+ ```ruby
110
+ popular_videos = PexelsApiClient::Video.popular # => Fallback to default options
111
+ -- or --
112
+ popular_videos = PexelsApiClient::Video.popular(per_page: 5, page: 2) # => With custom options
113
+
114
+ popular_videos.videos # => [video1, video2, etc]
115
+ popular_videos.videos.first.user.name # => John Doe
116
+ # ...
117
+ ```
118
+
119
+ * **Random**: Returns a random video from the popular videos
120
+
121
+ ```ruby
122
+ random_video = PexelsApiClient::Video.random
123
+
124
+ random_video.videos # => [photo1]
125
+ random_video.videos.first.user.name # => John Doe
126
+ # ...
127
+ ```
128
+
129
+ * **Search**: Search for videos related to a query
130
+
131
+ | **options** | |
132
+ | ------ | ------ |
133
+ | query | Get videos related to this query. (required) |
134
+ | per_page | Defines the number of results per page. (optional, default: 15, max: 80) |
135
+ | page | Defines the number of the page. (optional, default: 1) |
136
+ | min_width | The minimum width in pixels of the returned videos. (optional, default: "") |
137
+ | max_width | The maximum width in pixels of the returned videos. (optional, default: "") |
138
+ | min_duration | The minimum duration in seconds of the returned videos. (optional, default: "")|
139
+ | max_duration | The maximum duration in seconds of the returned videos. (optional, default: "") |
140
+
141
+ ```ruby
142
+ search_videos = PexelsApiClient::Video.search(per_page: 5, page: 2, query: 'people')
143
+
144
+ search_videos.videos # => [video1, video2,etc]
145
+ search_videos.videos.first.user.name # => John Doe
146
+ # ...
147
+ ```
148
+
149
+ ## Development
150
+
151
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
152
+
153
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
154
+
155
+ ## Contributing
156
+
157
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pexels_api_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
158
+
159
+ ## License
160
+
161
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
162
+
163
+ ## Code of Conduct
164
+
165
+ Everyone interacting in the PexelsApiClient project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](http://contributor-covenant.org)
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'pexels_api_client'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=#x27;\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/pexels_api_client.rb ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'flexirest'
4
+
5
+ module PexelsApiClient
6
+ require 'pexels_api_client/errors'
7
+
8
+ autoload :Base, 'pexels_api_client/base'
9
+ autoload :Photo, 'pexels_api_client/photo'
10
+ autoload :Video, 'pexels_api_client/video'
11
+ autoload :Config, 'pexels_api_client/config'
12
+
13
+ BASE_URL = 'https://api.pexels.com/'
14
+
15
+ def self.config
16
+ if block_given?
17
+ yield(PexelsApiClient::Config)
18
+ else
19
+ PexelsApiClient::Config
20
+ end
21
+ end
22
+ end
data/lib/pexels_api_client/base.rb ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+
5
+ module PexelsApiClient
6
+ class Base < Flexirest::Base
7
+ after_request :rescue_errors
8
+
9
+ def rescue_errors(_name, response)
10
+ if (400..499).cover?(response.status)
11
+ result = JSON.parse(response.body)
12
+ message = result['errors'] || [result['error']]
13
+ raise BadRequestError, message.to_a.join(', ')
14
+ elsif (500..599).cover?(response.status)
15
+ raise ServerError, "Could not process your request: status #{response.status}"
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/pexels_api_client/config.rb ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PexelsApiClient
4
+ module Config
5
+ class << self
6
+ attr_reader :api_key, :base_url
7
+
8
+ def reset
9
+ @api_key = nil
10
+ @base_url = PexelsApiClient::BASE_URL
11
+ end
12
+
13
+ def api_key=(api_key)
14
+ @api_key = api_key
15
+ set_api_auth
16
+ end
17
+
18
+ def base_url=(base_url)
19
+ @base_url = base_url
20
+ set_api_auth
21
+ end
22
+
23
+ private
24
+
25
+ def set_api_auth
26
+ Flexirest::Base.base_url = base_url
27
+ Flexirest::Base.request_body_type = :json
28
+
29
+ Flexirest::Base.faraday_config do |faraday|
30
+ faraday.adapter(:net_http)
31
+ faraday.options.timeout = 10
32
+ faraday.headers['User-Agent'] = "Flexirest/#{Flexirest::VERSION}"
33
+ faraday.headers['Authorization'] = @api_key
34
+ end
35
+ end
36
+ end
37
+
38
+ reset
39
+ end
40
+ end
data/lib/pexels_api_client/errors.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PexelsApiClient
4
+ PexelsApiClientError = Class.new StandardError
5
+ BadRequestError = Class.new StandardError
6
+ ServerError = Class.new StandardError
7
+ ApiKeyError = Class.new StandardError
8
+ NotApiKeyError = Class.new ArgumentError
9
+ end
data/lib/pexels_api_client/photo.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PexelsApiClient
4
+ class Photo < PexelsApiClient::Base
5
+ get :curated, 'v1/curated', defaults: { per_page: 15, page: 1 }
6
+ get :random, 'v1/curated', defaults: { per_page: 1, page: rand(1..1000) }
7
+ get :search, 'v1/search', defaults: { per_page: 15, page: 1 }, required: [:query]
8
+ get :find, 'v1/photos/:id'
9
+ end
10
+ end
data/lib/pexels_api_client/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PexelsApiClient
4
+ VERSION = '0.1.3'
5
+ end
data/lib/pexels_api_client/video.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PexelsApiClient
4
+ class Video < PexelsApiClient::Base
5
+ get :find, 'videos/videos/:id'
6
+ get :popular, 'videos/popular', defaults: { per_page: 15, page: 1, min_width: '', max_width: '', min_duration: '', max_duration: '' }
7
+ get :random, 'videos/popular', defaults: { per_page: 1, page: rand(1..1000), min_width: '', max_width: '', min_duration: '', max_duration: '' }
8
+ get :search, 'videos/search', defaults: { per_page: 15, page: 1, min_width: '', max_width: '', min_duration: '', max_duration: '' }, required: [:query]
9
+ end
10
+ end
data/pexels_api_client.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'pexels_api_client/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'pexels_api_client'
9
+ spec.version = PexelsApiClient::VERSION
10
+ spec.authors = ['Nora Gabriela Alvarado']
11
+ spec.email = ['noragmora@gmail.com']
12
+
13
+ spec.summary = 'This gem is used to access the Pexels API.'
14
+ spec.description = 'Using this gem allows you to make requests to the Pexels API endpoints.'
15
+ spec.homepage = 'https://gitlab.com/aromaron/pexels_api_client'
16
+ spec.license = 'MIT'
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://gitlab.com/aromaron/pexels_api_client'
20
+ spec.metadata['changelog_uri'] = 'https://gitlab.com/aromaron/pexels_api_client/blob/master/CHANGELOG'
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+ spec.required_ruby_version = '~> 2.6.3'
32
+
33
+ spec.add_runtime_dependency 'flexirest', '~> 1.8.6'
34
+ spec.add_runtime_dependency 'json', '~> 2.2.0'
35
+ spec.add_runtime_dependency 'rest-client', '~> 2.1.0'
36
+
37
+ spec.add_development_dependency 'bump', '~> 0.8.0'
38
+ spec.add_development_dependency 'bundler', '~> 2.0'
39
+ spec.add_development_dependency 'rspec', '~> 3.9.0'
40
+ spec.add_development_dependency 'rubocop', '~> 0.77.0'
41
+ spec.add_development_dependency 'vcr', '~> 5.0.0'
42
+ spec.add_development_dependency 'webmock', '~> 3.7.6'
43
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pexels_api_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Nora Gabriela Alvarado
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: flexirest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bump
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.9.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.9.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.77.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.77.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 5.0.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 5.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 3.7.6
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 3.7.6
139
+ description: Using this gem allows you to make requests to the Pexels API endpoints.
140
+ email:
141
+ - noragmora@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".gitlab-ci.yml"
148
+ - ".rspec"
149
+ - ".rubocop.yml"
150
+ - ".travis.yml"
151
+ - CHANGELOG
152
+ - CODE_OF_CONDUCT.md
153
+ - Gemfile
154
+ - Gemfile.lock
155
+ - LICENSE.txt
156
+ - README.md
157
+ - Rakefile
158
+ - bin/console
159
+ - bin/setup
160
+ - lib/pexels_api_client.rb
161
+ - lib/pexels_api_client/base.rb
162
+ - lib/pexels_api_client/config.rb
163
+ - lib/pexels_api_client/errors.rb
164
+ - lib/pexels_api_client/photo.rb
165
+ - lib/pexels_api_client/version.rb
166
+ - lib/pexels_api_client/video.rb
167
+ - pexels_api_client.gemspec
168
+ homepage: https://gitlab.com/aromaron/pexels_api_client
169
+ licenses:
170
+ - MIT
171
+ metadata:
172
+ homepage_uri: https://gitlab.com/aromaron/pexels_api_client
173
+ source_code_uri: https://gitlab.com/aromaron/pexels_api_client
174
+ changelog_uri: https://gitlab.com/aromaron/pexels_api_client/blob/master/CHANGELOG
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: 2.6.3
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubygems_version: 3.0.3
191
+ signing_key:
192
+ specification_version: 4
193
+ summary: This gem is used to access the Pexels API.
194
+ test_files: []