({
placement,
active = false,
allowPostBoost = false,
allowSquadBoost = false,
}: FetchAdByPlacementOptions)
| 92 | }; |
| 93 | |
| 94 | export const fetchAdByPlacement = async ({ |
| 95 | placement, |
| 96 | active = false, |
| 97 | allowPostBoost = false, |
| 98 | allowSquadBoost = false, |
| 99 | }: FetchAdByPlacementOptions): Promise<Ad | null> => { |
| 100 | switch (placement) { |
| 101 | case AdPlacement.PostComment: |
| 102 | return fetchAdRequest({ path: '/v1/a/post' }); |
| 103 | case AdPlacement.SquadDirectory: { |
| 104 | const params = new URLSearchParams(); |
| 105 | if (allowSquadBoost) { |
| 106 | params.set('allow_squad_boost', 'true'); |
| 107 | } |
| 108 | |
| 109 | return fetchAdRequest({ path: '/v1/a/squads_directory', params }); |
| 110 | } |
| 111 | case AdPlacement.PostSidebar: |
| 112 | case AdPlacement.Feed: |
| 113 | default: { |
| 114 | const params = new URLSearchParams({ |
| 115 | active: active ? 'true' : 'false', |
| 116 | }); |
| 117 | |
| 118 | if (allowPostBoost) { |
| 119 | params.append('allow_post_boost', 'true'); |
| 120 | } |
| 121 | |
| 122 | if (allowSquadBoost) { |
| 123 | params.append('allow_squad_boost', 'true'); |
| 124 | } |
| 125 | |
| 126 | return fetchAdRequest({ path: '/v1/a', params }); |
| 127 | } |
| 128 | } |
| 129 | }; |
| 130 | |
| 131 | export const fetchAd = async (params: URLSearchParams): Promise<Ad | null> => |
| 132 | fetchAdRequest({ path: '/v1/a', params }); |
no test coverage detected