class HardCider::Client

Public Class Methods

new(options = {}) click to toggle source

@param options [Hash]

# File lib/hard_cider/client.rb, line 8
def initialize(options = {})
  @client = AppStoreConnect::Client.new(options)
end

Public Instance Methods

latest_build(bundle_id) click to toggle source

@param bundle_id [String] @return [Hash]

# File lib/hard_cider/client.rb, line 14
def latest_build(bundle_id)
  response = @client.builds(
    limit: 1,
    filter: {
      app: app_id(bundle_id)
    }
  )

  response.dig(:data, 0)
end
latest_build_processed?(bundle_id) click to toggle source

@param bundle_id [String] @return [String]

# File lib/hard_cider/client.rb, line 27
def latest_build_processed?(bundle_id)
  processing_state = latest_build(bundle_id).dig(:attributes, :processing_state)

  processing_state == 'VALID'
end

Private Instance Methods

app(bundle_id) click to toggle source

@param bundle_id [String] @return [Hash]

# File lib/hard_cider/client.rb, line 48
def app(bundle_id)
  apps(bundle_id).detect do |data|
    data.dig(:attributes, :bundle_id) == bundle_id
  end
end
app_id(bundle_id) click to toggle source

@param bundle_id [String] @return [String]

# File lib/hard_cider/client.rb, line 56
def app_id(bundle_id)
  @app_id ||= {}
  @app_id[bundle_id] ||= begin
    app(bundle_id)&.[](:id)
  end

  @app_id[bundle_id]
end
apps(bundle_id) click to toggle source

@param bundle_id [String]

# File lib/hard_cider/client.rb, line 36
def apps(bundle_id)
  response = @client.apps(
    filter: {
      bundle_id: bundle_id
    }
  )

  response[:data]
end