made execute_query a work on the methods inside of the PasteBinner class
This commit is contained in:
parent
94568018e3
commit
9da7b16a6e
1 changed files with 5 additions and 4 deletions
|
@ -8,7 +8,6 @@ module Pastebin
|
||||||
class Pastebinner
|
class Pastebinner
|
||||||
attr_reader :api_user_key
|
attr_reader :api_user_key
|
||||||
|
|
||||||
# PasteBinner.new(api_dev_key)
|
|
||||||
def initialize(api_dev_key, username, password)
|
def initialize(api_dev_key, username, password)
|
||||||
@api_dev_key = api_dev_key
|
@api_dev_key = api_dev_key
|
||||||
@username = username
|
@username = username
|
||||||
|
@ -43,7 +42,7 @@ module Pastebin
|
||||||
|
|
||||||
# example - params = { "api_dev_key": api_dev_key, "api_option": "paste", "api_paste_code": paste_data }
|
# example - params = { "api_dev_key": api_dev_key, "api_option": "paste", "api_paste_code": paste_data }
|
||||||
def create_paste(params)
|
def create_paste(params)
|
||||||
self.api_post(params)
|
execute_query(:api_post, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_api_user_key
|
def get_api_user_key
|
||||||
|
@ -61,7 +60,7 @@ module Pastebin
|
||||||
'api_user_key': @api_user_key,
|
'api_user_key': @api_user_key,
|
||||||
'api_results_limit': '100',
|
'api_results_limit': '100',
|
||||||
'api_option': 'list'}
|
'api_option': 'list'}
|
||||||
self.api_post(params)
|
execute_query(:api_post, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_post(params)
|
def api_post(params)
|
||||||
|
@ -78,6 +77,7 @@ module Pastebin
|
||||||
url: @scraping_api_url + ENDPOINTS[:scraping])
|
url: @scraping_api_url + ENDPOINTS[:scraping])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# keep this method private so we are not letting anyone run any method in our program
|
||||||
private
|
private
|
||||||
# this will be the main way to execute any of these methods. this has the exception handling taken care of.
|
# 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)
|
def execute_query(selector, *args)
|
||||||
|
@ -99,13 +99,14 @@ end
|
||||||
|
|
||||||
# setup our object and grab a session key
|
# setup our object and grab a session key
|
||||||
pb = Pastebin::Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password'])
|
pb = Pastebin::Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password'])
|
||||||
|
api_dev_key = ENV['pastebin_api_key']
|
||||||
|
|
||||||
#### CREATE PASTE
|
#### CREATE PASTE
|
||||||
# prepare some sample paste data to send
|
# prepare some sample paste data to send
|
||||||
paste_data = 'this is a test paste two two two.'
|
paste_data = 'this is a test paste two two two.'
|
||||||
# prepare our paste params
|
# prepare our paste params
|
||||||
params = { "api_dev_key": api_dev_key, "api_option": "paste", "api_paste_code": paste_data }
|
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
|
#### SCRAPE PUBLIC PASTES
|
||||||
#public_pastes = pb.execute_query(:scrape_public_pastes)
|
#public_pastes = pb.execute_query(:scrape_public_pastes)
|
||||||
|
|
Loading…
Add table
Reference in a new issue