New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What do people think of the proposed API? #1

Open
jdormit opened this Issue Jan 15, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@jdormit
Copy link
Contributor

jdormit commented Jan 15, 2019

The public API is proposed in the "Usage" section of the README. I'd like to start a discussion about what the final API should look like before I get too far into implementing it. Please comment below!

@judahnator

This comment has been minimized.

Copy link

judahnator commented Jan 15, 2019

At a glance, I am not a huge fan of passing arrays of options into functions. I would rather a stronger typed system with concrete options to pass, either as paramaters or a dedicated object.

Instead of this:

    $actorArray = array(
        'id' => 'https://mysite.com/my_actor',
        'type' => 'Person',
        'preferredUsername' => 'myActor',
    );
    $actor = $activitypub->createActor( $actorArray );

I would rather see this (pseudocode):

    $actor = $activitypub->createActor(string $id, string $type, string $preferredUsername);

Or if the number of options are many and individual options would be a pain, perhaps setters and accessors might be a good way to go.

    $actor = $activitypub->createActor()
        ->setId($id)
        ->setType($type)
        ->setPreferredUsername($preferredUsername);
@jdormit

This comment has been minimized.

Copy link
Contributor Author

jdormit commented Jan 15, 2019

I hear that. It would be a lot of work to create a full type system for ActivityStreams objects (see https://www.w3.org/TR/activitystreams-vocabulary/), so it might make sense to pass around arrays at first so I can something useful shipped and then build in a strong type system afterwards. I really like the idea of fluent API/builder pattern type thing.https://github.com/landrok/ActivityPub seems to implement a full type system but none of the protocol yet, so there could be a fruitful collaboration there in the future.

@jdormit

This comment has been minimized.

Copy link
Contributor Author

jdormit commented Jan 23, 2019

@judahnator Circling back here, although I think a builder API for ActivityPub objects is still a post-release project, I did change the ActivityPub class constructor to take a type-safe config class rather than an array:

https://github.com/pterotype-project/activitypub-php/blob/master/src/Config/ActivityPubConfigBuilder.php

I think the API for AP objects will be similar, except that the build() methods for those objects will return arrays to maintain compatibility with the existing API and with potential other libraries.

@squeevee

This comment has been minimized.

Copy link

squeevee commented Jan 28, 2019

I like the API. It suits my application very well

@squeevee squeevee referenced this issue Jan 28, 2019

Open

Webfinger #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment