Skip to content

Commit

Permalink
feat: registerForEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
jgravois committed Mar 28, 2019
1 parent 8c902e4 commit f4bd391
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 35 deletions.
2 changes: 1 addition & 1 deletion demos/oauth2-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"@esri/arcgis-rest-auth": "^1.16.0",
"@esri/arcgis-rest-request": "^1.16.0",
"@esri/hub-auth": "^1.8.1"
"@esri/hub-auth": "^1.9.0"
},
"devDependencies": {
"http-server": "0.11.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/domains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@esri/hub-common": "^1.8.0"
},
"devDependencies": {
"@esri/hub-common": "^1.8.1"
"@esri/hub-common": "^1.9.0"
},
"files": [
"dist/**"
Expand Down
38 changes: 23 additions & 15 deletions packages/events/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions packages/events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
"types": "dist/esm/index.d.ts",
"license": "Apache-2.0",
"dependencies": {
"@esri/arcgis-rest-auth": "^1.17.0",
"@esri/arcgis-rest-common-types": "^1.17.0",
"@esri/arcgis-rest-feature-service": "^1.17.0",
"@esri/arcgis-rest-items": "^1.17.0",
"@esri/arcgis-rest-request": "^1.17.0",
"@esri/arcgis-rest-auth": "^1.18.0",
"@esri/arcgis-rest-common-types": "^1.18.0",
"@esri/arcgis-rest-feature-service": "^1.18.0",
"@esri/arcgis-rest-items": "^1.18.0",
"@esri/arcgis-rest-groups": "^1.18.0",
"@esri/arcgis-rest-request": "^1.18.0",
"tslib": "^1.9.3"
},
"files": [
Expand Down
1 change: 1 addition & 0 deletions packages/events/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

export * from "./util";
export * from "./search";
export * from "./register";
57 changes: 57 additions & 0 deletions packages/events/src/register.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* Copyright (c) 2019 Environmental Systems Research Institute, Inc.
* Apache-2.0 */

import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
import { joinGroup, leaveGroup } from "@esri/arcgis-rest-groups";

export interface IEventRegisterRequestOptions extends IUserRequestOptions {
/**
* Identifier for the group associated with the ArcGIS Hub event.
*/
groupId: string;
}
/**
* ```js
* import { registerForEvent } from "@esri/hub-events";
* //
* registerForEvent({
* groupId,
* authentication
* })
* .then(response)
* ```
* Register for an ArcGIS Hub event.
* @param requestOptions - request options that include authentication
* @returns A Promise that will resolve with the response from the service.
*/
export function registerForEvent(
requestOptions: IEventRegisterRequestOptions
): Promise<{ success: boolean; groupId: string }> {
return joinGroup({
id: requestOptions.groupId,
authentication: requestOptions.authentication
});
}

/**
* ```js
* import { unregisterForEvent } from "@esri/hub-events";
* //
* unregisterForEvent({
* groupId,
* authentication
* })
* .then(response)
* ```
* Unregister for an ArcGIS Hub event.
* @param requestOptions - request options that include authentication
* @returns A Promise that will resolve with the response from the service.
*/
export function unregisterForEvent(
requestOptions: IEventRegisterRequestOptions
): Promise<{ success: boolean; groupId: string }> {
return leaveGroup({
id: requestOptions.groupId,
authentication: requestOptions.authentication
});
}
2 changes: 1 addition & 1 deletion packages/events/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { UserSession } from "@esri/arcgis-rest-auth";
* import { getEventServiceUrl } from "@esri/hub-events";
* // org ids can be retrieved via a call to portals/self
* request("http://custom.maps.arcgis.com/sharing/rest/portals/self")
* then(response => {
* .then(response => {
* getEventServiceUrl(response.id)
* .then(url)
* })
Expand Down
6 changes: 3 additions & 3 deletions packages/initiatives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"@esri/hub-sites": "^1.8.0"
},
"devDependencies": {
"@esri/hub-common": "^1.8.1",
"@esri/hub-domains": "^1.8.1",
"@esri/hub-sites": "^1.8.1",
"@esri/hub-common": "^1.9.0",
"@esri/hub-domains": "^1.9.0",
"@esri/hub-sites": "^1.9.0",
"blob": "0.0.4"
},
"files": [
Expand Down
6 changes: 1 addition & 5 deletions packages/initiatives/src/follow.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
request,
getPortalUrl,
IRequestOptions
} from "@esri/arcgis-rest-request";
import { request, IRequestOptions } from "@esri/arcgis-rest-request";
import { UserSession, getUserUrl } from "@esri/arcgis-rest-auth";
import { IUser } from "@esri/arcgis-rest-common-types";

Expand Down
4 changes: 2 additions & 2 deletions packages/sites/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"@esri/hub-domains": "^1.8.0"
},
"devDependencies": {
"@esri/hub-common": "^1.8.1",
"@esri/hub-domains": "^1.8.1"
"@esri/hub-common": "^1.9.0",
"@esri/hub-domains": "^1.9.0"
},
"files": [
"dist/**"
Expand Down
4 changes: 2 additions & 2 deletions packages/solutions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"@esri/hub-domains": "^1.8.0"
},
"devDependencies": {
"@esri/hub-common": "^1.8.1",
"@esri/hub-domains": "^1.8.1"
"@esri/hub-common": "^1.9.0",
"@esri/hub-domains": "^1.9.0"
},
"files": [
"dist/**"
Expand Down

0 comments on commit f4bd391

Please sign in to comment.