{"size": 832, "ext": "js", "max_stars_repo_path": "src/www/api/administrator/subscriptions/refunds.js", "max_stars_repo_name": "userdashboard/stripe-subscriptions", "max_stars_repo_stars_event_min_datetime": "2019-08-20T23:29:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-03T15:09:49.000Z", "max_issues_repo_path": "src/www/api/administrator/subscriptions/refunds.js", "max_issues_repo_name": "userappstore/stripe-subscriptions", "max_issues_repo_issues_event_min_datetime": "2018-07-19T16:18:58.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-07T14:45:26.000Z", "max_forks_repo_path": "src/www/api/administrator/subscriptions/refunds.js", "max_forks_repo_name": "userappstore/stripe-subscriptions", "max_forks_repo_forks_event_min_datetime": "2019-08-04T12:00:55.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-05T06:15:45.000Z"}
{"max_stars_count": 4, "max_issues_count": 7, "max_forks_count": 4, "avg_line_length": 32.0, "max_line_length": 93, "alphanum_fraction": 0.6310096154}
const subscriptions = require('../../../../../index.js')

module.exports = {
  get: async (req) => {
    req.query = req.query || {}
    let refundids
    if (req.query.all) {
      refundids = await subscriptions.StorageList.listAll(`${req.appid}/refunds`)
    } else {
      const offset = req.query.offset ? parseInt(req.query.offset, 10) : 0
      const limit = req.query.limit ? parseInt(req.query.limit, 10) : global.pageSize
      refundids = await subscriptions.StorageList.list(`${req.appid}/refunds`, offset, limit)
    }
    if (!refundids || !refundids.length) {
      return null
    }
    const items = []
    for (const refundid of refundids) {
      req.query.refundid = refundid
      const refund = await global.api.administrator.subscriptions.Refund.get(req)
      items.push(refund)
    }
    return items
  }
}
