UNPKG

@gameroom/cli

Version:

A command line tool for Gameroom

34 lines (32 loc) 1.18 kB
const axios = require('axios'), cosmetic = require('cosmetic'), { shopifyCredentials, tryRepeatedly } = require('../../helpers'), { spinner } = require('../../refs') module.exports = class Location { constructor(data) { if (!data) data = {} this.active = data.active this.address1 = data.address1 this.address2 = data.address2 this.city = data.city this.country = data.country this.country_code = data.country_code this.created_at = data.created_at this.id = data.id this.legacy = data.legacy this.name = data.name this.phone = data.phone this.province = data.province this.province_code = data.province_code this.updated_at = data.updated_at this.zip = data.zip } static async get() { const { username, password, store_url } = shopifyCredentials() const result = await tryRepeatedly(() => axios.get('/locations.json', { auth: { username, password }, baseURL: `https://${store_url}/admin/api/2019-10`, }), (err) => spinner.warn(`error getting ${cosmetic.green('locations')} ${err}`)) return result && result.data && result.data.locations ? result.data.locations : [] } }