Skip to main content

Fetch MarketEdge for Item

The Entrupy iOS SDK provides a fetchMarketEdgeForItem(withEntrupyID:) API that enables programmatic fetching of MarketEdge data for an authentication result. This guide covers prerequisites, the delegate-based flow, response structure, and how to decode and use the data in your own UI or business logic.

Overview

Prioritize SDK UI

For displaying MarketEdge (grade, value, match, region), prefer MarketEdge View UI using displayMarketEdgeViewForItem(withEntrupyID:withConfiguration:). Use fetchMarketEdgeForItem(withEntrupyID:) when you need the data in your own UI or business logic.

The fetchMarketEdgeForItem API provides:

  • MarketEdge data - MarketGrade, MarketValue, MarketMatch and disclaimer.
  • Delegate based flow - Set the marketEdgeDelegate and handle success and failure via delegate callbacks, data is delivered through these callbacks.

Prerequisites

  • User must be authorized: entrupyApp.isAuthorizationValid() == true
  • Set entrupyApp.marketEdgeDelegate to an object conforming to EntrupyMarketEdgeDelegate before calling

Method Signature

func fetchMarketEdgeForItem(withEntrupyID entrupyID: String)

Usage Examples

// 1. Set delegate
entrupyApp.marketEdgeDelegate = self

// 2. Call API (e.g. after user provides entrupyId)
entrupyApp.fetchMarketEdgeForItem(withEntrupyID: entrupyId)

Handling Success and Decoding

The success callback receives a response dictionary that can be decoded into the SDK-provided model EntrupyMarketEdge.

func didFetchMarketEdgeCompleteSuccessfully(_ response: [AnyHashable : Any], forEntrupyID entrupyID: String) {
do {
let data = try JSONSerialization.data(withJSONObject: response, options: [])
let marketEdge = try JSONDecoder().decode(EntrupyMarketEdge.self, from: data)

// Check for MarketEdge level error
if let error = marketEdge.error {
// Handle MarketEdge error
return
}

// Access MarketEdge properties
let identifier = marketEdge.identifier
let marketGrade = marketEdge.market_grade
let marketValue = marketEdge.market_value
let marketMatch = marketEdge.market_match
let disclaimer = marketEdge.disclaimer


// Use the parsed data to populate UI or business logic
} catch {
// Handle decoding errors
}
}

Handling Failure

func didFetchMarketEdgeFailWithError(_ errorCode: EntrupyErrorCode, description: String, localizedDescription: String, forEntrupyID entrupyID: String) {
DispatchQueue.main.async {
// Get the error code and localizedDescription when fetchMarketEdgeForItem fails
}
}

Response Structure

The success callback's response dictionary can be decoded into the SDK-provided model EntrupyMarketEdge (e.g. via JSONSerialization and JSONDecoder).

Model Property

FieldDescription
identifierAuthentication identifiers for the item.
market_gradeCondition rating based on submitted images, includes rating, item report details, and region-level descriptions. Typed as EntrupyMarketGrade.
market_valueBest estimate of the item's value based on recent market data; includes price and currency. Typed as EntrupyMarketValue.
market_matchRecent marketplace listings similar to the submitted item (e.g. brand, style, price). Typed as EntrupyMarketMatch.
disclaimerDisclaimer text for MarketGrade and MarketValue.
errorError information when MarketEdge data is unavailable or failed.

Error Handling

Use the localizedDescription parameter in the failure callback to display user-friendly error messages. For detailed information about specific error codes and handling strategies, see the Error Code Reference.

Next Steps