This documentation describes API handlers provided by this module for others to use. It expects your application is based on the CRM skeleton provided by us.
We recommend using Composer for installation and update management.
composer require remp/crm-subscriptions-module
Add installed extension to your app/config/config.neon
file.
extensions:
- Crm\SubscriptionsModule\DI\SubscriptionsModuleExtension
Widgets are small reusable components that can be used on different places within CRM. Module can provide widget placeholders for other modules to populate or widget implementations.
Widget displays list of all subscribers with specified content access that don't have specified address type entered in the system. It is placed at the admin.payments.top
placeholder, above the payments listing.
By default the widget displays all print
subscribers without print
address type entered. You can change the configuration in your config.local.neon
and check different content access names against different address types:
subscribersWithMissingAddressWidget:
setup:
- setContentAccessNames(print, print_friday)
- setAddressTypes(print, print_other)
These are widget placeholders provided by Payments Module. You can register your own widgets to be displayed at following places:
admin.payments.top
payments.banktransfer.right
payments.admin.payment_source_listing
payments.admin.payment_item_listing
payments.frontend.payments_my.top
payments.arpu.bottom
All examples use http://crm.press
as a base domain. Please change the host to the one you use
before executing the examples.
All examples use XXX
as a default value for authorization token, please replace it with the
real tokens:
- API tokens. Standard API keys for server-server communication. It identifies the calling application as a whole.
They can be generated in CRM Admin (
/api/api-tokens-admin/
) and each API key has to be whitelisted to access specific API endpoints. By default the API key has access to no endpoint. - User tokens. Generated for each user during the login process, token identify single user when communicating between
different parts of the system. The token can be read:
- From
n_token
cookie if the user was logged in via CRM. - From the response of
/api/v1/users/login
endpoint - you're free to store the response into your own cookie/local storage/session.
- From
API responses can contain following HTTP codes:
Value | Description |
---|---|
200 OK | Successful response, default value |
400 Bad Request | Invalid request (missing required parameters) |
403 Forbidden | The authorization failed (provided token was not valid) |
404 Not found | Referenced resource wasn't found |
If possible, the response includes application/json
encoded payload with message explaining
the error further.
Returns all user subscriptions with information when they start/end and which content type they give an access to.
Name | Value | Required | Description |
---|---|---|---|
Authorization | Bearer String | yes | User token. |
Name | Value | Required | Description |
---|---|---|---|
show_finished | Boolean | no | Flag indicating whether to include finished subscriptions or not. If not provided, only active and future subscriptions are returned. |
curl -X POST \
http://crm.press/api/v1/users/subscriptions \
-H 'Authorization: Bearer XXX' \
-H 'Content-Type: application/x-www-form-urlencoded'
Response:
{
"status": "ok",
"subscriptions": [ // Array; list of subscriptions
{
"start_at": "2019-01-15T00:00:00+01:00", // String; RFC3339 encoded start time
"end_at": "2020-01-15T00:00:00+01:00", // String; RFC3339 encoded end time
"code": "web_year", // String; subscription code (slug)
"access": [ // Array: list of all types of content subscription includes
"web" // String; name of the content type
]
},
{
"start_at": "2019-03-05T00:00:00+01:00",
"end_at": "2019-03-19T00:00:00+01:00",
"code": "mobile-welcome-action",
"access": [
"web",
"mobile"
]
}
]
}
Creates new subscription for given user and returns new instance.
Name | Value | Required | Description |
---|---|---|---|
Authorization | Bearer String | yes | Bearer token. |
Name | Value | Required | Description |
---|---|---|---|
String | yes | Email of existing user. | |
subscription_type_id | String | yes | ID of subscription type to use. List of all subscription types is available at /subscriptions/subscription-types-admin . |
start_time | String | no | RFC3339 formatted start time. If not present, subscription will start immediately. |
type | String | yes | Type of subscription - values allowed: regular , free , donation , gift , special , upgrade , prepaid . If not provided, defaults to regular . |
curl -X POST \
http://crm.press/api/v1/subscriptions/create \
-H 'Authorization: Bearer XXX' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'email=user%40user.sk&subscription_type_id=73'
Response:
{
"status": "ok",
"message": "Subscription created",
"subscriptions": {
"id": 628893, // string; ID of new subscription
"start_time": "2019-03-08T13:35:05+01:00", // String; RFC3339 formatted start time of subscription
"end_time": "2019-05-09T13:35:05+02:00" // String; RFC3339 formatted end time of subscription
}
}
ActualSubscribersRegistrationSourceStatsWidget
Admin dashboard stats graph widget.
ActualSubscribersStatWidget
Admin dashboard stats widget.
ActualSubscriptionLabel
Admin user listing component.
ActualSubscriptionsStatWidget
Admin dashboard actual subscriptions count widget.
ActualUserSubscriptions
Admin user detail stats widget.
EndingSubscriptionsWidget
Admin ending subscriptions listing widget.
MonthSubscriptionsSmallBarGraphWidget
Admin users header graph widget.
MonthSubscriptionStatWidget
Admin dashboard single stat widget.
MonthToDateSubscriptionStatWidget
Admin dashboard single stat widget.
PrintSubscribersWithoutPrintAddressWidget
Admin payments listing header widget.
RenewedSubscriptionsEndingWithinPeriodWidget
Admin dashboard stats widget.
SubscriptionButton
Admin listing edit subscription button widget.
SubscriptionEndsStats
Admin ending subscriptions types and content access listing component.
SubscriptionsEndingWithinPeriodWidget
Admin dashboard ending subscriptions stats widget.
TodaySubscriptionsStatWidget
Admin dashboard single stat widget.
TotalSubscriptionsStatWidget
Admin dashboard single stat widget.
UserSubscriptions
Admin user detail subscriptions listing widget.