Struct CatalogApi

Source
pub struct CatalogApi { /* private fields */ }
Expand description

Programmatically catalogs a Square seller’s products for sale and services for hire.

Implementations§

Source§

impl CatalogApi

Source

pub fn new(config: Configuration, client: HttpClient) -> Self

Instantiates a new CatalogApi

Source

pub async fn batch_delete_catalog_objects( &self, body: &BatchDeleteCatalogObjectsRequest, ) -> Result<BatchDeleteCatalogObjectsResponse, ApiError>

Deletes a set of [CatalogItem]s based on the provided list of target IDs and returns a set of successfully deleted IDs in the response.

Deletion is a cascading event such that all children of the targeted object are also deleted. For example, deleting a CatalogItem will also delete all of its [CatalogItemVariation] children.

BatchDeleteCatalogObjects succeeds even if only a portion of the targeted IDs can be deleted. The response will only include IDs that were actually deleted.

Source

pub async fn batch_retrieve_catalog_objects( &self, body: &BatchRetrieveCatalogObjectsRequest, ) -> Result<BatchRetrieveCatalogObjectsResponse, ApiError>

Returns a set of objects based on the provided ID.

Each [CatalogItem] returned in the set includes all of its child information including: all of its [CatalogItemVariation] objects, references to its [CatalogModifierList] objects, and the ids of any [CatalogTax] objects that apply to it.

Source

pub async fn batch_upsert_catalog_objects( &self, body: &BatchUpsertCatalogObjectsRequest, ) -> Result<BatchUpsertCatalogObjectsResponse, ApiError>

Creates or updates up to 10,000 target objects based on the provided list of objects.

The target objects are grouped into batches and each batch is inserted/updated in an all-or-nothing manner. If an object within a batch is malformed in some way, or violates a database constraint, the entire batch containing that item will be disregarded. However, other batches in the same request may still succeed. Each batch may contain up to 1,000 objects, and batches will be processed in order as long as the total object count for the request (items, variations, modifier lists, discounts, and taxes) is no more than 10,000.

Source

pub async fn create_catalog_image( &self, body: &CreateCatalogImageRequest, image_filepath: &str, ) -> Result<CreateCatalogImageResponse, ApiError>

Uploads an image file to be represented by a [CatalogImage] object that can be linked to an existing [CatalogObject] instance.

The resulting CatalogImage is unattached to any CatalogObject if the object_id is not specified.

This CreateCatalogImage endpoint accepts HTTP multipart/form-data requests with a JSON part and an image file part in JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.

Source

pub async fn update_catalog_image( &self, image_id: &str, body: &UpdateCatalogImageRequest, image_filepath: &str, ) -> Result<UpdateCatalogImageResponse, ApiError>

Uploads a new image file to replace the existing one in the specified [CatalogImage] object.

This UpdateCatalogImage endpoint accepts HTTP multipart/form-data requests with a JSON part and an image file part in JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.

Source

pub async fn catalog_info(&self) -> Result<CatalogInfoResponse, ApiError>

Retrieves information about the Square Catalog API, such as batch size limits that can be used by the BatchUpsertCatalogObjects endpoint.

Source

pub async fn list_catalog( &self, params: &ListCatalogParameters, ) -> Result<ListCatalogResponse, ApiError>

Returns a list of all [CatalogObject]s of the specified types in the catalog.

The types parameter is specified as a comma-separated list of the [CatalogObjectType] values, for example, “ITEM, ITEM_VARIATION, MODIFIER, MODIFIER_LIST, CATEGORY, DISCOUNT, TAX, IMAGE”.

Important: ListCatalog does not return deleted catalog items. To retrieve deleted catalog items, use [SearchCatalogObjects] and set the include_deleted_objects attribute value to true.

Source

pub async fn upsert_catalog_object( &self, body: &UpsertCatalogObjectRequest, ) -> Result<UpsertCatalogObjectResponse, ApiError>

Creates or updates the target [CatalogObject].

Source

pub async fn delete_catalog_object( &self, object_id: &str, ) -> Result<DeleteCatalogObjectResponse, ApiError>

Deletes a single [CatalogObject] based on the provided ID and returns the set of successfully deleted IDs in the response.

Deletion is a cascading event such that all children of the targeted object are also deleted. For example, deleting a [CatalogItem] will also delete all of its [CatalogItemVariation] children.

Source

pub async fn retrieve_catalog_object( &self, object_id: &str, params: &RetrieveCatalogObjectParameters, ) -> Result<RetrieveCatalogObjectResponse, ApiError>

Returns a single [CatalogItem] as a [CatalogObject] based on the provided ID.

The returned object includes all of the relevant [CatalogItem] information including: [CatalogItemVariation] children, references to its [CatalogModifierList] objects, and the ids of any [CatalogTax] objects that apply to it.

Source

pub async fn search_catalog_objects( &self, body: &SearchCatalogObjectsRequest, ) -> Result<SearchCatalogObjectsResponse, ApiError>

Searches for [CatalogObject] of any type by matching supported search attribute values, excluding custom attribute values on items or item variations, against one or more of the specified query filters.

This (SearchCatalogObjects) endpoint differs from the SearchCatalogItems endpoint in the following aspects:

  • SearchCatalogItems can only search for items or item variations, whereas SearchCatalogObjects can search for any type of catalog objects.
  • SearchCatalogItems supports the custom attribute query filters to return items or item variations that contain custom attribute values, where SearchCatalogObjects does not.
  • SearchCatalogItems does not support the include_deleted_objects filter to search for deleted items or item variations, whereas SearchCatalogObjects does.
  • The both endpoints have different call conventions, including the query filter formats.
Source

pub async fn search_catalog_items( &self, body: &SearchCatalogItemsRequest, ) -> Result<SearchCatalogItemsResponse, ApiError>

Searches for catalog items or item variations by matching supported search attribute values, including custom attribute values, against one or more of the specified query filters.

This (SearchCatalogItems) endpoint differs from the SearchCatalogObjects endpoint in the following aspects:

  • SearchCatalogItems can only search for items or item variations, whereas SearchCatalogObjects can search for any type of catalog objects.
  • SearchCatalogItems supports the custom attribute query filters to return items or item variations that contain custom attribute values, where SearchCatalogObjects does not.
  • SearchCatalogItems does not support the include_deleted_objects filter to search for deleted items or item variations, whereas SearchCatalogObjects does.
  • The both endpoints use different call conventions, including the query filter formats.
Source

pub async fn update_item_modifier_lists( &self, body: &UpdateItemModifierListsRequest, ) -> Result<UpdateItemModifierListsResponse, ApiError>

Updates the [CatalogModifierList] objects that apply to the targeted [CatalogItem] without having to perform an upsert on the entire item.

Source

pub async fn update_item_taxes( &self, body: &UpdateItemTaxesRequest, ) -> Result<UpdateItemTaxesResponse, ApiError>

Updates the [CatalogTax] objects that apply to the targeted [CatalogItem] without having to perform an upsert on the entire item.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,