Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
fix: refactor to fix api extractor warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado authored and moltar committed Jun 28, 2020
1 parent d1286db commit c9a392f
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 84 deletions.
16 changes: 8 additions & 8 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export interface MWSOptions {
secretKey: string
}

type HttpMethod = 'GET' | 'POST'
type ParameterTypes =
export type HttpMethod = 'GET' | 'POST'
export type ParameterTypes =
| string
| number
| (number | string)[]
Expand All @@ -67,8 +67,8 @@ type ParameterTypes =
| { [key: string]: ParameterTypes }
| undefined

type Parameters = Record<string, ParameterTypes>
type CleanParameters = Record<string, string>
export type Parameters = Record<string, ParameterTypes>
export type CleanParameters = Record<string, string>

export enum Resource {
FulfilmentInventory = 'FulfillmentInventory',
Expand All @@ -80,7 +80,7 @@ export enum Resource {
Subscriptions = 'Subscriptions',
}

interface ResourceActions {
export interface ResourceActions {
[Resource.Sellers]:
| 'ListMarketplaceParticipations'
| 'ListMarketplaceParticipationsByNextToken'
Expand Down Expand Up @@ -145,14 +145,14 @@ interface ResourceActions {
| 'GetServiceStatus'
}

interface Request {
export interface Request {
url: string
method: HttpMethod
headers: Record<string, string>
data?: string
}

interface ResourceInfo<TResource extends Resource> {
export interface ResourceInfo<TResource extends Resource> {
resource: TResource
version: string
action: ResourceActions[TResource]
Expand All @@ -167,7 +167,7 @@ export interface RequestMeta {
quotaResetOn: Date
}

interface RequestResponse {
export interface RequestResponse {
data: string
headers: Record<string, string>
}
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ export * from './sections/products/codec'
export * from './sections/products/type'
export * from './sections/reports'
export * from './sections/sellers'
export * from './sections/types'
export * from '@scaleleap/amazon-marketplaces'
export { NextToken } from './parsing'
export { MWSApiError } from './error-codec'
34 changes: 15 additions & 19 deletions src/sections/finances/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import {
} from 'purify-ts'

import { ensureArray, ensureString, mwsDate, nextToken as nextTokenCodec } from '../../parsing'
import { FulfillmentChannelEnum } from '../types'

enum ProcessingStatusEnum {
export enum ProcessingStatusEnum {
Open = 'Open',
Closed = 'Closed',
}
Expand All @@ -37,7 +38,7 @@ const FinancialEventGroup = Codec.interface({
FinancialEventGroupEnd: optional(mwsDate),
})

const ListFinancialEventGroups = Codec.interface({
export const ListFinancialEventGroups = Codec.interface({
NextToken: optional(nextTokenCodec('ListFinancialEventGroups')),
FinancialEventGroupList: ensureArray('FinancialEventGroup', FinancialEventGroup),
})
Expand Down Expand Up @@ -68,7 +69,7 @@ const FeeComponent = Codec.interface({
FeeAmount: optional(CurrencyAmount),
})

enum ChargeTypeEnum {
export enum ChargeTypeEnum {
Principal = 'Principal',
Tax = 'Tax',
'MarketplaceFacilitatorTax-Principal' = 'MarketplaceFacilitatorTax-Principal',
Expand Down Expand Up @@ -109,7 +110,7 @@ const ChargeComponent = Codec.interface({
ChargeAmount: optional(CurrencyAmount),
})

enum DirectPaymentTypeEnum {
export enum DirectPaymentTypeEnum {
StoredValueCardRevenue = 'StoredValueCardRevenue',
StoredValueCardRefund = 'StoredValueCardRefund',
PrivateLabelCreditCardRevenue = 'PrivateLabelCreditCardRevenue',
Expand All @@ -125,7 +126,7 @@ const DirectPayment = Codec.interface({
DirectPaymentAmount: optional(CurrencyAmount),
})

enum TaxCollectionModelEnum {
export enum TaxCollectionModelEnum {
MarketplaceFacilitator = 'MarketplaceFacilitator',
Standard = 'Standard',
}
Expand Down Expand Up @@ -178,11 +179,6 @@ const RefundEvent = ShipmentEvent
const GuaranteeClaimEvent = ShipmentEvent
const ChargebackEvent = ShipmentEvent

enum FulfillmentChannelEnum {
AFN = 'AFN',
MFN = 'MFN',
}

const FulfillmentChannel = enumeration(FulfillmentChannelEnum)

const PayWithAmazonEvent = Codec.interface({
Expand All @@ -198,7 +194,7 @@ const PayWithAmazonEvent = Codec.interface({
StoreName: optional(string),
})

enum ProviderTransactionTypeEnum {
export enum ProviderTransactionTypeEnum {
ProviderCredit = 'ProviderCredit',
ProviderCreditReversal = 'ProviderCreditReversal',
}
Expand All @@ -216,7 +212,7 @@ const SolutionProviderCreditEvent = Codec.interface({
ProviderStoreName: optional(string),
})

enum RetrochargeEventTypeEnum {
export enum RetrochargeEventTypeEnum {
Retrocharge = 'Retrocharge',
RetrochargeReversal = 'RetrochargeReversal',
}
Expand All @@ -235,7 +231,7 @@ const RetrochargeEvent = Codec.interface({
),
})

enum RentalEventTypeEnum {
export enum RentalEventTypeEnum {
'RentalCustomerPayment-Buyout' = 'RentalCustomerPayment-Buyout',
'RentalCustomerPayment-Extension' = 'RentalCustomerPayment-Extension',
'RentalCustomerRefund-Buyout' = 'RentalCustomerRefund-Buyout',
Expand Down Expand Up @@ -267,7 +263,7 @@ const PerformanceBondRefundEvent = unknown
/**
* Not sure what case MWS returns. Sample requests has them captialized but docs has them in lower case
*/
enum transactionTypeEnum {
export enum transactionTypeEnum {
charge = 'charge',
refund = 'refund',
Charge = 'Charge',
Expand Down Expand Up @@ -311,7 +307,7 @@ const ChargeInstrument = Codec.interface({
Amount: optional(CurrencyAmount),
})

enum DebtRecoveryTypeEnum {
export enum DebtRecoveryTypeEnum {
DebtPayment = 'DebtPayment',
DebtPaymentFailure = 'DebtPaymentFailure',
DebtAdjustment = 'DebtAdjustment',
Expand All @@ -327,7 +323,7 @@ const DebtRecoveryEvent = Codec.interface({
ChargeInstrumentList: optional(ensureArray('ChargeInstrument', ChargeInstrument)),
})

enum SourceBusinessEventTypeEnum {
export enum SourceBusinessEventTypeEnum {
LoanAdvance = 'LoanAdvance',
LoanPayment = 'LoanPayment',
LoanRefund = 'LoanRefund',
Expand All @@ -340,7 +336,7 @@ const LoanServicingEvent = Codec.interface({
SourceBusinessEventType: optional(SourceBusinessEventType),
})

enum AdjustmentTypeEnum {
export enum AdjustmentTypeEnum {
FBAInventoryReimbursement = 'FBAInventoryReimbursement',
ReserveEvent = 'ReserveEvent',
PostageBilling = 'PostageBilling',
Expand Down Expand Up @@ -441,7 +437,7 @@ const AffordabilityExpenseReversalEvent = Codec.interface({
MarketplaceId: optional(string),
})

enum NetworkComminglingTransactionTypeEnum {
export enum NetworkComminglingTransactionTypeEnum {
ComminglingVAT = 'ComminglingVAT',
NetCo = 'NetCo',
}
Expand Down Expand Up @@ -516,7 +512,7 @@ const FinancialEvents = Codec.interface({
TDSReimbursementEventList: optional(ensureArray('TDSReimbursementEvent', TDSReimbursementEvent)),
})

const ListFinancialEvents = Codec.interface({
export const ListFinancialEvents = Codec.interface({
NextToken: optional(nextTokenCodec('ListFinancialEvents')),
FinancialEvents,
})
Expand Down
12 changes: 6 additions & 6 deletions src/sections/fulfillment-inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { RequireOnlyOne } from './types'

const FULFILLMENT_INVENTORY_API_VERSION = '2010-10-01'

enum Condition {
export enum InventoryCondition {
NewItem = 'NewItem',
NewWithWarranty = 'NewWithWarranty',
NewOEM = 'NewOEM',
Expand All @@ -31,13 +31,13 @@ enum Condition {
'' = '',
}

enum TimepointType {
export enum TimepointType {
Immediately = 'Immediately',
DateTime = 'DateTime',
Unknown = 'Unknown',
}

enum SupplyType {
export enum SupplyType {
InStock = 'InStock',
Inbound = 'Inbound',
Transfer = 'Transfer',
Expand All @@ -59,14 +59,14 @@ const InventorySupply = Codec.interface({
SellerSKU: optional(string),
FNSKU: string,
ASIN: optional(string),
Condition: optional(oneOf(Object.values(Condition).map((x) => exactly(x)))),
Condition: optional(oneOf(Object.values(InventoryCondition).map((x) => exactly(x)))),
TotalSupplyQuantity: number,
InStockSupplyQuantity: number,
EarliestAvailability: optional(Timepoint),
SupplyDetail: optional(ensureArray('member', InventorySupplyDetail)),
})

const InventorySupplyList = Codec.interface({
export const InventorySupplyList = Codec.interface({
NextToken: optional(nextTokenCodec('ListInventorySupply')),
MarketplaceId: optional(string),
InventorySupplyList: ensureArray('member', InventorySupply),
Expand All @@ -78,7 +78,7 @@ const ListInventorySupplyResponse = Codec.interface({
}),
})

const InventorySupplyListByNextToken = Codec.interface({
export const InventorySupplyListByNextToken = Codec.interface({
NextToken: optional(nextTokenCodec('ListInventorySupply')),
InventorySupplyList: ensureArray('member', InventorySupply),
})
Expand Down
13 changes: 4 additions & 9 deletions src/sections/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
nextToken as nextTokenCodec,
} from '../parsing'
import { getServiceStatusByResource } from './shared'
import { RequireOnlyOne } from './types'
import { FulfillmentChannelEnum, RequireOnlyOne } from './types'

const ORDERS_API_VERSION = '2013-09-01'

Expand All @@ -33,11 +33,6 @@ export enum OrderStatusEnum {
Unfulfillable = 'Unfulfillable',
}

export enum FulfillmentChannelEnum {
AFN = 'AFN',
MFN = 'MFN',
}

export enum PaymentMethodEnum {
COD = 'COD',
CVS = 'CVS',
Expand Down Expand Up @@ -137,7 +132,7 @@ const Money = Codec.interface({
Amount: optional(number),
})

const Order = Codec.interface({
export const Order = Codec.interface({
AmazonOrderId: string,
SellerOrderId: optional(string),
PurchaseDate: mwsDate,
Expand Down Expand Up @@ -185,7 +180,7 @@ const Order = Codec.interface({
IsEstimatedShipDateSet: optional(boolean),
})

const ListOrders = Codec.interface({
export const ListOrders = Codec.interface({
NextToken: optional(nextTokenCodec('ListOrders')),
LastUpdatedBefore: optional(mwsDate),
CreatedBefore: optional(mwsDate),
Expand All @@ -212,7 +207,7 @@ const GetOrderResponse = Codec.interface({
}),
})

const ListOrderItems = Codec.interface({
export const ListOrderItems = Codec.interface({
NextToken: optional(string),
AmazonOrderId: string,
OrderItems: ensureArray(
Expand Down

0 comments on commit c9a392f

Please sign in to comment.