Comments (8)
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.
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.
@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.
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.
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.
This still seems like a good feature to have to me, it's something I'd find very useful.
from intercom-java.
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.
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)
- Please add possibility to update OWNER_ID field in contact and user HOT 1
- NotFoundException user not found when creating a user HOT 1
- Document what version of the Intercom API this SDK supports HOT 3
- Unable to fetch Admin objects using list(Map<String, String> params) method HOT 2
- Why doesn't conversation object contain a statistics object?
- Multiple CVE's exists on the jackson version used by the intercom library. HOT 2
- Missing "external_id" in the `Contact` model HOT 3
- Restore Company.delete method HOT 2
- Bintray deprecation - move artifacts elsewhere HOT 2
- InvalidDefinitionException: Joda date/time type `org.joda.time.DateTime` not supported by default HOT 1
- Finding Contacts or Users Returns Deserialization Error HOT 4
- Support for version 2.3
- Contact.update() doesn't work HOT 2
- joda_zoneinfomap FATAL EXCEPTION HOT 1
- List for tags and contacts returns empty response (no data)
- Monthly spend value doesn't update when the value is set to zero
- Is this library dead? HOT 3
- Tagging API seems odd, or maybe needs more documentation HOT 2
- conversationId not returned from Conversation.Create
- Intercom-java SDK is not compatible with recent versions of Jackson HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intercom-java.