From 25e131269db92570f39a52c9aa259e346050ded9 Mon Sep 17 00:00:00 2001 From: Pavel Sinitsin Date: Sat, 7 Sep 2024 19:18:32 +0300 Subject: [PATCH] Refactor API client initialization and simplify types Streamlined API client initialization within the NewApi function by directly invoking the client creation. Additionally, removed custom type declarations and constants in model/product.go, replacing them with simpler string types to reduce complexity. --- api/api.go | 3 +-- model/product.go | 29 ++++++++--------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/api/api.go b/api/api.go index c332b77..44d6dcd 100644 --- a/api/api.go +++ b/api/api.go @@ -16,8 +16,7 @@ type IApi interface { } func NewApi(credentials client.Credentials) IApi { - client := client.NewClient(credentials) return &Api{ - Client: client, + Client: client.NewClient(credentials), } } diff --git a/model/product.go b/model/product.go index c607944..66fcbe3 100644 --- a/model/product.go +++ b/model/product.go @@ -1,18 +1,5 @@ package model -type VideosType string -type WarehouseDataIncomingType string - -const ( - VideoTypeFile VideosType = "file" - VideoTypeUrl VideosType = "url" -) - -const ( - WarehouseDataIncomingTypeShipping WarehouseDataIncomingType = "shipping" - WarehouseDataIncomingTypeProduction WarehouseDataIncomingType = "production" -) - type ( ImageVariant struct { Url string `json:"url"` @@ -42,10 +29,10 @@ type ( } Video struct { - Name string `json:"name"` - Description string `json:"description"` - Url string `json:"url"` - Type VideosType `json:"type"` + Name string `json:"name"` + Description string `json:"description"` + Url string `json:"url"` + Type string `json:"type"` } Software struct { @@ -72,10 +59,10 @@ type ( WarehouseName string `json:"warehouseName"` AvailableAmount int `json:"availableAmount"` Incoming []struct { - DateBegan string `json:"dateBegan"` - DateEnd string `json:"dateEnd"` - Amount int `json:"amount"` - Type WarehouseDataIncomingType `json:"type"` + DateBegan string `json:"dateBegan"` + DateEnd string `json:"dateEnd"` + Amount int `json:"amount"` + Type string `json:"type"` } }