You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
631 B
30 lines
631 B
import map from 'lodash/map'
|
|
|
|
import { API_ROOT } from 'config'
|
|
import { callApi } from 'helpers'
|
|
|
|
import type { SubscriptionType } from 'features/BuyMatchPopup/types'
|
|
|
|
type Subscription = {
|
|
id: number,
|
|
type: SubscriptionType,
|
|
}
|
|
|
|
const buyMatchSubscription = ({ id, type }: Subscription) => {
|
|
const config = {
|
|
body: {
|
|
interval: type,
|
|
is_scheduled: 0,
|
|
subscription_plan: id,
|
|
},
|
|
}
|
|
|
|
return callApi({
|
|
config,
|
|
url: `${API_ROOT}/account/purchase`,
|
|
})
|
|
}
|
|
|
|
export const buyMatchSubscriptions = (subscriptions: Array<Subscription>) => (
|
|
Promise.all(map(subscriptions, buyMatchSubscription))
|
|
)
|
|
|