diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 341ed3c..a5e9e0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: # Maintains CHANGELOG.md, bumps version in cargo.toml and creates PR against current branch release-PR: - needs: build_and_test + needs: format runs-on: ubuntu-latest steps: - name: Checkout repository diff --git a/README.md b/README.md index 0f85376..d7e21d4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,34 @@ +![Crates.io](https://img.shields.io/crates/l/shopify/0.1.0) +![Crates.io](https://img.shields.io/crates/v/shopify) +![Crates.io](https://img.shields.io/crates/d/shopify) +![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/Ventmere/shopify/ci.yml) + # shopify -Shopify API Client for Rust -Testing CI -Testiong Release PLease + +Shopify is an unofficial sdk for the Shopify e-commerce platform written in rust. + +## Installation +```rust +cargo install shopify +``` + +## Usage +```rust +use shopify::client::Client; +use shopify::shop; + +// Create a new client +let client = Client::new( + "SHOPIFY_BASE_URL", + "SHOPIFY_API_KEY", + "SHOPIFY_PASSWORD" +); + +// Retrieve shop details +let shop = shop::ShopApi::get(&client); + +``` + +## License +This project is license under an MIT license \ No newline at end of file diff --git a/shopify-cli/src/main.rs b/shopify-cli/src/main.rs index 441b20e..f370fac 100644 --- a/shopify-cli/src/main.rs +++ b/shopify-cli/src/main.rs @@ -20,6 +20,7 @@ enum SubCommand { OrderGetRisks(OrderGet), OrderGetFulfillmentOrders(OrderGet), OrderFulfill(OrderFulfill), + LocationList, } #[derive(Parser)] @@ -57,6 +58,7 @@ fn main() { } SubCommand::OrderList => order_list(&client), SubCommand::OrderFulfill(fulfill) => order_fulfill(&client, &fulfill), + SubCommand::LocationList => location_list(&client), } } @@ -160,6 +162,7 @@ fn order_fulfill(client: &Client, fulfill: &OrderFulfill) { use shopify::order::*; let fos = client.get_fulfillment_orders(fulfill.id).unwrap(); + dbg!(&fos); let (fo, li) = fos .iter() .filter(|fo| fo.status == FulfillmentOrderStatus::Open) @@ -196,9 +199,9 @@ fn order_fulfill(client: &Client, fulfill: &OrderFulfill) { .create_fulfillment(&CreateFulfillmentRequest { line_items_by_fulfillment_order: vec![LineItemsByFulfillmentOrder { fulfillment_order_id: fo.id, - line_items: vec![FulfillmentOrderLineItems { + fulfillment_order_line_items: vec![FulfillmentOrderLineItems { id: li.id, - quantity: None, + quantity: 1, }], }], notify_customer: Some(true), @@ -212,3 +215,9 @@ fn order_fulfill(client: &Client, fulfill: &OrderFulfill) { serde_json::to_writer_pretty(std::io::stdout(), &r).unwrap() } + +fn location_list(client: &Client,) { + use shopify::inventory::LocationApi; + + serde_json::to_writer_pretty(std::io::stdout(), &client.get_list().unwrap()).unwrap() +} \ No newline at end of file diff --git a/shopify/src/order/fulfillment.rs b/shopify/src/order/fulfillment.rs index f2a9e41..0f5d947 100644 --- a/shopify/src/order/fulfillment.rs +++ b/shopify/src/order/fulfillment.rs @@ -77,12 +77,13 @@ pub struct CreateFulfillmentRequest { #[derive(Debug, Serialize, Deserialize)] pub struct LineItemsByFulfillmentOrder { pub fulfillment_order_id: i64, - pub line_items: Vec, + pub fulfillment_order_line_items: Vec, } #[derive(Debug, Serialize, Deserialize)] pub struct TrackingInfo { pub company: String, pub number: String, + #[serde(skip_serializing_if = "Option::is_none")] pub url: Option, } diff --git a/shopify/src/order/fulfillment_order.rs b/shopify/src/order/fulfillment_order.rs index ee21f75..9afffab 100644 --- a/shopify/src/order/fulfillment_order.rs +++ b/shopify/src/order/fulfillment_order.rs @@ -74,7 +74,7 @@ pub struct MoveFulfillmentOrderRequest { #[derive(Debug, Serialize, Deserialize)] pub struct FulfillmentOrderLineItems { pub id: i64, - pub quantity: Option, + pub quantity: i64, } #[derive(Debug, Serialize, Deserialize)]