npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rs-leads-api

v0.4.0

Published

RepairShopr Leads API

Downloads

20

Readme

rs-leads-api

A small module to post website form submissions to repairshopr's RESTful API Leads module.

Install

  • Available on NPMjs.com
  • yarn add rs-leads-api
  • Add the following variables to your environment: RS_API, RS_URI, and STORES*
RS_API="<Your Repairshopr API Key>"
RS_URI="https://<your_subDomain>.repairshopr.com/api/v1"
STORES="<Stringified JSON object with store data>"
  • import into your project and start generating leads!

Methods

  • getCustomerID(query)
    • returns the customer ID of the first customer whose name matches query, otherwise returns false
  • recordCustomer(customerData)
    • Records a new customer in repairshopr with the given customerData
import RS from 'rs-leads-api';
let c = {
	firstname:"John",
	lastname:"Smith",
	email:"[email protected]",
	phone:"9180000000",
	location:"41st",
	make:"Apple",
	model:"iPhone 13",
	issue:"Screen Repair",
	price:"249.99"
};
RS.recordCustomer(c).then((e,c)=>{
	if(!e) console.log(c)
	else console.log(e)
})
  • getLeads()
    • Return array of all leads in RepairShopr
  • recordLead(leadData)
    • Records a new lead in repairshopr with the given leadData
import RS from 'rs-leads-api';
let l = {
	firstname:String,
	lastname:String,
	email:String,
	phone:String,
	location:String,
	make:String,
	model:String,
	issue:String,
	price:String,
}
RS.recordLead(l).then((e,l)=>{
	if(!e) console.log(l)
	else console.log(e)
})

Simple Example with Express.js

import express from 'express';
import RS from 'rs-leads-api';
const app = express();
app.get('/getLeads',async(req,res)=>{
	try{
		let leads = await RS.getLeads()
		res.send(leads)
	}
	catch(e){
		console.log(e)
		res.send(false)
	}
});
app.get('/getCustomerID/:first/:last',async(req,res)=>{
	try{
		let query = `${req.params.first} ${req.params.last}`
		let ID= await RS.getCustomerID(query)
		res.send(ID)
	}
	catch(e){
		console.log(e)
		res.send(false)
	}
});
app.post('/recordCustomer',async(req,res)=>{
	try{
		let customer = await RS.recordCustomer(req.body)
		res.send(customer)
	}
	catch(e){
		console.log(e)
		res.send(false)
	}
});
app.post('/recordLead',async(req,res)=>{
	try{
		let lead= await RS.recordLead(req.body)
		res.send(lead)
	}
	catch(e){
		console.log(e)
		res.send(false)
	}
});
app.listen(process.env.PORT||3000,()=>console.log('Server started...')
  

STORES Environment Variable

In order to record the leads for the correct locations, you will need a STORES variable. This is a JSON object that has been stringified. To generate this variable, you will need to make an object with the locations exact name in RepairShopr and the location_id, which can be found at : https://<your-subdomain>.repairshopr.com/locations Once you have this information, you should build an object like the following, then stringify it using any means (like this one). The resulting string is what you should add to your environment variables as STORES

Example STORES JSON Object:
{
2126:"Store Name 1",
2127:"Store Name 2",
2128:"Store Name 3"
}

Exmple ENV variable STORES = '{"2126":"Store Name 1","2127":"Store Name 2","2128":"Store Name 3",}'