| Did you know ... | Search Documentation: |
| Pack bitrix24 -- README.md |
!GitHub !GitHub !GitHub !SWI-Prolog !Bitrix24 # About
bitrix24 is an infrastructure pack for working with the Bitrix24 REST API
from SWI-Prolog.
The core pack now focuses on:
pack_install(bitrix24).
swipl -g run_tests -t halt prolog/test_bitrix24.plt
The library expects an application-defined provider module that implements:
get_config(Key, Value). load_context(ContextRef, Context). save_context(ContextRef, Context). delete_context(ContextRef). default_context(ContextRef).
Supported context references:
global. member(MemberID).
Runtime context is normalized as a dict with expires_at:
_{
member_id: MemberID,
access_token: AccessToken,
refresh_token: RefreshToken,
expires_at: ExpiresAt,
client_endpoint: ClientEndpoint,
server_endpoint: ServerEndpoint,
application_token: ApplicationToken,
user_id: UserID,
domain: Domain
}
See docs/provider-contract.md for the full contract.
:- use_module(bitrix24_rest).
check_install_status(Provider, ContextRef, Result) :-
bitrix24_rest:api_call(Provider, ContextRef, 'app.info', [], Result).
call_custom_method(Provider, ContextRef, Method, Params, Result) :-
bitrix24_rest:api_call(Provider, ContextRef, Method, Params, Result).
Examples:
bitrix24_rest:api_call(MyProvider, member(portal_a), 'user.current', [], Result).
bitrix24_rest:api_call(MyProvider, member(portal_a), 'crm.lead.list',
[select=['ID', 'TITLE']], Result).
If the provider can resolve a default context, you can use the shorter form:
bitrix24_rest:api_call(MyProvider, 'app.info', [], Result).
Install callbacks can be normalized into ContextRef + Context without binding
the library to a particular storage backend:
:- use_module(bitrix24_install).
normalize_install_payload(Payload, ContextRef, Context) :-
bitrix24_install:payload_context(Payload, ContextRef, Context).
If you want the library to persist normalized contexts through the provider, use:
persist_install_payload(Provider, Payload, ContextPairs) :-
bitrix24_install:save_payload_contexts(Provider, Payload, ContextPairs).
The helper persists only the normalized ContextRef extracted from the payload:
member(MemberID) when `auth[member_id]` is present, otherwise global.
bitrix24_request, bitrix24_auth, bitrix24_rest, and bitrix24_install.