text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  var Blips = /** @class */ (function () {
      function Blips(pageLimit, requestServices) {
          this.pageLimit = pageLimit;
          this.requestServices = requestServices;
      }
      /** Create a blip, either in response to another blip or standalone
       * @param {string} bodyText Text of the blip's body to create
       * @param {(number | string)} [responseID] ID of another blip to respond to
       * @returns Promise<e621POSTResponse>
       * @memberof Blips
       */
      Blips.prototype.create = function (bodyText, responseID) {
          var url = "https://e621.net/blip/create.json";
          var postObj;
          if (!responseID) {
              postObj = {
                  "blip[body]": bodyText,
                  "blip[response]": responseID
              };
          }
          else {
              postObj = {
                  "blip[body]": bodyText,
              };
          }
          return this.requestServices.post(url, postObj)
              .then(function (response) {
              return response;
          })
              .catch(function (err) {
              throw Error(err);
          });
      };
      /** Update a blip's body by ID
       * @param {(number | string)} blipID ID of the blip to update
       * @param {string} bodyText New text of the blip body
       * @returns Promise<e621POSTResponse>
       * @memberof Blips
       */
      Blips.prototype.update = function (blipID, bodyText) {
          var url = "https://e621.net/blip/update.json";
          var postObj = {
              "id": blipID,
              "blip[body]": bodyText
          };
          return this.requestServices.post(url, postObj)
              .then(function (response) {
              return response;
          })
              .catch(function (err) {
              throw Error(err);
          });
      };
      /** Get a set of recent blips
       * @param {number} [page] Page number to return
       * @returns Promise<e621BlipInfo[]>
       * @memberof Blips
       */
      Blips.prototype.getRecentBlips = function (page) {
          var url = "https://e621.net/blip/index.json?";
          if (page)
              url += "page=" + page;
          return this.requestServices.get(url)
              .then(function (response) {
              return response;
          })
              .catch(function (err) {
              throw Error(err);
          });
      };
      /** Get a blip's information by ID, returns a single blip
       * @param {(number | string)} blipID ID of the blip to retrieve
       * @returns Promise<e621BlipInfo>
       * @memberof Blips
       */
      Blips.prototype.getBlipByID = function (blipID) {
          var url = "https://e621.net/blip/show.json?id=" + blipID;
          return this.requestServices.get(url)
              .then(function (response) {
              return response;
          })
              .catch(function (err) {
              throw Error(err);
          });
      };
      /** Get a blip's responses (if any). If an error is thrown, then their are no responses for the first (or given) page
       * @param {(number | string)} blipID ID for the blip to retrieve the responses of
       * @param {number} [page] Page number to return
       * @returns Promise<e621BlipInfo[]>
       * @memberof Blips
       */
      Blips.prototype.getBlipResponses = function (blipID, page) {
          var url = "https://e621.net/blip/index.json?response_to=" + blipID;
          if (page)
              url += "page=" + page;
          return this.requestServices.get(url)
              .then(function (response) {
              return response;
          })
              .catch(function (err) {
              throw Error(err);
          });
      };
      /** Search for a blip that contains a given `textToMatch` string
       * @param {string} textToMatch String to search for matching blips
       * @param {number} [page] Page number to return
       * @returns Promise<e621BlipInfo[]>
       * @memberof Blips
       */
      Blips.prototype.getBlipByText = function (textToMatch, page) {
          var url = "https://e621.net/blip/index.json?body==" + textToMatch;
          if (page)
              url += "page=" + page;
          return this.requestServices.get(url)
              .then(function (response) {
              return response;
          })
              .catch(function (err) {
              throw Error(err);
          });
      };
      return Blips;
  }());
  exports.default = Blips;
  