Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
brandibble
Advanced tools
An API wrapper for communicating with the Brandibble API in the browser. Currently not compatible with Node.JS environments (but could easily, we'd just need two build targets, and an isomorphic fetch library).
import Brandibble from 'brandibble';
import localforage from 'localforage'; // or another storage library
// Build a global Brandibble Ref
localforage.config({name: 'sanctu', storeName: 'compu'});
let BrandibbleRef = new Brandibble({
apiKey: '12345',
brandId: 23,
storage: localforage,
});
// You'll need to set it up like so:
BrandibbleRef.setup().then(() => {
// ... do stuff
});
// Create A Customer
let password = 'password';
Brandibble.customers.create({
first_name: 'Sanctuary',
last_name: 'Computer',
email: 'hello@sanctuary.computer',
password
}).then(response => {
// Authenticate that new customer
return BrandibbleRef.customers.authenticate({ response.email, password });
});
// Now your client will be authenticated (that state is persisted over
// page refreshes in localStorage), which you can check like so:
let isAuthenticated = !!BrandibbleRef.adapter.customerToken;
// Now you can fetch the current user
Brandibble.customers.current().then(currentCustomer => {
console.log(`Welcome to Brandibble ${currentCustomer.first_name}!`);
})
Every method returns a promise (unless otherwise noted).
A note on statefulness:
Brandibble.JS provides a slew of both stateful (dependent on the adapter's state), and stateless (simple, 'dumb' methods). It's totally up to the developer how to use these - but generally the stateful methods are simply composed of a few stateless methods.
Used for serializing and deserializing JSON, and making requests. The adapter is also responsible for restoring data from LocalStorage (or Cookies, for Safari Private Browsing). Check the object for more info (lib/adapter.js).
Stateful Methods
Brandibble.customers.authenticate({ email, password })
Brandibble.customers.invalidate()
Brandibble.customers.current()
Brandibble.customers.updateCurrent({ email, password, first_name, last_name, phone })
Stateless Methods
Brandibble.customers.create({ email, password, first_name, last_name, phone })
Brandibble.customers.resetPassword({ email })
Brandibble.customers.token({ email, password })
authenticate
.Brandibble.customers.show(customerId)
current
.Brandibble.customers.update({ email, password, first_name, last_name, phone }, customerId)
updateCurrent
.All Address Methods are dependent on the authenticated customer (stateful).
Stateful Methods
Brandibble.addresses.all()
Brandibble.addresses.create(AddressObject)
Your address object should look something like this:
let AddressObject = {
street_address: '110 Bowery',
unit: '4 FL',
city: 'New York',
state_code: 'NY',
zip_code: 10013,
latitude: 40.755912,
longitude: -73.9709333,
company: 'Sanctuary Computer, Inc.',
contact_name: 'Hugh Francis',
contact_phone: '5512213610'
}
Brandibble.locations.index()
TODO: Menus
// Assemble an Order first!
BrandibbleRef.orders.create(location, 'pickup');
let newOrder = BrandibbleRef.orders.current();
let lineItem = newOrder.addLineItem(product, 1);
newOrder.isValid(); // false
lineItem.isValid(); // false
lineItem.errors(); // error details, formatted as an array
let bases = lineItem.optionGroups()[0];
// Configure Line Item
lineItem.addOption(bases, bases.option_items[2]);
lineItem.removeOption(bases, bases.option_items[2]);
lineItem.addOption(bases, bases.option_items[1]);
lineItem.setLineItemQuantity(lineItem, 7);
lineItem.isValid() // true
newOrder.isValid() // true
BrandibbleRef.orders.validate(newOrder);
// Now Setup The order for Submission, assu
newOrder.setCustomer(customer);
newOrder.setAddress(address);
newOrder.setCard(card);
BrandibbleRef.orders.submit(newOrder);
There are only three methods that you can do on an Order:
Brandibble.orders.validateCart(BrandibbleOrderModel)
Brandibble.orders.validate(BrandibbleOrderModel)
Brandibble.orders.submit(BrandibbleOrderModel)
BRANDIBBLE_API_KEY
with your Brandibble API key before running tests.npm test
FAQs
API Wrapper for Brandibble.co
The npm package brandibble receives a total of 0 weekly downloads. As such, brandibble popularity was classified as not popular.
We found that brandibble demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.