Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
Add API for fetching the payment history for a user
Acho Arnoldbd94f49bcf4e
diff --git a/api/docs/docs.go b/api/docs/docs.goindex 21f3a971..60d623e7 100644--- a/api/docs/docs.go+++ b/api/docs/docs.go@@ -151,7 +151,7 @@ const docTemplate = `{"ApiKeyAuth": []}],- "description": "Sends bulk SMS messages to multiple users from a CSV or Excel file.",+ "description": "Sends bulk SMS messages to multiple users based on our [CSV template](https://httpsms.com/templates/httpsms-bulk.csv) or our [Excel template](https://httpsms.com/templates/httpsms-bulk.xlsx).","consumes": ["multipart/form-data"],@@ -165,7 +165,7 @@ const docTemplate = `{"parameters": [{"type": "file",- "description": "The Excel or CSV file formatted according to the templates",+ "description": "The Excel or CSV file containing the messages to be sent.","name": "document","in": "formData","required": true@@ -710,53 +710,6 @@ const docTemplate = `{}}},- "/lemonsqueezy/event": {- "post": {- "description": "Publish a lemonsqueezy event to the registered listeners",- "consumes": [- "application/json"- ],- "produces": [- "application/json"- ],- "tags": [- "Lemonsqueezy"- ],- "summary": "Consume a lemonsqueezy event",- "responses": {- "204": {- "description": "No Content",- "schema": {- "$ref": "#/definitions/responses.NoContent"- }- },- "400": {- "description": "Bad Request",- "schema": {- "$ref": "#/definitions/responses.BadRequest"- }- },- "401": {- "description": "Unauthorized",- "schema": {- "$ref": "#/definitions/responses.Unauthorized"- }- },- "422": {- "description": "Unprocessable Entity",- "schema": {- "$ref": "#/definitions/responses.UnprocessableEntity"- }- },- "500": {- "description": "Internal Server Error",- "schema": {- "$ref": "#/definitions/responses.InternalServerError"- }- }- }- }- },"/message-threads": {"get": {"security": [@@ -1419,7 +1372,7 @@ const docTemplate = `{"ApiKeyAuth": []}],- "description": "Add a new SMS message to be sent by the android phone",+ "description": "Add a new SMS message to be sent by your Android phone","consumes": ["application/json"],@@ -1429,10 +1382,10 @@ const docTemplate = `{"tags": ["Messages"],- "summary": "Send a new SMS message",+ "summary": "Send an SMS message","parameters": [{- "description": "PostSend message request payload",+ "description": "Send message request payload","name": "payload","in": "body","required": true,@@ -2410,6 +2363,110 @@ const docTemplate = `{}}},+ "/users/subscription/invoices": {+ "get": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "Subscription invoices are generated throughout the lifecycle of a subscription, typically there is one at the time of purchase and then one for each renewal.",+ "consumes": [+ "application/json"+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "Users"+ ],+ "summary": "Get the last 10 subscription invoices.",+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "$ref": "#/definitions/responses.UserInvoicesResponse"+ }+ },+ "400": {+ "description": "Bad Request",+ "schema": {+ "$ref": "#/definitions/responses.BadRequest"+ }+ },+ "401": {+ "description": "Unauthorized",+ "schema": {+ "$ref": "#/definitions/responses.Unauthorized"+ }+ },+ "422": {+ "description": "Unprocessable Entity",+ "schema": {+ "$ref": "#/definitions/responses.UnprocessableEntity"+ }+ },+ "500": {+ "description": "Internal Server Error",+ "schema": {+ "$ref": "#/definitions/responses.InternalServerError"+ }+ }+ }+ }+ },+ "/users/subscription/invoices/{subscriptionInvoiceID}": {+ "post": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "Generates a new invoice for the given subscription with given parameters.",+ "consumes": [+ "application/json"+ ],+ "produces": [+ "application/pdf"+ ],+ "tags": [+ "Users"+ ],+ "summary": "Generate a subscription invoice",+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "type": "file"+ }+ },+ "400": {+ "description": "Bad Request",+ "schema": {+ "$ref": "#/definitions/responses.BadRequest"+ }+ },+ "401": {+ "description": "Unauthorized",+ "schema": {+ "$ref": "#/definitions/responses.Unauthorized"+ }+ },+ "422": {+ "description": "Unprocessable Entity",+ "schema": {+ "$ref": "#/definitions/responses.UnprocessableEntity"+ }+ },+ "500": {+ "description": "Internal Server Error",+ "schema": {+ "$ref": "#/definitions/responses.InternalServerError"+ }+ }+ }+ }+ },"/users/{userID}/api-keys": {"delete": {"security": [@@ -2946,28 +3003,16 @@ const docTemplate = `{"entities.Message": {"type": "object","required": [- "can_be_polled","contact","content","created_at",- "delivered_at","encrypted",- "expired_at",- "failed_at",- "failure_reason","id",- "last_attempted_at","max_send_attempts","order_timestamp","owner",- "received_at",- "request_id","request_received_at",- "scheduled_at",- "scheduled_send_time","send_attempt_count",- "send_time",- "sent_at","sim","status","type",@@ -2975,10 +3020,6 @@ const docTemplate = `{"user_id"],"properties": {- "can_be_polled": {- "type": "boolean",- "example": false- },"contact": {"type": "string","example": "+18005550100"@@ -3158,12 +3199,10 @@ const docTemplate = `{"type": "object","required": ["created_at",- "fcm_token","id","max_send_attempts","message_expiration_seconds","messages_per_minute",- "missed_call_auto_reply","phone_number","sim","updated_at",@@ -3284,7 +3323,6 @@ const docTemplate = `{"entities.User": {"type": "object","required": [- "active_phone_id","api_key","created_at","email",@@ -3293,11 +3331,7 @@ const docTemplate = `{"notification_message_status_enabled","notification_newsletter_enabled","notification_webhook_enabled",- "subscription_ends_at",- "subscription_id","subscription_name",- "subscription_renews_at",- "subscription_status","timezone","updated_at"],@@ -3342,10 +3376,6 @@ const docTemplate = `{"type": "string","example": "2022-06-05T14:26:02.302718+03:00"},- "subscription_id": {- "type": "string",- "example": "8f9c71b8-b84e-4417-8408-a62274f65a08"- },"subscription_name": {"type": "string","example": "free"@@ -3639,9 +3669,9 @@ const docTemplate = `{"example": "153554b5-ae44-44a0-8f4f-7bbac5657ad4"},"send_at": {- "description": "SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone.",+ "description": "SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone and you can queue messages for up to 20 days (480 hours) in the future.","type": "string",- "example": "2022-06-05T14:26:09.527976+03:00"+ "example": "2025-12-19T16:39:57-08:00"},"to": {"type": "string",@@ -4288,6 +4318,27 @@ const docTemplate = `{}}},+ "responses.UserInvoicesResponse": {+ "type": "object",+ "required": [+ "data",+ "message",+ "status"+ ],+ "properties": {+ "data": {+ "$ref": "#/definitions/responses.subscriptionInvoicesAPIResponse"+ },+ "message": {+ "type": "string",+ "example": "Request handled successfully"+ },+ "status": {+ "type": "string",+ "example": "success"+ }+ }+ },"responses.UserResponse": {"type": "object","required": [@@ -4353,6 +4404,154 @@ const docTemplate = `{"example": "success"}}+ },+ "responses.subscriptionInvoicesAPIResponse": {+ "type": "object",+ "required": [+ "data"+ ],+ "properties": {+ "data": {+ "type": "array",+ "items": {+ "type": "object",+ "required": [+ "attributes",+ "id",+ "type"+ ],+ "properties": {+ "attributes": {+ "type": "object",+ "required": [+ "billing_reason",+ "card_brand",+ "card_last_four",+ "created_at",+ "currency",+ "currency_rate",+ "discount_total",+ "discount_total_formatted",+ "discount_total_usd",+ "refunded",+ "refunded_amount",+ "refunded_amount_formatted",+ "refunded_amount_usd",+ "refunded_at",+ "status",+ "status_formatted",+ "subtotal",+ "subtotal_formatted",+ "subtotal_usd",+ "tax",+ "tax_formatted",+ "tax_inclusive",+ "tax_usd",+ "total",+ "total_formatted",+ "total_usd",+ "updated_at",+ "user_email",+ "user_name"+ ],+ "properties": {+ "billing_reason": {+ "type": "string"+ },+ "card_brand": {+ "type": "string"+ },+ "card_last_four": {+ "type": "string"+ },+ "created_at": {+ "type": "string"+ },+ "currency": {+ "type": "string"+ },+ "currency_rate": {+ "type": "string"+ },+ "discount_total": {+ "type": "integer"+ },+ "discount_total_formatted": {+ "type": "string"+ },+ "discount_total_usd": {+ "type": "integer"+ },+ "refunded": {+ "type": "boolean"+ },+ "refunded_amount": {+ "type": "integer"+ },+ "refunded_amount_formatted": {+ "type": "string"+ },+ "refunded_amount_usd": {+ "type": "integer"+ },+ "refunded_at": {},+ "status": {+ "type": "string"+ },+ "status_formatted": {+ "type": "string"+ },+ "subtotal": {+ "type": "integer"+ },+ "subtotal_formatted": {+ "type": "string"+ },+ "subtotal_usd": {+ "type": "integer"+ },+ "tax": {+ "type": "integer"+ },+ "tax_formatted": {+ "type": "string"+ },+ "tax_inclusive": {+ "type": "boolean"+ },+ "tax_usd": {+ "type": "integer"+ },+ "total": {+ "type": "integer"+ },+ "total_formatted": {+ "type": "string"+ },+ "total_usd": {+ "type": "integer"+ },+ "updated_at": {+ "type": "string"+ },+ "user_email": {+ "type": "string"+ },+ "user_name": {+ "type": "string"+ }+ }+ },+ "id": {+ "type": "string"+ },+ "type": {+ "type": "string"+ }+ }+ }+ }+ }}},"securityDefinitions": {diff --git a/api/docs/swagger.json b/api/docs/swagger.jsonindex 5cef4eb0..35e5a245 100644--- a/api/docs/swagger.json+++ b/api/docs/swagger.json@@ -133,7 +133,7 @@"ApiKeyAuth": []}],- "description": "Sends bulk SMS messages to multiple users from a CSV or Excel file.",+ "description": "Sends bulk SMS messages to multiple users based on our [CSV template](https://httpsms.com/templates/httpsms-bulk.csv) or our [Excel template](https://httpsms.com/templates/httpsms-bulk.xlsx).","consumes": ["multipart/form-data"],"produces": ["application/json"],"tags": ["BulkSMS"],@@ -141,7 +141,7 @@"parameters": [{"type": "file",- "description": "The Excel or CSV file formatted according to the templates",+ "description": "The Excel or CSV file containing the messages to be sent.","name": "document","in": "formData","required": true@@ -638,47 +638,6 @@}}},- "/lemonsqueezy/event": {- "post": {- "description": "Publish a lemonsqueezy event to the registered listeners",- "consumes": ["application/json"],- "produces": ["application/json"],- "tags": ["Lemonsqueezy"],- "summary": "Consume a lemonsqueezy event",- "responses": {- "204": {- "description": "No Content",- "schema": {- "$ref": "#/definitions/responses.NoContent"- }- },- "400": {- "description": "Bad Request",- "schema": {- "$ref": "#/definitions/responses.BadRequest"- }- },- "401": {- "description": "Unauthorized",- "schema": {- "$ref": "#/definitions/responses.Unauthorized"- }- },- "422": {- "description": "Unprocessable Entity",- "schema": {- "$ref": "#/definitions/responses.UnprocessableEntity"- }- },- "500": {- "description": "Internal Server Error",- "schema": {- "$ref": "#/definitions/responses.InternalServerError"- }- }- }- }- },"/message-threads": {"get": {"security": [@@ -1287,14 +1246,14 @@"ApiKeyAuth": []}],- "description": "Add a new SMS message to be sent by the android phone",+ "description": "Add a new SMS message to be sent by your Android phone","consumes": ["application/json"],"produces": ["application/json"],"tags": ["Messages"],- "summary": "Send a new SMS message",+ "summary": "Send an SMS message","parameters": [{- "description": "PostSend message request payload",+ "description": "Send message request payload","name": "payload","in": "body","required": true,@@ -2186,6 +2145,98 @@}}},+ "/users/subscription/invoices": {+ "get": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "Subscription invoices are generated throughout the lifecycle of a subscription, typically there is one at the time of purchase and then one for each renewal.",+ "consumes": ["application/json"],+ "produces": ["application/json"],+ "tags": ["Users"],+ "summary": "Get the last 10 subscription invoices.",+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "$ref": "#/definitions/responses.UserInvoicesResponse"+ }+ },+ "400": {+ "description": "Bad Request",+ "schema": {+ "$ref": "#/definitions/responses.BadRequest"+ }+ },+ "401": {+ "description": "Unauthorized",+ "schema": {+ "$ref": "#/definitions/responses.Unauthorized"+ }+ },+ "422": {+ "description": "Unprocessable Entity",+ "schema": {+ "$ref": "#/definitions/responses.UnprocessableEntity"+ }+ },+ "500": {+ "description": "Internal Server Error",+ "schema": {+ "$ref": "#/definitions/responses.InternalServerError"+ }+ }+ }+ }+ },+ "/users/subscription/invoices/{subscriptionInvoiceID}": {+ "post": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "Generates a new invoice for the given subscription with given parameters.",+ "consumes": ["application/json"],+ "produces": ["application/pdf"],+ "tags": ["Users"],+ "summary": "Generate a subscription invoice",+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "type": "file"+ }+ },+ "400": {+ "description": "Bad Request",+ "schema": {+ "$ref": "#/definitions/responses.BadRequest"+ }+ },+ "401": {+ "description": "Unauthorized",+ "schema": {+ "$ref": "#/definitions/responses.Unauthorized"+ }+ },+ "422": {+ "description": "Unprocessable Entity",+ "schema": {+ "$ref": "#/definitions/responses.UnprocessableEntity"+ }+ },+ "500": {+ "description": "Internal Server Error",+ "schema": {+ "$ref": "#/definitions/responses.InternalServerError"+ }+ }+ }+ }+ },"/users/{userID}/api-keys": {"delete": {"security": [@@ -2686,28 +2737,16 @@"entities.Message": {"type": "object","required": [- "can_be_polled","contact","content","created_at",- "delivered_at","encrypted",- "expired_at",- "failed_at",- "failure_reason","id",- "last_attempted_at","max_send_attempts","order_timestamp","owner",- "received_at",- "request_id","request_received_at",- "scheduled_at",- "scheduled_send_time","send_attempt_count",- "send_time",- "sent_at","sim","status","type",@@ -2715,10 +2754,6 @@"user_id"],"properties": {- "can_be_polled": {- "type": "boolean",- "example": false- },"contact": {"type": "string","example": "+18005550100"@@ -2898,12 +2933,10 @@"type": "object","required": ["created_at",- "fcm_token","id","max_send_attempts","message_expiration_seconds","messages_per_minute",- "missed_call_auto_reply","phone_number","sim","updated_at",@@ -3021,7 +3054,6 @@"entities.User": {"type": "object","required": [- "active_phone_id","api_key","created_at","email",@@ -3030,11 +3062,7 @@"notification_message_status_enabled","notification_newsletter_enabled","notification_webhook_enabled",- "subscription_ends_at",- "subscription_id","subscription_name",- "subscription_renews_at",- "subscription_status","timezone","updated_at"],@@ -3079,10 +3107,6 @@"type": "string","example": "2022-06-05T14:26:02.302718+03:00"},- "subscription_id": {- "type": "string",- "example": "8f9c71b8-b84e-4417-8408-a62274f65a08"- },"subscription_name": {"type": "string","example": "free"@@ -3332,9 +3356,9 @@"example": "153554b5-ae44-44a0-8f4f-7bbac5657ad4"},"send_at": {- "description": "SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone.",+ "description": "SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone and you can queue messages for up to 20 days (480 hours) in the future.","type": "string",- "example": "2022-06-05T14:26:09.527976+03:00"+ "example": "2025-12-19T16:39:57-08:00"},"to": {"type": "string",@@ -3877,6 +3901,23 @@}}},+ "responses.UserInvoicesResponse": {+ "type": "object",+ "required": ["data", "message", "status"],+ "properties": {+ "data": {+ "$ref": "#/definitions/responses.subscriptionInvoicesAPIResponse"+ },+ "message": {+ "type": "string",+ "example": "Request handled successfully"+ },+ "status": {+ "type": "string",+ "example": "success"+ }+ }+ },"responses.UserResponse": {"type": "object","required": ["data", "message", "status"],@@ -3930,6 +3971,148 @@"example": "success"}}+ },+ "responses.subscriptionInvoicesAPIResponse": {+ "type": "object",+ "required": ["data"],+ "properties": {+ "data": {+ "type": "array",+ "items": {+ "type": "object",+ "required": ["attributes", "id", "type"],+ "properties": {+ "attributes": {+ "type": "object",+ "required": [+ "billing_reason",+ "card_brand",+ "card_last_four",+ "created_at",+ "currency",+ "currency_rate",+ "discount_total",+ "discount_total_formatted",+ "discount_total_usd",+ "refunded",+ "refunded_amount",+ "refunded_amount_formatted",+ "refunded_amount_usd",+ "refunded_at",+ "status",+ "status_formatted",+ "subtotal",+ "subtotal_formatted",+ "subtotal_usd",+ "tax",+ "tax_formatted",+ "tax_inclusive",+ "tax_usd",+ "total",+ "total_formatted",+ "total_usd",+ "updated_at",+ "user_email",+ "user_name"+ ],+ "properties": {+ "billing_reason": {+ "type": "string"+ },+ "card_brand": {+ "type": "string"+ },+ "card_last_four": {+ "type": "string"+ },+ "created_at": {+ "type": "string"+ },+ "currency": {+ "type": "string"+ },+ "currency_rate": {+ "type": "string"+ },+ "discount_total": {+ "type": "integer"+ },+ "discount_total_formatted": {+ "type": "string"+ },+ "discount_total_usd": {+ "type": "integer"+ },+ "refunded": {+ "type": "boolean"+ },+ "refunded_amount": {+ "type": "integer"+ },+ "refunded_amount_formatted": {+ "type": "string"+ },+ "refunded_amount_usd": {+ "type": "integer"+ },+ "refunded_at": {},+ "status": {+ "type": "string"+ },+ "status_formatted": {+ "type": "string"+ },+ "subtotal": {+ "type": "integer"+ },+ "subtotal_formatted": {+ "type": "string"+ },+ "subtotal_usd": {+ "type": "integer"+ },+ "tax": {+ "type": "integer"+ },+ "tax_formatted": {+ "type": "string"+ },+ "tax_inclusive": {+ "type": "boolean"+ },+ "tax_usd": {+ "type": "integer"+ },+ "total": {+ "type": "integer"+ },+ "total_formatted": {+ "type": "string"+ },+ "total_usd": {+ "type": "integer"+ },+ "updated_at": {+ "type": "string"+ },+ "user_email": {+ "type": "string"+ },+ "user_name": {+ "type": "string"+ }+ }+ },+ "id": {+ "type": "string"+ },+ "type": {+ "type": "string"+ }+ }+ }+ }+ }}},"securityDefinitions": {diff --git a/api/docs/swagger.yaml b/api/docs/swagger.yamlindex efc316c4..fdde688c 100644--- a/api/docs/swagger.yaml+++ b/api/docs/swagger.yaml@@ -102,9 +102,6 @@ definitions:type: objectentities.Message:properties:- can_be_polled:- example: false- type: booleancontact:example: "+18005550100"type: string@@ -192,28 +189,16 @@ definitions:example: WB7DRDWrJZRGbYrv2CKGkqbzvqdCtype: stringrequired:- - can_be_polled- contact- content- created_at- - delivered_at- encrypted- - expired_at- - failed_at- - failure_reason- id- - last_attempted_at- max_send_attempts- order_timestamp- owner- - received_at- - request_id- request_received_at- - scheduled_at- - scheduled_send_time- send_attempt_count- - send_time- - sent_at- sim- status- type@@ -314,12 +299,10 @@ definitions:type: stringrequired:- created_at- - fcm_token- id- max_send_attempts- message_expiration_seconds- messages_per_minute- - missed_call_auto_reply- phone_number- sim- updated_at@@ -405,9 +388,6 @@ definitions:subscription_ends_at:example: "2022-06-05T14:26:02.302718+03:00"type: string- subscription_id:- example: 8f9c71b8-b84e-4417-8408-a62274f65a08- type: stringsubscription_name:example: freetype: string@@ -424,7 +404,6 @@ definitions:example: "2022-06-05T14:26:10.303278+03:00"type: stringrequired:- - active_phone_id- api_key- created_at@@ -433,11 +412,7 @@ definitions:- notification_message_status_enabled- notification_newsletter_enabled- notification_webhook_enabled- - subscription_ends_at- - subscription_id- subscription_name- - subscription_renews_at- - subscription_status- timezone- updated_attype: object@@ -659,8 +634,9 @@ definitions:description:SendAt is an optional parameter used to schedule a message tobe sent in the future. The time is considered to be in your profile's local- timezone.- example: "2022-06-05T14:26:09.527976+03:00"+ timezone and you can queue messages for up to 20 days (480 hours) in the+ future.+ example: "2025-12-19T16:39:57-08:00"type: stringto:example: "+18005550100"@@ -1135,6 +1111,21 @@ definitions:- message- statustype: object+ responses.UserInvoicesResponse:+ properties:+ data:+ $ref: "#/definitions/responses.subscriptionInvoicesAPIResponse"+ message:+ example: Request handled successfully+ type: string+ status:+ example: success+ type: string+ required:+ - data+ - message+ - status+ type: objectresponses.UserResponse:properties:data:@@ -1182,6 +1173,114 @@ definitions:- message- statustype: object+ responses.subscriptionInvoicesAPIResponse:+ properties:+ data:+ items:+ properties:+ attributes:+ properties:+ billing_reason:+ type: string+ card_brand:+ type: string+ card_last_four:+ type: string+ created_at:+ type: string+ currency:+ type: string+ currency_rate:+ type: string+ discount_total:+ type: integer+ discount_total_formatted:+ type: string+ discount_total_usd:+ type: integer+ refunded:+ type: boolean+ refunded_amount:+ type: integer+ refunded_amount_formatted:+ type: string+ refunded_amount_usd:+ type: integer+ refunded_at: {}+ status:+ type: string+ status_formatted:+ type: string+ subtotal:+ type: integer+ subtotal_formatted:+ type: string+ subtotal_usd:+ type: integer+ tax:+ type: integer+ tax_formatted:+ type: string+ tax_inclusive:+ type: boolean+ tax_usd:+ type: integer+ total:+ type: integer+ total_formatted:+ type: string+ total_usd:+ type: integer+ updated_at:+ type: string+ user_email:+ type: string+ user_name:+ type: string+ required:+ - billing_reason+ - card_brand+ - card_last_four+ - created_at+ - currency+ - currency_rate+ - discount_total+ - discount_total_formatted+ - discount_total_usd+ - refunded+ - refunded_amount+ - refunded_amount_formatted+ - refunded_amount_usd+ - refunded_at+ - status+ - status_formatted+ - subtotal+ - subtotal_formatted+ - subtotal_usd+ - tax+ - tax_formatted+ - tax_inclusive+ - tax_usd+ - total+ - total_formatted+ - total_usd+ - updated_at+ - user_email+ - user_name+ type: object+ id:+ type: string+ type:+ type: string+ required:+ - attributes+ - id+ - type+ type: object+ type: array+ required:+ - data+ type: objecthost: api.httpsms.cominfo:contact:@@ -1282,9 +1381,11 @@ paths:post:consumes:- multipart/form-data- description: Sends bulk SMS messages to multiple users from a CSV or Excel file.+ description:+ Sends bulk SMS messages to multiple users based on our [CSV template](https://httpsms.com/templates/httpsms-bulk.csv)+ or our [Excel template](https://httpsms.com/templates/httpsms-bulk.xlsx).parameters:- - description: The Excel or CSV file formatted according to the templates+ - description: The Excel or CSV file containing the messages to be sent.in: formDataname: documentrequired: true@@ -1650,37 +1751,6 @@ paths:summary: Sends a 3CX SMS messagetags:- 3CXIntegration- /lemonsqueezy/event:- post:- consumes:- - application/json- description: Publish a lemonsqueezy event to the registered listeners- produces:- - application/json- responses:- "204":- description: No Content- schema:- $ref: "#/definitions/responses.NoContent"- "400":- description: Bad Request- schema:- $ref: "#/definitions/responses.BadRequest"- "401":- description: Unauthorized- schema:- $ref: "#/definitions/responses.Unauthorized"- "422":- description: Unprocessable Entity- schema:- $ref: "#/definitions/responses.UnprocessableEntity"- "500":- description: Internal Server Error- schema:- $ref: "#/definitions/responses.InternalServerError"- summary: Consume a lemonsqueezy event- tags:- - Lemonsqueezy/message-threads:get:consumes:@@ -2220,9 +2290,9 @@ paths:post:consumes:- application/json- description: Add a new SMS message to be sent by the android phone+ description: Add a new SMS message to be sent by your Android phoneparameters:- - description: PostSend message request payload+ - description: Send message request payloadin: bodyname: payloadrequired: true@@ -2253,7 +2323,7 @@ paths:$ref: "#/definitions/responses.InternalServerError"security:- ApiKeyAuth: []- summary: Send a new SMS message+ summary: Send an SMS messagetags:- Messages/phone-api-keys:@@ -2866,6 +2936,75 @@ paths:summary: Currently authenticated user subscription update URLtags:- Users+ /users/subscription/invoices:+ get:+ consumes:+ - application/json+ description:+ Subscription invoices are generated throughout the lifecycle of+ a subscription, typically there is one at the time of purchase and then one+ for each renewal.+ produces:+ - application/json+ responses:+ "200":+ description: OK+ schema:+ $ref: "#/definitions/responses.UserInvoicesResponse"+ "400":+ description: Bad Request+ schema:+ $ref: "#/definitions/responses.BadRequest"+ "401":+ description: Unauthorized+ schema:+ $ref: "#/definitions/responses.Unauthorized"+ "422":+ description: Unprocessable Entity+ schema:+ $ref: "#/definitions/responses.UnprocessableEntity"+ "500":+ description: Internal Server Error+ schema:+ $ref: "#/definitions/responses.InternalServerError"+ security:+ - ApiKeyAuth: []+ summary: Get the last 10 subscription invoices.+ tags:+ - Users+ /users/subscription/invoices/{subscriptionInvoiceID}:+ post:+ consumes:+ - application/json+ description: Generates a new invoice for the given subscription with given parameters.+ produces:+ - application/pdf+ responses:+ "200":+ description: OK+ schema:+ type: file+ "400":+ description: Bad Request+ schema:+ $ref: "#/definitions/responses.BadRequest"+ "401":+ description: Unauthorized+ schema:+ $ref: "#/definitions/responses.Unauthorized"+ "422":+ description: Unprocessable Entity+ schema:+ $ref: "#/definitions/responses.UnprocessableEntity"+ "500":+ description: Internal Server Error+ schema:+ $ref: "#/definitions/responses.InternalServerError"+ security:+ - ApiKeyAuth: []+ summary: Generate a subscription invoice+ tags:+ - Users/webhooks:get:consumes:diff --git a/api/go.mod b/api/go.modindex 1a9e4882..a798964a 100644--- a/api/go.mod+++ b/api/go.mod@@ -10,7 +10,7 @@ require (github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.54.0github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.30.0github.com/NdoleStudio/go-otelroundtripper v0.0.13- github.com/NdoleStudio/lemonsqueezy-go v1.2.4+ github.com/NdoleStudio/lemonsqueezy-go v1.3.1github.com/NdoleStudio/plunk-go v0.0.2github.com/avast/retry-go v3.0.0+incompatiblegithub.com/carlmjohnson/requests v0.25.1diff --git a/api/go.sum b/api/go.sumindex 083d8121..d1685d6c 100644--- a/api/go.sum+++ b/api/go.sum@@ -56,8 +56,8 @@ github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCgithub.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=github.com/NdoleStudio/go-otelroundtripper v0.0.13 h1:fDgdxcNJov4LTrMhXqJnF/E3jO4HJVczj90wkxh5PSc=github.com/NdoleStudio/go-otelroundtripper v0.0.13/go.mod h1:UIUQ22ErFoBUyLuPDrVNRRKmBHBTfzQO9GF1ztqDvqo=-github.com/NdoleStudio/lemonsqueezy-go v1.2.4 h1:BhWlCUH+DIPfSn4g/V7f2nFkMCQuzno9DXKZ7YDrXXA=-github.com/NdoleStudio/lemonsqueezy-go v1.2.4/go.mod h1:2uZlWgn9sbNxOx3JQWLlPrDOC6NT/wmSTOgL3U/fMMw=+github.com/NdoleStudio/lemonsqueezy-go v1.3.1 h1:lMUVgdAx2onbOUJIVPR05xAANYuCMXBRaGWpAdA4LiM=+github.com/NdoleStudio/lemonsqueezy-go v1.3.1/go.mod h1:xKRsRX1jSI6mLrVXyWh2sF/1isxTioZrSjWy6HpA3xQ=github.com/NdoleStudio/plunk-go v0.0.2 h1:afPW7MHK4Z3rsybpJBnmTmxKCLKF1M7sPI+BNGPf35A=github.com/NdoleStudio/plunk-go v0.0.2/go.mod h1:pqG3zKhpn/A2bL1K+WsWzvfTpOeSkYgXhNk5H65uEc8=github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo=diff --git a/api/pkg/entities/user.go b/api/pkg/entities/user.goindex a6a92371..fd8de1a5 100644--- a/api/pkg/entities/user.go+++ b/api/pkg/entities/user.go@@ -78,7 +78,7 @@ type User struct {Timezone string `json:"timezone" example:"Europe/Helsinki" gorm:"default:Africa/Accra"`ActivePhoneID *uuid.UUID `json:"active_phone_id" gorm:"type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb" validate:"optional"`SubscriptionName SubscriptionName `json:"subscription_name" example:"free"`- SubscriptionID *string `json:"-" example:"8f9c71b8-b84e-4417-8408-a62274f65a08" swaggerignore:"true"`+ SubscriptionID *string `json:"subscription_id" example:"8f9c71b8-b84e-4417-8408-a62274f65a08" swaggerignore:"true"`SubscriptionStatus *string `json:"subscription_status" example:"on_trial" validate:"optional"`SubscriptionRenewsAt *time.Time `json:"subscription_renews_at" example:"2022-06-05T14:26:02.302718+03:00" validate:"optional"`SubscriptionEndsAt *time.Time `json:"subscription_ends_at" example:"2022-06-05T14:26:02.302718+03:00" validate:"optional"`diff --git a/api/pkg/handlers/user_handler.go b/api/pkg/handlers/user_handler.goindex 44ec619e..574edf27 100644--- a/api/pkg/handlers/user_handler.go+++ b/api/pkg/handlers/user_handler.go@@ -46,6 +46,8 @@ func (h *UserHandler) RegisterRoutes(router fiber.Router, middlewares ...fiber.Hrouter.Put("/v1/users/:userID/notifications", h.computeRoute(middlewares, h.UpdateNotifications)...)router.Get("/v1/users/subscription-update-url", h.computeRoute(middlewares, h.subscriptionUpdateURL)...)router.Delete("/v1/users/subscription", h.computeRoute(middlewares, h.cancelSubscription)...)+ router.Get("/v1/users/subscription/invoices", h.computeRoute(middlewares, h.subscriptionPayments)...)+ router.Post("/v1/users/subscription/invoices/:subscriptionInvoiceID", h.computeRoute(middlewares, h.subscriptionInvoice)...)}// Show returns an entities.User@@ -272,3 +274,62 @@ func (h *UserHandler) DeleteAPIKey(c *fiber.Ctx) error {return h.responseOK(c, "API Key rotated successfully", user)}++// subscriptionPayments returns the last 10 payments of the currently authenticated user+// @Summary Get the last 10 subscription payments.+// @Description Subscription payments are generated throughout the lifecycle of a subscription, typically there is one at the time of purchase and then one for each renewal.+// @Security ApiKeyAuth+// @Tags Users+// @Accept json+// @Produce json+// @Success 200 {object} responses.UserSubscriptionPaymentsResponse+// @Failure 400 {object} responses.BadRequest+// @Failure 401 {object} responses.Unauthorized+// @Failure 422 {object} responses.UnprocessableEntity+// @Failure 500 {object} responses.InternalServerError+// @Router /users/subscription/payments [get]+func (h *UserHandler) subscriptionPayments(c *fiber.Ctx) error {+ ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger)+ defer span.End()++ invoices, err := h.service.GetSubscriptionPayments(ctx, h.userIDFomContext(c))+ if err != nil {+ msg := fmt.Sprintf("cannot get current subscription invoices for user [%s]", h.userFromContext(c))+ ctxLogger.Error(stacktrace.Propagate(err, msg))+ return h.responseInternalServerError(c)+ }++ return h.responseOK(c, "fetched subscription invoices billing usage", invoices)+}++// subscriptionInvoice generates an invoice for a given subscription invoice ID+// @Summary Generate a subscription invoice+// @Description Generates a new invoice PDF file for the given subscription payment with given parameters.+// @Security ApiKeyAuth+// @Tags Users+// @Accept json+// @Produce application/pdf+// @Success 200 {file} file+// @Failure 400 {object} responses.BadRequest+// @Failure 401 {object} responses.Unauthorized+// @Failure 422 {object} responses.UnprocessableEntity+// @Failure 500 {object} responses.InternalServerError+// @Router /users/subscription/invoices/{subscriptionInvoiceID} [post]+func (h *UserHandler) subscriptionInvoice(c *fiber.Ctx) error {+ ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger)+ defer span.End()++ invoiceID := c.Params("subscriptionInvoiceID")++ data, err := h.service.GenerateReceipt(ctx, h.userIDFomContext(c))+ if err != nil {+ msg := fmt.Sprintf("cannot generate receipt for invoice ID [%s] and user [%s]", invoiceID, h.userFromContext(c))+ ctxLogger.Error(stacktrace.Propagate(err, msg))+ return h.responseInternalServerError(c)+ }++ c.Set(fiber.HeaderContentType, "application/pdf")+ c.Set(fiber.HeaderContentDisposition, fmt.Sprintf("attachment; filename=\"%s.pdf\"", invoiceID))++ return c.SendStream(data)+}diff --git a/api/pkg/responses/billing_responses.go b/api/pkg/responses/billing_responses.goindex bb51d6ab..0ce46415 100644--- a/api/pkg/responses/billing_responses.go+++ b/api/pkg/responses/billing_responses.go@@ -1,6 +1,8 @@package responses-import "github.com/NdoleStudio/httpsms/pkg/entities"+import (+ "github.com/NdoleStudio/httpsms/pkg/entities"+)// BillingUsagesResponse is the payload containing []entities.BillingUsagetype BillingUsagesResponse struct {diff --git a/api/pkg/responses/user_responses.go b/api/pkg/responses/user_responses.goindex f2ee6c37..31f95341 100644--- a/api/pkg/responses/user_responses.go+++ b/api/pkg/responses/user_responses.go@@ -1,9 +1,51 @@package responses-import "github.com/NdoleStudio/httpsms/pkg/entities"+import (+ "time"++ "github.com/NdoleStudio/httpsms/pkg/entities"+)// UserResponse is the payload containing entities.Usertype UserResponse struct {responseData entities.User `json:"data"`}++// UserSubscriptionPaymentsResponse is the payload containing lemonsqueezy.SubscriptionInvoicesAPIResponse+type UserSubscriptionPaymentsResponse struct {+ response+ Data []struct {+ Type string `json:"type"`+ ID string `json:"id"`+ Attributes struct {+ BillingReason string `json:"billing_reason"`+ CardBrand string `json:"card_brand"`+ CardLastFour string `json:"card_last_four"`+ Currency string `json:"currency"`+ CurrencyRate string `json:"currency_rate"`+ Status string `json:"status"`+ StatusFormatted string `json:"status_formatted"`+ Refunded bool `json:"refunded"`+ RefundedAt any `json:"refunded_at"`+ Subtotal int `json:"subtotal"`+ DiscountTotal int `json:"discount_total"`+ Tax int `json:"tax"`+ TaxInclusive bool `json:"tax_inclusive"`+ Total int `json:"total"`+ RefundedAmount int `json:"refunded_amount"`+ SubtotalUsd int `json:"subtotal_usd"`+ DiscountTotalUsd int `json:"discount_total_usd"`+ TaxUsd int `json:"tax_usd"`+ TotalUsd int `json:"total_usd"`+ RefundedAmountUsd int `json:"refunded_amount_usd"`+ SubtotalFormatted string `json:"subtotal_formatted"`+ DiscountTotalFormatted string `json:"discount_total_formatted"`+ TaxFormatted string `json:"tax_formatted"`+ TotalFormatted string `json:"total_formatted"`+ RefundedAmountFormatted string `json:"refunded_amount_formatted"`+ CreatedAt time.Time `json:"created_at"`+ UpdatedAt time.Time `json:"updated_at"`+ } `json:"attributes"`+ } `json:"data"`+}diff --git a/api/pkg/services/user_service.go b/api/pkg/services/user_service.goindex e030e1f8..860e1a42 100644--- a/api/pkg/services/user_service.go+++ b/api/pkg/services/user_service.go@@ -3,10 +3,10 @@ package servicesimport ("context""fmt"+ "io""time""firebase.google.com/go/auth"-"github.com/NdoleStudio/httpsms/pkg/events""github.com/NdoleStudio/httpsms/pkg/emails"@@ -56,6 +56,42 @@ func NewUserService(}}+// GetSubscriptionPayments fetches the subscription payments for an entities.User+func (service *UserService) GetSubscriptionPayments(ctx context.Context, userID entities.UserID) (invoices []lemonsqueezy.ApiResponseData[lemonsqueezy.SubscriptionInvoiceAttributes, lemonsqueezy.APIResponseRelationshipsSubscriptionInvoice], err error) {+ ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger)+ defer span.End()++ user, err := service.repository.Load(ctx, userID)+ if err != nil {+ msg := fmt.Sprintf("could not get [%T] with with ID [%s]", user, userID)+ return invoices, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))+ }++ if user.SubscriptionID == nil {+ ctxLogger.Info(fmt.Sprintf("no subscription ID found for [%T] with ID [%s], returning empty invoices", user, user.ID))+ return invoices, nil+ }++ ctxLogger.Info(fmt.Sprintf("fetching subscription payments for [%T] with ID [%s] and subscription [%s]", user, user.ID, *user.SubscriptionID))+ invoicesResponse, _, err := service.lemonsqueezyClient.SubscriptionInvoices.List(ctx, map[string]string{"filter[subscription_id]": *user.SubscriptionID})+ if err != nil {+ msg := fmt.Sprintf("could not get invoices for subscription [%s] for [%T] with with ID [%s]", *user.SubscriptionID, user, user.ID)+ return invoices, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))+ }++ ctxLogger.Info(fmt.Sprintf("fetched [%d] payments for [%T] with ID [%s] and subscription ID [%s]", len(invoicesResponse.Data), user, user.ID, *user.SubscriptionID))+ return invoicesResponse.Data, nil+}++// GenerateReceipt generates a receipt for a subscription payment.+func (service *UserService) GenerateReceipt(ctx context.Context, userID entities.UserID) (reader io.Reader, err error) {+ ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger)+ defer span.End()++ ctxLogger.Info(fmt.Sprintf("generating receipt for user [%s]", userID))+ return nil, nil+}+// Get fetches or creates an entities.Userfunc (service *UserService) Get(ctx context.Context, source string, authUser entities.AuthContext) (*entities.User, error) {ctx, span := service.tracer.Start(ctx)diff --git a/web/models/api.ts b/web/models/api.tsindex 7b2d542f..99f15064 100644--- a/web/models/api.ts+++ b/web/models/api.ts@@ -64,8 +64,6 @@ export interface EntitiesHeartbeat {}export interface EntitiesMessage {- /** @example false */- can_be_polled: boolean/** @example "+18005550100" */contact: string/** @example "This is a sample text message" */@@ -73,19 +71,19 @@ export interface EntitiesMessage {/** @example "2022-06-05T14:26:02.302718+03:00" */created_at: string/** @example "2022-06-05T14:26:09.527976+03:00" */- delivered_at: string+ delivered_at?: string/** @example false */encrypted: boolean/** @example "2022-06-05T14:26:09.527976+03:00" */- expired_at: string+ expired_at?: string/** @example "2022-06-05T14:26:09.527976+03:00" */- failed_at: string+ failed_at?: string/** @example "UNKNOWN" */- failure_reason: string+ failure_reason?: string/** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */id: string/** @example "2022-06-05T14:26:09.527976+03:00" */- last_attempted_at: string+ last_attempted_at?: string/** @example 1 */max_send_attempts: number/** @example "2022-06-05T14:26:09.527976+03:00" */@@ -93,24 +91,24 @@ export interface EntitiesMessage {/** @example "+18005550199" */owner: string/** @example "2022-06-05T14:26:09.527976+03:00" */- received_at: string+ received_at?: string/** @example "153554b5-ae44-44a0-8f4f-7bbac5657ad4" */- request_id: string+ request_id?: string/** @example "2022-06-05T14:26:01.520828+03:00" */request_received_at: string/** @example "2022-06-05T14:26:09.527976+03:00" */- scheduled_at: string+ scheduled_at?: string/** @example "2022-06-05T14:26:09.527976+03:00" */- scheduled_send_time: string+ scheduled_send_time?: string/** @example 0 */send_attempt_count: number/*** SendDuration is the number of nanoseconds from when the request was received until when the mobile phone send the message* @example 133414*/- send_time: number+ send_time?: number/** @example "2022-06-05T14:26:09.527976+03:00" */- sent_at: string+ sent_at?: string/*** SIM is the SIM card to use to send the message* * SMS1: use the SIM card in slot 1@@ -160,7 +158,7 @@ export interface EntitiesPhone {/** @example "2022-06-05T14:26:02.302718+03:00" */created_at: string/** @example "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzd....." */- fcm_token: string+ fcm_token?: string/** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */id: string/**@@ -173,7 +171,7 @@ export interface EntitiesPhone {/** @example 1 */messages_per_minute: number/** @example "This phone cannot receive calls. Please send an SMS instead." */- missed_call_auto_reply: string+ missed_call_auto_reply?: string/** @example "+18005550199" */phone_number: string/** SIM card that received the message */@@ -185,7 +183,7 @@ export interface EntitiesPhone {}export interface EntitiesPhoneAPIKey {- /** @example "pk_DGW8NwQp7mxKaSZ72Xq9v67SLqSbWQvckzzmK8D6rvd7NywSEkdMJtuxKyEkYnCY" */+ /** @example "pk_DGW8NwQp7mxKaSZ72Xq9v6xxxxx" */api_key: string/** @example "2022-06-05T14:26:02.302718+03:00" */created_at: string@@ -193,9 +191,9 @@ export interface EntitiesPhoneAPIKey {id: string/** @example "Business Phone Key" */name: string- /** @example ["[32343a19-da5e-4b1b-a767-3298a73703cb","32343a19-da5e-4b1b-a767-3298a73703cc]"] */+ /** @example ["32343a19-da5e-4b1b-a767-3298a73703cb","32343a19-da5e-4b1b-a767-3298a73703cc"] */phone_ids: string[]- /** @example ["[+18005550199","+18005550100]"] */+ /** @example ["+18005550199","+18005550100"] */phone_numbers: string[]/** @example "2022-06-05T14:26:02.302718+03:00" */updated_at: string@@ -207,7 +205,7 @@ export interface EntitiesPhoneAPIKey {export interface EntitiesUser {/** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */- active_phone_id: string+ active_phone_id?: string/** @example "x-api-key" */api_key: string/** @example "2022-06-05T14:26:02.302718+03:00" */@@ -225,15 +223,13 @@ export interface EntitiesUser {/** @example true */notification_webhook_enabled: boolean/** @example "2022-06-05T14:26:02.302718+03:00" */- subscription_ends_at: string- /** @example "8f9c71b8-b84e-4417-8408-a62274f65a08" */- subscription_id: string+ subscription_ends_at?: string/** @example "free" */subscription_name: string/** @example "2022-06-05T14:26:02.302718+03:00" */- subscription_renews_at: string+ subscription_renews_at?: string/** @example "on_trial" */- subscription_status: string+ subscription_status?: string/** @example "Europe/Helsinki" */timezone: string/** @example "2022-06-05T14:26:10.303278+03:00" */@@ -243,11 +239,11 @@ export interface EntitiesUser {export interface EntitiesWebhook {/** @example "2022-06-05T14:26:02.302718+03:00" */created_at: string- /** @example ["[message.phone.received]"] */+ /** @example ["message.phone.received"] */events: string[]/** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */id: string- /** @example ["[+18005550199","+18005550100]"] */+ /** @example ["+18005550199","+18005550100"] */phone_numbers: string[]/** @example "DGW8NwQp7mxKaSZ72Xq9v67SLqSbWQvckzzmK8D6rvd7NywSEkdMJtuxKyEkYnCY" */signing_key: string@@ -352,10 +348,10 @@ export interface RequestsMessageSend {/** @example "This is a sample text message" */content: string/**- * Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app+ * Encrypted is an optional parameter used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app* @example false*/- encrypted: boolean+ encrypted?: boolean/** @example "+18005550199" */from: string/**@@ -364,8 +360,8 @@ export interface RequestsMessageSend {*/request_id?: string/**- * SendAt is an optional parameter used to schedule a message to be sent at a later time- * @example "2022-06-05T14:26:09.527976+03:00"+ * SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone and you can queue messages for up to 20 days (480 hours) in the future.+ * @example "2025-12-19T16:39:57-08:00"*/send_at?: string/** @example "+18005550100" */@@ -465,7 +461,7 @@ export interface ResponsesBadRequest {export interface ResponsesBillingUsageResponse {data: EntitiesBillingUsage- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -473,7 +469,7 @@ export interface ResponsesBillingUsageResponse {export interface ResponsesBillingUsagesResponse {data: EntitiesBillingUsage[]- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -481,7 +477,7 @@ export interface ResponsesBillingUsagesResponse {export interface ResponsesDiscordResponse {data: EntitiesDiscord- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -489,7 +485,7 @@ export interface ResponsesDiscordResponse {export interface ResponsesDiscordsResponse {data: EntitiesDiscord[]- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -497,7 +493,7 @@ export interface ResponsesDiscordsResponse {export interface ResponsesHeartbeatResponse {data: EntitiesHeartbeat- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -505,7 +501,7 @@ export interface ResponsesHeartbeatResponse {export interface ResponsesHeartbeatsResponse {data: EntitiesHeartbeat[]- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -520,7 +516,7 @@ export interface ResponsesInternalServerError {export interface ResponsesMessageResponse {data: EntitiesMessage- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -528,7 +524,7 @@ export interface ResponsesMessageResponse {export interface ResponsesMessageThreadsResponse {data: EntitiesMessageThread[]- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -536,7 +532,7 @@ export interface ResponsesMessageThreadsResponse {export interface ResponsesMessagesResponse {data: EntitiesMessage[]- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -566,7 +562,7 @@ export interface ResponsesOkString {export interface ResponsesPhoneAPIKeyResponse {data: EntitiesPhoneAPIKey- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -574,7 +570,7 @@ export interface ResponsesPhoneAPIKeyResponse {export interface ResponsesPhoneAPIKeysResponse {data: EntitiesPhoneAPIKey[]- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -582,7 +578,7 @@ export interface ResponsesPhoneAPIKeysResponse {export interface ResponsesPhoneResponse {data: EntitiesPhone- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -590,7 +586,7 @@ export interface ResponsesPhoneResponse {export interface ResponsesPhonesResponse {data: EntitiesPhone[]- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -607,15 +603,23 @@ export interface ResponsesUnauthorized {export interface ResponsesUnprocessableEntity {data: Record<string, string[]>- /** @example "validation errors while sending message" */+ /** @example "validation errors while handling request" */message: string/** @example "error" */status: string}+export interface ResponsesUserInvoicesResponse {+ data: ResponsesSubscriptionInvoicesAPIResponse+ /** @example "Request handled successfully" */+ message: string+ /** @example "success" */+ status: string+}+export interface ResponsesUserResponse {data: EntitiesUser- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -623,7 +627,7 @@ export interface ResponsesUserResponse {export interface ResponsesWebhookResponse {data: EntitiesWebhook- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string@@ -631,8 +635,46 @@ export interface ResponsesWebhookResponse {export interface ResponsesWebhooksResponse {data: EntitiesWebhook[]- /** @example "item created successfully" */+ /** @example "Request handled successfully" */message: string/** @example "success" */status: string}++export interface ResponsesSubscriptionInvoicesAPIResponse {+ data: {+ attributes: {+ billing_reason: string+ card_brand: string+ card_last_four: string+ created_at: string+ currency: string+ currency_rate: string+ discount_total: number+ discount_total_formatted: string+ discount_total_usd: number+ refunded: boolean+ refunded_amount: number+ refunded_amount_formatted: string+ refunded_amount_usd: number+ refunded_at: any+ status: string+ status_formatted: string+ subtotal: number+ subtotal_formatted: string+ subtotal_usd: number+ tax: number+ tax_formatted: string+ tax_inclusive: boolean+ tax_usd: number+ total: number+ total_formatted: string+ total_usd: number+ updated_at: string+ user_email: string+ user_name: string+ }+ id: string+ type: string+ }[]+}diff --git a/web/pages/billing/index.vue b/web/pages/billing/index.vueindex d17b7c9a..74862f7a 100644--- a/web/pages/billing/index.vue+++ b/web/pages/billing/index.vue@@ -288,6 +288,76 @@</v-alert></v-col></v-row>+ <template v-if="$store.getters.getUser?.subscription_id != null">+ <h5 class="text-h4 mb-3 mt-12">Subscription Payments</h5>+ <p class="text--secondary">+ This is a list of your last 10 subscription payments made using+ our payment provider+ <a+ class="text-decoration-none"+ href="https://www.lemonsqueezy.com"+ >Lemon Squeezy</a+ >.+ </p>+ <v-progress-circular+ v-if="invoices == null && loadingSubscriptionInvoices"+ :size="20"+ :width="2"+ color="primary"+ indeterminate+ ></v-progress-circular>+ <v-simple-table v-if="invoices">+ <template #default>+ <thead>+ <tr class="text-uppercase">+ <th class="text-left">Timestamp</th>+ <th class="text-left">Status</th>+ <th v-if="$vuetify.breakpoint.lgAndUp" class="text-left">+ Tax+ </th>+ <th class="text-left">Total</th>+ <th></th>+ </tr>+ </thead>+ <tbody>+ <tr v-for="payment in invoices.data" :key="payment.id">+ <td>+ {{ payment.attributes.created_at | timestamp }}+ </td>+ <td>+ <v-chip+ v-if="payment.attributes.status === 'paid'"+ color="success"+ >+ <v-avatar size="4" left class="green darken-4">+ <v-icon small>{{ mdiCheck }}</v-icon>+ </v-avatar>+ {{ payment.attributes.status_formatted }}+ </v-chip>+ <v-chip v-else color="error">+ <v-avatar size="4" left class="red darken-4">+ <v-icon small>{{ mdiAlert }}</v-icon>+ </v-avatar>+ {{ payment.attributes.status_formatted }}+ </v-chip>+ </td>+ <td v-if="$vuetify.breakpoint.lgAndUp">+ {{ payment.attributes.tax_formatted }}+ </td>+ <td class="font-weight-bold">+ {{ payment.attributes.total_formatted }}+ </td>+ <td class="text-right">+ <v-btn color="primary" small>+ <v-icon left>{{ mdiInvoice }}</v-icon>+ Invoice+ </v-btn>+ </td>+ </tr>+ </tbody>+ </template>+ </v-simple-table>+ </template><h5 class="text-h4 mb-3 mt-12">Usage History</h5><p class="text--secondary">Summary of all the sent and received messages in the past 12@@ -349,6 +419,9 @@ import {mdiDelete,mdiCog,mdiContentSave,+ mdiCheck,+ mdiAlert,+ mdiInvoice,mdiEye,mdiEyeOff,mdiCallReceived,@@ -356,6 +429,10 @@ import {mdiCreditCard,mdiSquareEditOutline,} from '@mdi/js'+import {+ EntitiesPhoneAPIKey,+ ResponsesSubscriptionInvoicesAPIResponse,+} from '~/models/api'type PaymentPlan = {name: string@@ -373,6 +450,9 @@ export default Vue.extend({mdiEyeOff,mdiArrowLeft,mdiAccountCircle,+ mdiCheck,+ mdiAlert,+ mdiInvoice,mdiShieldCheck,mdiDelete,mdiCog,@@ -382,7 +462,9 @@ export default Vue.extend({mdiCreditCard,mdiSquareEditOutline,loading: true,+ loadingSubscriptionInvoices: false,dialog: false,+ invoices: null as ResponsesSubscriptionInvoicesAPIResponse | null,plans: [{name: 'Free',@@ -513,7 +595,22 @@ export default Vue.extend({this.$store.dispatch('loadBillingUsageHistory'),])this.loading = false+ this.loadSubscriptionInvoices()+ },++ loadSubscriptionInvoices() {+ this.loadingSubscriptionInvoices = true+ this.$store+ .dispatch('indexSubscriptionPayments')+ .then((invoices: ResponsesSubscriptionInvoicesAPIResponse) => {+ console.log(invoices)+ this.invoices = invoices+ })+ .finally(() => {+ this.loadingSubscriptionInvoices = false+ })},+updateDetails() {this.loading = truethis.$storediff --git a/web/store/index.ts b/web/store/index.tsindex 92c15c5d..54fc875a 100644--- a/web/store/index.ts+++ b/web/store/index.ts@@ -25,7 +25,9 @@ import {ResponsesOkString,ResponsesPhoneAPIKeyResponse,ResponsesPhoneAPIKeysResponse,+ ResponsesSubscriptionInvoicesAPIResponse,ResponsesUnprocessableEntity,+ ResponsesUserInvoicesResponse,ResponsesUserResponse,ResponsesWebhookResponse,ResponsesWebhooksResponse,@@ -533,6 +535,36 @@ export const actions = {})},+ indexSubscriptionPayments(context: ActionContext<State, State>) {+ return new Promise<ResponsesSubscriptionInvoicesAPIResponse>(+ (resolve, reject) => {+ axios+ .get<ResponsesUserInvoicesResponse>(+ `/v1/users/subscription/payments`,+ {+ params: {+ limit: 100,+ },+ },+ )+ .then((response: AxiosResponse<ResponsesUserInvoicesResponse>) => {+ resolve(response.data.data)+ })+ .catch(async (error: AxiosError) => {+ await Promise.all([+ context.dispatch('addNotification', {+ message:+ (error.response?.data as any)?.message ??+ 'Error while fetching subscription payments.',+ type: 'error',+ }),+ ])+ reject(getErrorMessages(error))+ })+ },+ )+ },+async handleAxiosError(context: ActionContext<State, State>,error: AxiosError<ResponsesUnprocessableEntity>,