added all of the methods.
will need to go back through and fix the scraping api endpoints to use the execute_query private method
This commit is contained in:
parent
2be2d4419c
commit
092bbb252b
3 changed files with 37 additions and 8 deletions
5
lib/exceptions.rb
Normal file
5
lib/exceptions.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class PastebinnerError < StandardError
|
||||
|
||||
end
|
||||
|
||||
raise PastebinnerError
|
|
@ -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')
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue