Coder Social home page Coder Social logo

sure-pet-care's Introduction

Sure PetCare API Client

This API client provides basic functionality for Sure PetCare products.

Available features:

  • Get details on a pet, including location
  • Set the location of pets

Installation

npm install --save-dev sure-pet-care-client

Usage

With ES modules

import { SurePetCareClient } from 'sure-pet-care-client';

const client = new SurePetCareClient();
client.authenticate('username', 'password').then(...)

API Reference

Available functions

Constructor

Creates a new instance of the client.

const client = new SurePetCareClient();

Authenticate

Authenticates the user using email and password.

client.authenticate(email: string, password: string): Promise<void>;

Get pets

Returns a list of all pets for authenticated user.

client.getPets(): Promise<Pet[]>;

Get pet by name

Returns a pet by a given name (case insensitive). Throws an error if the pet is not found.

client.getPetByName(name: string): Promise<Pet>;

Get pet by ID

Returns a pet by ID. Throws an error if the pet is not found.

client.getPetByName(id: number): Promise<Pet>;

Set pet location

Sets the location of a pet, with an optional timestamp for when the change happened.

client.setPetLocation(petID: number, location: PetLocation, since?: Date): Promise<void>;

Example:

await client.setPetLocation(123, PetLocation.Inside, new Date());

Types

All types are available in the ./src/types.ts

sure-pet-care's People

Contributors

dependabot[bot] avatar rmhonor avatar

Stargazers

 avatar

Watchers

 avatar  avatar

sure-pet-care's Issues

Node rest API...

Hi! I'm very new to setting up a rest API from scratch... So this is a real nub question. :)

I want to setup a small node app that is just a "get status" and "set status" on the cats and the flaps.
But, being a nub, I don't really know how... :)
So, if you have an example on how to include your package in a script it would be great! :)

This is as far as I've come...

const express = require('express');
const app = express();
const client = ('sure-pet-care-client');

// How to authenticate and set / get status?... :)

// Route home
app.get('/', (req, res) => {
	res.send('Home');
});

// Route post
app.get('/post', (req, res) => {
	res.send('Post');
});

// Route get
app.get('/get', (req, res) => {
	res.send('Get');
});

// Port to listen on.
app.listen(3000);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.