Skip to content
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

Support full API url in request() #47

Closed
deremer opened this issue Nov 13, 2018 · 4 comments · Fixed by #48
Closed

Support full API url in request() #47

deremer opened this issue Nov 13, 2018 · 4 comments · Fixed by #48
Labels

Comments

@deremer
Copy link

deremer commented Nov 13, 2018

At the moment I don't have time to do a PR, but I wanted to share this as it easy enough that your internal team may be able to implement it quickly.

Current Behavior

The webhooks generated by Eventbrite provide an api_url which is a full URL. In order to use this with this SDK, we need to extract that path after /v3. This is potentially brittle.

Expected Behavior

.request() should also support valid full API URLs. Or alternatively, perhaps the webhooks could return something like api_endpoint

Possible Solution

If the url matches the regex ^https://www.eventbriteapi.com/v3/ use the url provided.

I.e., Somewhere around here do:

  let url:string;
  if (urlRegex.test(endpoint)) { 
    url = endpoint;
  } else {
    url = `${baseUrl}${endpoint}`;
  }

where urlRegex is the valid API url regex to match.

@benmvp
Copy link
Contributor

benmvp commented Nov 14, 2018

Hi @deremer thanks for the suggestion!

Technically the SDK does support passing a full API url to request. You can do so by specifying empty string ('') as the baseUrl:

const eventbrite = require('eventbrite');

// Create configured Eventbrite SDK
const sdk = eventbrite({
    token: 'OATH_TOKEN_HERE',
    baseUrl: '',
});

const fullUrl = 'https://www.eventbriteapi.com/v3/users/me';

sdk.request(fullUrl).then(res => {
    // handle response data
});

Would that work for you?

@deremer
Copy link
Author

deremer commented Nov 14, 2018

@benmvp Oh great! Yes, that works. 💯 Might I suggest adding that to the README? It's specifically useful to teams also using the webhooks. Thank you for the response.

benmvp referenced this issue in benmvp/eventbrite-sdk-javascript Nov 14, 2018
It was requested in #47 to add support to `.request()` for full URLs because [webooks](https://www.eventbrite.com/developer/v3/api_overview/webhooks/) returns full API urls. However instead of updating `.request()` a client can just set the `baseUrl` to empty string (`''`) when configuring the SDK object.

This adds docs and an example for future users.

Closes #47.
@benmvp
Copy link
Contributor

benmvp commented Nov 14, 2018

Glad to help.

That's also a great idea! Done!

BenAtEventbrite pushed a commit that referenced this issue Nov 15, 2018
It was requested in #47 to add support to `.request()` for full URLs because [webooks](https://www.eventbrite.com/developer/v3/api_overview/webhooks/) returns full API urls. However instead of updating `.request()` a client can just set the `baseUrl` to empty string (`''`) when configuring the SDK object.

This adds docs and an example for future users.

Closes #47.
@ebtravis
Copy link
Collaborator

🎉 This issue has been resolved in version 1.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants