Skip to content

Commit

Permalink
use vimeo api
Browse files Browse the repository at this point in the history
  • Loading branch information
yshmarov committed Oct 26, 2024
1 parent 9e1276e commit 03a798a
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ group :test do
gem "capybara"
gem "selenium-webdriver"
end

gem "faraday", "~> 2.12"
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ GEM
reline (>= 0.3.8)
drb (2.2.1)
erubi (1.13.0)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-net_http (3.3.0)
net-http
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.6)
Expand Down Expand Up @@ -131,6 +137,8 @@ GEM
mini_mime (1.1.5)
minitest (5.25.1)
msgpack (1.7.3)
net-http (0.4.1)
uri
net-imap (0.5.0)
date
net-protocol
Expand Down Expand Up @@ -273,6 +281,7 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (0.13.1)
useragent (0.16.10)
web-console (4.2.1)
actionview (>= 6.0.0)
Expand Down Expand Up @@ -309,6 +318,7 @@ DEPENDENCIES
brakeman
capybara
debug
faraday (~> 2.12)
importmap-rails
jbuilder
puma (>= 5.0)
Expand Down
30 changes: 30 additions & 0 deletions app/jobs/vimeo_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class VimeoJob < ApplicationJob
queue_as :default

ACCESS_TOKEN = "testtesttesttesttesttest"
def perform(*args)
url = "https://api.vimeo.com"
conn = Faraday.new(url:) do |faraday|
faraday.request :authorization, :Bearer, ACCESS_TOKEN
end

# response = conn.get('/me')
# return unless response.success?
# body = JSON.parse response.body

# user_id = body["uri"]
# response = conn.get(user_id)
# return unless response.success?
# body = JSON.parse response.body

# response = conn.get('/me/videos')
# return unless response.success?
# body = JSON.parse response.body
# response = conn.get('/users/:id/videos')

Check failure on line 24 in app/jobs/vimeo_job.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/TrailingWhitespace: Trailing whitespace detected.
response = conn.get("/videos/123123123")
return unless response.success?
body = JSON.parse response.body
video = Video.create(vimeo_payload: body.to_h)
end
end
2 changes: 2 additions & 0 deletions app/models/video.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Video < ApplicationRecord
end
9 changes: 9 additions & 0 deletions db/migrate/20241026170531_create_videos.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateVideos < ActiveRecord::Migration[7.2]
def change
create_table :videos do |t|
t.json :vimeo_payload

t.timestamps
end
end
end
19 changes: 19 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 03a798a

Please sign in to comment.