-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-added internet permissions -added more dependencies -added retrofit client -added mappers
- Loading branch information
1 parent
f5a9597
commit aede04a
Showing
10 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/build | ||
/build | ||
Config.kt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/example/stockmarketcheck/mainFeature/Domain/model/CompanyListing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.example.stockmarketcheck.mainFeature.Domain.model | ||
|
||
data class CompanyListing( | ||
val name: String, | ||
val symbol: String, | ||
val exchange: String, | ||
) |
12 changes: 12 additions & 0 deletions
12
...src/main/java/com/example/stockmarketcheck/mainFeature/data/local/CompanyListingEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.stockmarketcheck.mainFeature.data.local | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity | ||
data class CompanyListingEntity( | ||
val name: String, | ||
val symbol: String, | ||
val exchange: String, | ||
@PrimaryKey val id: Int? = null, | ||
) |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/example/stockmarketcheck/mainFeature/data/local/StockDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.stockmarketcheck.mainFeature.data.local | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
|
||
@Dao | ||
interface StockDao { | ||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun insertCompanyListings(companyListingEntities: List<CompanyListingEntity>) | ||
|
||
@Query("DELETE FROM companylistingentity") | ||
suspend fun clearCompanyListings() | ||
|
||
@Query( | ||
""" | ||
SELECT * | ||
FROM companylistingentity | ||
WHERE LOWER(name) LIKE '%' || LOWER(:query) || '%' OR | ||
UPPER(:query) == symbol | ||
""", | ||
) | ||
suspend fun searchCompanyListings(query: String): List<CompanyListingEntity> | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/example/stockmarketcheck/mainFeature/data/local/StockDatabase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.example.stockmarketcheck.mainFeature.data.local | ||
|
||
import androidx.room.Database | ||
|
||
@Database( | ||
entities = [CompanyListingEntity::class], | ||
version = 1, | ||
) | ||
abstract class StockDatabase { | ||
abstract val dao: StockDao | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/example/stockmarketcheck/mainFeature/data/mapper/CompanyMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.stockmarketcheck.mainFeature.data.mapper | ||
|
||
import com.example.stockmarketcheck.mainFeature.Domain.model.CompanyListing | ||
import com.example.stockmarketcheck.mainFeature.data.local.CompanyListingEntity | ||
|
||
fun CompanyListingEntity.toCompanyListing(): CompanyListing { | ||
return CompanyListing( | ||
name = name, | ||
symbol = symbol, | ||
exchange = exchange, | ||
) | ||
} | ||
|
||
fun CompanyListing.toCompanyListingEntity(): CompanyListingEntity { | ||
return CompanyListingEntity( | ||
name = name, | ||
symbol = symbol, | ||
exchange = exchange, | ||
) | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/example/stockmarketcheck/mainFeature/data/remote/StockClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.stockmarketcheck.mainFeature.data.remote | ||
|
||
import com.example.stockmarketcheck.Config | ||
import okhttp3.ResponseBody | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface StockClient { | ||
@GET("query?function=LISTING_STATUS") | ||
suspend fun getListings( | ||
@Query("apikey") apikey: String = Config.API_KEY, | ||
): ResponseBody | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters