Skip to content

Commit

Permalink
Merge pull request #5 from abhi3700/code-refactoring
Browse files Browse the repository at this point in the history
Code refactoring
  • Loading branch information
abhi3700 authored Oct 31, 2024
2 parents 6ece4e6 + 4042404 commit 0647a98
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Dummy JSON Rust SDK

This is a Rust SDK for the [Dummy JSON API](https://dummyjson.com/).

<u>Objective:</u> This SDK could be used to handle BE of any Rust App that interacts with the Dummy JSON API.

## Build

```bash
cargo build -r
```

## Run tests

```bash
cargo test -r
```

## Format code

```bash
cargo fmt
```

## Lint code

```bash
cargo clippy
```

<!--
TODO:
## Run benchmarks
```bash
cargo bench
``` -->
2 changes: 1 addition & 1 deletion src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use serde_json::json;

const AUTH_BASE_URL: Lazy<String> = Lazy::new(|| format!("{}/auth", API_BASE_URL));
static AUTH_BASE_URL: Lazy<String> = Lazy::new(|| format!("{}/auth", API_BASE_URL));

/// Login request payload
#[derive(Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/carts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{DummyJsonClient, API_BASE_URL};
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};

const CARTS_BASE_URL: Lazy<String> = Lazy::new(|| format!("{}/carts", API_BASE_URL));
static CARTS_BASE_URL: Lazy<String> = Lazy::new(|| format!("{}/carts", API_BASE_URL));

#[derive(Serialize, Deserialize, Debug, Default)]
pub struct CartProduct {
Expand Down
2 changes: 1 addition & 1 deletion src/products.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{DummyJsonClient, API_BASE_URL};
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};

const PRODUCTS_BASE_URL: Lazy<String> = Lazy::new(|| format!("{}/products", API_BASE_URL));
static PRODUCTS_BASE_URL: Lazy<String> = Lazy::new(|| format!("{}/products", API_BASE_URL));

#[derive(Deserialize, Debug)]
pub struct Product {
Expand Down
2 changes: 1 addition & 1 deletion src/todos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use reqwest::Error;
use serde::Deserialize;
use serde_json::json;

const TODOS_BASE_URL: Lazy<String> = Lazy::new(|| format!("{}/todos", API_BASE_URL));
static TODOS_BASE_URL: Lazy<String> = Lazy::new(|| format!("{}/todos", API_BASE_URL));

/// Todo item
#[derive(Deserialize, Debug)]
Expand Down

0 comments on commit 0647a98

Please sign in to comment.