class OAuth::TTY::Commands::QueryCommand

Public Instance Methods

_run() click to toggle source
   # File lib/oauth/tty/commands/query_command.rb
21 def _run
22   consumer = OAuth::Consumer.new(
23     options[:oauth_consumer_key],
24     options[:oauth_consumer_secret],
25     scheme: options[:scheme],
26   )
27 
28   access_token = OAuth::AccessToken.new(consumer, options[:oauth_token], options[:oauth_token_secret])
29 
30   # append params to the URL
31   uri = URI.parse(options[:uri])
32   params = parameters.map do |k, v|
33     Array(v).map do |v2|
34       "#{OAuth::Helper.escape(k)}=#{OAuth::Helper.escape(v2)}"
35     end * "&"
36   end
37   uri.query = [uri.query, *params].compact * "&"
38   puts uri
39 
40   response = access_token.request(options[:method].to_s.downcase.to_sym, uri.to_s)
41   puts "#{response.code} #{response.message}"
42   puts response.body
43 end
required_options() click to toggle source
   # File lib/oauth/tty/commands/query_command.rb
17 def required_options
18   %i[oauth_consumer_key oauth_consumer_secret oauth_token oauth_token_secret]
19 end