<commit_before>
import fs from 'fs';
import mime from 'mime';
import request from 'request';
import wsse from 'wsse';
import xml2js from 'xml2js';

type FotolifeOptions = FotolifeOptionsOAuth | FotolifeOptionsWSSE;

interface FotolifeOptionsOAuth {
  accessToken: string;
  accessTokenSecret: string;
  consumerKey: string;
  consumerSecret: string;
  type: 'oauth';
}

interface FotolifeOptionsWSSE {
  apikey: string;
  type?: 'wsse';
  username: string;
}

type XMLObject = any;

const rejectE = (s: string): Promise<never> => Promise.reject(new Error(s));

const requestPromise = (
  params: request.UrlOptions & request.CoreOptions
): Promise<request.Response> => {
  return new Promise((resolve, reject) => {
    return request(params, (error, response) => {
      if (error !== null)
        return reject(error);
      else
        return resolve(response);
    });
  });
};

const xmlStringToObject = (xmlString: string): Promise<XMLObject> => {
  return new Promise((resolve, reject) => {
    const parser = new xml2js.Parser({
      explicitArray: false,
      explicitCharkey: true
    });
    return parser.parseString(
      xmlString,
      (error: Error | null, result: any) => {
        if (error !== null)
          return reject(error);
        else
          return resolve(result);
      });
  });
};

const xmlObjectToXmlString = (xmlObject: XMLObject): Promise<string> => {
  try {
    const builder = new xml2js.Builder();
    const xmlString = builder.buildObject(xmlObject);
    return Promise.resolve(xmlString);
  } catch (error) {
    return Promise.reject(error);
  }
};

// Hatena::Fotolife API wrapper
//
// - POST   PostURI (/atom/post)                => Fotolife#create
// - PUT    EditURI (/atom/edit/XXXXXXXXXXXXXX) => Fotolife#update
// - DELETE EditURI (/atom/edit/XXXXXXXXXXXXXX) => Fotolife#destroy
// - GET    EditURI (/atom/edit/XXXXXXXXXXXXXX) => Fotolife#show
// - GET    FeedURI (/atom/feed)                => Fotolife#index
class Fotolife {
  private static BASE_URL = 'http://f.hatena.ne.jp';
  private _type: 'oauth' | 'wsse';
  private _username: string | null;
  private _apikey: string | null;
  private _consumerKey: string | null;<commit_msg>Changed API Endpoint, http -> https<commit_after>
import fs from 'fs';
import mime from 'mime';
import request from 'request';
import wsse from 'wsse';
import xml2js from 'xml2js';

type FotolifeOptions = FotolifeOptionsOAuth | FotolifeOptionsWSSE;

interface FotolifeOptionsOAuth {
  accessToken: string;
  accessTokenSecret: string;
  consumerKey: string;
  consumerSecret: string;
  type: 'oauth';
}

interface FotolifeOptionsWSSE {
  apikey: string;
  type?: 'wsse';
  username: string;
}

type XMLObject = any;

const rejectE = (s: string): Promise<never> => Promise.reject(new Error(s));

const requestPromise = (
  params: request.UrlOptions & request.CoreOptions
): Promise<request.Response> => {
  return new Promise((resolve, reject) => {
    return request(params, (error, response) => {
      if (error !== null)
        return reject(error);
      else
        return resolve(response);
    });
  });
};

const xmlStringToObject = (xmlString: string): Promise<XMLObject> => {
  return new Promise((resolve, reject) => {
    const parser = new xml2js.Parser({
      explicitArray: false,
      explicitCharkey: true
    });
    return parser.parseString(
      xmlString,
      (error: Error | null, result: any) => {
        if (error !== null)
          return reject(error);
        else
          return resolve(result);
      });
  });
};

const xmlObjectToXmlString = (xmlObject: XMLObject): Promise<string> => {
  try {
    const builder = new xml2js.Builder();
    const xmlString = builder.buildObject(xmlObject);
    return Promise.resolve(xmlString);
  } catch (error) {
    return Promise.reject(error);
  }
};

// Hatena::Fotolife API wrapper
//
// - POST   PostURI (/atom/post)                => Fotolife#create
// - PUT    EditURI (/atom/edit/XXXXXXXXXXXXXX) => Fotolife#update
// - DELETE EditURI (/atom/edit/XXXXXXXXXXXXXX) => Fotolife#destroy
// - GET    EditURI (/atom/edit/XXXXXXXXXXXXXX) => Fotolife#show
// - GET    FeedURI (/atom/feed)                => Fotolife#index
class Fotolife {
  private static BASE_URL = 'https://f.hatena.ne.jp';
  private _type: 'oauth' | 'wsse';
  private _username: string | null;
  private _apikey: string | null;
  private _consumerKey: string | null;
{'fraction_non_alphanumeric': 0.13256288239293, 'fraction_numerical': 0.0018128257421255382, 'mean_word_length': 3.2812803103782735, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 38, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 24}, 'pii_count': 0, 'substrings_counts': 6, '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': '7438114', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1390, 'n_words': 351}