<commit_before>
/**
 * Module dependencies.
 */

var req = require('request');
var qs = require('querystring');
var end = require('./lib/endpoints.js');
var merge = require('extend');
var debug = require('debug')('wp-connect');

/**
 * Default options
 */

var default_opts = {
  url: {
    api_rest_v1: "https://public-api.wordpress.com/rest/v1"
  }
};

/**
 * Globals
 */

var api_url = default_opts.url.api_rest_v1;

/**
 * Wordpress connect class
 *
 * @param {Object} options
 * @api public
 */

function WPCONN(options){
  this.options = options = {};
  this.headers = {};
}

/**
 * Set Resource ID (blog, etc ...)
 *
 * @param {String} id
 * @api public
 */

WPCONN.prototype.setResource = function(id){
  this.resource = id;
};

/**
 * Set Access token
 *
 * @param {String} token
 * @api public
 */

WPCONN.prototype.setToken = function(token){
  this.token = token;
  this.headers.authorization = "Bearer " + this.token;
};

/**
 * User profiles
 *
 * @param {Object} opts (optional)
 * @param {Function} fn
 * @api private
 */

WPCONN.prototype.me = function (opts, fn){
  this.req('me', null, opts, fn);
};

/**
 * Get wordpress posts
 *
 * @param {String} rid resource id
 * @param {Object} opts
 * @param {Function} fn<commit_msg>core: add site() method<commit_after>
/**
 * Module dependencies.
 */

var req = require('request');
var qs = require('querystring');
var end = require('./lib/endpoints.js');
var merge = require('extend');
var debug = require('debug')('wp-connect');

/**
 * Default options
 */

var default_opts = {
  url: {
    api_rest_v1: "https://public-api.wordpress.com/rest/v1"
  }
};

/**
 * Globals
 */

var api_url = default_opts.url.api_rest_v1;

/**
 * Wordpress connect class
 *
 * @param {Object} options
 * @api public
 */

function WPCONN(options){
  this.options = options = {};
  this.headers = {};
}

/**
 * Set Resource ID (blog, etc ...)
 *
 * @param {String} id
 * @api public
 */

WPCONN.prototype.setResource = function(id){
  this.resource = id;
};

/**
 * Set Access token
 *
 * @param {String} token
 * @api public
 */

WPCONN.prototype.setToken = function(token){
  this.token = token;
  this.headers.authorization = "Bearer " + this.token;
};

/**
 * User profiles
 *
 * @param {Object} opts (optional)
 * @param {Function} fn
 * @api private
 */

WPCONN.prototype.me = function (opts, fn){
  this.req('me', null, opts, fn);
};

/**
 * Get wordpress site info
 *
 * @param {String|Number} rid resource id
 * @param {Object} opts
 * @param {Function} fn
 * @api public
 */

WPCONN.prototype.site = function (rid, opts, fn){
  this.req('site', { site: rid }, opts, fn);
};

/**
 * Get wordpress posts
 *
 * @param {String} rid resource id
 * @param {Object} opts
 * @param {Function} fn
{'fraction_non_alphanumeric': 0.18278000729660707, 'fraction_numerical': 0.0021889821233126595, 'mean_word_length': 3.359300476947536, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '28301', 'n_tokens_mistral': 962, 'n_tokens_neox': 962, 'n_words': 237}