Skip to content

Commit

Permalink
Merge pull request #17 from alexanderwe/issue-6
Browse files Browse the repository at this point in the history
Implement a way to download and access the Manifest file
  • Loading branch information
alexanderwe authored Oct 11, 2017
2 parents 26378e6 + a05eee5 commit f665c2a
Show file tree
Hide file tree
Showing 146 changed files with 2,400 additions and 1,685 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ src/index.js
.vscode
.DS_Store
build
*.zip
*.content


# Coverage directory used by tools like istanbul
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_js:
install:
- yarn install
before_script:
- yarn add sqlite3
- yarn build
script:
- yarn test
Expand Down
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# the-traveler
[![npm](https://img.shields.io/npm/v/the-traveler.svg)](https://www.npmjs.com/package/the-traveler)
[![npm](https://img.shields.io/npm/dt/the-traveler.svg)](https://www.npmjs.com/package/the-traveler)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/alexanderwe/the-traveler/blob/master/LICENSE.md)
[![GitHub issues](https://img.shields.io/github/issues/alexanderwe/the-traveler.svg)](https://github.com/alexanderwe/the-traveler/issues)
[![Build Status](https://travis-ci.org/alexanderwe/the-traveler.svg?branch=master)](https://travis-ci.org/alexanderwe/the-traveler)
[![codecov](https://codecov.io/gh/alexanderwe/the-traveler/branch/master/graph/badge.svg)](https://codecov.io/gh/alexanderwe/the-traveler)
[![dependencies Status](https://david-dm.org/alexanderwe/the-traveler/status.svg)](https://david-dm.org/alexanderwe/the-traveler)
[![Known Vulnerabilities](https://snyk.io/test/github/alexanderwe/the-traveler/badge.svg)](https://snyk.io/test/github/alexanderwe/the-traveler/badge.svg)

the-traveler is a small npm package which wraps around the Destiny 2 API. It uses Promises for a modern workflow in your application.

Expand All @@ -17,7 +17,7 @@ Table of Contents
* [Prerequisites](#prerequisites)
* [OAuth](#oauth)
* [Notices](#notices)
* [Typescript Support](#typescript-support)
* [Typescript Support](#typescript-support)
* [Typical Response](#typical-response)
* [Privacy](#privacy)
* [Documentation](#documentation)
Expand All @@ -26,6 +26,7 @@ Table of Contents
* [Get a character for an PSN Account](#get-a-character-for-an-psn-account)
* [Transfer item from vault to character (needs OAuth)](#transfer-item-from-vault-to-character-needs-oauth)
* [Async await approach (pseudo-code)](#async-await-approach-pseudo-code)
* [Manifest](#manifest)
* [Progress](#progress)
* [Built With](#built-with)
* [Versioning](#versioning)
Expand All @@ -35,6 +36,7 @@ Table of Contents




## Getting Started


Expand Down Expand Up @@ -335,6 +337,51 @@ async () => {
}
```

### Manifest

To use the manifest you first have to download it via 'traveler.downloadManifest(manifestUrl, filename)'. **Be aware that you have to install [node-sqlite3](https://github.com/mapbox/node-sqlite3) to use the manifest class**

The `manifestUrl` can be every URL contained in the response of `traveler.getManifest()`

This method will download the specified manifest, unzip it and save it as `filename`. Afterwards you are able to create a new instance of the `Manifest` class. With this it is possible to query the saved file with valid sqlite queries. A good hint for querying is noted in the [Gist](https://gist.github.com/vpzed/efb7b29f5dfda49633d62801ac30566c) from [@vpzed](https://github.com/vpzed). The result is retrieved asynchronously which makes it possible to integrate it with the `async` `await` flow.

_common way_
```
import Traveler from 'the-traveler';
import Manifest from 'the-traveler/build/Manifest'
traveler.getDestinyManifest().then(result => {
traveler.downloadManifest(result.Response.mobileWorldContentPaths.en, './manifest.content').then(filepath => {
const manifest = new Manifest(filepath);
manifest.queryManifest('SELECT name FROM sqlite_master WHERE type="table"').then(queryResult => {
console.log(queryResult);
}).catch(err => {
console.log(err);
});
}).catch(err => {
console.log(err);
})
})
```


_async way_
```
import Traveler from 'the-traveler';
import Manifest from 'the-traveler/build/Manifest'
async ()=> {
const result = await traveler.getDestinyManifest();
const filepath = await traveler.downloadManifest(result.Response.mobileWorldContentPaths.en, './manifest.content');
const manifest = new Manifest(filepath);
const queryResult = await manifest.queryManifest('SELECT name FROM sqlite_master WHERE type="table"')
}
```


## Progress

Please visit the [official documentation for the API](https://bungie-net.github.io/multi/operation_get_Destiny2-GetDestinyManifest.html#operation_get_Destiny2-GetDestinyManifest) to check if the endpoints are working or if they are still in preview. If you find endpoints in preview, please keep in mind that errors can occur quite often. If the endpoints get finalized also this package will adopt changes and test the functionalities.
Expand Down Expand Up @@ -374,6 +421,8 @@ Please visit the [official documentation for the API](https://bungie-net.github.

* [request-promise-native](https://github.com/request/request-promise-native) - Request package
* [Typescript](https://github.com/Microsoft/TypeScript) - Programming Language
* [node-stream-zip](https://github.com/antelle/node-stream-zip) - Unzipping files in node (for Manifest interaction)
* [node-sqlite3](https://github.com/mapbox/node-sqlite3) - Use sqlite 3 in node (for Manifest interaction as a peer dependency)

## Versioning

Expand Down
2 changes: 1 addition & 1 deletion docs/assets/js/search.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/classes/httpservice.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/alexanderwe/the-traveler/blob/354c7c2/src/HttpService.ts#L8">HttpService.ts:8</a></li>
<li>Defined in <a href="https://github.com/alexanderwe/the-traveler/blob/c1e668b/src/HttpService.ts#L9">HttpService.ts:9</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -141,7 +141,7 @@ <h3><span class="tsd-flag ts-flagPrivate">Private</span> <span class="tsd-flag t
<div class="tsd-signature tsd-kind-icon">debug<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/alexanderwe/the-traveler/blob/354c7c2/src/HttpService.ts#L8">HttpService.ts:8</a></li>
<li>Defined in <a href="https://github.com/alexanderwe/the-traveler/blob/c1e668b/src/HttpService.ts#L9">HttpService.ts:9</a></li>
</ul>
</aside>
</section>
Expand All @@ -158,7 +158,7 @@ <h3>get</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/alexanderwe/the-traveler/blob/354c7c2/src/HttpService.ts#L20">HttpService.ts:20</a></li>
<li>Defined in <a href="https://github.com/alexanderwe/the-traveler/blob/c1e668b/src/HttpService.ts#L24">HttpService.ts:24</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -194,7 +194,7 @@ <h3>post</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/alexanderwe/the-traveler/blob/354c7c2/src/HttpService.ts#L50">HttpService.ts:50</a></li>
<li>Defined in <a href="https://github.com/alexanderwe/the-traveler/blob/c1e668b/src/HttpService.ts#L52">HttpService.ts:52</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down
Loading

0 comments on commit f665c2a

Please sign in to comment.