Class ShopifyApiReader

Direct Known Subclasses:
ShopifyCustomerReader, ShopifyEventReader, ShopifyInventoryItemReader, ShopifyInventoryLevelReader, ShopifyLocationReader, ShopifyOrderReader, ShopifyProductReader

public abstract class ShopifyApiReader extends IntegrationReader
Base class for readers that page through a Shopify Admin API resource using page_info cursors and retry requests that fail with a 429 (rate limit) error.
  • Field Details

  • Constructor Details

    • ShopifyApiReader

      public ShopifyApiReader(String domain, String token)
      Creates a reader for the store at domain, a base URL such as https://example.myshopify.com, using an access token.
  • Method Details

    • getBatchSize

      public int getBatchSize()
      Returns the number of records requested per page (defaults to 250, the maximum).
    • setBatchSize

      public ShopifyApiReader setBatchSize(int batchSize)
      Sets the number of records requested per page; values above 250 are capped and values of 0 or less reset it to 250.
    • getRetryStrategy

      public IRetryStrategy getRetryStrategy()
      Returns the strategy for the delay before retrying a rate-limited request (defaults to RetryStrategy.EXPONENTIAL_BACKOFF).
    • setRetryStrategy

      public ShopifyApiReader setRetryStrategy(IRetryStrategy retryStrategy)
      Sets the strategy for the delay before retrying a rate-limited request (defaults to RetryStrategy.EXPONENTIAL_BACKOFF).
    • getMaxRetryCount

      public int getMaxRetryCount()
      Returns the maximum number of attempts, including the first, for a rate-limited request (defaults to 5).
    • setMaxRetryCount

      public ShopifyApiReader setMaxRetryCount(int maxRetryCount)
      Sets the maximum number of attempts, including the first, for a rate-limited request (defaults to 5).
    • getInitialRetryDelay

      public long getInitialRetryDelay()
      Returns the delay in milliseconds before the first retry of a rate-limited request (defaults to 1000).
    • setInitialRetryDelay

      public ShopifyApiReader setInitialRetryDelay(long initialRetryDelay)
      Sets the delay in milliseconds before the first retry of a rate-limited request (defaults to 1000).
    • getNextPageInfo

      protected String getNextPageInfo()
      Returns the page_info cursor of the next page to request or null for the first page.
    • open

      public void open() throws DataException
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open in class IntegrationReader
      Throws:
      DataException
    • close

      public void close() throws DataException
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class DataEndpoint
      Throws:
      DataException
    • readImpl

      protected Record readImpl() throws Throwable
      Description copied from class: DataReader
      Overridden by subclasses to read the next record from this DataReader. The default implementation of DataReader.read() now insures that this method will not be called again after it returns a null.

      If no record is available, null will be returned.

      Contract for subclasses (see also docs/authoring/DataReader.md):

      Specified by:
      readImpl in class DataReader
      Throws:
      Throwable
    • invokeRequest

      protected abstract Record invokeRequest()
      Fetches the page for the getNextPageInfo() cursor (up to getBatchSize() records); must not return null. Reading continues with another page only if the response has a non-empty next field.
    • getRecordsFromResponse

      protected abstract ArrayValue getRecordsFromResponse(Record record)
      Returns the records in a response from invokeRequest(), such as its orders array; null or empty ends reading.
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class DataReader