#import <React/RCTBridgeModule.h>

@interface RCT_EXTERN_MODULE(MoneyHash, NSObject)

RCT_EXTERN_METHOD(getIntentDetails:(NSString *)intentId
                  intentType:(NSString *)intentType
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(getMethods:(NSString *)intentId
                  intentType:(NSString *)intentType
                  currency:(NSString *)currency
                  amount:(NSString *)amount
                  customer:(NSString *)customer
                  flowId:(NSString *)flowId
                  operation:(NSString *)operation
                  customFields: (NSDictionary *)customFields
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(resetSelectedMethod:(NSString *)intentId
                  intentType:(NSString *)intentType
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(proceedWithMethod:(NSString *)intentId
                  intentType:(NSString *)intentType
                  selectedMethodId:(NSString *)selectedMethodId
                  methodType:(NSString *)methodType
                  methodMetaData:(NSDictionary *)methodMetaData
                  useWalletBalance:(BOOL)useWalletBalance
                  installmentPlanData:(NSDictionary *)installmentPlanData
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(deleteSavedCard:(NSString *)cardTokenId
                  intentSecret:(NSString *)intentSecret
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(renderForm:(NSString *)intentId
                  intentType:(NSString *)intentType
                  embedStyle:(NSDictionary *)embedStyle
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(renderSubscriptionEmbed:(NSString *)intentId
                  embedStyle:(NSDictionary *)embedStyle
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(renderURL:(NSString *)url
                  intentId:(NSString *)intentId
                  intentType:(NSString *)intentType
                  embedStyle:(NSDictionary *)embedStyle
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(submitForm:(NSString *)intentId
                  selectedMethodId:(NSString *)selectedMethodId
                  billingData:(NSDictionary *)billingData
                  shippingData:(NSDictionary *)shippingData
                  cardData:(NSDictionary *)cardData
                  saveCard:(BOOL)saveCard
                  installmentPlanData:(NSDictionary *)installmentPlanData
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(submitCardCVV:(NSString *)intentId
                  cvv:(NSString *)cvv
                  installmentPlanData:(NSDictionary *)installmentPlanData
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(submitPaymentReceipt:(NSString *)intentId
                  receipt:(NSDictionary *)receipt
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(setLogLevel:(NSString *)logLevel
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(setNativeApplePayConfig:(NSDictionary *)nativeApplePayConfig
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)


RCT_EXTERN_METHOD(generateApplePayReceiptWithApplePayData:(double *)depositAmount
                  applePayData:(NSDictionary *)applePayData
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(generateRecurringApplePayReceipt:(double)depositAmount
                  merchantIdentifier:(NSString *)merchantIdentifier
                  currencyCode:(NSString *)currencyCode
                  countryCode:(NSString *)countryCode
                  supportedNetworks:(NSArray *)supportedNetworks
                  merchantCapabilities:(NSArray *)merchantCapabilities
                  recurringPayment:(NSDictionary *)recurringPayment
                  automaticReload:(NSDictionary *)automaticReload
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(updateCardField:(NSString *)fieldType
                  value:(NSString *)value
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(validateCardField:(NSString *)fieldType
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(isValidCardForm:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(isDeviceCompatibleWithApplePay:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(collectCardForm:(NSString *)token
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(pay:(NSString *)intentId
                  cardData:(NSDictionary *)cardData
                  saveCard:(BOOL)saveCard
                  billingData:(NSDictionary *)billingData
                  shippingData:(NSDictionary *)shippingData
                  installmentPlanData:(NSDictionary *)installmentPlanData
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(setCardFormConfiguration:(NSDictionary *)configuration
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(createCardToken:(NSString *)cardIntentId
                  cardData:(NSDictionary *)cardData
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(binLookup:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(binLookupWithCardData:(NSDictionary *)cardData
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(setLocale:(NSString *)locale
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(setPublicKey:(NSString *)publicKey
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(setVersionName:(NSString *)versionName
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(updateFees:(NSString *)intentId
                  fees:(NSArray *)fees
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(updateDiscount:(NSString *)intentId
                  discount:(NSDictionary *)discount
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

 RCT_EXTERN_METHOD(selectInstallmentPlan:(NSString *)intentId
                  installmentPlanData:(NSDictionary *)installmentPlanData
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(getInstallmentPlans:(double *)amount
                  currency:(NSString *)currency
                  first6Digits:(NSString *)first6Digits
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(getApplePayBinLookup:(NSDictionary *)receipt
                  methodID:(NSString *)methodID
                  flowId:(NSString *)flowId
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(tokenizeReceipt:(NSString *)receipt
                  methodId:(NSString *)methodId
                  cardTokenIntentId:(NSString *)cardTokenIntentId
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(getSubscriptionPlans:(NSString *)planGroupId
                  customerId:(NSString *)customerId
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(selectSubscriptionPlan:(NSString *)planGroupId
                  customerId:(NSString *)customerId
                  planId:(NSString *)planId
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(getSubscriptionPlanGroups:(NSInteger)limit
                  offset:(NSInteger)offset
                  currency:(NSString *)currency
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(renderCreateBankAccountTokenEmbed:(NSString *)intentId
                  withResolver:(RCTPromiseResolveBlock)resolve
                  withRejecter:(RCTPromiseRejectBlock)reject)

+ (BOOL)requiresMainQueueSetup
{
  return NO;
}

@end
