diff --git a/lib/exceptions.rb b/lib/exceptions.rb new file mode 100644 index 0000000..d5788a8 --- /dev/null +++ b/lib/exceptions.rb @@ -0,0 +1,5 @@ +class PastebinnerError < StandardError + +end + +raise PastebinnerError diff --git a/lib/pastebinner.rb b/lib/pastebinner.rb index c248412..1cbf875 100755 --- a/lib/pastebinner.rb +++ b/lib/pastebinner.rb @@ -69,6 +69,15 @@ class Pastebinner execute_query(:api_post, params) end + def list_raw_user_paste(api_paste_key) + params = { 'api_dev_key': api_dev_key, + 'api_user_key': api_user_key, + 'api_paste_key': api_paste_key, + 'api_option': 'show_paste' + } + execute_query(:api_post, params) + end + # api_paste_key = this is the unique key of the paste data you want to delete. def delete_user_paste(api_paste_key) params = { 'api_dev_key': api_dev_key, @@ -98,6 +107,18 @@ class Pastebinner url: @scraping_api_url + ENDPOINTS[:scraping]) end + def raw_paste_data(unique_paste_key) + response = RestClient::Request.execute( + method: :get, + url: @scraping_api_url + ENDPOINTS[:scrape_item] + "?i=#{unique_paste_key}") + end + + def raw_paste_metadata(unique_paste_key) + response = RestClient::Request.execute( + method: :get, + url: @scraping_api_url + ENDPOINTS[:scrape_item_meta] + "?i=#{unique_paste_key}") + 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. @@ -108,7 +129,7 @@ class Pastebinner puts e.message end end - # make my own exception class + # make my own exception class # inherit ruby standard error class end @@ -129,8 +150,11 @@ api_dev_key = ENV['pastebin_api_key'] #puts pb.create_paste(params) #### SCRAPE PUBLIC PASTES -#public_pastes = pb.execute_query(:scrape_public_pastes) -#puts public_pastes - -#### LIST USER PASTES puts pb.scrape_public_pastes + +#### SCRAPING - WHITELISTED IP ONLY +#### SCRAPE RAW PASTE DATA OF A PASTE KEY +#puts pb.raw_paste_data('Gkb4ukK9') + +#### SCRAPE RAW METADATA OF A PASTE KEY (WORKS WITH WHITELISTED IP ONLY) +#puts pb.raw_paste_metadata('Gkb4ukK9') diff --git a/pastebinner.gemspec b/pastebinner.gemspec index 85622e0..b666ec4 100644 --- a/pastebinner.gemspec +++ b/pastebinner.gemspec @@ -6,11 +6,11 @@ require "pastebinner/version" Gem::Specification.new do |spec| spec.name = "pastebinner" spec.version = Pastebinner::VERSION - spec.authors = ["booboy"] - spec.email = ["bpmcdevitt@thelinuxspace.com"] + spec.authors = ["Brendan McDevitt"] + spec.email = ["brendan@mcdevitt.tech"] spec.summary = "A ruby client library for interacting with the pastebin API." - spec.homepage = "https://github.com/booboy/pastebinner" + spec.homepage = "https://git.mcdevitt.tech/bpmcdevitt/pastebinner" # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' # to allow pushing to a single host or delete this section to allow pushing to any host.