Using API requests

All API requests should be made through postUser/postAccount calls regarding to request type

public static <Res extends TLType, Req extends TLCall<Res>> Observable<Res> postAccount(TPContext context, SessionCall<Res, Req> call) 
public static <Res extends TLType, Req extends TLCall<Res> & TLRequest> Observable<Res> postUser(TPContext context, String orgToken, SessionCall<Res, Req> userCall) {

Please note, that currenlty a lot of helper wrappers exists around thouse call, so it useful to made require request throug appropriate warpper function. As example, to get a tist of public organizations:

        // construct request object from library with desired paremeters
        TLGetPublicOrganizations request = new TLGetPublicOrganizations(limit, offset);
        // all request should be made through live session context
        return session
                .postAccount(SessionCall.ensure(request)) // constructs "ensure" request and use wrapper postAcconut
                .subscribeOn(scheduler) // make requests apart from ui thread
                .map(response -> OrganizationFactory.organizationFromTlList(response.getOrganizations()));

Session object is an internal wrapper over base MtProto session, and become live after application lifecycle component callback being fired:

    private fun onFirstComponentStarted(component: Any) {
        TPLog.d(TAG, "[onFirstComponentStarted] cmp: %s", component)
        sessionSubscription?.unsubscribe()
        sessionComponent.session.start()
    }

Last updated