Sha256: 8afb25581d82d19f2b52554a1bfa3b9396865c460f23b9a7b3c3d2d2145c28b7

Contents?: true

Size: 910 Bytes

Versions: 11

Compression:

Stored size: 910 Bytes

Contents

class OAuth::CLI
  class QueryCommand < BaseCommand
    extend OAuth::Helper

    def required_options
      [:oauth_consumer_key, :oauth_consumer_secret, :oauth_token, :oauth_token_secret]
    end

    def _run
      consumer = OAuth::Consumer.new(options[:oauth_consumer_key], options[:oauth_consumer_secret], scheme: options[:scheme])

      access_token = OAuth::AccessToken.new(consumer, options[:oauth_token], options[:oauth_token_secret])

      # append params to the URL
      uri = URI.parse(options[:uri])
      params = parameters.map { |k,v| Array(v).map { |v2| "#{OAuth::Helper.escape(k)}=#{OAuth::Helper.escape(v2)}" } * "&" }
      uri.query = [uri.query, *params].reject { |x| x.nil? } * "&"
      puts uri.to_s

      response = access_token.request(options[:method].to_s.downcase.to_sym, uri.to_s)
      puts "#{response.code} #{response.message}"
      puts response.body
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
oauth-0.5.8 lib/oauth/cli/query_command.rb
oauth-0.5.7 lib/oauth/cli/query_command.rb
oauth-0.5.7.pre.pre1 lib/oauth/cli/query_command.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/oauth-0.5.6/lib/oauth/cli/query_command.rb
oauth-0.5.6 lib/oauth/cli/query_command.rb
oauth-0.5.5 lib/oauth/cli/query_command.rb
tdiary-5.0.8 vendor/bundle/gems/oauth-0.5.4/lib/oauth/cli/query_command.rb
oauth-0.5.4 lib/oauth/cli/query_command.rb
tdiary-5.0.5 vendor/bundle/gems/oauth-0.5.3/lib/oauth/cli/query_command.rb
oauth-0.5.3 lib/oauth/cli/query_command.rb
oauth-0.5.2 lib/oauth/cli/query_command.rb