diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru new file mode 100644 index 0000000..9cd109b --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru @@ -0,0 +1,16 @@ +meta { + name: Check Customer Balances + type: http + seq: 7 +} + +get { + url: {{credytApiUrl}}/customers/{{customerId}}/wallet + body: none + auth: inherit +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru new file mode 100644 index 0000000..caab42d --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru @@ -0,0 +1,36 @@ +meta { + name: Create a Credit Asset + type: http + seq: 1 +} + +post { + url: {{credytApiUrl}}/assets + body: json + auth: inherit +} + +body:json { + { + "code": "CREDIT", + "name": "Credits", + "precision": 0, + "symbol": "⭐", + "label": "CR", + "rates": [ + { + "source": "USD", + "rate": 0.05 + } + ] + } +} + +script:pre-request { + bru.setEnvVar("assetCode", req.getBody().code); +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru new file mode 100644 index 0000000..25da161 --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru @@ -0,0 +1,54 @@ +meta { + name: Create a Customer + type: http + seq: 4 +} + +post { + url: {{credytApiUrl}}/customers + body: json + auth: inherit +} + +body:json { + { + "name": "{{$randomFullName}}", + "external_id": "{{customerExternalId}}", + "email": "{{$randomEmail}}", + "subscriptions": [ + { + "return_url": "https://glitch.ai/account", + "failure_url": "https://glitch.ai/callbacks/credyt/failure", + "products": [ + { + "code": "{{productCode}}" + } + ] + } + ] + } +} + +script:pre-request { + const { v4 } = require('uuid'); + + const generateUuidWithoutHyphens = () => v4().replace(/-/g,""); + + const externalId = `${generateUuidWithoutHyphens()}`; + bru.setVar("customerExternalId", externalId); +} + +script:post-response { + if(res.status === 201){ + const responseJson = res.getBody(); + + if (responseJson && responseJson.id) { + bru.setEnvVar("customerId", responseJson.id); + } + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Free Tier Product (Promotional).bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Free Tier Product (Promotional).bru new file mode 100644 index 0000000..97a9607 --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Free Tier Product (Promotional).bru @@ -0,0 +1,74 @@ +meta { + name: Create a Free Tier Product (Promotional) + type: http + seq: 3 +} + +post { + url: {{credytApiUrl}}/products + body: json + auth: inherit +} + +body:json { + { + "name": "Free Tier Product", + "code": "free_tier_01", + "entitlements": [ + { + "name": "Daily Reward", + "asset": "CREDIT", + "amount": 50, + "purpose": "promotion", + "refresh": { + "interval": "day", + "strategy": "expire_and_replace" + }, + "accounting": { + "revenue_basis": 0.0, + "cost_basis": "auto" + } + } + ], + "prices": [ + { + "name": "Image Generation", + "type": "usage_based", + "billing_model": { + "type": "real_time" + }, + "usage_calculation": { + "event_type": "image_generated", + "usage_type": "unit" + }, + "pricing": [ + { + "asset": "CREDIT", + "values": [ + { + "unit_price": 5 + } + ] + } + ] + } + ], + "publish": true + } +} + +script:post-response { + if(res.status === 201){ + const responseJson = res.getBody(); + + if (responseJson && responseJson.id) { + bru.setEnvVar("freeProductId", responseJson.id); + bru.setEnvVar("freeProductCode", responseJson.code); + } + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru new file mode 100644 index 0000000..5dcacbc --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru @@ -0,0 +1,95 @@ +meta { + name: Create a Product with Entitlements + type: http + seq: 2 +} + +post { + url: {{credytApiUrl}}/products + body: json + auth: inherit +} + +body:json { + { + "name": "Premium Plan", + "code": "premium_monthly_01", + "description": "Standard monthly subscription with included credit allowance.", + "entitlements": [ + { + "name": "Monthly Credit Allowance", + "asset": "CREDIT", + "amount": 1000, + "purpose": "bundled", + "refresh": { + "interval": "month", + "strategy": "expire_and_replace" + }, + "accounting": { + "revenue_basis": 0, + "cost_basis": "auto" + } + } + ], + "prices": [ + { + "name": "Monthly Subscription Fee", + "type": "fixed", + "billing_model": { + "type": "recurring", + "recurring": { + "interval": "month" + } + }, + "pricing": [ + { + "asset": "USD", + "values": [ + { + "unit_price": 20 + } + ] + } + ] + }, + { + "name": "Image Generation", + "type": "usage_based", + "billing_model": { + "type": "real_time" + }, + "usage_calculation": { + "event_type": "image_generated", + "usage_type": "unit" + }, + "pricing": [ + { + "asset": "CREDIT", + "values": [ + { + "unit_price": 10 + } + ] + } + ] + } + ], + "publish": true + } +} + +script:post-response { + if(res.status === 201){ + const responseJson = res.getBody(); + + if (responseJson && responseJson.id) { + bru.setEnvVar("productId", responseJson.id); + bru.setEnvVar("productCode", responseJson.code); + } + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru new file mode 100644 index 0000000..a6ca375 --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru @@ -0,0 +1,16 @@ +meta { + name: Get Product Details + type: http + seq: 5 +} + +get { + url: {{credytApiUrl}}/products/{{productId}} + body: none + auth: inherit +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Send Usage Events.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Send Usage Events.bru new file mode 100644 index 0000000..fa78430 --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Send Usage Events.bru @@ -0,0 +1,35 @@ +meta { + name: Send Usage Events + type: http + seq: 6 +} + +post { + url: {{credytApiUrl}}/events + body: json + auth: inherit +} + +headers { + Content-Type: application/json +} + +body:json { + { + "customer_id": "{{customerId}}", + "events": [ + { + "id": "{{$randomUUID}}", + "event_type": "image_generated", + "occurred_at": "{{$isoTimestamp}}", + "subject": "img_{{$randomUUID}}", + "description": "Image Generated" + } + ] + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/folder.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/folder.bru new file mode 100644 index 0000000..882155a --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/folder.bru @@ -0,0 +1,8 @@ +meta { + name: Entitlements + seq: 2 +} + +auth { + mode: inherit +}