Class: Vm::VimeoAccount
- Inherits:
-
Object
- Object
- Vm::VimeoAccount
- Includes:
- Authenticable, Readable
- Defined in:
- lib/vm/vimeo_account.rb,
lib/vm/google_account.rb
Overview
Provides read & write access to a Vimeo (or Vimeo+) account.
Class Method Summary collapse
-
.attribute(name) ⇒ Object
Define a method to return each attribute of the profile separately.
-
.oauth_scopes ⇒ Object
Set the scopes to grant access to Vimeo user profile and email.
Instance Method Summary collapse
-
#email ⇒ Object
Return the email attribute of the Vimeo Account.
-
#family_name ⇒ Object
Return the family_name attribute of the Vimeo Account.
-
#gender ⇒ Object
Return the gender attribute of the Vimeo Account.
-
#given_name ⇒ Object
Return the given_name attribute of the Vimeo Account.
-
#hd ⇒ Object
Return the hd attribute of the Vimeo Account.
-
#id ⇒ Object
Return the id attribute of the Vimeo Account.
-
#info ⇒ Hash
Return the profile info of a Vimeo account in OpenID Connect format.
-
#link ⇒ Object
Return the link attribute of the Vimeo Account.
-
#locale ⇒ Object
Return the locale attribute of the Vimeo Account.
-
#name ⇒ Object
Return the name attribute of the Vimeo Account.
-
#perform!(activity, target_kind, target_id) ⇒ Object
Promote a Vimeo target resource on this Vimeo Channel Note that liking a video does not also subscribe to a channel.
-
#picture ⇒ Object
Return the picture attribute of the Vimeo Account.
-
#verified_email ⇒ Object
Return the verified_email attribute of the Vimeo Account.
Methods included from Readable
#description, #kind, #thumbnail_url, #title
Methods included from Authenticable
Methods included from Requestable
Methods included from ClientTokens
#client_id, client_id=, #client_secret, client_secret=
Class Method Details
.attribute(name) ⇒ Object
Define a method to return each attribute of the profile separately.
51 52 53 |
# File 'lib/vm/google_account.rb', line 51 def self.attribute(name) define_method(name) { info[name] } end |
.oauth_scopes ⇒ Object
Set the scopes to grant access to Vimeo user profile and email
74 75 76 |
# File 'lib/vm/vimeo_account.rb', line 74 def self.oauth_scopes %w(https://www.googleapis.com/auth/vimeo) end |
Instance Method Details
#email ⇒ Object
Return the email attribute of the Vimeo Account.
56 |
# File 'lib/vm/google_account.rb', line 56 attribute :email |
#family_name ⇒ Object
Return the family_name attribute of the Vimeo Account.
60 |
# File 'lib/vm/google_account.rb', line 60 attribute :family_name |
#gender ⇒ Object
Return the gender attribute of the Vimeo Account.
63 |
# File 'lib/vm/google_account.rb', line 63 attribute :gender |
#given_name ⇒ Object
Return the given_name attribute of the Vimeo Account.
59 |
# File 'lib/vm/google_account.rb', line 59 attribute :given_name |
#hd ⇒ Object
Return the hd attribute of the Vimeo Account.
65 |
# File 'lib/vm/google_account.rb', line 65 attribute :hd |
#id ⇒ Object
Return the id attribute of the Vimeo Account.
55 |
# File 'lib/vm/google_account.rb', line 55 attribute :id |
#info ⇒ Hash
Return the profile info of a Vimeo account in OpenID Connect format.
38 39 40 41 42 43 44 45 |
# File 'lib/vm/vimeo_account.rb', line 38 def info @info ||= request! method: :get, auth: credentials[:access_token], host: 'https://www.googleapis.com', path: '/vimeo/v3/channels?part=id,snippet&mine=true', valid_if: -> resp, body {resp.code == '200' && body['items'].any?}, extract: -> body {body['items'].first} end |
#link ⇒ Object
Return the link attribute of the Vimeo Account.
61 |
# File 'lib/vm/google_account.rb', line 61 attribute :link |
#locale ⇒ Object
Return the locale attribute of the Vimeo Account.
64 |
# File 'lib/vm/google_account.rb', line 64 attribute :locale |
#name ⇒ Object
Return the name attribute of the Vimeo Account.
58 |
# File 'lib/vm/google_account.rb', line 58 attribute :name |
#perform!(activity, target_kind, target_id) ⇒ Object
Promote a Vimeo target resource on this Vimeo Channel Note that liking a video does not also subscribe to a channel
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vm/vimeo_account.rb', line 49 def perform!(activity, target_kind, target_id) params = {}.tap do |params| params[:method] = :post params[:auth] = credentials[:access_token] params[:host] = 'https://www.googleapis.com' case [activity.to_sym, target_kind.to_sym] when [:like, :video] params[:path] = "/vimeo/v3/videos/rate?rating=like&id=#{target_id}" params[:valid_if] = -> response, body {response.code == '204'} when [:subscribe_to, :channel] params[:json] = true params[:path] = '/vimeo/v3/subscriptions?part=snippet' params[:body] = {snippet: {resourceId: {channelId: target_id}}} params[:valid_if] = -> response, body {response.code == '200'} else raise RequestError, "#{activity} invalid for #{target_kind} #{target_id}" end end request! params end |
#picture ⇒ Object
Return the picture attribute of the Vimeo Account.
62 |
# File 'lib/vm/google_account.rb', line 62 attribute :picture |
#verified_email ⇒ Object
Return the verified_email attribute of the Vimeo Account.
57 |
# File 'lib/vm/google_account.rb', line 57 attribute :verified_email |