Class: VimeoRuby::Base
- Inherits:
-
Object
- Object
- VimeoRuby::Base
- Defined in:
- lib/vimeo_ruby/base.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#additional_info ⇒ Object
readonly
Returns the value of attribute additional_info.
-
#vimeo_id ⇒ Object
readonly
Returns the value of attribute vimeo_id.
Class Method Summary collapse
- .base_uri ⇒ Object
- .client_identifier ⇒ Object
- .client_secret ⇒ Object
- .get(uri, query_params: {}, access_token: nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(access_token: nil, vimeo_id: nil, remaining_attrs: {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(access_token: nil, vimeo_id: nil, remaining_attrs: {}) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 |
# File 'lib/vimeo_ruby/base.rb', line 8 def initialize(access_token: nil, vimeo_id: nil, remaining_attrs: {}) @access_token = access_token @vimeo_id = extract_vimeo_id_from_uri(vimeo_id) @additional_info = OpenStruct.new(remaining_attrs) end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/vimeo_ruby/base.rb', line 6 def access_token @access_token end |
#additional_info ⇒ Object (readonly)
Returns the value of attribute additional_info.
6 7 8 |
# File 'lib/vimeo_ruby/base.rb', line 6 def additional_info @additional_info end |
#vimeo_id ⇒ Object (readonly)
Returns the value of attribute vimeo_id.
6 7 8 |
# File 'lib/vimeo_ruby/base.rb', line 6 def vimeo_id @vimeo_id end |
Class Method Details
.base_uri ⇒ Object
15 16 17 |
# File 'lib/vimeo_ruby/base.rb', line 15 def base_uri "https://api.vimeo.com" end |
.client_identifier ⇒ Object
19 20 21 |
# File 'lib/vimeo_ruby/base.rb', line 19 def client_identifier ENV["VIMEO_CLIENT_IDENTIFIER"] end |
.client_secret ⇒ Object
23 24 25 |
# File 'lib/vimeo_ruby/base.rb', line 23 def client_secret ENV["VIMEO_CLIENT_SECRET"] end |
.get(uri, query_params: {}, access_token: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vimeo_ruby/base.rb', line 27 def get(uri, query_params: {}, access_token: nil) uri = URI.parse(uri) uri.query = URI.encode_www_form(query_params) Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |https| request = Net::HTTP::Get.new(uri) request["Authorization"] = "bearer #{access_token}" response = https.request(request) JSON.parse(response.body) end end |