Skip to content

Commit

Permalink
added login with google, facebook, apple, and patched register device…
Browse files Browse the repository at this point in the history
… for customer
  • Loading branch information
roncodes committed Jan 23, 2025
1 parent 8ebe0b5 commit d7f7ac9
Show file tree
Hide file tree
Showing 10 changed files with 4,116 additions and 4,096 deletions.
2 changes: 1 addition & 1 deletion dist/@storefront.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/@storefront.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/storefront.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/storefront.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/storefront.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/storefront.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/storefront",
"version": "1.1.11",
"version": "1.1.12",
"description": "Fleetbase Storefront JS & Node SDK",
"license": "AGPL-3.0-or-later",
"author": "Ronald A. Richardson <[email protected]> (https://ron.dev)",
Expand Down
8,161 changes: 4,079 additions & 4,082 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

31 changes: 24 additions & 7 deletions src/resources/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ export const customerActions = new StoreActions({
return this.adapter.post('customers/login', { identity, password, ...attributes }).then(this.afterFetch.bind(this));
},

// const customer = await storefront.customers.loginWithApple('<appleUserId>', '<identityToken>', '<authorizationCode>', '<email>', '<name>');
loginWithApple: function (appleUserId, identityToken, authorizationCode, email, name, attributes = {}) {
return this.adapter.post('customers/login-with-apple', { appleUserId, identityToken, authorizationCode, email, name, ...attributes }).then(this.afterFetch.bind(this));
},

// const customer = await storefront.customers.loginWithFacebook('<facebookUserId>', '<email>', '<name>', '<avatarUrl>');
loginWithFacebook: function (facebookUserId, email, name, avatarUrl, attributes = {}) {
return this.adapter.post('customers/login-with-facebook', { facebookUserId, email, name, avatarUrl, ...attributes }).then(this.afterFetch.bind(this));
},

// const customer = await storefront.customers.loginWithGoogle('<idToken>', '<clientId>');
loginWithGoogle: function (idToken, clientId, attributes = {}) {
return this.adapter.post('customers/login-with-google', { idToken, clientId, ...attributes }).then(this.afterFetch.bind(this));
},

verifyCode: function (identity, code, attributes = {}) {
return this.adapter.post('customers/verify-code', { identity, code, ...attributes }).then(this.afterFetch.bind(this));
},
Expand Down Expand Up @@ -66,13 +81,15 @@ export default class Customer extends Resource {
return this.getAttribute('token');
}

async syncDevice(token) {
return this.adapter
.setHeaders({ 'Customer-Token': this.token })
.post('customers/register-device', token)
.then(() => {
return this;
});
async syncDevice(token, platform) {
try {
const headers = { 'Customer-Token': this.token };
const response = await this.adapter.setHeaders(headers).post('customers/register-device', { token, platform });
return response;
} catch (error) {
console.error(`Error making request to register customer device token:`, error);
throw error;
}
}

async performAuthorizedRequest(endpoint, params = {}, method = 'GET') {
Expand Down
6 changes: 6 additions & 0 deletions src/resources/delivery-service-quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ export default class DeliveryServiceQuote extends ServiceQuote {
return formatCurrency(amount / 100, currency);
}

async fromCart() {
return this.fetchServiceQuotesFromCart(...arguments);
}

async fetchServiceQuotesFromCart(origin, destination, cart, config = 'storefront', all = false) {
if (origin?.id) {
origin = origin.id;
}

if (destination?.id) {
destination = destination.id;
}

if (cart?.id) {
cart = cart.id;
}
Expand Down

0 comments on commit d7f7ac9

Please sign in to comment.