Skip to content

Commit 71f5b0a

Browse files
committed
separate fetch config from script. Updated Readme.
1 parent 01dbd30 commit 71f5b0a

4 files changed

Lines changed: 24 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ build
99
.externalNativeBuild
1010
.idea
1111
.iml
12+
mirror/api

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ class App : Application() {
5555
}
5656
```
5757

58-
And then you can make requests from Coroutine Scopes to get data for each resource. All the domain models are also `Parcelable` so you can safely pass them as arguments.
58+
And then you can make requests from Coroutine Scopes to get data for each resource.
59+
60+
You can also pass in your own `OkHttpClient` instance if you have a global one in your app and decide if you want to use mirror or origin API server.
61+
62+
> By default, to reduce loads on SWAPI.co, the client will point to the SWAPI mirror hosted on this project's GitHub Pages: https://gotev.github.io/swapi-android
63+
64+
All the domain models are also `Parcelable` so you can safely pass them as arguments.
5965

6066
```kotlin
6167
swapiClient.species()
@@ -80,6 +86,17 @@ It's also possible to fetch a single resource from its URL. Each domain model ha
8086
val lukeSkywalker = swapiClient.character("https://swapi.co/api/people/1/")
8187
```
8288

89+
## Mirror
90+
This project has the ability to make a complete API mirror from `SWAPI.co`. Go into `mirror` directory and launch:
91+
92+
```
93+
./fetch
94+
```
95+
96+
This will update:
97+
- The JSONs used in SWAPI SDK unit tests, saved in `fetched` sub directory
98+
- The SWAPI.co API mirror in the `docs` directory, which is the GitHub Pages source
99+
83100
## Dependency Updates
84101
Keeping dependencies always up to date can be annoying. To ease things, a gradle plugin has been added which automatically checks for new versions. Just run:
85102

mirror/config.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FETCHED_DIR="fetched"
2+
API_DIR="api"
3+
API_SOURCE_URI="https://swapi.co/api/"
4+
API_MIRROR_URI="https://gotev.github.io/swapi-android/"

mirror/fetch

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/bin/bash -e
22

3-
FETCHED_DIR="fetched"
4-
API_DIR="api"
5-
API_SOURCE_URI="https://swapi.co/api/"
6-
API_MIRROR_URI="https://gotev.github.io/swapi-android/"
3+
. config.txt
74

85
function rewrite_urls {
96
sed "s*${API_SOURCE_URI}*${API_MIRROR_URI}*g" | sed 's/?page=\([0-9]*\)/page\1.json/g'

0 commit comments

Comments
 (0)