Files
strike_me-api/lib/strike_me/api/invoices.rb
T
2025-10-18 12:37:08 -05:00

31 lines
634 B
Ruby

# frozen_string_literal: true
module StrikeMe
module API
# Factory helper object connecting the client to the models
class Invoices
include BaseClient
include Enumerable
autoload_default :Invoice
delegate :first, :last, :size, :any?, to: :list
def each(&block)
list.each(&block)
end
def list
return @list if @list.present?
url = 'invoices'
response = client.get url
raise ResponseError.new(url, response.body) unless response.success?
@list = response.body['items'].map { |item| Invoice.new item }
end
end
end
end