Coder Social home page Coder Social logo

Comments (8)

martina-if avatar martina-if commented on August 11, 2024 1

Also, using static methods is generally bad practice. It makes things like this ^ and testing very hard.

From an API point of view it would be easier to use if you could create instances, here is an idea:

IntercomSession intercom = new IntercomSession(apiKey, apiId,...);
UserResource user = intercom.userResource();
user.list()
user.create(new User());

With this approach consumers of your library could:

  • Pick which intercom app to talk to
  • Mock the connection to intercom making testing easier

from intercom-java.

esiqveland avatar esiqveland commented on August 11, 2024 1

The current very static-based api makes it nearly impossible to use this SDK with multiple app-ids, requiring a separate java application for each api key.
This makes it very awkward to use, so please consider giving a builder-based api.

Something like:

Intercom app1 = Intercom.create()
        .withToken(API_TOKEN_APP1)
        .withAppId(appid1)
        //... whatever more
        .build()

Intercom app2 = Intercom.create()
        .withToken(API_TOKEN_APP2)
        .withAppId(appid2)
        //... whatever more
        .build()

or maybe require the non-optional settings directly as paramters to the create or build method.

from intercom-java.

dehora avatar dehora commented on August 11, 2024

@prismec thanks for raising this. This looks like a good idea at first glance; will want to think through the API signatures a bit - guessing based on the example, your preference is to supply an app context object?

from intercom-java.

prismec avatar prismec commented on August 11, 2024

The example uses the session (IntercomSession) as a factory for further resource accessors (e.g. UserResource). This is a common pattern found in many APIs. From a testing point of view it would be good if the factory, as well as all resources are encapsulated using interfaces, so that it’s much easier to mock it for testing purposes.


Smarter Ecommerce GmbH

Spittelwiese 15
4020 Linz

T +43 732 997002-100
[email protected]
http://www.smarter-ecommerce.com http://www.smarter-ecommerce.com/

UID: ATU 63760825

smec – we automate ecommerce success

On 21 Dec 2015, at 12:22 , Bill de hΓ“ra [email protected] wrote:

@prismec https://github.com/prismec thanks for raising this. This looks like a good idea at first glance; will want to think through the API signatures a bit - guessing based on the example, your preference to supply an app context object?

β€”
Reply to this email directly or view it on GitHub #89 (comment).

from intercom-java.

choran avatar choran commented on August 11, 2024

Hi @prismec,
We were just reviewing some older issue and wanted to check in on this one.
Unfortunately we have not been able to make any specific changes with regard to this issue.
So as far as I can see I think this is still a valid issue to remain open.
I just wanted to check in with you to see if you had any other thoughts on it in the meantime or were there any changes that might have been related to this issue?
Like I said, it sounds like it is still valid to leave open as an issue but wanted to confirm with you.

Thanks
Cathal

from intercom-java.

danielcompton avatar danielcompton commented on August 11, 2024

This still seems like a good feature to have to me, it's something I'd find very useful.

from intercom-java.

xgp avatar xgp commented on August 11, 2024

I also had the problem of using this lib for multiple appIDs and tokens (on behalf of OAuth'd customers). I made a version of the library which eliminates the static config, and passes the config object to every service method that requires it.

My fork is here: https://github.com/xgp/intercom-java

You can use it like this example:

Intercom intercom = new Intercom();
intercom.setAppID("put_app_id_here");
intercom.setToken("put_token_here");

AdminCollection admins = Admin.list(intercom);
while(admins.hasNext()) {
    Admin admin = admins.next();
    System.err.println("Admin: "+admin.toString());
}

Note, this is not a drop-in replacement for the official library from Intercom, as all of the service methods require the Intercom config object.

from intercom-java.

thewheat avatar thewheat commented on August 11, 2024

Thanks so much for sharing @xgp πŸ‘ Definitely a good starting point but as you mentioned it isn't a drop-in replacement due to a breaking change in the code

I've tagged this issue as "help wanted" as I don't think I'd have the resources to look into this right now but definitely open to ideas and PRs to see how we can get this moving forward πŸ‘

from intercom-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.