Comparing version 0.0.12 to 0.0.13
{ | ||
"name": "ponsqb", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "ponsqb js client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
import createRequestInstance from './request.js' | ||
export default async function (connection, attributes) { | ||
export default function (connection, attributes) { | ||
let me = attributes | ||
if (!id()) { | ||
me = await connection.createBridge(me) | ||
} | ||
function id () { | ||
@@ -33,3 +29,9 @@ return me?.id | ||
} | ||
async function create () { | ||
me = await connection.createBridge(me) | ||
return this | ||
} | ||
async function refresh () { | ||
@@ -60,3 +62,3 @@ me = await connection.bridge(id()) | ||
async function createRequest (attributes) { | ||
return await createRequestInstance(connection, this, attributes) | ||
return await createRequestInstance(connection, this, attributes).create() | ||
} | ||
@@ -73,2 +75,3 @@ | ||
rotateQbSecret, | ||
create, | ||
update, | ||
@@ -75,0 +78,0 @@ destroy, |
import createConnection from './connection.js' | ||
import createBridgeInstance from './bridge.js' | ||
export default async function (token, options = {}) { | ||
export default function (token, options = {}) { | ||
const connection = createConnection(token, options) | ||
let me = null | ||
await refresh() | ||
function id () { | ||
@@ -27,2 +25,6 @@ return me.id | ||
async function refresh () { | ||
await get () | ||
} | ||
async function get () { | ||
me = await connection.me() | ||
@@ -40,3 +42,3 @@ } | ||
async function bridge (id) { | ||
return await createBridgeInstance(connection, (await connection.bridge(id))) | ||
return createBridgeInstance(connection, (await connection.bridge(id))) | ||
} | ||
@@ -48,3 +50,3 @@ | ||
for (const attributes of attributeList) { | ||
const bridge = await createBridgeInstance(connection, attributes) | ||
const bridge = createBridgeInstance(connection, attributes) | ||
bridges.push(bridge) | ||
@@ -56,3 +58,3 @@ } | ||
async function createBridge (attributes) { | ||
return await createBridgeInstance(connection, attributes) | ||
return await createBridgeInstance(connection, attributes).create() | ||
} | ||
@@ -59,0 +61,0 @@ |
import createPoll from './poll.js' | ||
export default async function (connection, bridge, attributes) { | ||
export default function (connection, bridge, attributes) { | ||
let me = attributes | ||
if (!id()) { | ||
me = await connection.createRequest(bridge.id(), me) | ||
} | ||
function id () { | ||
@@ -62,6 +58,16 @@ return me?.id | ||
async function refresh () { | ||
async function create () { | ||
me = await connection.createRequest(bridge.id(), me) | ||
return this | ||
} | ||
async function get () { | ||
me = await connection.request(id()) | ||
} | ||
async function refresh () { | ||
await get () | ||
} | ||
async function destroy () { | ||
@@ -99,2 +105,3 @@ await connection.destroyRequest(id()) | ||
bridgeId, | ||
create, | ||
refresh, | ||
@@ -101,0 +108,0 @@ destroy, |
8160
344