Class: Yt::Request
- Inherits:
-
Object
- Object
- Yt::Request
- Defined in:
- lib/yt/actions/request.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Request
Returns a new instance of Request.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/yt/actions/request.rb', line 11 def initialize( = {}) [:query] ||= [:params].to_param @uri = URI::HTTPS.build .slice(:host, :path, :query) @method = [:method] @format = [:format] @scope = [:scope] @body = [:body] @body_type = [:body_type] @auth = [:auth] @headers = {} end |
Class Method Details
.default_params ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/yt/actions/request.rb', line 32 def self.default_params {}.tap do |params| params[:format] = :json params[:host] = 'www.googleapis.com' params[:scope] = 'https://www.googleapis.com/auth/youtube' params[:body_type] = :json end end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/yt/actions/request.rb', line 23 def run fetch_response.tap do |response| response.body = parse_format response.body if response.body # puts "You can try again running #{to_curl}" raise RequestError, response.body unless response.is_a? Net::HTTPSuccess end end |