This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(accounts): Added AccountAddresses and contact field for orders
BREAKING CHANGE: Moved Address endpoint to CustomerAddresss
- Loading branch information
Showing
29 changed files
with
985 additions
and
550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import * as moltin from '..' | ||
|
||
async function main() { | ||
const gateway = moltin.gateway({ | ||
host: 'epcc-integration.global.ssl.fastly.net', | ||
client_id: 'R7paB5xa2ngzuEM8N6PkTOGpO9jTcAgW1DO2U2KzOl', | ||
client_secret: 'lsKTS0hKMzbxpNBAVjX0NoXt8FeALVPcQxh4lgofWD', | ||
headers: { | ||
'EP-Beta-Features': 'account-management,accounts' | ||
} | ||
}) | ||
// await gateway.Authenticate() | ||
// console.log('=======account created successfully') | ||
// await gateway.Accounts.Create({ | ||
// email: 'email@email.com', | ||
// password: 'pwd', | ||
// name: 'name', | ||
// type: 'account' | ||
// }) | ||
const accounts = await gateway.Accounts.All() | ||
// console.log(accounts) | ||
await gateway.AccountAddresses.Create({ | ||
body: { | ||
type: 'account-address', | ||
first_name: 'first_name', | ||
last_name: 'last_name', | ||
line_1: 'line_1', | ||
postcode: 'postcode', | ||
county: 'county', | ||
country: 'RU' | ||
}, | ||
account: accounts.data[0].id | ||
}) | ||
console.log('=======account address created successfully') | ||
const addresses = await gateway.AccountAddresses.All({ | ||
account: accounts.data[0].id | ||
}) | ||
console.log(addresses) | ||
const fetchAddresses = await gateway.AccountAddresses.Get({ | ||
address: addresses.data[0].id, | ||
account: accounts.data[0].id | ||
}) | ||
console.log('=======Account address fetched successfully:') | ||
console.log(fetchAddresses) | ||
|
||
const updated = await gateway.AccountAddresses.Update({ | ||
address: addresses.data[0].id, | ||
body: { | ||
id: addresses.data[0].id, | ||
type: 'account-address', | ||
first_name: 'first_name22', | ||
last_name: 'last_name22', | ||
line_1: 'line_122', | ||
postcode: 'postcode22', | ||
county: 'county22', | ||
country: 'US' | ||
}, | ||
account: accounts.data[0].id | ||
}) | ||
console.log('=======Account address updated successfully:') | ||
console.log(updated) | ||
const deleted = await gateway.AccountAddresses.Delete({ | ||
address: addresses.data[0].id, | ||
account: accounts.data[0].id | ||
}) | ||
console.log('=======Deleted successfully:') | ||
console.log(deleted) | ||
} | ||
main().catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import * as moltin from '..' | ||
|
||
async function main() { | ||
const gateway = moltin.gateway({ | ||
host: 'epcc-integration.global.ssl.fastly.net', | ||
client_id: 'R7paB5xa2ngzuEM8N6PkTOGpO9jTcAgW1DO2U2KzOl', | ||
client_secret: 'lsKTS0hKMzbxpNBAVjX0NoXt8FeALVPcQxh4lgofWD', | ||
headers: { | ||
'EP-Beta-Features': 'account-management,accounts' | ||
} | ||
}) | ||
// await gateway.Authenticate() | ||
// console.log('=======customer created successfully') | ||
await gateway.Customers.Create({ | ||
email: 'email@email.com', | ||
password: 'pwd', | ||
name: 'name', | ||
type: 'customer' | ||
}) | ||
const customers = await gateway.Customers.All() | ||
console.log(customers) | ||
await gateway.CustomerAddresses.Create({ | ||
body: { | ||
type: 'customer-address', | ||
first_name: 'first_name', | ||
last_name: 'last_name', | ||
line_1: 'line_1', | ||
postcode: 'postcode', | ||
county: 'county', | ||
country: 'RU' | ||
}, | ||
customer: customers.data[0].id | ||
}) | ||
console.log('=======customer address created successfully') | ||
const addresses = await gateway.CustomerAddresses.All({ | ||
customer: customers.data[0].id | ||
}) | ||
console.log(addresses) | ||
const fetchAddresses = await gateway.CustomerAddresses.Get({ | ||
address: addresses.data[0].id, | ||
customer: customers.data[0].id | ||
}) | ||
console.log('=======Customer address fetched successfully:') | ||
console.log(fetchAddresses) | ||
|
||
const updated = await gateway.CustomerAddresses.Update({ | ||
address: addresses.data[0].id, | ||
body: { | ||
id: addresses.data[0].id, | ||
type: 'customer-address', | ||
first_name: 'first_name22', | ||
last_name: 'last_name22', | ||
line_1: 'line_122', | ||
postcode: 'postcode22', | ||
county: 'county22', | ||
country: 'US' | ||
}, | ||
customer: customers.data[0].id | ||
}) | ||
console.log('=======Customer address updated successfully:') | ||
console.log(updated) | ||
const deleted = await gateway.CustomerAddresses.Delete({ | ||
address: addresses.data[0].id, | ||
customer: customers.data[0].id | ||
}) | ||
console.log('=======Deleted successfully:') | ||
console.log(deleted) | ||
} | ||
main().catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { singularize } from 'inflected' | ||
|
||
import BaseExtend from '../extends/base' | ||
|
||
class AccountAddressesEndpoint extends BaseExtend { | ||
constructor(endpoint) { | ||
super(endpoint) | ||
|
||
this.endpoint = 'addresses' | ||
} | ||
|
||
All({ account, token = null }) { | ||
return this.request.send( | ||
`accounts/${account}/${this.endpoint}`, | ||
'GET', | ||
undefined, | ||
undefined, | ||
token | ||
) | ||
} | ||
|
||
Get({ account, address, token = null }) { | ||
return this.request.send( | ||
`accounts/${account}/${this.endpoint}/${address}`, | ||
'GET', | ||
undefined, | ||
undefined, | ||
token | ||
) | ||
} | ||
|
||
Create({ account, body, token = null }) { | ||
return this.request.send( | ||
`accounts/${account}/${this.endpoint}`, | ||
'POST', | ||
{ ...body, type: singularize(this.endpoint) }, | ||
undefined, | ||
token | ||
) | ||
} | ||
|
||
Delete({ account, address, token = null }) { | ||
return this.request.send( | ||
`accounts/${account}/${this.endpoint}/${address}`, | ||
'DELETE', | ||
undefined, | ||
undefined, | ||
token | ||
) | ||
} | ||
|
||
Update({ account, address, body, token = null }) { | ||
return this.request.send( | ||
`accounts/${account}/${this.endpoint}/${address}`, | ||
'PUT', | ||
{ ...body, type: singularize(this.endpoint) }, | ||
undefined, | ||
token | ||
) | ||
} | ||
} | ||
|
||
export default AccountAddressesEndpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ class AccountMembershipsEndpoint extends BaseExtend { | |
'GET', | ||
undefined, | ||
token, | ||
undefined, | ||
this | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ class AccountsEndpoint extends CRUDExtend { | |
'GET', | ||
undefined, | ||
token, | ||
undefined, | ||
this, | ||
headers | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,6 +205,7 @@ class CatalogEndpoint extends CatalogQuery { | |
'GET', | ||
undefined, | ||
token, | ||
undefined, | ||
this | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ class PriceBookPricesEndpoint { | |
'GET', | ||
undefined, | ||
token, | ||
undefined, | ||
this | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.