working on rdoc support with yard

This commit is contained in:
Brendan McDevitt 2019-11-13 00:53:41 -06:00
parent 2713a9cc9c
commit 93935f1a5a

View file

@ -4,6 +4,14 @@
module Pastebinner module Pastebinner
class ApiClient class ApiClient
# Creates a new instance of Pastebinner::ApiClient
# @param api_dev_key [Symbol] the users pastebin api key
# @param username [String] the username for the users pastebin account
# @param password [String] the password for the users pastebin account username
# @note: official api docs for pastebin can be located the following url: https://pastebin.com/api
# @return [Pastebinner::ApiClient] a new Pastebinner::ApiClient object
# @example Create an object
# api_client = Pastebinner::ApiClient.new('123456789', 'johnsmith', 'mypassword')
attr_accessor :api_dev_key, :username, :password attr_accessor :api_dev_key, :username, :password
def initialize(api_dev_key, username, password) def initialize(api_dev_key, username, password)
@ -13,31 +21,34 @@ module Pastebinner
@base_api_url = 'https://pastebin.com/api' @base_api_url = 'https://pastebin.com/api'
@scraping_api_url = 'https://scrape.pastebin.com' @scraping_api_url = 'https://scrape.pastebin.com'
end end
# A hash of every endpoint that the Pastebinner Api Client will use.
ENDPOINTS =
{
login: '/api_login.php',
post: '/api_post.php',
raw: '/api_raw.php',
scraping: '/api_scraping.php',
scrape_item: '/api_scrape_item.php',
scrape_item_meta: '/api_scrape_item_meta.php'
}.freeze
# this should be a hash of { endpoint_name: '/url_endpoint.php'} # Basic example hash for creating a paste:
ENDPOINTS = { login: '/api_login.php',
post: '/api_post.php',
raw: '/api_raw.php',
scraping: '/api_scraping.php',
scrape_item: '/api_scrape_item.php',
scrape_item_meta: '/api_scrape_item_meta.php' }.freeze
# basic example hash for creating a paste:
# 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}
# required params: # Required params:
# api_dev_key - your unique developer api key # @param api_dev_key [String] your unique developer api key
# api_option - set as paste, this will indicate you want to create a new paste # @param api_option [String] set as paste, this will indicate you want to create a new paste
# api_paste_code - this is the text that will be written inside of your paste # @param api_paste_code [String] this is the text that will be written inside of your paste
# optional params: # Optional params:
# api_user_key - this parameter is part of the login system, which is explained further down the page # api_user_key - this parameter is part of the login system, which is explained further down the page
# api_paste_name - this will be the name / title of your paste # api_paste_name - this will be the name / title of your paste
# api_paste_format - this will be the syntax highlighting value, which is explained in detail further down the page # api_paste_format - this will be the syntax highlighting value, which is explained in detail further down the page
# api_paste_private - this makes a paste public, unlisted, or private, public = 0, unlisted = 1, private = 2 # api_paste_private - this makes a paste public, unlisted, or private, public = 0, unlisted = 1, private = 2
# api_paste_expire_date - this sets the expiration date of your paste, the values are explained further down the page # api_paste_expire_date - this sets the expiration date of your paste, the values are explained further down the page
# 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)
execute_query(:api_post, params) execute_query(:api_post, params)
end end
@ -61,6 +72,7 @@ module Pastebinner
execute_query(:api_post, params) execute_query(:api_post, params)
end end
# @param api_paste_key - this is the unique key of the paste data that you want to list.
def list_raw_user_paste(api_paste_key) def list_raw_user_paste(api_paste_key)
params = { 'api_dev_key': api_dev_key, params = { 'api_dev_key': api_dev_key,
'api_user_key': api_user_key, 'api_user_key': api_user_key,
@ -69,7 +81,7 @@ module Pastebinner
execute_query(:api_post, params) execute_query(:api_post, params)
end end
# api_paste_key = this is the unique key of the paste data you want to delete. # @param api_paste_key - this is the unique key of the paste data you want to delete.
def delete_user_paste(api_paste_key) def delete_user_paste(api_paste_key)
params = { 'api_dev_key': api_dev_key, params = { 'api_dev_key': api_dev_key,
'api_user_key': api_user_key, 'api_user_key': api_user_key,
@ -106,11 +118,6 @@ module Pastebinner
pp.map { |p| p['key'] } pp.map { |p| p['key'] }
end end
def unique_paste_keys(public_pastes)
pp = JSON.parse(public_pastes)
pp.map { |paste| :url => paste['url'], :key => paste['key'] }
end
def raw_paste_data(unique_paste_key) def raw_paste_data(unique_paste_key)
response = RestClient::Request.execute( response = RestClient::Request.execute(
method: :get, method: :get,