Skip to content

Instantly share code, notes, and snippets.

@tylerlong
Last active November 22, 2018 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerlong/ec13f0f1867deaee00d018c78d479f01 to your computer and use it in GitHub Desktop.
Save tylerlong/ec13f0f1867deaee00d018c78d479f01 to your computer and use it in GitHub Desktop.
update device emergency address
updating device 803480313004
{ uri:
   'http://api-xmnup.lab.nordigy.ru/restapi/v1.0/account/225033004/device/803480313004',
  id: '803480313004',
  type: 'HardPhone',
  sku: 'HP-52',
  model: { id: '52', name: 'Cisco SPA-122 ATA', addons: [] },
  name: 'Phone',
  serial: 'HELL803480313004-225033004',
  status: 'Offline',
  extension:
   { uri:
      'http://api-xmnup.lab.nordigy.ru/restapi/v1.0/account/225033004/extension/225033004',
     id: 225033004,
     extensionNumber: '101' },
  phoneLines:
   [ { lineType: 'Standalone',
       emergencyAddress: [Object],
       phoneInfo: [Object] } ],
  emergencyServiceAddress:
   { street: '10th floor, Century Tower',
     street2: 'No. 7, YiLan Road',
     city: 'Xiamen',
     state: 'Fujian',
     country: 'CN',
     countryId: '46',
     countryIsoCode: 'CN',
     countryName: 'China',
     zip: '36000',
     customerName: 'San Zhang' },
  shipping:
   { address:
      { street: '123 Main St',
        street2: 'Apt 4',
        city: 'San Mateo',
        state: 'CA',
        stateId: '16',
        stateIsoCode: 'CA',
        stateName: 'California',
        country: 'US',
        countryId: '1',
        countryIsoCode: 'US',
        countryName: 'United States',
        zip: '94404',
        customerName: 'Something1 New1' },
     method: { id: '1', name: 'Ground' },
     status: 'Initial' },
  linePooling: 'Host' }
import RingCentral from 'ringcentral-js-concise'
const rc = new RingCentral(
process.env.RINGCENTRAL_CLIENT_ID,
process.env.RINGCENTRAL_CLIENT_SECRET,
process.env.RINGCENTRAL_SERVER_URL
)
;(async () => {
try {
await rc.authorize({
username: process.env.RINGCENTRAL_USERNAME,
extension: process.env.RINGCENTRAL_EXTENSION,
password: process.env.RINGCENTRAL_PASSWORD
})
let r = await rc.get('/restapi/v1.0/account/~/device')
const device = r.data.records.find(d => d.id === '803480313004')
console.log('updating device', device.id)
r = await rc.put('/restapi/v1.0/account/~/device/' + device.id, {
emergencyServiceAddress: {
customerName: 'San Zhang',
street: '10th floor, Century Tower',
street2: 'No. 7, YiLan Road',
city: 'Xiamen',
zip: '36000',
state: 'Fujian',
country: 'CN'
}
})
console.log(r.data)
} finally {
await rc.revoke()
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment