Skip to content

Commit

Permalink
Merge pull request #46 from gunjandatta/gdatta
Browse files Browse the repository at this point in the history
Updated the other libraries to no longer need to instantiate the object.
  • Loading branch information
gunjandatta authored Sep 8, 2017
2 parents c9d1dda + 81a6bca commit 15c4bf0
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 21 deletions.
44 changes: 41 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,21 @@ An easy way to develop against the SharePoint 2013/Online REST API.
```
npm install gd-sprest --save
```
### NodeJS
#### JavaScript
```
var $REST = require("gd-sprest");
// Get the current web and lists
$REST.Web().query({
Expand: ["Lists"]
}).execute(function(web) {
// Parse the lists
for(var i=0; i<web.Lists.results.length; i++) {
var list = web.Lists.results[i];
}
});
```
#### NodeJS
```
const $REST = require("gd-sprest);
Expand All @@ -65,7 +79,30 @@ console.log(request.getInfo());
// url: 'https://dev.sharepoint.com'
// }
```
### React
#### TypeScript
```
import { List }
// Get the "Site Assets" library, fields and views
(new List("Site Assets"))
// Query the list
.query({
Expand: ["Fields", "Views"]
})
// Execute the request
.execute((list) => {
// Parse the fields
for(let i=0; i<list.Fields.results.length; i++) {
let field = list.Fields.results[i];
}
// Parse the views
for(let i=0; i<list.Views.results.length; i++) {
let field = list.Views.results[i];
}
});
```
#### React
```
import {
ContextInfo,
Expand All @@ -86,7 +123,8 @@ import {
Web
} from "gd-sprest";
```
### Manual

### In Browser Requests
1. Download the gd-sprest.min.js script from the "dist" folder
2. Upload the script file to a SharePoint document library
3. Reference the script in any page
Expand Down
10 changes: 5 additions & 5 deletions build/gd-sprest.js

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

2 changes: 1 addition & 1 deletion build/gd-sprest.js.map

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

18 changes: 13 additions & 5 deletions dist/gd-sprest.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ exports.Web = lib_1.Web;
* SharePoint REST Library
*/
var gd_sprest = {
__ver: 1.95,
__ver: 1.96,
ContextInfo: lib_1.ContextInfo,
DefaultRequestToHostFl: false,
Email: lib_1.Email,
Expand All @@ -255,10 +255,18 @@ var gd_sprest = {
List: function List(listName, targetInfo) {
return new lib_1.List(listName, targetInfo);
},
PeopleManager: lib_1.PeopleManager,
PeoplePicker: lib_1.PeoplePicker,
ProfileLoader: lib_1.ProfileLoader,
Search: lib_1.Search,
PeopleManager: function PeopleManager(targetInfo) {
return new lib_1.PeopleManager(targetInfo);
},
PeoplePicker: function PeoplePicker(targetInfo) {
return new lib_1.PeoplePicker(targetInfo);
},
ProfileLoader: function ProfileLoader(targetInfo) {
return new lib_1.ProfileLoader(targetInfo);
},
Search: function Search(url, targetInfo) {
return new lib_1.Search(url, targetInfo);
},
Site: function Site(url, targetInfo) {
return new lib_1.Site(url, targetInfo);
},
Expand Down
2 changes: 1 addition & 1 deletion dist/gd-sprest.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gd-sprest",
"version": "1.9.5",
"version": "1.9.6",
"description": "An easy way to develop against the SharePoint REST API.",
"author": "Gunjan Datta <[email protected]> (https://gunjandatta.github.io/sprest)",
"license": "MIT",
Expand Down
10 changes: 5 additions & 5 deletions src/gd-sprest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ export {
* SharePoint REST Library
*/
const gd_sprest = {
__ver: 1.95,
__ver: 1.96,
ContextInfo,
DefaultRequestToHostFl: false,
Email,
Helper,
JSLink,
List: (listName: string, targetInfo?: Types.ITargetInfo) => { return new List(listName, targetInfo); },
PeopleManager,
PeoplePicker,
ProfileLoader,
Search,
PeopleManager: (targetInfo?: Types.ITargetInfo) => { return new PeopleManager(targetInfo); },
PeoplePicker: (targetInfo?: Types.ITargetInfo) => { return new PeoplePicker(targetInfo); },
ProfileLoader: (targetInfo?: Types.ITargetInfo) => { return new ProfileLoader(targetInfo); },
Search: (url?: string, targetInfo?: Types.ITargetInfo) => { return new Search(url, targetInfo); },
Site: (url?: string, targetInfo?: Types.ITargetInfo) => { return new Site(url, targetInfo); },
SocialFeed,
UserProfile,
Expand Down

0 comments on commit 15c4bf0

Please sign in to comment.