Plans API
The Plans API is an integral component of the core
service. As a result, all requests should be directed to: https://api.subsbase.io/core/v2/graphql
.
The core service expects 2 headers, the X-SITE-ID
and Authorization
so the request would be:
POST https://api.subsbase.io/core/v2/graphql
Authorization: Bearer {server token}
X-SITE-ID: {your site id}
Consuming the Plans API requires that a server token is used to authenticate the request. The server token is expected in the Authorization header.
Queries
Plans Query
query GetPlans($siteId: String!, $filter: FilterGQLInputType, $pagination: PaginationGQLInputType, $sorting: [SortingGQLInputType]) {
plans (siteId: $siteId, filter: $filter, pagination: $pagination, sorting: $sorting) {
isSuccess
pagination
data{
id
#All properties are found in the PlanGQLType
}
message
}
}
- Request Variables Sample:
{"siteId":"", "filter":"", "pagination":"", "sorting":""}
- Returns an array of plans.
- You can specify any of the fields detailed in the Plan Type Definition.
- For details about Pagination, Sorting, and Filtering Input Types, please check out PaginationGQLInputType, SortingGQLInputType, FilteringGQLInputType.
Plan Query
query GetPlan($siteId: String!, $planCode: String!) {
plan (siteId: $siteId, planCode: $planCode) {
siteId
planCode
id
name
#All properties are found in the PlanGQLType
}
### variables
{"siteId":"test-site", "planCode":"123"}
- Returns a specific plan.
- You can specify any of the fields detailed in the Plan Type Definition.
Billing Cycles Query
query GetBillingCycles($siteId: String!,$filter: FilterGQLInputType,$pagination: PaginationGQLInputType,$sorting: [SortingGQLInputType]) {
billingCycles (siteId: $siteId,filter: $filter,pagination: $pagination,sorting: $sorting) {
isSuccess
pagination
data{
id
#All properties are found in the BillingCycleGQLType
}
message
}
}
### variables
{"siteId":"", "filter":"", "pagination":"", "sorting":""}
- Returns an array of billing cycles.
- You can specify any of the fields detailed in the Billing Cycle Type Definition.
- For details about Pagination, Sorting, and Filtering Input Types, please check out PaginationGQLInputType, SortingGQLInputType, FilteringGQLInputType.
Plan Mutations/Operations
Create Plan
- To create a plan, you need to use the following Mutation, it is advisable to use
variables
in this case since the input types are more complex than just strings:
mutation CreatePlan($siteId: String!, $plan: PlanGQLInputType!) {
plans(siteId: $siteId) {
create(plan: $plan) {
isSuccess
message
value {
id
#All properties are found in the PlanGQLType
}
}
}
}
### variables
{
"plan": {
"siteId": "test-site",
"name": "test17281q",
"planCode": "test17281q",
"productName": "test",
"billingModel": "PrePaid",
"description": "",
"data": "{}",
"pricingModel": "Fixed",
"fixedPricing": {
"price": 144,
"displayCurrencyConversion": null,
"taxes": null,
"extraFees": null
},
"variablePricing": null,
"perUnitPricing": null,
"setupFee": 12,
"status": "Active",
"displaySettings": "{\"description\":{},\"image\":{}}",
"discountedFrom": null,
"defaultCurrencyCode": "egp",
"displayCurrencyCode": null,
"trialPeriod": {
"duration": 0,
"unit": "Day"
},
"billingType": "Recurring",
"planPausingDurations": [],
"planFutureStarts": [],
"billingCycle": {
"unit": "Month",
"duration": 1,
"termLimit": {
"cycles": 0,
"actionOnEnd": "renew"
},
"earlyInvoiceCreationSettings": {
"duration": 0,
"unit": "Day"
},
"dueInvoiceDueSettings": {
"duration": 3,
"unit": "Day",
"action": "DoNothing"
},
"usageQuery": null
},
"infoFields": [],
"planRules": {
"maxTotalAddonsQuantity": null
},
"addOns": []
},
"siteId": "test-site"
}
- You can specify any of the fields detailed in the Plan Type Definition.
Update Plan
- To update a plan, you need to use the following Mutation:
mutation UpdatePlan($siteId: String!, $planId: String!, $plan: PlanGQLInputType!) {
plan(siteId: $siteId, planId: $planId) {
update(plan: $plan) {
isSuccess
message
value {
id
#All properties are found in the PlanGQLType
}
}
}
}
### variables
{
"plan": {
"siteId": "test-site",
"name": "12121",
"planCode": "12121",
"productName": "hamzaa",
"invoiceName": null,
"imageUrl": null,
"accountingCode": "accounting code",
"billingModel": "PrePaid",
"description": "",
"data": "{\"taxInvoicing\":{\"sku\":\"sssss\",\"item-type\":\"sssss\",\"unit-type\":\"ssss\",\"integrationId\":\"685EFEA0-165F-42DC-ADB9-D325C51C216A\"}}",
"pricingModel": "Fixed",
"fixedPricing": {
"price": 12,
"displayCurrencyConversion": null,
"taxes": [
{
"type": "Percentage",
"name": "1212",
"value": 0.2
}
],
"extraFees": []
},
"variablePricing": null,
"perUnitPricing": null,
"setupFee": 12,
"status": "Active",
"displaySettings": "{\"image\":{},\"description\":{}}",
"discountedFrom": null,
"defaultCurrencyCode": "egp",
"displayCurrencyCode": null,
"trialPeriod": {
"duration": 0,
"unit": "Day",
"requiresCreditCard": false
},
"billingType": "Recurring",
"planPausingDurations": [],
"planFutureStarts": [],
"billingCycle": {
"unit": "Month",
"duration": 1,
"termLimit": {
"cycles": 12,
"actionOnEnd": "Renew"
},
"earlyInvoiceCreationSettings": {
"duration": 0,
"unit": "Day"
},
"dueInvoiceDueSettings": {
"duration": 3,
"unit": "Day",
"action": "DoNothing"
},
"usageQuery": null
},
"infoFields": [
{
"name": "name",
"label": "Full Name",
"type": "Full Name",
"validation": ".*\\s+.+",
"required": true,
"editable": false,
"disabled": false
},
{
"name": "email",
"label": "Email",
"type": "Email",
"validation": "^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$",
"required": true,
"editable": false,
"disabled": false
},
{
"name": "registration",
"label": "Registration Number/National ID",
"type": "Text",
"validation": "",
"required": true,
"editable": false,
"disabled": true
},
{
"name": "tax-number",
"label": "Tax number",
"type": "Text",
"validation": "",
"required": true,
"editable": false,
"disabled": true
},
{
"name": "is-individual",
"label": "Is Person",
"type": "Checkbox",
"validation": "",
"required": false,
"editable": false,
"disabled": true
},
{
"name": "country-iso-code",
"label": "Country ISO code",
"type": "Text",
"validation": "",
"required": true,
"editable": false,
"disabled": true
}
],
"planRules": {
"maxTotalAddonsQuantity": null,
"exactTotalAddonsQuantity": null
},
"addOns": [
{
"id": "37dfd8b5-b534-464e-98db-77542319c8ef",
"name": "sssdsadasdasdasd",
"data": "{\"taxInvoicing\":{\"sku\":\"ssss\",\"item-type\":\"ssss\",\"unit-type\":\"ssss\"}}",
"code": "sssdsadasdasdasd",
"description": null,
"imageUrl": null,
"status": "Active",
"billingModel": "PrePaid",
"billingType": "Recurring",
"displaySettings": "{\"image\":{},\"description\":{}}",
"billingCycle": {
"unit": "Month",
"duration": 1,
"termLimit": {
"cycles": 12,
"actionOnEnd": "Renew"
}
},
"pricingModel": "Fixed",
"fixedPricing": {
"price": 22,
"required": false,
"displayCurrencyConversion": null
},
"variablePricing": null,
"perUnitPricing": null
},
{
"id": "3d703b6b-e499-4c28-95c6-5021c48d5088",
"name": "addon 1",
"data": "{\"taxInvoicing\":{\"sku\":\"sssss\",\"item-type\":\"ssss\",\"unit-type\":\"sssss\"}}",
"code": "addon-1",
"description": null,
"imageUrl": null,
"status": "Active",
"billingModel": "PrePaid",
"billingType": "Recurring",
"displaySettings": "{\"image\":{},\"description\":{}}",
"billingCycle": {
"unit": "Month",
"duration": 1,
"termLimit": {
"cycles": 12,
"actionOnEnd": "Renew"
}
},
"pricingModel": "PerUnit",
"fixedPricing": null,
"variablePricing": null,
"perUnitPricing": {
"pricePerUnit": 150,
"freeQuantity": 0,
"unit": "giga",
"rules": {
"min": 1,
"max": 10,
"step": 1
},
"displayCurrencyConversion": null
}
}
],
"id": "571a6b8f-0730-4146-b2f5-7a5a6b92279d"
},
"planId": "571a6b8f-0730-4146-b2f5-7a5a6b92279d",
"siteId": "test-site"
}
- You can specify any of the fields detailed in the Plan Type Definition.
Copy Plan
- To copy a plan, you need to use the following Mutation:
mutation CopyPlan($siteId: String!, $planId: String!){
plan(siteId: $siteId, planId: $planId){
copy{
isSuccess
message
value{
id
#All properties are found in the PlanGQLType
}
}
}
}
### variables
{
"siteId": "test-site",
"planId": "0110d46e-6e33-4817-839d-d600cba83f6b"
}
- You can specify any of the fields detailed in the Plan Type Definition.
Delete Plan
- To delete a plan, you need to use the following Mutation:
mutation DeletePlan($siteId: String!, $planId: String!){
plan(siteId: $siteId, planId: $planId){
delete{
isSuccess
message
}
}
}
### variables
{
"siteId": "test-site",
"planId": "0110d46e-6e33-4817-839d-d600cba83f6b"
}
- You can specify any of the fields detailed in the Plan Type Definition.