Skip to content

Commit

Permalink
Rename EnturService to EnturClient and related parts
Browse files Browse the repository at this point in the history
The SDK is a _client library_, used to consume Entur's services.
It is not a service itself. Therefore it is weird to call it a
service. "Client" is a more commonly used word for this.

Examples of other SDKs using the client term:
* Auth0 (https://github.com/auth0/node-auth0)
* AWS (https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-started-nodejs.html)
  • Loading branch information
draperunner committed Jul 23, 2021
1 parent cd577c9 commit c88078a
Show file tree
Hide file tree
Showing 28 changed files with 136 additions and 123 deletions.
10 changes: 6 additions & 4 deletions docs/advanced/queryJourneyPlanner.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ An object containing a subset of `RequestInit` options that's applied to the req
The example below finds lines that stops at the given stop places. Also check this out at [Shamash](https://api.staging.entur.io/journey-planner/v2/ide/?query=%7B%0A%20%20%0A%7D&variables=%7B%0A%20%20%22ids%22%3A%20%5B%22NSR%3AStopPlace%3A4089%22%2C%20%22NSR%3AStopPlace%3A1337%22%5D%0A%7D).

```typescript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

Expand All @@ -61,5 +61,7 @@ const variables = {
ids: ['NSR:StopPlace:4089', 'NSR:StopPlace:1337'],
}

service.queryJourneyPlanner(query, variables).then((res) => console.log(res)) // Print out lines servicing these stop places
enturClient
.queryJourneyPlanner(query, variables)
.then((res) => console.log(res)) // Print out lines servicing these stop places
```
8 changes: 4 additions & 4 deletions docs/bikes/getBikeRentalStation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const bikeRentalStation = await service.getBikeRentalStation(
const bikeRentalStation = await enturClient.getBikeRentalStation(
'YBE:VehicleSharingParkingArea:368',
)
console.log(bikeRentalStation)
Expand Down
8 changes: 4 additions & 4 deletions docs/bikes/getBikeRentalStations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const bikeRentalStations = await service.getBikeRentalStations([
const bikeRentalStations = await enturClient.getBikeRentalStations([
'YBE:VehicleSharingParkingArea:368',
'YBE:VehicleSharingParkingArea:83',
])
Expand Down
8 changes: 4 additions & 4 deletions docs/bikes/getBikeRentalStationsByPosition.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const bikeRentalStations =
await service.getBikeRentalStationsByPosition(
await enturClient.getBikeRentalStationsByPosition(
{
latitude: 59.95,
longitude: 10.75,
Expand Down
2 changes: 1 addition & 1 deletion docs/geocoder/getFeatures.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The search string that should resemble the name of the desired stop place or add
A set of coordinates to use when the weighting search results. Examples: `{ latitude: 59.909774, longitude: 10.763712 }`.

The results closest to the coordinates will be weighted above results with equally good string matches.
As an example, the street `Dronningens gate` exists both in Oslo and Trondheim. If you call `service.getFeatures('Dronningens gate', { latitude: 63.4305103, longitude: 10.3949874 })` (coordinates of Trondheim city center), the Dronningens gate in Trondheim will be preferred to the one in Oslo.
As an example, the street `Dronningens gate` exists both in Oslo and Trondheim. If you call `enturClient.getFeatures('Dronningens gate', { latitude: 63.4305103, longitude: 10.3949874 })` (coordinates of Trondheim city center), the Dronningens gate in Trondheim will be preferred to the one in Oslo.

### params (`GetFeaturesQuery`) [Optional]

Expand Down
16 changes: 9 additions & 7 deletions docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@ npm install @entur/sdk --save

## Setup

Import the service creator:
Import the client creator:

```javascript
import createEnturService from '@entur/sdk'
import createEnturClient from '@entur/sdk'
```

Or if you are using CommonJS:

```javascript
const createEnturService = require('@entur/sdk').default
const createEnturClient = require('@entur/sdk').default
```

Then create an instance of the service:
Then create an instance of the client:

```javascript
const service = createEnturService({ clientName: 'awesomecompany-awesomeapp' })
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})
```

### Configuration
Expand All @@ -44,7 +46,7 @@ followed by a hyphen and your application's name. See https://developer.entur.or

#### hosts

The Entur SDK uses multiple endpoints for its services. Each endpoint can be overridden with hosts config (in case you use a proxy or a local instance of the endpoint). Available hosts are:
The Entur SDK uses multiple endpoints for its clients. Each endpoint can be overridden with hosts config (in case you use a proxy or a local instance of the endpoint). Available hosts are:

```javascript
{
Expand All @@ -63,7 +65,7 @@ If you need to configure the fetch implementation that is used, use this. You co
- Do some common logging on all SDK requests

```
const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
fetch: (url, init) => {
const startTime = new Date()
Expand Down
8 changes: 4 additions & 4 deletions docs/mobility/getOperators.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const operators = await service.mobility.getOperators()
const operators = await enturClient.mobility.getOperators()
console.log(operators)
} catch (error) {
console.error(error)
Expand Down
8 changes: 4 additions & 4 deletions docs/mobility/getStations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const stations = await service.mobility.getStations({
const stations = await enturClient.mobility.getStations({
lat: 59.95,
lon: 10.75,
range: 200,
Expand Down
8 changes: 4 additions & 4 deletions docs/mobility/getVehicles.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const vehicles = await service.mobility.getVehicles({
const vehicles = await enturClient.mobility.getVehicles({
lat: 59.95,
lon: 10.75,
range: 200,
Expand Down
8 changes: 4 additions & 4 deletions docs/nsr/getFareZone.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const fareZone = await service.nsr.getFareZone('MOR:FareZone:411')
const fareZone = await enturClient.nsr.getFareZone('MOR:FareZone:411')
console.log(fareZone)
} catch (error) {
console.error(error)
Expand Down
8 changes: 4 additions & 4 deletions docs/nsr/getGroupOfStopPlaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const groupOfStopPlaces = await service.nsr.getGroupOfStopPlaces(
const groupOfStopPlaces = await enturClient.nsr.getGroupOfStopPlaces(
'NSR:GroupOfStopPlaces:1',
)
console.log(groupOfStopPlaces)
Expand Down
8 changes: 4 additions & 4 deletions docs/nsr/getParking.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const parking = await service.nsr.getParking('NSR:Parking:41')
const parking = await enturClient.nsr.getParking('NSR:Parking:41')
console.log(parking)
} catch (error) {
console.error(error)
Expand Down
8 changes: 4 additions & 4 deletions docs/nsr/getParkingsForStopPlace.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const parkings = await service.nsr.getParkingsForStopPlace(
const parkings = await enturClient.nsr.getParkingsForStopPlace(
'NSR:StopPlace:337',
)
console.log(parkings)
Expand Down
8 changes: 4 additions & 4 deletions docs/nsr/getQuay.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const quay = await service.nsr.getQuay('NSR:Quay:1')
const quay = await enturClient.nsr.getQuay('NSR:Quay:1')
console.log(quay)
} catch (error) {
console.error(error)
Expand Down
10 changes: 6 additions & 4 deletions docs/nsr/getStopPlace.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const stopPlace = await service.nsr.getStopPlace('NSR:StopPlace:337')
const stopPlace = await enturClient.nsr.getStopPlace(
'NSR:StopPlace:337',
)
console.log(stopPlace)
} catch (error) {
console.error(error)
Expand Down
10 changes: 6 additions & 4 deletions docs/nsr/getStopPlaceForQuay.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const stopPlace = await service.nsr.getStopPlaceForQuay('NSR:Quay:1')
const stopPlace = await enturClient.nsr.getStopPlaceForQuay(
'NSR:Quay:1',
)
console.log(stopPlace)
} catch (error) {
console.error(error)
Expand Down
8 changes: 4 additions & 4 deletions docs/nsr/getTariffZone.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const tariffZone = await service.nsr.getTariffZone(
const tariffZone = await enturClient.nsr.getTariffZone(
'NOR:TariffZone:4020',
)
console.log(tariffZone)
Expand Down
8 changes: 4 additions & 4 deletions docs/nsr/getTopographicPlace.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ An object containing a subset of `RequestInit` options that's applied to the req
## Example

```javascript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default
import createEnturClient from '@entur/sdk'
// or: const createEnturClient = require('@entur/sdk').default

const service = createEnturService({
const enturClient = createEnturClient({
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const topographicPlace = await service.nsr.getTopographicPlace(
const topographicPlace = await enturClient.nsr.getTopographicPlace(
'KVE:TopographicPlace:5402',
)
console.log(topographicPlace)
Expand Down
Loading

0 comments on commit c88078a

Please sign in to comment.