0.0.16 • Published 2 years ago

@danieloaks/codingtest-birdhouse-js v0.0.16

Weekly downloads
-
License
CC0-1.0
Repository
-
Last release
2 years ago

birdhouse-js

npm version Test status

This is a typescript wrapper around the Smart BirdHouse API.

Usage

npm i @danieloaks/codingtest-birdhouse-js

import API from "@danieloaks/codingtest-birdhouse-js";

const api = new API({
  apiBase: "https://example.com",
});

async function run() {
  const page = 1;
  const entriesPerPage = 15;
  const res = await api.registration.getRegistrationPage(page, entriesPerPage);

  for (const item of res.items) {
    console.log(
      `${item.value}: ${item.birdhouse?.name || "No birdhouse registered"}`,
    );

    if (!item.birdhouse) {
      continue;
    }

    const occupancyPage = 1;
    const occupancyEntriesPerPage = 15;
    const occupancy = await api.occupancy.getOccupancy(
      item.birdhouse.ubidValue,
      occupancyPage,
      occupancyEntriesPerPage,
    );

    for (const state of occupancy.items) {
      console.log(
        `  ${state.createdAt.toLocaleDateString()} - birds: ${
          state.birds
        } - eggs: ${state.eggs}`,
      );
    }
  }
}

run();
c36ba382-959d-48ff-8b72-de092c88d55e: Tessa's Birdhouse
  11/1/2022 - birds: 0 - eggs: 2
  10/30/2022 - birds: 1 - eggs: 2
  10/29/2022 - birds: 1 - eggs: 3
  10/28/2022 - birds: 0 - eggs: 1
91aa01b8-4248-495a-8fc0-9323b4d74e1e: Daniel's Birdhouse
  11/1/2022 - birds: 1 - eggs: 2
  10/30/2022 - birds: 2 - eggs: 21
  10/29/2022 - birds: 4 - eggs: 42
  10/28/2022 - birds: 6 - eggs: 63
0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago