Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
[ADD] Added Contribution and Installation guide to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaesung committed Apr 23, 2023
1 parent 8025495 commit 444bd3e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: The Satellite Swift Package Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: The Satellite Unit Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

Expand Down
58 changes: 51 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,67 @@

The Satellite is an API communication module written in Swift.

# Contribution

I welcome and appreciate contributions from the community. If you find a bug, have a feature request, or want to contribute code, please submit an issue or a pull request on our GitHub repository freely.
Please see [💪 How to Contribute in Discussion](https://github.com/kuring/the-satellite/discussions/1) tab.

> **Important**
>
> When you contribute code via pull request, please add the unit tests for your new functions.
# License
**The Satellite** is released under the MIT license. See [LICENSE](https://github.com/kuring/the-satellite/blob/main/LICENSE) for details.

# Installation

## Installation guide for your Swift Package
1. In your `Package.swift` Swift Package Manager manifest, add the following dependency to your dependencies argument:
```swift
.package(url: "https://github.com/kuring/the-satellite.git, .branch("main")),
```
2. Add the dependency to any targets you've declared in your manifest:
```swift
.target(name: "MyTarget", dependencies: ["Satellite"]),
```
## Installation guide for your Xcode project
To use the Satellite in your project, follow these steps:
1. In Xcode, select **File** > **Swift Packages** > **Add Package Dependency**.
2. In the search bar, paste the the Satellite URL: https://github.com/kuring/the-satellite
3. Select the branch as **main** to install.
4. Click **Next**, and then click **Finish**.
# Usage
To use the Satellite in your project, add the following import statement at the top of your file:
```swift
import Satellite
```
## v1: Sputnik
"Version **Sputnik**" is the very first version of **The Satellite**, providing very basic public interfaces for API communication in Swift. It offers two main interfaces, one for *Swift concurrency* and another for *Combine*. Let's see how to use them.
"Version **Sputnik**" is the very first version of **the Satellite**, providing very basic public interfaces for API communication in Swift. It offers two main interfaces, one for *Swift concurrency* and another for *Combine*. Let's see how to use them.
### Setting up with API key and your domain
### 1. Creating the new Satellite instance with your host domain
```swift
let satellite = Satellite(
host: "{BASE.URL}",
scheme: .http // default: `.https`
)
```
### Declare Request and Response
### 2. Declare Request and Response
```swift
// Expected response object
struct CatFact: Codable {
let text: String
}
```
### Sending the request and receiving the response (Combine/Publisher)
### 3-a. Sending the request and receiving the response (Combine/Publisher)
```swift
let satellite = Satellite(host: "cat-fact.herokuapp.com")
cancellable = statellite
Expand All @@ -40,9 +80,11 @@ cancellable = statellite
)
```
> **INFORMATION** For the more information on URLSession data task publisher, please see this [link](https://developer.apple.com/documentation/foundation/urlsession/processing_url_session_data_task_results_with_combine)
> **INFORMATION**
>
> For the more information on URLSession data task publisher, please see this [link](https://developer.apple.com/documentation/foundation/urlsession/processing_url_session_data_task_results_with_combine)
### Sending the request and waiting the response (Async await)
### 3-b. Sending the request and waiting the response (Async await)
```swift
let satellite = Satellite(host: "cat-fact.herokuapp.com")
let catFacts: [CatFact] = try await satellite.response(
Expand All @@ -58,4 +100,6 @@ self.text = catFacts
.joined(separator: ", ")
```
> **INFORMATION** For the more information on using async/await style, please see this [link](https://developer.apple.com/documentation/swift/updating_an_app_to_use_swift_concurrency)
> **INFORMATION**
>
> For the more information on using async/await style, please see this [link](https://developer.apple.com/documentation/swift/updating_an_app_to_use_swift_concurrency)

0 comments on commit 444bd3e

Please sign in to comment.