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

Add support for low-level request method #6

Closed
benmvp opened this issue Feb 23, 2018 · 1 comment · Fixed by #8
Closed

Add support for low-level request method #6

benmvp opened this issue Feb 23, 2018 · 1 comment · Fixed by #8
Assignees
Milestone

Comments

@benmvp
Copy link
Contributor

benmvp commented Feb 23, 2018

Add a request(url, fetchOptions) low-level method that can be used to make any API request without having any special method for it. It will need to support the optional token & baseUrl properties that can be passed in when configuring the SDK object.

Something like:

import eventbrite from 'eventbrite';

const sdk = eventbrite({token: 'FOO'});

// create an event
sdk.request('/events/', {
    method: 'POST',
   data: JSON.stringify(eventProperties)
})

Eventually all of the endpoint methods in the SDK will call this low-level request method.

benmvp referenced this issue in benmvp/eventbrite-sdk-javascript Feb 28, 2018
Adds `sdk.request(url, fetchOptions)` that can be used to make any API request without having a convience method for it.

It reads in the `token` & `baseUrl` properties that are passed in while creating the `sdk` object in order to generate the full URL.

Sample usage:

```js
const sdk = require('eventbrite')({token: 'OATH_TOKEN_HERE'});

// See: https://www.eventbrite.com/developer/v3/endpoints/users/#ebapi-get-users-id
sdk.request('/users/me').then(res => {
    // handle response data
});
```

Also:
- Renamed package from `brite-rest` to `eventbrite`
- Updated README to reflect sample usage
- Moved `index.spec.ts` into `__tests__` folder
- Had to disable `camelcase` ESLint rule because Prettier was unquoting non-conforming property names and the `camelcase` rule doesn't have fix functionality for prettier-eslint to fix

NOTE: Per https://www.eventbrite.com/developer/v3/api_overview/authentication/#ebapi-authenticating-requests we should move the token into an authorization header instead of a query parameter, which is preferred. It'd also allow us to remove the `url-lib` dependency.

Fixes #6.
BenAtEventbrite pushed a commit that referenced this issue Mar 1, 2018
Adds `sdk.request(url, fetchOptions)` that can be used to make any API request without having a convience method for it.

It reads in the `token` & `baseUrl` properties that are passed in while creating the `sdk` object in order to generate the full URL.

Sample usage:

```js
const eventbrite = require('eventbrite');

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

// See: https://www.eventbrite.com/developer/v3/endpoints/users/#ebapi-get-users-id
sdk.request('/users/me').then(res => {
    // handle response data
});
```

Also:
- Renamed package from `brite-rest` to `eventbrite`
- Updated README to reflect sample usage
- Moved `index.spec.ts` into `__tests__` folder
- Had to disable `camelcase` ESLint rule because Prettier was unquoting non-conforming property names and the `camelcase` rule doesn't have fix functionality for prettier-eslint to fix
- Added a bunch of `eslint-plugin-typescript` rules

NOTE: Per https://www.eventbrite.com/developer/v3/api_overview/authentication/#ebapi-authenticating-requests we should move the token into an authorization header instead of a query parameter, which is preferred. It'd also allow us to remove the `url-lib` dependency (and the one-off Typescript definition file).

Fixes #6
@BenAtEventbrite BenAtEventbrite added this to the Alpha milestone Apr 5, 2018
@ebtravis
Copy link
Collaborator

🎉 This issue has been resolved in version 1.0.0 🎉

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
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants