From 9da7b16a6edce7797611e3addf449677e2460df0 Mon Sep 17 00:00:00 2001 From: kenna-bmcdevitt Date: Wed, 22 Aug 2018 13:32:53 -0500 Subject: [PATCH] made execute_query a work on the methods inside of the PasteBinner class --- lib/pastebinner.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pastebinner.rb b/lib/pastebinner.rb index f02f233..901f4f9 100755 --- a/lib/pastebinner.rb +++ b/lib/pastebinner.rb @@ -8,7 +8,6 @@ module Pastebin class Pastebinner attr_reader :api_user_key - # PasteBinner.new(api_dev_key) def initialize(api_dev_key, username, password) @api_dev_key = api_dev_key @username = username @@ -43,7 +42,7 @@ module Pastebin # example - params = { "api_dev_key": api_dev_key, "api_option": "paste", "api_paste_code": paste_data } def create_paste(params) - self.api_post(params) + execute_query(:api_post, params) end def get_api_user_key @@ -61,7 +60,7 @@ module Pastebin 'api_user_key': @api_user_key, 'api_results_limit': '100', 'api_option': 'list'} - self.api_post(params) + execute_query(:api_post, params) end def api_post(params) @@ -78,6 +77,7 @@ module Pastebin url: @scraping_api_url + ENDPOINTS[:scraping]) end + # keep this method private so we are not letting anyone run any method in our program private # this will be the main way to execute any of these methods. this has the exception handling taken care of. def execute_query(selector, *args) @@ -99,13 +99,14 @@ end # setup our object and grab a session key pb = Pastebin::Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password']) +api_dev_key = ENV['pastebin_api_key'] #### CREATE PASTE # prepare some sample paste data to send paste_data = 'this is a test paste two two two.' # prepare our paste params params = { "api_dev_key": api_dev_key, "api_option": "paste", "api_paste_code": paste_data } -#puts pb.execute_query(:create_paste, params) +puts pb.create_paste(params) #### SCRAPE PUBLIC PASTES #public_pastes = pb.execute_query(:scrape_public_pastes)