-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] base classes for generics [fix] config conflicts
- Loading branch information
1 parent
c0a3965
commit 547f41d
Showing
23 changed files
with
326 additions
and
272 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
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 |
---|---|---|
@@ -1,3 +1,29 @@ | ||
export class DataStoreDefault { | ||
import { Generic } from '../Generic' | ||
|
||
export class DataStoreDefault extends Generic { | ||
upload(buffer) { | ||
const res = { | ||
status: 'success', | ||
url: 'https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150' | ||
} | ||
return Promise.resolve(res) | ||
} | ||
|
||
uploadFile(file) { | ||
const res = { | ||
status: 'success', | ||
url: file.url | ||
} | ||
return Promise.resolve(res) | ||
} | ||
|
||
uploadFiles(files) { | ||
const res = files.map(file => { | ||
return { | ||
status: 'success', | ||
url: file.url | ||
} | ||
}) | ||
return Promise.resolve(res) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,11 @@ | ||
export class EmailDefault { | ||
import { Generic } from '../Generic' | ||
|
||
export class EmailDefault extends Generic { | ||
send(data) { | ||
return Promise.resolve([]) | ||
} | ||
|
||
sendTemplate(data) { | ||
return Promise.resolve([]) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,34 @@ | ||
export class FulfillmentDefault { | ||
import { Generic } from '../Generic' | ||
|
||
export class FulfillmentDefault extends Generic { | ||
createOrder(data) { | ||
return Promise.resolve({}) | ||
} | ||
createOrders(data) { | ||
return Promise.resolve([]) | ||
} | ||
updateOrder(data) { | ||
return Promise.resolve({}) | ||
} | ||
updateOrders(data) { | ||
return Promise.resolve([]) | ||
} | ||
destroyOrder(data) { | ||
return Promise.resolve({}) | ||
} | ||
destroyOrders(data) { | ||
return Promise.resolve([]) | ||
} | ||
getOrder(data) { | ||
return Promise.resolve({}) | ||
} | ||
getOrders(data) { | ||
return Promise.resolve([]) | ||
} | ||
holdOrder(data) { | ||
return Promise.resolve({}) | ||
} | ||
holdOrders(data) { | ||
return Promise.resolve([]) | ||
} | ||
} |
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,10 @@ | ||
import { Generic } from '../Generic' | ||
|
||
export class GeolocationDefault extends Generic { | ||
locate(data) { | ||
return Promise.resolve({ | ||
latitude: 0.000000, | ||
longitude: 0.000000 | ||
}) | ||
} | ||
} |
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,5 @@ | ||
import { Generic } from '../Generic' | ||
|
||
export class ImageDefault extends Generic { | ||
|
||
} |
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 |
---|---|---|
@@ -1,3 +1,153 @@ | ||
export class PaymentDefault { | ||
import { Generic } from '../Generic' | ||
import * as shortid from 'shortid' | ||
|
||
export class PaymentDefault extends Generic { | ||
authorize(transaction) { | ||
|
||
transaction.kind = 'authorize' | ||
transaction.authorization = 'abc123' | ||
|
||
if (transaction.payment_details.length === 0) { | ||
transaction.error_code = 'processing_error' | ||
transaction.status = 'failure' | ||
} | ||
else { | ||
transaction.status = 'success' | ||
transaction.payment_details.avs_result_code = '123' | ||
transaction.payment_details.credit_card_iin = '123' | ||
transaction.payment_details.credit_card_company = 'visa' | ||
transaction.payment_details.credit_card_number = '**** **** **** 1234' | ||
transaction.payment_details.cvv_result_code = 'Y' | ||
} | ||
return Promise.resolve(transaction) | ||
} | ||
|
||
capture(transaction) { | ||
transaction.status = 'success' | ||
transaction.kind = 'capture' | ||
return Promise.resolve(transaction) | ||
} | ||
|
||
sale(transaction) { | ||
transaction.authorization = 'abc123' | ||
transaction.status = 'success' | ||
transaction.kind = 'sale' | ||
transaction.payment_details.avs_result_code = '123' | ||
transaction.payment_details.credit_card_iin = '123' | ||
transaction.payment_details.credit_card_company = 'visa' | ||
transaction.payment_details.credit_card_number = '**** **** **** 1234' | ||
transaction.payment_details.cvv_result_code = 'Y' | ||
|
||
return Promise.resolve(transaction) | ||
} | ||
|
||
void(transaction) { | ||
transaction.kind = 'void' | ||
transaction.status = 'success' | ||
return Promise.resolve(transaction) | ||
} | ||
|
||
refund(transaction) { | ||
transaction.kind = 'refund' | ||
transaction.status = 'success' | ||
return Promise.resolve(transaction) | ||
} | ||
|
||
createCustomer(customer) { | ||
const res = { | ||
gateway: 'payment_processor', | ||
foreign_key: 'customer', | ||
foreign_id: 'customer_' + shortid.generate(), | ||
data: customer | ||
} | ||
return Promise.resolve(res) | ||
} | ||
|
||
createCustomerSource(source) { | ||
const res = { | ||
gateway: 'payment_processor', | ||
account_foreign_key: 'customer', | ||
account_foreign_id: source.account_foreign_id, | ||
foreign_key: 'customer', | ||
foreign_id: 'source_' + shortid.generate(), | ||
payment_details: source | ||
} | ||
return Promise.resolve(res) | ||
} | ||
|
||
findCustomer(customer) { | ||
const res = { | ||
gateway: 'payment_processor', | ||
foreign_key: 'customer', | ||
foreign_id: customer.foreign_id, | ||
data: customer | ||
} | ||
return Promise.resolve(res) | ||
} | ||
|
||
findCustomerSource(source) { | ||
const res = { | ||
gateway: 'payment_processor', | ||
account_foreign_key: 'customer', | ||
account_foreign_id: source.account_foreign_id, | ||
foreign_key: 'source', | ||
foreign_id: source.foreign_key, | ||
payment_details: source | ||
} | ||
return Promise.resolve(res) | ||
} | ||
|
||
getCustomerSources(customer) { | ||
const res = { | ||
gateway: 'payment_processor', | ||
foreign_key: 'customer', | ||
foreign_id: customer.foreign_id, | ||
data: customer, | ||
sources: [ | ||
{ | ||
gateway: 'payment_processor', | ||
account_foreign_key: 'customer', | ||
account_foreign_id: customer.foreign_id, | ||
foreign_key: 'source', | ||
foreign_id: 'source_' + shortid.generate(), | ||
payment_details: {} | ||
} | ||
] | ||
} | ||
return Promise.resolve(res) | ||
} | ||
|
||
updateCustomer(customer) { | ||
const res = { | ||
gateway: 'payment_processor', | ||
foreign_key: 'customer', | ||
foreign_id: customer.id, | ||
data: customer | ||
} | ||
return Promise.resolve(res) | ||
} | ||
|
||
updateCustomerSource(source) { | ||
const res = { | ||
gateway: 'payment_processor', | ||
account_foreign_id: source.account_foreign_id, | ||
account_foreign_key: 'customer', | ||
foreign_key: 'source', | ||
foreign_id: source.foreign_id, | ||
payment_details: source | ||
} | ||
return Promise.resolve(res) | ||
} | ||
|
||
removeCustomerSource(source) { | ||
const res = { | ||
gateway: 'payment_processor', | ||
account_foreign_id: source.account_foreign_id, | ||
account_foreign_key: 'customer', | ||
foreign_key: 'source', | ||
foreign_id: source.foreign_id, | ||
payment_details: source | ||
} | ||
return Promise.resolve(res) | ||
} | ||
} |
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,10 @@ | ||
import { Generic } from '../Generic' | ||
|
||
export class RenderDefault extends Generic { | ||
render(data) { | ||
return Promise.resolve({document: data}) | ||
} | ||
renderSync(data) { | ||
return { document: data } | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,15 @@ | ||
export class ShippingDefault { | ||
import { Generic } from '../Generic' | ||
|
||
export class ShippingDefault extends Generic { | ||
validateAddress(data) { | ||
return Promise.resolve(data) | ||
} | ||
|
||
getRate(data) { | ||
return Promise.resolve({}) | ||
} | ||
|
||
getRates(data) { | ||
return Promise.resolve([]) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,35 @@ | ||
export class TaxDefault { | ||
import { Generic } from '../Generic' | ||
|
||
export class TaxDefault extends Generic { | ||
getRate(data) { | ||
return Promise.resolve({ | ||
amount: 1000, | ||
rate: 0.075, | ||
title: 'Sales Tax', | ||
tax_details: {} | ||
}) | ||
} | ||
|
||
taxForOrder(data) { | ||
return Promise.resolve({ | ||
total_taxes: 10, | ||
tax_lines: [ | ||
{ | ||
name: 'fake sales tax', | ||
price: data.line_items.length * 5 | ||
} | ||
], | ||
line_items: data.line_items.map(item => { | ||
return Object.assign({}, item, { | ||
total_taxes: 5, | ||
tax_lines: [ | ||
{ | ||
name: 'fake sales tax', | ||
price: 5 | ||
} | ||
] | ||
}) | ||
}) | ||
}) | ||
} | ||
} |
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,9 @@ | ||
export { DataStoreDefault } from './DataStoreDefault' | ||
export { EmailDefault } from './EmailDefault' | ||
export { FulfillmentDefault } from './FulfillmentDefault' | ||
export { GeolocationDefault } from './GeolocationDefault' | ||
export { ImageDefault } from './ImageDefault' | ||
export { PaymentDefault } from './PaymentDefault' | ||
export { RenderDefault } from './RenderDefault' | ||
export { ShippingDefault } from './ShippingDefault' | ||
export { TaxDefault } from './TaxDefault' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Oops, something went wrong.