|
1 | 1 | -- | The API
|
2 |
| - |
3 | 2 | module Stripe.Api where
|
4 | 3 |
|
5 |
| -import Stripe.Resources |
6 |
| - |
7 |
| -import Servant.API |
8 | 4 | import qualified Data.Text as T
|
| 5 | +import Servant.API |
| 6 | +import Stripe.Resources |
9 | 7 |
|
10 | 8 | type StripeAuth = BasicAuth "Stripe API" ()
|
11 | 9 |
|
12 |
| -type StripeApi |
13 |
| - = "v1" :> StripeApiInternal |
14 |
| - |
15 |
| -type StripeApiInternal |
16 |
| - = "customers" :> CustomerApi |
17 |
| - :<|> "products" :> ProductApi |
18 |
| - :<|> "prices" :> PriceApi |
19 |
| - :<|> "subscriptions" :> SubscriptionApi |
20 |
| - :<|> "checkout" :> "sessions" :> CheckoutApi |
21 |
| - :<|> "billing_portal" :> "sessions" :> CustomerPortalApi |
22 |
| - :<|> "events" :> EventApi |
23 |
| - |
24 |
| -type CustomerApi |
25 |
| - = StripeAuth :> ReqBody '[FormUrlEncoded] CustomerCreate :> Post '[JSON] Customer |
26 |
| - :<|> StripeAuth :> Capture ":customer_id" CustomerId :> Get '[JSON] Customer |
27 |
| - :<|> StripeAuth :> Capture ":customer_id" CustomerId :> ReqBody '[FormUrlEncoded] CustomerUpdate :> Post '[JSON] Customer |
28 |
| - :<|> StripeAuth :> QueryParam "starting_after" CustomerId :> Get '[JSON] (StripeList Customer) |
29 |
| - |
30 |
| -type EventApi |
31 |
| - = StripeAuth :> Capture ":event_id" EventId :> Get '[JSON] Event |
32 |
| - :<|> StripeAuth :> QueryParam "starting_after" EventId :> Get '[JSON] (StripeList Event) |
33 |
| - |
34 |
| -type ProductApi |
35 |
| - = StripeAuth :> ReqBody '[FormUrlEncoded] ProductCreate :> Post '[JSON] Product |
36 |
| - :<|> StripeAuth :> Capture ":product_id" ProductId :> Get '[JSON] Product |
37 |
| - |
38 |
| -type PriceApi |
39 |
| - = StripeAuth :> ReqBody '[FormUrlEncoded] PriceCreate :> Post '[JSON] Price |
40 |
| - :<|> StripeAuth :> Capture ":product_id" PriceId :> Get '[JSON] Price |
41 |
| - :<|> StripeAuth :> QueryParam "lookup_keys[]" T.Text :> Get '[JSON] (StripeList Price) |
42 |
| - |
43 |
| -type SubscriptionApi |
44 |
| - = StripeAuth :> ReqBody '[FormUrlEncoded] SubscriptionCreate :> Post '[JSON] Subscription |
45 |
| - :<|> StripeAuth :> Capture ":subscription_id" SubscriptionId :> Get '[JSON] Subscription |
46 |
| - :<|> StripeAuth :> QueryParam "customer" CustomerId :> Get '[JSON] (StripeList Subscription) |
47 |
| - |
48 |
| -type CheckoutApi |
49 |
| - = StripeAuth :> ReqBody '[FormUrlEncoded] CheckoutSessionCreate :> Post '[JSON] CheckoutSession |
50 |
| - :<|> StripeAuth :> Capture ":session_id" CheckoutSessionId :> Get '[JSON] CheckoutSession |
51 |
| - |
52 |
| -type CustomerPortalApi |
53 |
| - = StripeAuth :> ReqBody '[FormUrlEncoded] CustomerPortalCreate :> Post '[JSON] CustomerPortal |
| 10 | +type StripeApi = |
| 11 | + "v1" :> StripeApiInternal |
| 12 | + |
| 13 | +type StripeApiInternal = |
| 14 | + "customers" :> CustomerApi |
| 15 | + :<|> "products" :> ProductApi |
| 16 | + :<|> "prices" :> PriceApi |
| 17 | + :<|> "subscriptions" :> SubscriptionApi |
| 18 | + :<|> "checkout" :> "sessions" :> CheckoutApi |
| 19 | + :<|> "billing_portal" :> "sessions" :> CustomerPortalApi |
| 20 | + :<|> "events" :> EventApi |
| 21 | + |
| 22 | +type CustomerApi = |
| 23 | + StripeAuth :> ReqBody '[FormUrlEncoded] CustomerCreate :> Post '[JSON] Customer |
| 24 | + :<|> StripeAuth :> Capture ":customer_id" CustomerId :> Get '[JSON] Customer |
| 25 | + :<|> StripeAuth |
| 26 | + :> Capture ":customer_id" CustomerId |
| 27 | + :> ReqBody '[FormUrlEncoded] CustomerUpdate |
| 28 | + :> Post '[JSON] Customer |
| 29 | + :<|> StripeAuth |
| 30 | + :> QueryParam "starting_after" CustomerId |
| 31 | + :> Get '[JSON] (StripeList Customer) |
| 32 | + |
| 33 | +type EventApi = |
| 34 | + StripeAuth :> Capture ":event_id" EventId :> Get '[JSON] Event |
| 35 | + :<|> StripeAuth |
| 36 | + :> QueryParam "starting_after" EventId |
| 37 | + :> Get '[JSON] (StripeList Event) |
| 38 | + |
| 39 | +type ProductApi = |
| 40 | + StripeAuth :> ReqBody '[FormUrlEncoded] ProductCreate :> Post '[JSON] Product |
| 41 | + :<|> StripeAuth :> Capture ":product_id" ProductId :> Get '[JSON] Product |
| 42 | + |
| 43 | +type PriceApi = |
| 44 | + StripeAuth :> ReqBody '[FormUrlEncoded] PriceCreate :> Post '[JSON] Price |
| 45 | + :<|> StripeAuth :> Capture ":product_id" PriceId :> Get '[JSON] Price |
| 46 | + :<|> StripeAuth |
| 47 | + :> QueryParam "lookup_keys[]" T.Text |
| 48 | + :> Get '[JSON] (StripeList Price) |
| 49 | + |
| 50 | +type SubscriptionApi = |
| 51 | + StripeAuth |
| 52 | + :> ReqBody '[FormUrlEncoded] SubscriptionCreate |
| 53 | + :> Post '[JSON] Subscription |
| 54 | + :<|> StripeAuth |
| 55 | + :> Capture ":subscription_id" SubscriptionId |
| 56 | + :> Get '[JSON] Subscription |
| 57 | + :<|> StripeAuth |
| 58 | + :> QueryParam "customer" CustomerId |
| 59 | + :> Get '[JSON] (StripeList Subscription) |
| 60 | + |
| 61 | +type CheckoutApi = |
| 62 | + StripeAuth |
| 63 | + :> ReqBody '[FormUrlEncoded] CheckoutSessionCreate |
| 64 | + :> Post '[JSON] CheckoutSession |
| 65 | + :<|> StripeAuth |
| 66 | + :> Capture ":session_id" CheckoutSessionId |
| 67 | + :> Get '[JSON] CheckoutSession |
| 68 | + |
| 69 | +type CustomerPortalApi = |
| 70 | + StripeAuth |
| 71 | + :> ReqBody '[FormUrlEncoded] CustomerPortalCreate |
| 72 | + :> Post '[JSON] CustomerPortal |
0 commit comments